Programming Languages:
My (Biased) Two Cents' Worth
by Philip Guo (philip@pgbovine.net)
This is my current view on whatever computer programming languages I feel like writing/ranting about. Many supposedly objective programming language description articles that I have read on the Internet are really not objective at all (you know who you are!), so I won't make any claims about objectivity. Everything below is (obviously) my own opinion, although I will try to not be too biased.
C
This is the language that I am the most familiar with because it is what I used for making my program analysis research tools at MIT and Stanford. I have also written a C Programming Tips page. C has its cultural roots in UNIX; today, it still has a massive following in the descendants of UNIX in the open source and free software communities (e.g., GNU, *BSD). I think that C is great for low-level, grungy tasks like OS, embedded systems, (really) performance-critical servers, and interfacing with hardware devices - basically anything where assembly is your only other feasible alternative. However, I am not too keen on user-level applications being written in C nowadays just for the sake of performance. Human time (for development, testing, debugging, etc.) is far more valuable than machine time. We're not in the 70's anymore!
And oh yeah, I would pretty much NEVER program in C for fun, unless there was some library that was really, really compelling and could not be found in any other language.
C++
This is the industry-standard language for most user-level applications (with the exception of free software), and I can see why. There is a strong emphasis on performance optimizations in compilers (so that C++ code can be almost or just as fast as C code), and also lots of language support for object-oriented and generic programming. C++ encourages good modular design without sacrificing performance, which makes it great for most user-level applications ranging from web browsers to word processors. However, it is a language that is ultra-intimidating to beginners and students because it's just plain UGLY. I would NOT recommend it as a teaching language, because it will make students think that programming is gross.
Java
This can be thought of as a leaner, cleaner C++ with a great standard library, well-planned language features (and wise omissions, such as multiple class inheritance), and amazing tool support (e.g., Eclipse and tons of program analysis tools, thanks to its well-defined specs which are conducive to automated tool usage). I would really like more user-level applications to be written in Java instead of C++, now that JVMs and computers are much faster than in Java's early days. I hope that Java can soon play the role that C++ played in the 1990's, and that soon C++ will only be used for truly performance-critical apps (and no, most user-level apps aren't truly performance-critical). Oh yeah, some really smart people tend to bash Java because it's 'dumbed down for the masses' (and doesn't support X or Y uber-advanced feature), but my retort is that most programming tasks are pretty 'dumb' (according to the really smart peoples' definition), so a language that makes it easy to do 'dumbed down' things is awesome for most people and thus has great popular appeal. If I had to write a medium to large user-level desktop application, Java would probably be my language of choice.
Python
This is my language of choice for small hacks and scripting applications and for prototyping medium-sized software systems. It is my favorite programming language, and whenever I program in Python, I feel that programming is fun and exciting, a feeling that rarely arises when I am programming in other languages. The excitement of Python programming makes it a great language for people who want to learn about the joys of programming. I love its clean syntax and lack of braces (or parens). I would never program in C, C++, or Java for the small hacks that I do for fun, just because I would need to write too much boilerplate code. Thus, Python has become my default 'weapon of choice' for most of the challenges that I attempt to overcome via programming.
Perl
The one-word difference between Perl and Python is 'implicitness' versus 'explicitness' --- in Perl, many constructs are implicit (and based on context), so the code can be extremely concise (but also unreadable by the untrained), whereas in Python, most constructs are explicit, so the code is a bit lengthier but much more readable and maintainable. I tried taking a stab at learning Perl for small scripting projects, but found that I didn't really want to pay the setup cost of learning all the idioms of its 'implicitness', so I'm just still sticking with Python :)
Original version from 2006-06-10: I don't think I ever intend to learn Perl because I already know Python. Yep, that's it. It's ugly to me because I didn't learn it from Day 1. I respect people who know their Perl well, but I don't aspire to be one of them. I think it's cool how there is a lot of trivia and culture behind the language and how it's intertwined with old-school UNIX hacker roots. Great for street cred, but I prefer to be able to read and maintain my code.
BASH shell
I think that every semi-serious UNIX user should learn at least one shell scripting language, and I have chosen to learn BASH simply because it's the most pervasive. Basically every UNIX-like system I've come across has BASH installed as the default, so if I write BASH scripts, it's more likely that I can run them conveniently on all of my machines and also other people can run them on theirs too. BASH has really ugly, archaic syntax, but I don't really care. It is amazing not because the language is beautiful, but simply because it provides such easy access to all popular UNIX programs, as well as to my own command-line programs written in anything that I want.
JavaScript
I have done most of my web-related programming in JavaScript because it's the current de facto standard for client-side web programming. I really like it because it's a fairly simple but powerful language that can manipulate HTML pages. The language itself isn't amazing, but it has such a powerful platform that it can run on - namely, all modern web browsers. Now it's even more popular because of AJAX (e.g., Google Maps). My only gripe with it is the slightly inconsistent implementations across different web browsers (IE, Mozilla, Safari, etc.), so it can be painful to get a JavaScript app to work just right on all major browsers. It took me weeks of effort to tweak my XML Photo Gallery (several thousand lines of JavaScript) to work on the 3 major browsers. Also, there isn't a good way to debug it on IE an Safari, which, unlike Mozilla, don't have JS debuggers.
XSLT
I really like modeling data in an XML format (because I've never really had experience with relational databases, the alternative for most data-centric tasks), and XSLT is a language that transforms XML into XML. Since HTML (XHTML to be precise) is a subset of XML, XSLT can be used to transform XML data into HTML webpages. I've played around a bit with XSLT in my XML Photo Gallery project, but often times I just find it easier to manipulate XML using Python. I'm still not used to the declarative style of XSLT programming, but I'd like to have more practice in the future.
PHP
This is the current de facto standard for server-side web programming, but I haven't really written many server-side scripts. I don't know whether the convenience offered by PHP (e.g., the ability to embed itself within HTML) can outweigh my familiarity with Python for me to use it instead of Python for server-side scripting tasks. I hear that there are good security benefits to using the PHP standard library functions for handling web data rather than, say, the Python ones, but I don't have much firsthand experience with either.
Common LISP
Some really smart people evangelize LISP as the most powerful programming language EVER, and I've enjoyed reading what they've had to say about it. However, I've personally never been compelled to use LISP in my programming repertoire when Python would suffice, mostly because it's just so darn convenient to do most of what I need to do in Python. I suppose that if I were trained as a LISP hacker from Day 1, I would 'see the light' and not live, as most of us do, in LISP near-ignorance. I think that things like true macros and the concept of programs as data are really cool, but I've never had occasion to apply them to my everyday programming tasks. Perhaps it's because I don't work on hard enough problems where the power of LISP really shines through.
Scheme
I love Scheme as a teaching language, and I think that every undergraduate Computer Science major should learn it (in addition to C, Java, and Python). SICP is a book that every aspiring Computer Scientists should own and read (and it's available online for FREE). Scheme programming problems can really stretch one's mind and challenge one to think creatively rather than focus on abstruse syntactic details (it elegantly simplifies the syntax of Common LISP, which is itself fairly simple, to eliminate some non-intuitive constructs). However, I've never, ever used Scheme outside of the classroom. Again, not because I don't like it, but simply because I just find it easier to solve my problems with Python (or JavaScript or whatever). Once again, convenient and easy-to-use libraries trump language elegance or theoretical power.
OCaml
If I had to learn a functional language, I would pick OCaml over Haskell since I've actually witnessed real practical software systems built using OCaml (e.g., my personal favorite, Unison), but I can't say the same for Haskell, as far as I know.
Update (2007-06-02): I tried programming in OCaml for the past few weeks for my research, and it was pretty painful because it took me forever to get the compiler to stop yelling at me and to finally let my code type check and compile. Now you might be wondering, 'Geez, how can this idiot not even get his own code to compile? Shouldn't he know what the types of the stuff he's writing are???' Well, actually the problem mainly arises because I have to rely on library code that I didn't write myself, and the library code has quite complicated types for data structures, functions, etc., so it was really tough for me to get all the types in sync. My theory-minded friends love OCaml for the strong compile-time guarantees it provides, but I want to get code up and running as fast as possible, and OCaml just slows me down because I can't get the damn compiler to stop yelling at me. I've heard that you eventually get used to it, but I don't think I will try to pursue this path any further. In terms of semi-functional languages, I am going to pick Python/LISP (with dynamic typing) over OCaml (with static typing).
Ruby
Haven't tried it myself, but this is pretty hot nowadays, especially with Ruby on Rails for web application development. I've heard that it fits into the same niche as Python ... old LISP people prefer Python more, and old Smalltalk people prefer Ruby more. Ruby has gained a lot of street cred over the past few years, and a lot of young hackers are loving it (as well as Python), not just for web applications, but simply as a quick-slinging 'weapon of choice' language.
Feel free to send comments, suggestions, questions, or rants to me via email: philip@pgbovine.net
Last modified: 2007-06-02
