Programming Languages recommended for work in mathematics and to understand computational complexity

I agree with @Pieter21 that python is your best bet now for general usefulness as a math major, and later on in advanced work in pure mathematics.

For a striking (mind-bending) overview of computation, I strongly recommend Abelson and Sussman's Structure and Interpretation of Computer Programs. You're not likely to use Scheme (a dialect of Lisp) for actual programming projects, but the philosophical content of the book is enlightening.

I don't know of any language that would be particularly useful for thinking about complexity theory.

I think learning C would be a mistake - lots of up front cost before you get to the parts that you care about.


For an introduction into programming I would recommend a "script language":

  • Modern script languages (e.g. Python, Ruby) tend to be not the most efficient in hardware usage, but are expressive and great for developing complex programs. Ruby is more elegant than Python IMHO, but Python has lots of great mathematical libraries. So Python would be a good choice.

Then there are the languages which allow one to write fast programs, programs that utilize memory very efficiently and can talk to most hardware:

  • The general purpose languages that allow you to use the hardware very efficiently usually lack in abstraction and have only simple data structures. (C, FORTRAN)

  • C++ with modern libraries is hardware efficient and has advanced data structures.

Sometimes easy portability to different operating systems and hardware is important:

  • Java has the advantage of being quite portable, including its graphical user interface, but is not that expressive compared to modern script languages and used to be no language that uses the hardware efficiently. However that might have changed due to compiler and VM optimizations. E.g. GeoGebra is a mathematics software that is implemented in Java, because of these advantages. Java is probably the most mainstream language today. (E.g. see this ranking).

There are languages which focus on mathematics:

  • Mathematica, Maple, Matlab or R are examples. Each has its strengths.

  • Julia seems to be a promising new language, but I have no experience with it.

Then the occasional surprise:

  • JavaScript. As native language of the web browser it became more and more important over the years. It is an unlikely recommendation regarding mathematics right now, but it might continue to surprise.

Finally you might want to broaden your understanding of programming:

  • The languages above usually follow the imperative programming paradigm, as structured or object oriented languages. However there are alternative approaches to programming, like

  • declarative programming, e.g. Prolog or

  • functional programming (e.g. Lisp, Haskell, Erlang, OCaml, F#).

They excel for certain problems and widen the understanding of programming. Their ideas have connections to logic and theory of computation.


For your specific question, a language suited to mathematicians and to understanding computational complexity, I recommend a functional programming language, in particular Haskell or Scheme.

Haskell is a very elegant yet also practical functional programming. Inspired my mathematical notation, it has a very strong type system and a declarative style, reminiscent of mathematical reasoning. In specific with regards to your point of intersection between "a programming language for mathematicians" and "a programming language to understand computational complexity better", I would most strongly recommend Haskell.

Scheme is a dialect of Lisp, one of the oldest languages in existence today, which is inspired on $\lambda$-calculus. Very minimalist, very elegant, and I will almost guarantee you that understanding it will make you a better programmer and a better mathematician. If you want go down this route I recommend following The Little Schemer, an absolutely delightful book by Daniel P. Friedman and Matthias Felleisen.