Tuesday, August 12, 2014

Ruby versus Python - a programmer's choice

If you regard or call yourself a "programmer", the obvious choice is Ruby. If you spent an hour looking at both languages totally new to you, and you cannot tell which is better, I can assure you that Ruby got there first at two of the biggest things now, Ruby on Rail, and Chef/Puppet. Python is just playing catch up and doesn't seem to catch on. Would you ask yourself why?

The most important thing is programmer productivity. An early airline reservation system shared their experience that they are the early developers, with how many mega lines of Lisp code written by few programmers. Provided these guys are not static, there's no way other developers can catch up. If you are one many year ahead, others will always lag you by one year. If they throw in 12 man for one month, there will certainly be a disaster. When your product get to maturity, there's just no need for another similar product.

Many of the arguments and comparisons are irrelevant to "programmers". Ruby code can make your eyes bleed more. I agree but bad programming practice is a personal choice. Ruby is as object oriented and as functional as anybody else. There's no inherently obstacle to readability and maintainability. Perl is still alive and so are it's generation of system admins. If they want to write Ruby in Perl style that is a personal choice.

Most of the time veteran programmers and contractors deliberately make their code impossible to maintain by others so as to secure their job and status. This is hard to avoid but management would prefer something with more inherent restrictions. The majority of companies are not startups that need productivity and creativity.

Python has a lot more mature libraries. It's because Python was supposed to be a better Shell in it's early days. If you can't rewrite those things you need in Ruby you have no choice. If you have to learn you can always learn Ruby on the side or later.

I read about that most libraries in the scientific community are written in Python. That's true and I regard myself in the scientific/engineering community, but screw them. Many will be happy to use Fortran if Microsoft still let them. Since nobody let them they move on to Matlab.

Trust me, I had the privilege to help a professor who dug up a ancient dialect of Fortran program to interpret the moon's surface data using dot matrix printer. I knew too much Fortran than I would like to admit because I had failed to convert a few critical "routine", but utterly incomprehensible, to C or preferably C++. I managed to fix the dialect and get the programming running in a single lab lesson, which is a miracle to me. I even get to view a little of the moon's surface on a dot matrix printer!

I had little idea why that somebody in that community can write huge incomprehensible and eye bleeding programs. That's just me, from my viewpoint. They seems to enjoy it. But if you talk with them about objects, class, functions (as in functional program), they would walk away. Some C programmers challenge every C++ thing I made creeping into their system even though the compiler have no problem with it and they don't need to know. Most of them are commented out test code anyway.

Professors are wary that students run into bad program practice if the language lets them. Students are wary if the language is good enough. Nobody uses Pascal. There's no harm to teach or learn it, but ..., nobody ever uses Pascal. If you are a professor, you should be able to turn the disadvantage of an imperfect language into an advantage, of teaching. If you are a student that worry about learning bad programming practices, you should not learn anything on your own.

Many people worry about feature rich languages. If they come across something that they don't know, they will freak out. They cannot say they are competent in that language. A programmer will have no problem if you yourself are the only one that you answer for.

Every time you want something for yourself, somebody else will shoot you down one way or another. What about the runtime efficiency? Java didn't apologize for it and got compilers for it. Now Java became the "efficient" language to write compilers for others like Ruby.

C++ is the first language available on most computers that allows painless writing and using of "libraries" on anything. MS screwed it up. They are more happy to sell you visual basics and they charge you dearly for whatever language you use. Unix screwed it up. Even the compilers have no problem with it, the graphical system community soldiered on C way much longer.

Java is very limited as a general purpose language as compared to C++. For one there's no operator definition when the Math (not Mathlab) community uses it since ancient times. Not to mention the lack of overloading.

Nowadays you should enjoy the chance to open up any browser on any computer to learn and use a pretty object oriented language - Javascript, totally free. Ruby is even better outside the browser with all types of system, graphical and web related things.

No comments: