News for hackers. Stuff that matters.
Re:If you could only learn three programming languages, whic... by jrockway on Thursday December 09, 2010 @09:22AM (#1987497)
Three is a good number.

C needs to be one of them, because everyone writes their libraries in C, and you need to use them and be able to contribute your own libraries. Don't use C for applications, though; there is no performance gain (gluing C libraries together in C is as fast in $foo as it is in C for most values of $foo), and there is a maintainability and expressiveness loss. Libraries are simple enough and small enough in scope that this doesn't matter. Your HR org-chart editor web app? Not so much.

So I use C for libraries that other people need to use, but nothing else. This way, I get code reuse without having to force a "policy decision". Everyone is fine with C and it integrates well with pretty much every other programming language.

After C, you need a language for high-performance but moderately complex applications. This language needs to allow for expressive description of high-level tasks, but it also needs to expose primitives for writing "fast" code. A lot of people choose C++ for this, but I think C++ is a bit too low-level for application development. Most people choose Java or C#. (I hate both, but it's close to the right thing.) I use Haskell; other good options are OCaml, F#, Common Lisp, etc.

I use this class of languages for things like ETL or network-based computation services. The code is a little complex, and it needs to run fast. This family is perfect for that.

The third language you need to know is a "scripting language". This is a loaded term, because scripting sounds like it's not real programming. But this is wrong, making a Perl script to filter your email is just as "real programming" as writing the TCP stack for your OS. If you have a problem you want to solve and you type some stuff into a computer so that it learns how to solve the problem, that's programming.

I use Perl, but obviously there are a lot of options here; Perl, Python, and Ruby are the best choices, followed by Lua, various Scheme implementations, and so on. I picked Perl over Python and Ruby because they all really suck performance-wise, but at least Perl has a great community and a great library repository. It doesn't really matter which you choose, as long as you love it. (My favorite color is green. Yours may not be. Let's not argue about it, though.)

This class of languages, in general, is best for building complex applications where maintainability is the core requirement. Scripting languages give you the tools to design and build incredibly flexible abstractions that let you hide a lot of complexity where appropriate. They also make it really easy to write great tests, and to implement new ideas. Being unafraid to refactor your code and being able to design abstractions to refactor into are the keys to maintainability. And languages like Perl make that really easy.

Lately I've been playing with node.js, which I really like for "quick scripts" that need to be event-driven and need to talk to the network. I'm hesitant to include it in this category, though, because it lacks good namespace support, which makes writing complex apps tough. It also doesn't have a mature toolchain yet. But it is cool and if you have done web programming but haven't done any "scripting", you can get started and start having fun quickly. So do check it out.

(Also worth noting; I've written event-based network services in all three classes of languages. The performance is the same regardless of which you choose! Nothing is slow for IO; the plumbing is all handled in some generic C library and the OS. C is fast, Haskell is fast, Perl is fast, and node is fast.)

Finally, if you do web stuff, you need a fourth language that compiles to Javascript, just because that's how the web works. I think plain Javascript is fine, so I use that, but coffeescript and friends are also cool.

Re:If you could only learn three programming languages, whic... by eru on Thursday December 09, 2010 @09:33AM (#1987526)
> I picked Perl over Python and Ruby because they all really suck performance-wise, but at least Perl has a great community and a great library repository.

I recently learned that Lua is pretty fast, according to anecdote and shoot-out data. I did not like the syntax, when I last looked at it. But I might change my might. I mostly use Python for this class of things at the moment. Though I could see myself use Haskell more.

We use OCaml at work for your first and second category. (We do interface with C, too.)

Re:If you could only learn three programming languages, whic... by silentbicycle on Thursday December 09, 2010 @11:15AM (#1987937)
Lua's other strong point here is that it has an especially nice C API. Unlike Perl, Python, and Ruby, it was written primarily to script C, with use as a standalone language being secondary.

I prefer Lua to all of those, but that again is a matter of taste.

And yes, Lua is pretty fast, and LuaJIT (http://luajit.org/) is so fast that it's a major outlier among scripting languages.