

Ask HN: best languages to learn as a newcomer - stevejalim

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.<p>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?
======
mdasen
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.

~~~
yummyfajitas
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.

------
mnemonicsloth
_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
= A _x), 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.

~~~
gaius
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.

~~~
mnemonicsloth
_...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.

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

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

~~~
ruby_roo
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.

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

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

~~~
stevejalim
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

~~~
rmaccloy
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.

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

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

~~~
stevejalim
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.

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

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

~~~
gamache
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.

~~~
rmaccloy
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. :)

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

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

------
iigs
_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.

------
TomOfTTB
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)

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

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

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

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

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

~~~
stevejalim
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...

~~~
keefe
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.

------
hs
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

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

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

------
metatronscube
C

~~~
mahmud
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.

