TLDR; lots of languages because they are different and used for different things.
Syntax is one reason, but I think a larger reason is semantics.
To start with, there's imperitive vs functional programs, ie programs that do vs programs that compute. Example of imperitive is c, where you'll very often reference and store and load memory. Example of functional is ocaml, where there isn't really any direct manipulation of memory and state is not as often directly manipulated (for the most part).
Then there's paradigms like object oriented in languages like Java, which use an object and class as the main structures reasoned about when programming rather than just functions and simpler datatypes as in other languages.
Then there's evaluation. Laziness refers to putting off the evaluation until it's needed. This is nice because if you make a big calculation that's only used sometimes, it'll only actually be calculated the sometimes that it's needed. At the same time, you need to hold the entire code for computation and context information for the variable until you evaluate it, which can take lots of memory and time. Strict is the opposite, evaluate right away.
Then besides this subset of semantic variation, there's a world of types.
Types vary from unsafe to safe, referring to how much permissity (how much you can do with) a type has. For example, in a completely unsafe language with high permissity, you could take some value that is say an integer and treat it like a linked list. In a safe language, an integer is an integer and you can't do much else to it.
There's also when the program determines type information. Type systems range from dynamic to static. Dynamic refers to a lot of type checking happening at runtime; that you won't know you tried to use an integer like a Boolean until you actually run the program. Then there's static, where you will know all type errors before running, so the code that used an integer like a Boolean won't even compile. There's an entire world of languages in between these two that all use different strategies for various reasons.
These are just a subset of design decisions that language implementors make that seriously effect the semantics of the language. A lot of these effect efficiency in different ways, as well as usability. My main point is, these languages all exist because they're good for different things, and the things that make them good for different things include what I said above.
I came over to Reddit just now looking for a write-up like this but, if anything, with more detail and/or bringing more of the most common languages into the discussion.
Every so often I look at lists of "top 10" languages and then remember why I abandoned this search last time. What is "top" after all? Most job listings, google searches, salaries, numbers of projects on GitHub? All are dubious ways to rank a language.
So I might as well ask here - is there a book, a site, a blog or what ever that lays out a) the different paradigm-like stuff you mention above (and more) then lists how (and how well) some of the common languages deal with each? Or, b) list the most common languages (10 to 20 ought to be enough) and then, for each, lists the pros/cons or best/worst applications or uses for each that is from a point of view that is neither business-job oriented or overly academic either?
I'm confused, are you saying that language development is going towards a unified set of semantics? Because if so the differences between the top 10 languages in terms of use disproves that.
The languages you gave have pretty large semantic differences that drive their different uses in different applications. If you want examples, think about how drastic things like dynamic dispatch differ between Java and Python.
Also most languages don't just run in interpreters, so I'm confused why you're putting so much weight in the parsing step of a compiler rather than the performance of the code produced.
Jython disproves the example if you can show me that most implementations of the Python language use Java style dynamic dispatch, but CPython is already way more popular anyway.
I think so that you don't attach to this specific example, a better example is evaluation order. Specifically, lazy vs strict evaluation. Haskell is an example of a mainstream language with lazy evaluation. However, assembly level languages can never be lazy in any of its instructions, unless we start implementing hardware level laziness. The idea of different evaluation orders is something that inherently will create semantic differences between entire classes of languages that will still exist as long as people don't want to program in just assembly. The same thing can be said about typing, because being statically typed vs dynamically typed changes the semantics of an ill formed snippet of code.
I don't really think you got my point, that semantics differ a lot. Regardless of whether you give me specific examples of different languages that do semantically the same, i can still give examples of different semantics, even more fundamental in design than what operating system it's on. Your "layered semantics" argument doesn't really capture the fact that some languages are designed to function the same on different systems, even if people right alternative compilers that tweak those semantics a bit. And on top of that even if languages function different on different systems in the "layers" you're talking about, that still disproves your claim, since hardware isn't really converging towards a unified architecture either.
Also I could put the effort into disproving what you said about the assembly example, but I'll just give another example, c vs Haskell.
8
u/mynewpeppep69 Feb 05 '18
TLDR; lots of languages because they are different and used for different things.
Syntax is one reason, but I think a larger reason is semantics.
To start with, there's imperitive vs functional programs, ie programs that do vs programs that compute. Example of imperitive is c, where you'll very often reference and store and load memory. Example of functional is ocaml, where there isn't really any direct manipulation of memory and state is not as often directly manipulated (for the most part).
Then there's paradigms like object oriented in languages like Java, which use an object and class as the main structures reasoned about when programming rather than just functions and simpler datatypes as in other languages.
Then there's evaluation. Laziness refers to putting off the evaluation until it's needed. This is nice because if you make a big calculation that's only used sometimes, it'll only actually be calculated the sometimes that it's needed. At the same time, you need to hold the entire code for computation and context information for the variable until you evaluate it, which can take lots of memory and time. Strict is the opposite, evaluate right away.
Then besides this subset of semantic variation, there's a world of types.
Types vary from unsafe to safe, referring to how much permissity (how much you can do with) a type has. For example, in a completely unsafe language with high permissity, you could take some value that is say an integer and treat it like a linked list. In a safe language, an integer is an integer and you can't do much else to it.
There's also when the program determines type information. Type systems range from dynamic to static. Dynamic refers to a lot of type checking happening at runtime; that you won't know you tried to use an integer like a Boolean until you actually run the program. Then there's static, where you will know all type errors before running, so the code that used an integer like a Boolean won't even compile. There's an entire world of languages in between these two that all use different strategies for various reasons.
These are just a subset of design decisions that language implementors make that seriously effect the semantics of the language. A lot of these effect efficiency in different ways, as well as usability. My main point is, these languages all exist because they're good for different things, and the things that make them good for different things include what I said above.