Live data from Hacker News

Ask HN: Can someone explain to me why all languages don't try to have the same syntax?

news.ycombinator.com

31–40 of 60 posts

Re: Ask HN: Can someone explain to me why all languages don't try to have the same syntax?

#31
post #6

Because syntax is one of the features of a language.

and often times new syntax is created to support features in a language... ...and if you have the same syntax for all languages then what is the difference? All languages would just be extensions of the same basic language if the syntax is the same. It is a good question though. Why have more than 3 or 4 programming languages at all?

We have programming languages because people make them. The only way to have only 3 or 4 is to eradicate all but those and stop people from making more. However if we did that, I have a feeling we would now choose 1 or 2 that wouldn't exist if someone had done the same thing a decade ago.

Re: Ask HN: Can someone explain to me why all languages don't try to have the same syntax?

#32

In some important cases, languages already have common syntax (such as mathematical operators, regular expressions, and string interpolation such as "\n"). And in those cases, the simplest explanation seems to be: "there was no other sane way to do it". Some differences really are arbitrary, and could theoretically be merged. Some are historical, e.g. someone worked on Unix for years and thinks in terms of verbs like…

> In some important cases, languages already have common syntax (such as mathematical operators

Except that they don't. Almost everyone agrees about the relative precedence and associativity of the two argument forms of addition, subtraction, multiplication and division, but that's about it.

And then there are the folks who think that multiplication is denoted by a space. They call themselves mathematicians. Don't they know that space is concatenation or ignored?

> One reason is the inherent complexity of a parser for a full programming language.

For some full programming languages maybe. Other languages are so easy to parse that they added support for roman numerals, turing-complete read macros, and other things.

> It turns out that it's fairly easy to confuse a parser, because they're just not as good as human beings at correctly interpreting the "intent" of a statement.

It turns out that people aren't all that good either - they're subject to a 7+/-2 rule. Plus, very few people can reliably remember 10 levels of operator precedence.

> Most languages don't have a reason for being unless they introduce a bunch of unique constructs; and they're lucky if their own constructs can be parsed unambiguously.

Huh? Apart from some nastiness involving > when C++ templates were introduced, how many programming languages have ambiguous parsings? (Yes, many parse things in ways that some humans find "unintuitive", but that's different.)

Re: Ask HN: Can someone explain to me why all languages don't try to have the same syntax?

#34

Earlier quoted context omitted.

He asked why we need different syntaxes, not languages. Most of what you said doesn't relate to syntax at all.

How could you have two different languages with the same syntax? The only thing I can think of is one is a subset of the other.

Since you can write down all abstract syntax trees using the same syntax, and you can convert most languages into an abstract syntax tree (all the popular ones), it would be easy enough to write down most languages using the same syntax.

The real question would be whether that AST syntax would be better than the language's own syntax. I'm guessing it would be harder to read, since a good syntax for an AST would describe only the semantics of the tree, making it harder to pick out the structure of the language itself.

Re: Ask HN: Can someone explain to me why all languages don't try to have the same syntax?

#35
I can live with differences in language syntax since in many cases there are semantic reasons behind them. The thing that really gets on my nerves are minor differences in the representations of common data structures (lists, tables, dictionaries, etc).

Re: Ask HN: Can someone explain to me why all languages don't try to have the same syntax?

#37

Because people have different syntactic preferences? Because some people hate c-style brackets while others hate python-style white-space? While it would make life easier in the short-run for those trying to learn a language who have pre-existing knowledge of the standardized syntax, it's quite possible that some other syntax would lead to wildly improved programmer productivity or, at the very least, much more reada…

Python-style colon + whitespace.

Re: Ask HN: Can someone explain to me why all languages don't try to have the same syntax?

#38
Why does PHP need to use crap like echo and all those dollar signs instead of something more universal?

This strikes me as a bizarre statement. What's more universal than "echo" and "$", which are found in nearly every UNIX shell? UNIX has always been the backbone OS of the Internet, thus a language designed specifically for that purpose would naturally bring along some of those conventions common to administrators experience. (Technically, it probably happened this way in PHP because of the restraints of the way PHP began, but that's not to say $ and echo wouldn't have been natural choices, even if PHP had been more ambitious early on.)

There are many things to complain about in PHP, but these two conventions were not invented for or by the PHP developers.

I get your point, of course...but when you use examples like this, picking on what is very likely the most popular language in the world for developing web applications, it just makes me think you're really saying, "Why does PHP suck?"

Why doesn't Ruby use PHP syntax? After all, if we're going to agree on syntax, shouldn't the one that the largest number of people are already fluent in be the one we choose? Should we go back to earlier languages? Should Python have gone with C-like syntax, like Perl, since C syntax is far more common? Who decides what the right syntax is for all languages to converge on?

I think I have to conclude your question is invalid.

Re: Ask HN: Can someone explain to me why all languages don't try to have the same syntax?

#39

A better question is why doesn't everyone in the world speak Esparanto.

Or even, why isn't every language written using the latin alphabet?

To which an answer might be, latin doesn't support certain sounds, can't represent tones... and if it did, it would break chinese language interoperability.

Re: Ask HN: Can someone explain to me why all languages don't try to have the same syntax?

#40
post #30
post #26

Earlier quoted context omitted.

I don't mean to be pedantic, but the 'Java is slow' thing simply isn't true anymore. It certainly used to be slow back in the day, but it's actually pretty good these days. From what I've heard, programmers at Google put it in the same ballpark as C++. This brings me to another point.. the choice of programming language often has more to do with image and branding as opposed to actual technical merit. That's why we k…

A lot of java software implementations are still very very slow. Try restarting a tomcat servlet container (web server) for some java web project and then try the same with some apache or django dev server. One takes 10 seconds, the other is done in a blink in of an eye. Look at eclipse/netbeans vs. xcode, swing applications vs. wxwidgets applications and so on. Java very bad start up times still makes it effectively…

Give me a break. What are you running the tomcat on? an 386? let's go back to Assembly yeii! eat some stones baby
Post reply on HN