Python, Ruby, Node, Go, Java, Scala, Javascript - the language cocktail & its mystical nature
This post is going to be short, I don’t quite know that yet. I intend to make it short, but I am verbose, thats my flawed nature. I don’t have too much expertise on languages. But I will try to be as much informative as much possible to my capacity and capability.
Great people have studied, worked hard and developed new languages and made them reach their glory stages. Yes, programming languages, the food of every software engineer. Programming Language, the only real thing they know and believe in after The Big Bang.
Programming Language — its just a tool, don’t be hard on yourself and don’t let your fellow peers give you inferiority complexes, and tell your recruiters you can’t care less and so they should too.
Different Languages come with different flavours. They have their own style and syntax. You like some of them, you love some of them, you hate some of them and you just break up with some.
Time and now, we keep profiling people, your fellow colleague, your new interview candidate, your student counterpart by their programming language proficiency.
Enough of that. Can we get over it already? Grow up, please! Giving too much importance to programming languages is killing you already. Focus on the important things. Focus on the concepts. Focus on the system and its design. Focus on the architecture. Focus on the algorithms, the data structures. Focus on the ways you can solve a problem.
Programming languages are just tools which help you put all the above into a tangible usable product. So if you keep the above solid, no matter which programming language you use, the product comes out to be just fine.
You want more explanation. Don’t you? I am not convinced either.
Let’s talk about Instagram. It has over 500 million users. Thats huge folks. That is real huge. And guess what language our Instagram friends have used primarily to build their mighty product. Yes, its python. the much debated language when it comes to performance, given its super slow speed when compared to languages like Java, C/C++, Go, etc.
Whereas I know of a company which started their humble journey with Java, the mighty language, with great performance but verbose codebase. They had a good choice of programming language which is much proficient than python in terms of performance and yet they couldn’t reach more than ten thousand users. They shut shop after a while.
Now, the moral of the story is, that the product is important, not the tool you use to build that product. Well, the only anti-argument I can provide here is, that at a humongous scale like that of Instagram, if their primary language would have been Java or Java based, then they would be having lesser scalability issues or complexity problems as compared to python. Since python being super easy to use comes at a price of being a little slower and a slave to its GIL dictator.
But, as you grow, your expertise in a particular language grows too and then you become proficient enough to handle many bottlenecks the language you use provide you with.
Still, I need the best, how to decide?
Hmmmm…Adamant are we? Okay, Okay! I will try to make some sense here and try to give you a perspective.
See, languages are just like protocols, they have some rules that are followed when you write in a language. The implementation of language is the real deal.
For example, python is the language, which has laid out some rules regarding how its syntax will look like, what are its semantics, the conditions, the rules that must be followed to write a code. And thats it, thats python for you. Now, the implementation decides what and how the code will be run and thus the speed, the performance, etc. The implementation decides all of it. Cpython is the C implementation of python, Jython is the java implementation of python, similarly there is IronPython, Cython(a little different from the regular ones), then comes PyPy (a JIT flavoured python implementation, the fastest of all). All these different implementation have some slight differences in their syntaxes, and comparable differences in performance. See, the implementation of the language is the real deal.
Now every language has its own way of dealing with things like garbage collection, memory allocation, deallocation, memory leak, the way they assign heap and stack, the way object are defined and assigned values, the way the function calls are handled, the way the I/O is handled. All these are different for different languages. More, the way profiling is done, the way debugging is done, the flexibility of variable assignments, the nature of the type definition, assignments, some are statically typed like C/C++, Java, Go, some are dynamically typed like python, ruby, javascript, php.
All these factors are the ones you should look for if you are trying to be a perfectionist here. So you may just focus on the ease of development, I mean you want to just code fast without caring about memory allocation/deallocation, type definition, garbage collection, strict syntax, etc. Or may be you care about raw performance, you need granular control on memory, on how you want to do garbage collection, you want strict control over the variables you define, etc.
So these are the things most people just ignore and they just go ahead and use what others suggested them or the herd is using presently or what the industry is requiring or what the recruitment preferences are, all these are other factors that also play a part in deciding the language preference.
I know, I have pushed you even below and now you probably hate me more since I became a diplomat and never told you what you wanted to hear, the verdict, the ranking. Well, my apologies, I cannot do that. There is no ranking. There is just a use case. Anything and everything is fine. The focus is on the product. How you make the product is purely your choice. Use the tool which you know, which can help you make the product faster and still keep its quality to the best you can.
Slowly you can change your preference due to some bottlenecks your current tool is unable to solve, but that is a long shot. You will probably have bud of super soldier coders at your bay when you would want to or be in a requirement stage of making the shift.
So get over it already. Shout out to the recruiters, the budding engineers. the novice students. Please!
Languages are just tools, just use it like a tool. Focus on the bike, the car on the whole, not the name of the spanner company used to tighten the screws of your vehicle.
The Foundation and The Conclusion
Now as a closing argument, I would explain some of the implementation details I talked about in the above section. This would make things clear for you to quite some extent. I have been vague and all literature about the topic so far. Lets talk more like engieers in this section.
I will start with one language you can’t ignore given whatever your preference is. Its going to catch you from everywhere. You just can’t run away from it. yes Javascript. Javascript is the web language. Its an interpreted language. It runs on the Web. Actually it runs on web browsers, the clients. But to understand this let’s understand about how any language runs on the system.
Lets talk about java or java based languages. Java is the language, you code in java and then you compile your code. The compilation converts your raw code into some java bytecode which you then try to run on the system. But actually you run the java bytecode in a JVM. Its a special VM which is tailor made to run java applications.
Lets look at another language, every application you run, runs on a system. But when you try to run a program which is basically the code you write which is nothing but plain text, it has no meaning to the system, for the system it is just a mere text file, with lines of strings which have no meaning, no instructions for the computer to understand and act upon it. So for the system to run, it needs instructions, it needs a language it understands, machine code or assembly code. So there comes the need of a compiler. A compiler coverts your raw text code into machine readable file or code which can then run on the system. To be honest, there are a bunch of other processes that happen during the abstracted compilation process which we talked about, like ast generation, linking, shared library loading, assembly code conversion, etc. But we are abstracting away all that and saying the entire process is the compilation process and the end result is a file or code which you can run on the system.
C/C++ do what we talked about in the above paragraph. Whereas Java takes a little bit of a different take. Its doesn’t compile the code down to machine code which ties the output to a particular system and its architecture. On the other hand, Java compiles down to some pre-machine class or code which is universal and every system can generate that irrespective of what the architecture of the system is. And this universal code can be run universally across all machine but how? Every machine is unique and it needs its own instruction set to run any code. There comes the magic of JVM. JVM is the VM which comes in different flavours for different system and architecture but that all. After that every universal compiled java code which I mentioned is some pre-machine code, which when run on the JVM, further compiles the code into machine code which then actually runs on the JVM. Its a VM after all, it can run code as if its the sole system itself. JVM is a just-in-time compiler which does some optimizations and helps to run the java code faster.
Now lets talk about python, python is an interpreted language, actually the implementation of cpython is an interpreter. So python code which we write and run via the python code.py command interprets the code, line by line and runs on the CPython VM which is like JVM for python but not as good as JVM. JVM has JIT compiler, hence super fast. Cpython is interpreted, hence slower. And also one of the main reason for why python code runs slower than java by multifold times.
Javascript similarly is interpreted, and it runs only on the web(Well, I know you are probably frowning at this moment, but you already know that I am lying but we will come to that later) in its custom made VM called V8.
Node is another implementation kind of of V8. Its a run time engine for javascript based on V8 which allows javascript to run on any system and not just web browsers. Web browsers come with their custom V8 engines which let the javascript run on the browsers. Similarly, Node is like a VM which lets javascript run on systems which have Node installed. Node is to javascript what JVM is to Java based languages.
The unique quality of JS and Node is its built from ground up as a single threaded server. This makes them highly concurrent. But note that they are still interpreted, which has the disadvantage of being a tad slower than their compiled language counterparts. The asynchronous nature also means the are good at I/O related jobs. Computation heavy jobs will block the entire process since its single threaded.