Hacker News new | past | comments | ask | show | jobs | submit login

Excellent exposition of what I was trying to say.

The overarching concept is the ""expressiveness" of a language. Concept is "How easily can I express my goal in the language. A crude measure of the relative expressiveness of two languages is the ratio of the number of tokens in the respective implementations of a program. I remember reading a study a decade ago that ranked C at 1, Java at 2, Python at 5 (roughly). Having hashes and their literals as part of the language makes it more expressive than one where hash is in a library. Look at JavaScript where the literals for arrays are used as a serialization protocol.

Expressiveness goes beyond just literals. In python functions are first class objects, so there is no need for the thunk/functor/inner class kludge that you have in Java. Or look at list comprehensions which are way more powerful than for each.

The expressiveness shapes how programs are coded. Programmers will use a concise, powerful idiom because it saves time and thinking and the program is shorter. There is a corresponding obligation on the language developer to make sure the expressive idiom is almost always the best way to go.




The "crude measure" that you cite which "ranks C at 1, Java at 2, Python at 5 (roughly)" shows that on average, every line of code in Python is worth 5 lines of C. Let assume that this is true.

Naturally, this seems to imply that more powerful languages require less code to perform the same task. Python provides a good example of this, but it is not always true.

C is not a very expressive language. It is often cited as a portable assembly. Yet, decades of unix/GNU utilities show that powerful programs can be written in small amounts of C, which are combined to build elegant and decoupled systems.

Java is more expressive line by line, but its implementation of OOP requires so much boilerplate that it requires no less code than C to represent the same simple design as the C equivalent. Additionally, because each line of Java represents 2 lines of C, the resulting programs are far less efficient.

It is important to consider why this true. Java attempts to abstract many of the details of the underlying C implementation, allowing it to be much more expressive. This abstraction allows the higher level programmer to think about business logic rather than pointer arithmetic.

However, these abstractions constrain the programmer's ability to write code that the language designer hadn't considered.

Of course, you might consider these to be edge cases and that is a fair point. However, crippling the outliers pushes your userbase towards mediocrity.

As pg stated: "when you damp oscillations, you lose the high points as well as the low."


So we need a high pass filter for languages?


Oh certainly, Java's missing a heck of a lot more kinds of expressiveness than just literals; I was just trying to show, mutatis mutandis, what a Java-with-decent-literal-syntax would be like, as compared to the current state of affairs.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: