After one has been programming for several years and has messed around with enough languages, you start to notice that you like some languages better than others (and feel the need to tell the world this). This type of feeling is completely subjective and usually based on experiences with the different languages, and is quite different from programmer to programmer. I've met programmers who refuse to use any language that is interpreted or run inside a VM, at the same time I've met programmers who refuse to use any language that doesn't use garbage collection - for completely different reasons (if you must know, the first ones hated wasting the users' time/resources, the second ones hated wasting their own time/resources).
I'll share my story with you. I like to program in Ruby - in case you haven't noticed at this point. However, I also still like to program in C++. Anybody who has seen both of these languages (or have even met people who are fans of either language) can be completely boggled as to why, myself included. They are so completely different that it is almost surprising to say they are both imperative languages (you can get more different by going into functional languages like FORTH, but we won't go there right now).
However I've realized there are three things that I like about coding - freedom, elegance, and speed. It's really difficult to find a language where you can have all three of these while still having the available libraries for me to make games or web apps in (the only apps that I really like to program it seems). Freedom is present in both C++ and Ruby - it is the idea that there are many ways to solve a given problem. This is what really turned me off Java1 and to a lesser extent, Python2; and makes me pick C++ over C.
It is the other two that these two languages are at odds with. You don't really get faster than C++ - unless you're a whiz with assembly, which I am not. C might be faster, but I loves me the STL and the Boost. With C++ you have access to OO solutions and the security of a rigid type system (although I have to say I was amazed by the wonderful combination of flexibility and security in Haskell's type system). It seems like if I can write code that is really fast, not too much else matters - for example I ditched the std::complex class in favour of three doubles for my fractals implementation, it was a speed increase of like 10x which basically made it go from taking several seconds per frame to pretty much real-time. It's probably because g++ decided to put those doubles as floating point registers or something, where the complex objects were just being stored in RAM. I could probably find out for sure by doing an ASM dump of the code, but it's late and I'm going to sleep soon. Maybe I'll post on it some other time. Anyway, it finally occurred to me to upload this (a few months late), so take a look:
ASIDE: After watching this video I realized that this has been converted from screen capture to Ogg/Vorbis to AVI to FLV - if you want the code to watch it yourself, you can grab it here. It requires SDL and a C++ compiler.
At the same time though, Ruby is expressive. I can say what I want to say easily (more so than with pretty much every other language I've used - maybe I still have my head in the box and need to branch out more) and elegantly. It is the aesthetics of the language which appeals to me at a higher level. One thing that annoyed me when using Python was when I wanted to do string processing - Ruby's regex handling is amazing, especially when coupled with the OO aspect. And long method chains seem to have a much nicer flow to them than something like foo1(foo2(foo3(x))), so long as you don't have too many blocks thrown in. And finally, the fact that EVERYTHING is an object, and EVERYTHING works like an object (sorry Python, you're nice and all but things like len(str) annoyed me from this perspective), and finally EVERYTHING is modifiable. While Ruby's monkey-patching can be a royal pain in the ass even when used by people who know what they are doing, it is basically the language designer's way of saying, "I don't know everything. Have at 'er." I respect that a lot and think that it is a great way to make the language evolve.
So, what is it that you like?
1Note that I am not saying Java is bad - I know plenty of good programmers who I respect that love Java (and/or Python for that matter). I'm just saying that its way of doing things are not really the way I like doing things, I find myself fighting it more often than not.
2I actually kinda like Python. I respect it because it does what it wants to do really well - basically saying there is one way to do something, and not getting in your way while you do it. A thing that I love and hate about Python is that it removes the need for the thought, "I can think of multiple, equally good ways of doing this, but which is the most elegant?" With Python you just do whatever works. It bugs me and relieves me at the same time because sometimes I can think of a solution that is more "elegant", but not really any better (and possibly worse).
Jun 3, 2009
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment