1. 10
  1.  

  2. 7

    Really quickly, (fun x -> x + 1) 1 is not the same as a let-bound local var! It is in Scheme, but those have importantly different types in OCaml!

    1. 1

      I’d love some clarification here?

      1. 13

        In HM type systems like OCaml’s you have a notion of generalization. For instance, there’s a difference between the function (in Haskell notation, sorry)

        id :: Int -> Int
        

        and

        id :: forall a . a -> a
        

        In System F, a more complex type system without inference, there’s an explicit difference. The second one takes an extra argument—the particular type to instantiate a as

        id :: forall a . a -> a
        id a x = x
        
        idInt :: Int -> Int
        idInt = id Int -- passing the concrete Int in
        

        In order to make HM type inference tractable and general, there must be a formal rule for when to add these generalization steps by introducing foralls. If you do it too often then type inference fails. If you do it too rarely then few programs will check.

        HM resolves this through “let generalization”. The rule is that let-bound variables will be made as general as possible.

        The important note is that there’s no such thing as “lambda generalization”, thus the two syntaxes differ semantically.


        As an example, this fails to compile (again in Haskell, sorry)

        (\id -> (id 3, id 'c')) (\x -> x)
        

        but this succeeds

        let id = (\x -> x) in (id 3, id 'c')
        

        because in the second example let-generalization has solved the type of id to be forall a . a -> a while in the first it’ll somewhat arbitrarily try to type id as either Int -> Int or Char -> Char.

        1. 2

          Thanks for clarifying, I upvoted because I learned something, but I don’t think this distinction is important in the context of the post.

          1. 2

            No, but it’s a common misconception.

    2. 1

      (fun x = x + 1) 1

      Actually

      (fun x -> x + 1) 1
      

      let x = 1 in let y = 2 in let z = 3 in x + y + z

      Actually

      let x = 1
      and y = 2
      and z = 3
      in
      x + y + z
      

      Now you can argue all you want about why dynamic languages are a special case of staticly typed languages2, but that argument doesn’t help anyone get any (non PL-research) work done, just as character/typing overhead for local bindings, proves nothing about the merit of using one language over another.

      I would argue those two statements are not in the same ballpark. One is semantics, which are very important. The other is syntax which..who cares?

      1. 0

        The use of and in OCaml would be the same as using letrec in scheme, based on my understanding, which makes it an apples to oranges comparison. And, boo for my syntax error – thanks for catching it!

        I would argue those two statements are not in the same ballpark. One is semantics, which are very important. The other is syntax which..who cares?

        As languages like PHP and Perl have shown (languages which were not developed by programming language researchers), the semantics of a programming language has little effect on one’s ability to get work done in it. Programmers who want to get work done and go home, just don’t give a shit, and will use anything in their power to do so (copy and paste something a 1000 times instead of writing a complicated loop, etc).

        They do, however, tend to say things like, “I don’t use Erlang because the syntax is weird” or “I switched away from Perl to Python because I can actually read what I wrote the next day.”

        So, syntax does matter (unfortunately), and as much as you (and I) want to believe that programming language semantics is important, it’s really not (outside of academic settings) so long as it’s not so screwed up that work can’t be done in it.

        1. 2

          The use of and in OCaml would be the same as using letrec in scheme, based on my understanding, which makes it an apples to oranges comparison.

          Nope, the and does not make it recursive.

          So, syntax does matter

          While it may affect ones decision as to what language to use, it doesn’t affect ones ability to get work down (which was your statement). Semantics do.

          [semantics are] really not [important] (outside of academic settings) so long as it’s not so screwed up that work can’t be done in it.

          Semantics matter for average Joe’s. It’s the whole foundation of Java (a response to the semantics of C++). And Scala (a response to the semantics of Java).

          1. 3

            While it may affect ones decision as to what language to use, it doesn’t affect ones ability to get work down (which was your statement). Semantics do.

            One could argue the opposite! There is actually a book entitled “JavaScript: The Good Parts” which explains how to avoid using the semantically bad parts of the language. JavaScript is 10th on TIOBE, and the most popular language on GitHub (according to this) and among the top in regards to questions asked on StackOverflow, ibid.

            As for syntax, perception is all that matters. A language that has perfect semantics but perceived shitty syntax will never be popular. Lisp allows you to invent your own fucking language and anecdotally the reason it’s not used is defined by a self-referential acronym: LISP (Lots of ((Irritating Spurious) (Parentheses))).

            I also, unfortunately, don’t see much use of OCaml, or Haskell–languages with much better than average semantics according to academics, in toolbelts of average joes.

            Semantics matter for average Joe’s. It’s the whole foundation of Java (a response to the semantics of C++). And Scala (a response to the semantics of Java).

            A few follow ups:

            1. Java and C++ share quite a bit. They also differ in very important aspects of course, but the two languages aren’t so far from each other to the point where I think this matters.
            2. The Scala point matters a bunch because Scala adds a lot, and it’s perceived popularity might indicate that it’s in use by “average joes”, except that TIOBE sort of disagrees. C-style, “bad” semantics languages still dominate by volume like crazy.

            Look, I’m not saying that I don’t care about syntax or semantics. I’m suggesting that there is evidence to support the fact that a large majority of programmers just don’t give a shit.

            1. 1

              Look, I’m not saying that I don’t care about syntax or semantics. I’m suggesting that there is evidence to support the fact that a large majority of programmers just don’t give a shit.

              I’m not sure why you think you’re disagreeing with me though. You say Java and C++ have such similar semantics that it doesn’t matter, but semantics don’t have to be different from each other to be meaningful to developers. One reason for Java’s popularity is that it’s semantics are so similar to C++’s. Semantics being similar is just as important as their differences: developers can transition between the languages with less effort.

              Even if one takes TIOBE’s index seriously, most of the languages in it have some sort of object model which are all pretty similar. Or most importantly, has received an object model as part of becoming popular (PHP). JavaScript has received (or is about to?) an object model similar to these other languages because people just try to do it in JavaScript as-is, because that’s the semantics they are used to and want.

              1. 1

                but semantics don’t have to be different from each other to be meaningful to developers. One reason for Java’s popularity is that it’s semantics are so similar to C++’s. Semantics being similar is just as important as their differences: developers can transition between the languages with less effort. Even if one takes TIOBE’s index seriously, most of the languages in it have some sort of object model which are all pretty similar.

                You’re making my argument for me. In the equation of how does someone choose a language, semantics is more or less constant, and largely doesn’t matter, if the languages are this similar. If you look into the TIOBE rankings, say that the top 10 languages have pretty much the same semantics (give or take a few things), then the parameters left for choosing a language come down to some combination of:

                1. Will it run on the platform I need it to?
                2. Are there libraries that support common needs?
                3. Can I get help when things go bad?
                4. Is it fast enough for my purposes?
                5. Or, can I tolerate a runtime being a bit slower because it’s convenient in other areas (libraries, syntax readability, etc)?
                6. Is the syntax tolerable?
                1. 1

                  This implies, perhaps, that the majority of “average joe” programmers will only look to the top-10, which, given that the index is extremely top heavy by volume, doesn’t seem too off the wall.

                  And, yes, I know that there are likely biases and problems with TIOBE, but I’m assuming it’s accurate. If you know of a better comparison which takes into consideration all industries that hire programmers and isn’t biased (e.g. doesn’t rely on Github, or sourceforge, or bitbucket, etc) then by all means…

                  1. 1

                    In the equation of how does someone choose a language, semantics is more or less constant, and largely doesn’t matter, if the languages are this similar

                    The more likely explanation, IMO, is the opposite. The reason semantics are constant throughout these languages is because it does matter. People pick things that are similar to what they know already and most people are raised on imperative, c-like, semantics. Most ‘which language shall we use’ decisions I’ve seen in work places actually take for granted that the semantics will be the same and don’t even consider alternatives. Semantics are so important people don’t even consider languages that aren’t highly in-line with what they expect.

                    If you consider Haskell for your 6-point list. At this point I would say it passes all 6. What keeps people from using it is the semantics are not what they are familiar with. Consider the plethora of ‘monad’ tutorial on the internet relative to the barren desert of “Haskell Syntax Explained” tutorials.

                    1. 1

                      Semantics are so important people don’t even consider languages that aren’t highly in-line with what they expect.

                      I agree with that.

                      But, I think that also furthers my point. Assumption: Languages that are strong in the 6 points (there are likely more) are likely to be very high on the TIOBE index. If that’s the case, than, yes, semantics may be the differing factor, but as we’ve already stated (and agreed on), the languages at the top of the index have roughly the same semantics anyway, i.e., they’re roughly constant and don’t matter.

                      At this point I would say it passes all 6.

                      I think you’ll have a hard time getting help, and hiring people [which isn’t represented on the list, but let’s lump it into 3 as it’s similar enough]. You’ll be able to hire highly skilled Haskell people iff they’re looking for a job, or you’re doing something so incredibly awesome that they’re willing to give up their current position. You’ll also have to pay them very well, or someone else will snatch them up. The pool of talented Haskell people is also extremely small, and it’s not an easy language to obtain mastery in, so training people may or may not be a viable option – it’s an expensive option regardless.

                      Judging by the fact that I know a few very bright people (one was a functional programming languages PhD candidate), who were turned down by Jane St after a second phone screen, I’d say we’re underestimating the importance of this part of the equation. That isn’t to say that Jane St isn’t successful in their use of OCaml, just that they’ve spent lots of time and money in their HR process to make it happen. That doesnt' work for everyone.

                      1. 1

                        they’re roughly constant and don’t matter

                        I don’t understand why you insist that because the top languages on TIOBE all have the same semantics that means the semantics don’t matter. Semantics mattering the most also completely explains that observation. It also explains why many language converge on the same features (PHP and JS getting object models for example). Your claim that semantics not mattering does not explain that and one would expect to see the languages having a wide range of semantics if that were true.

                        Re Haskell:

                        This still does not address the core point: Haskell is fairly popular given it’s quite different semantics. Companies can, and do, hire Haskell developers. The ecosystem is large. Yet consistently the complaint about Haskell revolves around semantics, not about syntax. This is consistent with the TIOBE data under the hypothesis that semantics matter more than syntax.

                        1. 1

                          I’ve asserted multiple times that they do matter, and that I care about them.

                          I’ve also asserted, and continued to assert, that because most of the popular languages adopt such similar semantics, that it is becoming less and less a factor when adopting a language.

                          If there were only 10 programming languages in existence, and they all had exactly the same semantics, why would semantics matter?

                          And, I’m starting to think that your career has been spent working with knowledgeable people who expore their craft a bit more than most. I’ve worked with way too many people, who are good at what they do, who have never considered the fact that other programming languages exist outside of PHP and JavaScript. I’m willing to bet that if their world expands, it’ll be to other top 10 languages, because, that’s what they’ve heard of, and those are the languages with SYNTAX they are familiar with. Those are also the languages which they can learn and become effective in without too much trouble. They:

                          a) don’t really know what semantics are b) don’t understand that different semantics could possibly exist

                          And you know what? That’s fine. Like I said. These people are actually good at what they do and provide tremendous value to their employers. They leave their work at work, learn only what they need, and spend time with their families, do other hobbies, etc.

                          People on Lobste.rs, or Hacker News, or the Programming subreddit, or even mailing lists are a minority. Please don’t forget that.

                          1. 1

                            I’ve asserted multiple times that they do matter, and that I care about them.

                            Then you’re communicating your point poorly because you have stated multiple times that semantics don’t matter because the top 10 languages have the same semantics.

                            I’ve also asserted, and continued to assert, that because most of the popular languages adopt such similar semantics, that it is becoming less and less a factor when adopting a language.

                            I don’t believe this statement makes sense. Are you saying that semantics don’t matter because of a lack of options? There obviously significantly more than 10 languages out there so that thought experiment isn’t even worth happening.

                            And, I’m starting to think that your career has been spent working with knowledgeable people who expore their craft a bit more than most.

                            It hasn’t.

                            a) don’t really know what semantics are b) don’t understand that different semantics could possibly exist

                            But they don’t have! Have you ever had a discussion with someone about a functional language and they complain about how they can’t do a++? Or somebody that complains about lazy evaluation being weird? That’s complaining about semantics. One doesn’t need to be a semanticist in order to be bothered by semantics.

                            And you know what? That’s fine. Like I said. These people are actually good at what they do and provide tremendous value to their employers.

                            This discussion is not about this at all. This discussion is is purely about if semantics matter or not. My claim is:

                            Yes, they matter so much that every mainstream popular language has very similar semantics. Becoming mainstream depends on semantics being similar to an existing mainstream language. Complains about non-mainstream languages mostly revolve around the semantics being funny. For Haskell this comes down to lazyness and I/O. For FP in general it comes down to immutability. Yes, Erlang get syntax complaints but most complains about Erlang actually comes down to the semantics of strings and standard FP complaints (y u no loop!). One also does not need to be aware of semantics for semantics to bother, they just need to know they don’t like it and when they describe what they don’t like it comes down to semantics. I believe this explains all evidence given that semantics don’t matter. It also explains why languages converge on similar semantics as they become popular.

                            Let ‘er rip!

                          2. 1

                            The ecosystem is large.

                            No, it’s not. It may seem large because you hear about companies using it. But you’re in a bubble. You read Lobste.rs, an obscure site on the Internet which tends to promote articles on niche computer science topics. If you were to put all programmers in a single, very large room, and counted the number of hands that go up when you ask “Have you ever heard of the programming language Haskell?” Relatively few hands would go up. Ask the same question about C/C++ or Java and virtually all of them will go up.

                            The Haskell community does a great job of helping people. It has a quite a few dedicated programmers who write libraries for common tasks, and for not so common, niche tasks. There are even people working with Haskell for their day jobs. But, please don’t confuse these facts with the ecosystem being “large.”

                            1. 1

                              No, it’s not. It may seem large because you hear about companies using it

                              Apologies, when I say ecosystem I mean the library ecosystem. Which is quite large in Haskell. At the very least there exists solution for most major components a developer will use. When talking about talking about the actual number of people I would refer to that as the community.

                2. 1

                  Nope, the and does not make it recursive.

                  Oh, is there actually a letrec in OCaml? If so, my mistake. I’ll update.

                  1. 1

                    let rec, but you’d only use it to define mutually recursive functions, variables that depend on each other would be defined with multiple let’s.

                3. 2

                  Proof of existence of projects written in languages with bad semantics is not proof that semantics do not matter. Whining about Erlang syntax is not proof that syntax does matter. To each PHP project there is a person wondering whether they should use Clojure because everyone is saying it’s somehow magically better. To each person who things Erlang is dumb because you need to end “sentences” with “periods” there’s someone writing about how “it wasn’t that big of a transition, honestly” or a new concert to Elixir.

                  I have my beliefs and don’t mind you believing whatever you will, but the argument you made is really two-dimensional.

                  1. 2

                    I didn’t say that semantics don’t matter, I posited that people are more willing to look past shitty semantics than they are unfamiliar / shitty syntax.

                    As for “proof,” you’re right, it’s not proof – it’d be pretty hard to prove something like this. There’s evidence TIOBE index, for instance, that suggests it. Most of the popular languages have a familiar, C-style syntax. In terms of semantics, PHP, Perl, C++, C all rank very highly, but have “shitty” semantics in the opinions of academics.

                    But that opinion seems not to matter so much…

                    1. 1

                      By “proof” I meant not that it’s irrefutable, but instead that while you can draw one theory for why TIOBE falls the way it does, there are many conflicting ones. I don’t think it’s anything close to sufficient to say that syntax > semantics. Even in a casual sense.

                      The entire OO movement is a thing about semantics. Simultaneously it’s a massive marketing scheme. What does that say? Probably nothing much at all.

                      If I were forced to bet, I’d put more money on the explanatory power of historical momentum for TIOBE than syntax, semantics, marketing, money, or any of the above.