Ask HN: best languages to learn as a newcomer
A friend with an astrophysics and maths background is looking to get out of her current gig in journalism and into software. She's got minimal programming experience (beyond BASIC in the 80s), but has a startlingly sharp mind, so I don't see lack of experience as a major barrier. She's asked me what language/s is/are worth learning.
I've suggested Ruby or Python just to get the fundamentals down, BUT (and this is where it differs from previous Ask HN threads similar to this), she wants to use her maths/physics knowledge towards creating industrial/scientific applications. With that last bit in mind, what language(s) are worth her investing time in?
42 comments
[ 3.5 ms ] story [ 102 ms ] threadIf she has a sharp mind she will pick it up easy enough and that is where she wants to be with the ultimate aim.
Alternatively Java might be an option: purely if she fancies looking at distributed apps. I hate Java like crazy but it has some good background in distributed computing.
For the heavier stuff, C++, Erlang, Java...
I think HN is not the best place to ask about "languages to learn to get a job", though.
I'd also recommend learning R if you're at all interested in scientific data analysis.
Once you have that down, it's a lot easier to start dealing with things like static types, memory management, pointers, null bytes, and so on.
I learned the other way around (with C being my introductory language), but that was a useless way to learn. When you don't know exactly how to use a conditional, there's no reason to throw in things that can trip you up and have nothing to do with your understanding of a conditional.
And, to be honest, Python will do nicely for lots of applications. If she's going to be joining a company, she'll have to use what they want her to use, but if she's independent, Python will be fine unless the calculations are so complex that they are time constrained. Even then, Java isn't so hard to pick up if you know Python
It's a lot easier to add on CS concepts little by little than to have to deal with everything all at once.
After all, at its core CS is a specialized branch of discrete mathematics. Anybody with advanced mathematics should have encountered boolean logic somewhere along the line. That'll make picking up C a whole heck of a lot easier.
The "Batteries Included" philosophy means that in most cases there already is a module / library available for tasks at hand, e.g. graphing, PDF generation, number crunching, stats analysis, etc. python.org is a fantastic resource, even for experienced pythonistas.
If she's coming from a rigorous background, I highly suggest Scheme and the book Structure and Interpretation of Computer Programs (SICP: http://mitpress.mit.edu/sicp/.) For some people using a language with more batteries (and thus instant gratification) is better to learn programming, I think, but for learning to think about computation I think Scheme is pretty hard to beat.
Scientific programming might mean C/C++ (that's where the fast math libs are, to be sure), but it might mean Matlab or Forth or lots of R, who knows.
The penalty is that you must use Fortran, though. If the app does anything besides crunching numbers, most people would choose a more comfortable language, or just write the crunchy bits in Fortran and use a FFI if they're ambitious.
http://docs.scipy.org/doc/
http://numpy.scipy.org/
Many operations are fast, being implemented in C, an the facilities include all sorts of numerical operations, as well as graphing/plotting and other visual interactions.
If she's doing web based development I'd suggest Javascript. Javascript has a lot of superflous non-sense in it but if you learn it the right way it's a very powerfult language. More importantly if she wants to develop web applications that do a lot of math calculations she's probably better off learning a browser based technology (so the burden for all those calcs won't be on the server)
Anyway, I'd suggest Javascript: The Good Parts as a book to start with if she goes that way.
If she's doing desktop apps I'd probably suggest learning Actionscript and Adobe AIR (which provides the most cross-platform bang for the buck)
The functional programmer in me is really happy that so many people are saying "Haskell!" but based on my own experience in applied physics, it's a terrible idea.
Programming in the sciences is all about numerics. That means giant fiddly matrix manipulation libraries, adaptive conditioning, stability bounding, and adjustments for the phase of the moon.
There's a pretty simple reason for all the gobbledygook. Often, the entire solution to a given problem is expressed as one giant matrix equation (i.e. y = Ax), because that's an easy format for a big computer to chew on. The trouble is, there are lots of possible ways such computations can return a result that looks right but is actually completely buggered. Finite precision floating-point numbers is one, but there are others. And since inverting one giant matrix is pretty much the only thing* that happens in a computation, you don't have a lot of debugging options when something goes wrong. So boutique languages like Haskell won't be all that useful except for prototyping because nobody else will trust the numbers you produce.
There really aren't that many mainstream choices. Matlab is the all-singing, all-dancing prototyping tool that you must know if you want to have any dealings with scientists. Matlab can compile its code to C or Fortran (I'm pretty sure, anyway), which are your two other choices.
What's the basis for your claim here?
Over the years, I'd estimate I've worked with around a hundred grad students, postdocs, and professors in Physics, Electrical/Computer Engineering, and Applied Math. I have literally never met one who used OCaml. I would be very surprised if more than a handful had so much as heard of it. That's because these people are about as interested in programming as the average programmer is interested in Schur-Newton-Krylov solvers.
I've also seen job ads for it from other banks including Credit Suisse.
I'd download the java tutorials with full source, buy Core Java to her, Install a pretty minimal version of Eclipse nicely set up with the workspace for eclipse osculating the java tutorials source and Core Java source, give her a bookmark to javadocs, java tutorials - big index, java ranch, and just let her go.
She should be able to learn that with a minimum of assistance, and have fun too. The only alternative which can be more fun and rewarding would be Visual Basic I think. So java is it for obvious reasons.
Ruby - I'd start here. Ruby is an amazingly flexible language, with a gigantic "feature set". Learning Ruby will get her up to speed on imperative programming, functions, objects, libraries, DSLs, regexps, and some functional programming (via closures). The community is friendly, the docs are plentiful, and the available libraries (gems) are pretty comprehensive. Best of all, the learning curve is gentle and it gets you writing productive programs quickly. However, unlike many "beginner's languages", it's not particularly limiting. If you really need to, you can always call out to C or Java (via JRuby). Possible alternative: Python. Never worked with it, but I understand it offers a lot of the same benefits.
Java - If she wants to do a variety of scientific or industrial programming, she's eventually going to have to learn Java. Java has largely replaced C++ as the academic language of choice, and most industries have migrated to either Java or C# for general development. While some people scream about the "yuckiness" of Java, it's actually not that bad, especially for a beginner. It's highly object oriented and strongly typed, teaching a lot about those concepts. The verbosity is often helped by access to a lot of kick-ass dev tools. Best of all, though, is the libraries. The amount of open-source code that you can tap is HUGE, especially in the scientific and industrial arenas. Oh, and Java 6 is wicked fast, at least in comparison to Ruby and Python. :)
C - I would recommend C for two reasons. First, it teaches you a lot about how the underlying machine works. If your friend is doing scientific computations on large datasets, she's eventually going to run into some weirdness with memory. Knowing C helps (forces?) you to understand what's happening "behind the scenes" in these VM-based memory managed environments. If you dig far enough down, you're almost always going to find some C code, and it's helpful to know how that works. Secondly, there's some problem domains where still C reigns supreme, namely anything that demands extreme performance. The combination of Ruby and C can give you the best of both worlds, using Ruby for most of the "glue code" and C for stuff that needs rocketship speed.
NOT RECOMMENDED - C++. Almost everything done in C++ is better done in either C or Java. C++ is super-complex, verbose, error-prone, and you still have to manage your own memory. Unless she needs to work with legacy code, your friend's time is best spent learning more modern tools.
The docs are better, the code is probably easier to read for someone new to programming (there isn't a requirement to understand OOP to be productive), the community isn't alarmingly dysfunctional, and the conventions are more traditional. You can port a lot of Python concepts over to other languages easier than you could Ruby, I would think.
Python is classical music. Ruby is jazz. Choose the least subjective/nuanced approach first and build from there. But that's just me.
Is this for commercial/employment purposes? If so I'd consider looking at the job market for desirable positions and selecting a tool set from there. Even if the idea is to build products for sale/use from scratch herself it's probably worth understanding the field as it stands now before diving headlong into a programming environment that isn't going to be a good fit for the applications in question.
Python is a good starting point for intro to computer programming, but at very least (and I'm out of my league here), she should tour and understand the differences between popular FORTRAN environments, Python environments (scipy), Java environments (I don't know where to start), Mathematica, Scilab, Octave, and R.
I taught most of it to my 15 year old nephew over two weeks, this last winter holiday.
There is zero configuration; you double click on the downloaded package, it self installs, and you have 5+ different programming languages and levels of Scheme in one package. You can get help right from within the IDE.
Whether because of personality or because of the actual underlying mental thinking involved, people who tend to be good at C aren't good at Matlab or Haskell, and folks who are good at Matlab aren't necessarily good at either C or Haskell.
In light of this, I think it'd be really sad if your friend tried just one language, and wrote off programming forever because it was a bad experience.
the closest thing to matlab is python+numaray+matplotlib (maybe it changes name to scipy?)
i think she will face matrix calculation ... so, use python (matlab is easier, but less flexible) ... i didn't go too far with R but from my experience it's less flexible than python
NB: i did those 5 years ago so don't trust my words too much