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

21–30 of 60 posts

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

#21
post #17

It's because some people don't like s-expressions, so they've been making up a bunch of other stuff.

My theory: people who don't like s-expressions don't get programming; Thus, everyone who gets programming and is exposed to lisp becomes a lisp programmer, and people who suck at programming are left out.

I know many people who are counterexamples to your theory. Languages like Perl and Python have a strong advantage in libraries. If you don't need the things that only Lisp can do, there's not as much of a reason to use it.

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

#22
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 "echo" because that's what shells used.

But usually, there are very good reasons for any differences.

One reason is the inherent complexity of a parser for a full programming language. 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. 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, much less after adding support for extra "standard" constructs from other languages.

Yet another reason is that languages aren't as universal as you may think. For example, what would 'print "hello world"' mean in a makefile...when would the print-out occur? Would languages be allowed to ignore "standard" expressions that they can't logically use, or be forced to invent some interpretation of them?

A final reason is what would happen when languages are embedded in each other, which is even summed up by your example, PHP. If one language is embedded in another, it's a plus that they have different syntax: it clearly separates one from the other. This reduces the risk that you'll have to (for instance) escape or namespace every single name used by the embedded code, to avoid collisions with the surrounding file.

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

#23
post #3

The problem with standardization is that you iron out all of the innovations. Certain language constructs are simply better for certain tasks. Lisp is built for recursion so it's great with lists. Object-oriented languages in theory are great for modularity and maintainability. Granted all these aspects have a lot to do with the coder in addition to the language. If all languages required you to manage memory as in C…

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.

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

#24

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

There is an answer to that question:

http://www.xibalba.demon.co.uk/jbr/ranto/

Esperanto is not particularly easy to learn, despite the claims of its founder, so learners devote their time and effort to learning languages with much more return on investment once the language is learned.

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

#25

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.

scheme and common lisp?

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

#26
post #3

The problem with standardization is that you iron out all of the innovations. Certain language constructs are simply better for certain tasks. Lisp is built for recursion so it's great with lists. Object-oriented languages in theory are great for modularity and maintainability. Granted all these aspects have a lot to do with the coder in addition to the language. If all languages required you to manage memory as in C…

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 keep hearing the same old mantras:

Java -> uncool and slow

C/C++ -> fast

PHP -> hack

Ruby -> cool but slow

Cobol -> for dinosaurs

.. even after the problems are fixed, the image remains. It's pretty hard to change people's perceptions.

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

#29
post #25

Earlier quoted context omitted.

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.

scheme and common lisp?

Isn't scheme a subset of common lisp (at least loosely speaking)?

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

#30
post #26
post #3

The problem with standardization is that you iron out all of the innovations. Certain language constructs are simply better for certain tasks. Lisp is built for recursion so it's great with lists. Object-oriented languages in theory are great for modularity and maintainability. Granted all these aspects have a lot to do with the coder in addition to the language. If all languages required you to manage memory as in C…

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 slow.
Post reply on HN