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

1–10 of 60 posts

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

#1
Why does every language need its own syntax? Why does PHP need to use crap like echo and all those dollar signs instead of something more universal?

Why can't all those projects come together and figure out a single universal standard for writing syntax? So that writing code would be exactly the same, no matter what technology you choose to use. At least for the simple stuff.

Why do programmers need to waste time remembering 20 different ways to write something as stupid as a Hello World application?

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

#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'd wager we'd have many fewer entry-level script hackers. Sure, every program would be lickety-split fast, but the App Store certainly wouldn't have 10,000+ apps.

And if every app were written in Java everything would be very portable but also quite slow. It's all about trade-offs and picking the right tool for the right job.

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

#7
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 readable/aesthetically pleasing code.

In general, there seem to be a plethora of values which can be considered in choosing the syntactic form of a language: aesthetics, productivity, tradition, etc. Having different syntax between languages allows different niches for languages within these values not to mention allowing the possibility of great innovations which could improve the experience of programming. Seems unlikely that any current language has the optimal syntax with respect to maximizing all these values and hence it seems foolish to cut off innovation.

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

#8
post #5

If they did have the same syntax, would they be different languages?

Different semantics

Same syntax, different semantics.. that does not sound easier to me. At all.

Also, why don't we all just use one operating system for everything, have one kind of coffee, and eat one perfectly balanced meal all the time?

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

#9
This question can not be fully answered in prose. It can only be answered with a challenge: Learn four or five diverse languages reasonably well, then try to create the single syntax that works well for all of them. You'll understand when you're done... or perhaps rather, when you find you'll never be done.

I will give one example of the tens upon tens of issues you will encounter: What's the one true syntax for a type declaration? Then, once you've answered that, how does that one true syntax manifest in Python/Perl/Javascript?

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

#10
post #5

Earlier quoted context omitted.

Different semantics

Same syntax, different semantics.. that does not sound easier to me. At all. Also, why don't we all just use one operating system for everything, have one kind of coffee, and eat one perfectly balanced meal all the time?

It seems you're disagreeing with a statement I never made.

The question was "If they did have the same syntax, would they be different languages?"

I replied: "Yes, they would be different because their semantics would be different"

I never said it would be a good thing. And by stretching your analogy to the territory of food it only becomes weaker (with food diversity is a goal by itself). Also it can be argued that using the same operating system for the vast majority of tasks is desirable.

Post reply on HN