Interesting: code of the same application in PHP, Python, Ruby, Closure, node.js, Java and Go
Definitly worth a look: Adam Bard created a tiny application in 4 different languages (PHP, Python, Ruby, Closure), just to show how some basic syntax and application architecture of every language. Other people joined this idea and added versions in JavaScript/node.js/CoffeeScript, Java/JSP and Go. But – in theory a wonderful project – the results absolutly don’t represent the languages. In some case the pure language is used, in some a framework is used. Beside, the PHP example is horrible, no serious developer would mess up PHP and HTML in that kind of way. Third negative point: Sometimes the views or the view-code is put inside the main application, sometimes not. Number 4: Some examples have multiple view and a full form, some just put out one a string. This is simply not compareable. For a REAL comparison I would love to see experts in these languages writing the app in the best, modern and readable way possible (sounds like a serious project for 2014).
And to be honest, looking at the syntax says probably nothing about the pros and cons of a language.
Anyway, looking at the examples is still interesting: I’m surprised by the simplicity of the Python example, but that’s mainly because it’s not pure Python, he’s using a microframework here (which would also make look the PHP example much much cleaner). The usage of a framework makes this project a little bit cheesy, as it does not represent the original idea anymore. Especially the node.js example is remarkable: Nice code (but I hate to work without brackets!), very short, and readable, but the Go example looks much more organized (but is sooo long), I also like the PHP/JS-like func xxx() {} coding style. The final Closure example looks interesting too, very simple, but unusual/hard to read. Ruby seems to be a good candidate for extremely reduced code, the syntax shows why Ruby has such a hard fan-base. First impression: really good! Biggest surprise: The syntax of Java/JSP, it’s so extremely near JavaScript and PHP. Cool! A little side note here: There are languages on top of Java that have a simpler syntax.
I love clean and “visually readable” code. Code that has clearly visible “units” and “levels”. I also like brackets and use of natural basic human-readable english language. And the dotted.chaning.syntax feels totally right, something like x = model.cars.getCarById(7).sortDesc().yourMom().trim() clearly says what’s going on, and handles a lot of stuff in one line without looking weird.
Personal conclusion: As a PHP and JS developer I find it extremely easy to read und understand the Java example. Wow! I think every PHP developer with JavaScript knowledge who has never seen Java code before feels the same right now. The entire Java example is fully readable, each line makes sense, everything feels natural, logical and correct. Even without having any Java skills it would be easy to add and change stuff. Gentlemen, thanks for sharing this great moment with you! Maybe it’s time to read a Java book in the next holidays :)
Full article: http://adambard.com/blog/PHP-ruby-python-clojure-webapps-by-example/
Example in Java / JSP
Example in node.js / JavaScript / CoffeeScript
Example in Ruby
Example in Closure
Example in Go