Even though I often use one of Donald E. Knuth’s most famous quotes:
"Premature optimization is the root of all evil."
I seem to ignore this truth in every single project, code or word. The matter of the fact is that I love optimization. Rough patch work is not worth doing if it’s not going to last, a small web app is not worth doing if it’s not going to scale, and so on. Every piece of code that I do has to be as efficient and as scalable as possible, no matter if it takes forever to complete.
These simple, but legitimate coding belief has led me to a dilemma, and I admit that for the past 6 months I’ve really been confused about my coding, unable to get anything done at all, going into optimization prematurely. Hell, even my choice of language for my projects has been compromised. I’m no longer convinced that I should use .NET for everything, quite the contrary – currently I’ve got no projects planned where plan on using it.
Of course that last point is a good thing. .NET is good, for a few very distinct things, perhaps mostly those that have to do with parallel processing and developing in an enterprise. I’ve done a bit of Python, a bit of assembler, a bit of C++, a bit of Pascal, a bit of PHP, a bit of Java, a bit of everything really. I mean the real idea is that a “Good developer eats a new programming language for lunch,” and this is exactly what I’ve been doing for the past year or so.
When it came around to planning out WikiPub, among other projects, it was really hard for me to come to the conclusion of using Python(with AppEngine or not, it will be in Python). But why not Java, why not C#? We could use Google Web Toolkit in combination with AppEngine if we coded it in Java, or we could use ASP.NET AJAX(among other things) in combination with Azure if we did it in C#.
So, why Python? There is a simple and very smart reason for that, which has nothing to do with it being dynamic, syntactically sweet, well documented, the many libraries, or the support for it within AppEngine. The reason stroke me as I discussed this very dilemma with @slaveriq about a week ago. Or rather, he put another angle to the aforementioned Knuth quote.
The quote doesn’t imply that optimization is bad. Quite the contrary – optimization is implicitly implied as a must. Rather the quote warns of premature optimization(something I foolishly ignored before).
Optimizing before you know what you precisely know what you are doing. Thus we can conclude that what we need to do, when designing a piece of software to last for all eternity(alike the Oracle kernel), we need to have a clear idea of all the functionality involved and required, as well as be well-skilled in our tools.
Sounds kind of basic doesn’t it? Well, UML diagrams and certifications aren’t quite the whole package. Once you have those in place in a project, you usually turn to choosing a certain programming language. You might give up some of your functionality, speed or overall efficiency for ease of development, lower costs, or perhaps a billion other reasons.
The fact of the matter is that you are putting your code, it’s possible optimality(never used that word before) and it’s possible future implementations within a dimension of the very programming language you choose.
Thus, we must think long and hard before we make that choice, or perhaps, we don’t have to.
In the modern era where everyone is a bit of a developer, and only a minority are actual good developers, we have languages where optimality has been greatly given up for simplicity of development and possibility to run the code cross-platform and cross-OS(Java, .NET). But the few good developers know better, and stay as far away from these as possible, keeping on to their C and C++ cultures as if their lives depend on it. At the same time these languages high learning, developing and testing curve, which may require immense skill and dedication to execute.
We can argue for days which one is the better choice, believe I’ve been arguing with myself for the past 6 months, but now I believe I’ve found a suitable solution. I feel like I should build up a hype for this, ah, what a hell, here it goes.
What if you had a language that has the high-level features and attributes of a 4th generation language, but at the same time allowed for low-level optimization of parts of the code in the future? Thus you will tell me that you CAN use old DLL’s with .NET, but does the term DLL hell tell you something? You CAN also make inline C++ code in both Java and .NET, but the whole process isn’t intuitive, you can’t f.x. just replace a class, you have to either replace a few lines or a whole library. So, in this respect, why Python?
Knowing that a scripting language like Python would never surpass in speeds over the compiled C++, it’s developers decided to build in support for quite literally including C++ code as parts of your projects, big or small. The result? You have a dynamic scripting language with a very small learning curve, and features that make a developer say “ooooh”, that can in the aftermath be optimized with a low level language like C++.
Thus, my conclusion is as follows:
Get all your functionality in place with a high-level language, only then optimize it functionality by functionality with a low-level language.
What languages support this development process? Not too many really. As far as I know only Python really makes this way of developing for optimization really intuitive, but perhaps I am wrong?
P.S. Certain languages have better implementations, and ways of doing things than others. It would be nice with a Framework where you could optimize your code in different languages, or perhaps have it done for you out of a user-generated database of best-practices taken from a site like StackOverflow. I guess I have my first idea for a Ph. D. project 🙂