Hacker Newsnew | past | comments | ask | show | jobs | submitlogin
Ask HN: best languages to learn as a newcomer
16 points by stevejalim on May 26, 2009 | hide | past | favorite | 40 comments
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?



I personally think Python would be best. Python will allow her to understand conditionals, loops, variable assignment, etc. really simply and quickly.

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.


Additionally, python is also becoming fairly widely used in industrial/scientific applications. In terms of scientific libraries, it's only slightly more inconvenient than C or Fortran. The FFI is reasonable too.


And don't forget numpy/scipy for numerical computation and nodebox for plotting (http://www.nodebox.net) which are extremely convenient libraries.


For new users, I suggest Python v3 as the starting point. It cleans up some mistakes from earlier versions.

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.


I mostly agree, but I think you might be worrying pre-emptively. From the original poster's description, she might not have to be dealing with "everything all at once". A person with a strong math background will have a much easier time grasping many CS concepts than someone coming from the humanities.

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.


she wants to use her maths/physics knowledge towards creating industrial/scientific applications.

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.


Good points, but OCaml probably has enough credibility to get away with it. Haskell is great (tho' I am but a novice at it) but it is still a bit niche-y.


...OCaml probably has enough credibility to get away with it.

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.


As far as I can tell, OCaml is used at some French research labs, a freshman programming course at Caltech, and Jane Street Capital.


Firstly, if Jane Street are able to use it, it must have been signed off by their auditors and regulators, so we can be pretty confident in its numerical correctness. Secondly, it holds the record for the fastest Fourier transform - again, it couldn't do that if it was fastest by getting it wrong...

I've also seen job ads for it from other banks including Credit Suisse.


Python + SciPy (which uses NumPy)

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.


Haskell will be a perfect fit for these math/physics kind of projects. Writing these programs in a functional language is very close to how the theory in math/physics is explained so that is a nice fit.


Yeah, Haskell was also something I mentioned -- tho I have a question about how prevalent jobs using Haskell, Erlang, Clojure etc are compared to C++ etc. My orbits don't inlcude maths/physics-heavy development, so I have no idea


Any of the "academic" languages (Haskell, ML, Lispen, etc) are probably more likely to be found in math/physics-heavy development than in general development shops, but C/C++ is probably the standard (for fast-math libraries and realtime work) - you may see old fortran for some numeric stuff, and forth for some embedded work. Java is pretty rare, AFAIK.

I think HN is not the best place to ask about "languages to learn to get a job", though.


It depends. If her interests are highly focused, there's a few problem domains where niche languages (R, Matlab, Haskell, Fortran) really shine. However, if she wants more general purpose tools, I've got a few strong recommendations:

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.


It's funny. As a Rubyist, I still recommend Python for getting started in programming.

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.


I would hesitate to recommend any female get involved with the Ruby nutjobs.


Try a small diverse set of languages? Here's an interesting anecdote for you. I have two friends from CMU, both who have a CS degree. The first person was an ace at C. Could handle everything with ease, but faltered a bit when it came to ML/Haskell. The second person managed to screw up the "easy" C class, but she scrubbed off ML/Haskell as if it were trivial, but hated all other programming classes she took. At the time of this writing, the second person is on equal or greater footing than the first person, and both are in industry.

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.


With a background in physics and math, she might do well in a functional language, or in a language which supports functional development well. Python is a good choice due to its math libraries and ease of learning. I was also going to suggest Clojure but that basically requires knowing an amount of Java.


Yeah, Clojure seems a bit deep-end for her right off the bat, but did strike me as something she'd probably dig with more exposure under her belt. Cheers.


Though it's probably not a good first language, if she is going to be writing code for any astrophysical applications she will have to learn IDL at some point. It's a language that's rarely used in any other field, but in astrophysics it's the language of choice.


Somebody mentioned Clojure, which is a great language but has some baggage.

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 fastest math libs are in Fortran. You can get close in C/C++, but the everything-is-a-pointer philosophy of C gets in the way of some compiler optimizations that are available in Fortran. (Wasn't there something posted to HN about this in the last couple of weeks?)

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.


Indeed. (I mentioned Fortran in one of my replies above.) As far as I know, Fortran isn't used much for new development projects, though; I hear more about using the C interfaces to LAPACK or whatnot even in very crunchy (e.g. genome) apps. Far from a complete survey, I could be wrong. :)


Ruby or Python, leaning toward Python only because it's used more widely in physics applications and, as a result, has more developed libraries for scientific computation.


PLT Scheme is clean, free, well documented, widely supported and beautiful. It has a decent numeric tower, and a good GUI toolkit for writing simple interfaces.

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.


looking to get out of her current gig in journalism and into software

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.


Java is pretty prevalent and has an awfully large set of nice libraries. Once you write some utility classes to deal with reflection and some of the other annoyances - including tweaking eclipse to speed workflow - it's a great language to work in.


It depends what platform she wants to develop her solution for.

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)


If you want to create industrial/scientific applications, libraries are going to be pretty important. For that reason, I'd recommend Python (see SciPy and NumPy).

I'd also recommend learning R if you're at all interested in scientific data analysis.


For the easy learning curve and everyday scripting, Ruby/Python would do well.

For the heavier stuff, C++, Erlang, Java...


C++

If 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.


I don't know if I agree. Getting around in C++ depends on having not just a sharp mind, but a fairly broad knowledge of computer science concepts. Java is quite similar, requiring a familiarity with many (OO-centric) CS ideas. For a novice to programming but an expert in analytical thinking, I would suggest a more forgiving language, at least to begin with.


Cheers, yeah, I've mentioned both already and agree re C++. I've also pointed out to her that the fundamental methodologies are probably more important than any particular language, but C++ seems to cover most bases and seems likely to be used in the area she's targetting...


The thing worth noting about Java vs C++ is that C++ need be compiled to each arch and the open source IDEs are not as fun.


i did a lot of matrix analysis during my grad study, from statistics (general linear model, projection, pseudo inverse, design of experiment, etc) to dynamic system (control, state space, etc) using matlab -- i even used it to generate random distribution from uniform for simulations

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


Python's one of the easiest ways to get started in programming in general, and is widely used in science these days. It's the new Fortran in scienceland...


Thinks she have som objectives with programming.

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.


C


introducing her to C first might kill your friendship, once she learns of the other options. It's like finding out your parents played a prank on you and kept a remote controlled plastic monster in your closet throughout your childhood.




Consider applying for YC's Fall 2025 batch! Applications are open till Aug 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: