I currently am a programmer, I'm almost 16 years of age and have pretty much narrowed my careers down to something involving a Computer Science degree or Electrical Engineering degree (I know they are quite different but this question is about my friend) but my friend isn't so sure.

He is very interested in maths and is very good at it and I think he would enjoy programming but he isn't willing to try it (edit he is willing to try but has never done before). Can anyone give me an suggestions for a language or tool that he could dabble in programming (at a reasonably basic level I assume) to solve maths problems or involve some kind of maths.

As I say he enjoys maths a lot but I think he would enjoy programming, the problem is I don't want him to be put off by the stuff that isn't relevant at introductory levels such as memory allocation et al. I know that is very important but the point is that I want him to learn a bit of programming with maths then hopefully if he is interested enough he can start learning programming as programming.

Edit: Its not that he's completely uninterested - more that he hasn't actively explored the area before, maybe because he isn't informed about it. I wouldn't want to force him to do something he doesn't want to, I see this as more of a little push so that he can learn about programming. If he doesn't like it - fair enough, I can't control that and don't want to but if he turns out to enjoy it - this push will have been the right thing.

  • 18
    Why do you want to push your friend into a direction he is not interested in?
    – HLGEM
    Nov 14, 2011 at 19:56
  • 3
    For the record, a lot of the programmers I have worked with have math degrees. On top of that, they are quite good.
    – AngryBird
    Nov 14, 2011 at 20:13
  • 1
    I agree with @HLGEM. I would hate it if someone pushed me toward pure, theoretical math. Likewise, those who would like that stuff would hate it if they were pushed toward the boring applied stuff.
    – Job
    Nov 14, 2011 at 20:43
  • 4
    To put some perspective on things -- You're 16. You're not a programmer, you're a student who has done some programming. Your friend isn't a mathematician, he's a student who likes (and has learned some) math. While I like the answer from @perl.j, I think you may be over-reaching on this one. Dec 13, 2011 at 17:33
  • 2
    @perl.j: Until someone has the necessary degree to show the requisite "primary area of study" as evidence he is not a mathematician. Even someone in university whose major is math is not a mathematician just yet. Dec 14, 2011 at 0:40

17 Answers 17


Math Logo

If you want a "math-like" language, Haskell is your best friend (for your best friend). You can easily make new functions without hassle. It is the best language recommendation I can give you for you friend. Here are some links:


Wolfram's Mathematica is another interest he may have.

Mathematica is a computational software program used in scientific, engineering, and mathematical fields and other areas of technical computing. It was conceived by Stephen Wolfram and is developed by Wolfram Research of Champaign, Illinois.

Although it is expensive, it is worth it. Here are some links:


Algorithms are important for any program, but your buddy should start with these when he gets comfortable with a language. Here are some more links:

Hope this helps! If you have any questions or feedback feel free to comment! By the way, all of these links are to free resources. If you want a printed book, I have a few recommendations, just leave a comment!

  • 6
    Also, Eleven Reasons to use Haskell as a Mathematician.
    – hammar
    Nov 15, 2011 at 2:04
  • 2
    I'm a math major, and I can recommend Haskell as awesome from a math perspective. I also like reading some of the theoretical stuff that goes with it, much more than most languages. Nov 15, 2011 at 2:23
  • 2
    If he learns Haskell, he can later even move on to Agda, a dependently-typed language suitable for doing proofs in.
    – Peter C
    Nov 15, 2011 at 3:30
  • 4
    @SK-logic How can you even say that? Mathematics is all about learning new logical systems and reasoning about them (don't forget that mathematicians invented the Turing machine). You honestly think that someone who can handle mathematics can't handle the idea of variable mutation? And my point is, to do something as simple as variable mutation in Haskell requires a store monad! Saying that's easier than x = x + 1 is just ludicrous.
    – JeremyKun
    Dec 20, 2011 at 20:24
  • 2
    @Bean, that was actually my own first reaction to an assignment statement (and I knew nothing besides primitive linear equations from the math back then). Ever since then I saw the same reaction repeatedly. I deliberately tried introducing functional programming concepts to those with no previous programming experience, gradually moving to the imperative stuff. It was always easy first, and all that "WTF?!?" looks always started only with introduction of the imperative and OOP concepts.
    – SK-logic
    Jan 18, 2012 at 7:42

Functional programming and languages in the ML family or Haskell tend to fit quite well the mathematicians' minds.

  • Very true! Infinite lists and all that are great for math minds.
    – user1249
    Nov 14, 2011 at 20:26

If he majors in mathematics he then he will no doubt end up doing quite a bit of programming, if not in low level languages like C++, then in higher level, mathematics specific, languages like Maple or Mathematica depending on what he is doing.

Also, depending on his area of research he may end up doing applied mathematics or statical analysis, both of which will require a significant amount of programming. He better get used to programming now regardless on what he decides.

  • 1
    You can also try to sneak Python into his mind with Sage ( sagemath.org ). Nov 14, 2011 at 21:23
  • Here is another higher-level, mathematics-specific language: math.uiuc.edu/Macaulay2
    – RyanTM
    Nov 15, 2011 at 4:49
  • I suggest you just allow him to discover programming. When he is exposed to it, and he certainly will be required to do something that requires him to do something in a mathematic specific language, he will either like it or hate it. If he likes it when this happens he will be able to select the languages that best suite him. Its not that you should not help your friend, if has shown no interest, then you should drop it.
    – Ramhound
    Nov 18, 2011 at 15:09

Teach him Haskell. It's a language where you can think just as in mathematics:

  • A function is something that maps input to output
  • Stuff is evaluated as needed
  • Type inference and a crazy type system
  • Convenient syntax
  • Great community (for instance on StackOverflow)
  • Monads

I'd suggest you to show him http://learnyouahaskell.com, one of the best tutorials for Haskell.


As someone who studied math (I have a B.S. in pure mathematics and just received my M.S. in Applied Math/Statistics) and later realized the fun/practicality/importance of programming further along in my career, I really appreciate this question. I wish I had a friend like you 10 years ago to push me towards programming.

You should both check out Project Euler. What is it?

Project Euler is a series of challenging mathematical/computer programming problems that will require more than just mathematical insights to solve. Although mathematics will help you arrive at elegant and efficient methods, the use of a computer and programming skills will be required to solve most problems.

Although it is not a language specific suggestion, it would be a great motivator for getting started with programming (especially if there is already an interest in math). The problems start off very easy and approachable but quickly become very tricky and/or difficult. A good challenge and motivation that you both are likely to enjoy.

As for which language to use, I have experience with C++, R, Matlab and Mathematica which are all great and widely used within the math community. But more specifically, I strongly suggest learning Python which is very useful for math but isn't quite as restricted to math as some of the others (in case he wants more options later on in life). It is easy to get started with Python but there are tons of things to learn. It's also free unlike some of the others. C++ might be a good choice as well but could have more hurdles from the beginning.

  • +2 for Project Euler, was going to add as a comment on the main question until I saw your answer. OP and his friend should definitely get into this together.
    – cobaltduck
    Jun 17, 2013 at 15:28
  • For mathematicians, The greatest turn-on is Algorithms. Your friend must start implementing them in Python ( its friendly ).

  • Numberical computing environments like MATLAB will be useful for matrix manipulations, plotting of functions and data, implementation of algorithms.


It depends on the area of mathematics he is interested in.

If he is more into Abstract Algebra or Combinatorics, he would probably like Haskell as the complex type system allows for direct programming of a variety of mathematics. ATS might also be an option.

I'd recommend Learn You a Haskell for a Great Good for an intro tutorial and Purely Functional Data Structures for Algorithms.

If he is more into Matrix Analysis, Differential Equations or Dynamical Systems, I'd recommend Matlab, NumPy, or Octave. APL is via Dyalog might also be of interest; though I'd not start him on that. Numerical Recipes, while in C++ can be adapted to serve as a good guide to algorithms.

If he wants to do Statistics then R is the natural choice.


I'm a graduate student in mathematics, and did my undergraduate in computer science. I keep a blog called Math ∩ Programming in which I explore applications of mathematics to programming (and vice versa), and I have to admit I find most of the less-mathematical aspects of computer science rather dry and uninspired (basically, my opposition to all of the ridiculous hacks that go into systems programming in my experience in industry).

On the other hand, on my blog I look at problems like facial recognition (quite a bit of linear algebra), encryption methods, Turing machines and cellular automata, models for predicting serial killer activity, search engines, and a bunch of other mathematical concepts. The best part is that I get to implement the ideas, and any of my own!

To get your friend to love programming like the rest of us do, find him a truly interesting project. The programming aspect won't stick without his working toward a product he finds beautiful. As for languages, I recommend Mathematica, Racket (a very friendly, but still powerful Scheme derivative), Python, and Haskell. Mathematica is probably the best, because he can selectively implement his own mathematical functions, and use Mathematica's built in libraries to finish the project (e.g., write a function which computes Fourier coefficients, and then use Mathematica to do the rest of the analysis, such as filtering, image generation, etc.). Even the basic topics like integration give some fascinating projects (different quadrature rules, monte carlo integration, a gentle transition into machine learning with large data sets).

Also, it seems like a lot of the responses here are from people who don't do mathematics, or who haven't used the languages they're suggesting to do mathematical software. The reason people recommend Haskell is because it's as close to a literal implementation of category theory as possible, and fits well with some mathematical definitions of some basic concepts. But if your friend is close to your age, then he is not ready for category theory mathematically (that maturity is more or less useless until graduate school, and wicked hard to teach yourself), and as a first language Haskell has the steepest learning curve of the languages suggested (perhaps Prolog is steeper). I used Haskell to implement a Javascript compiler, and I ended up with a very beautiful elegant piece of code, but for intuitive things like variable mutation, you already have to dabble in nontrivial monads.

Python and Mathematica will be much friendlier, and Mathematica has the shallowest learning curve simply because all of the libraries is packaged into a nice user interface with awesome documentation (just hit F1!). On the other hand, there is one book I have heard of (but not read) which provides both a transition to advanced mathematics and an introduction to Haskell simultaneously. It seems to have positive Amazon reviews, so you might want to check it out. He can move up to languages like C# and Java if he ever wants to do industry stuff, but more likely he'll never need to enter that jungle (and lots of industry mathematics stuff is pure Matlab anyway).

But like I said, with the right project learning the language becomes a joy, whatever the project may be.


If your friend enjoys formal logic, and finds Artificial Intelligence interesting, he might like to take a look at Prolog.

With this language, you state your predicates (initial assumptions, "facts") and rules of inference ("relations"), and then ask questions.

Prolog then goes off and works out whether the question can be answered using only the given facts and relations, and if so, tells you the answer.

So you tell it that "tom is a cat" and "all cats are animals" and ask "is tom an animal?" and you'll get the answer "true".

Or you can ask it to "list all the animals that you know about" and you'll get the single item list "tom".

Of course the syntax is a little more complicated than that, but you get the general idea.

  • Prolog is frustratingly close to first-order logic, but really incompatible, since it has no way to distinguish "unproven" and "false". It's a neat language in some ways, but I wouldn't push it on a mathematician and call it programming logic. Jan 16, 2012 at 19:28
  • Can you not simply test the negation? Jan 16, 2012 at 20:38

The best way to encourage your friend to try it might be to have him start programming without thinking too much about the fact that he's programming.

Once he's ready to deal more with "programming", you could both start with the same book and learn programming from a more mathematical foundation. Two of my current favorite books are:

SICP is freely viewable at the MIT Press web site.

If your friend is mathematically inclined, Lisp will present no difficulty, and it frees you from having to learn any special syntax. I think Lisp is easier to learn than Haskell.


I agree with the Haskell, but from a practical point of view, he should also learn a language on a widely used abstract machine. I mean a JVM language or .NET language of course.

There are languages on these platforms that are a little more interesting than the flagship languages. On the JVM have a look at Clojure and Scala. On the .NET platform have a look at F#.

There was also a .NET language from Microsoft Research called c-omega which was very interesting, but is was just a research project.


Matlab is commonly used for mathematical and scientific programming. It is a script based language, not hard to learn and all the memory issues are hidden from the user.

Software Engineering and Electrical Engineering can be combined into Computer Engineering.


If your friend is unwilling to give programming a try, I don't see why you want to force the issue. I think a key to being a programmer is being willing to learn, and if he is unwilling to learn then programming is probably not for him

But that being said, your best bet might be to create a small program yourself and show it off to him. Perhaps leave some parts of it unfinished and see if you can get him interested in helping you finish it. I know for me, the algorithms and logic behind a program are far more interesting then writing out the syntax, so perhaps try and have him assist you with the logic of the program, and then you go and code the thing and let him see the results of it.

If he shows any interest at all in the source code, then show him how to write his own stuff. Personally I think the language itself doesn't matter as long as it's easy to learn and has plenty of documentation.


There is a whole free mathematical library and community built up around Python. I'd start with "Sage", he should really enjoy using it and will learn Programming in Python incidentally.


I think you should show your friend some different variants, like:

  • C
  • LISP/Scheme
  • bourne-shell
  • Prolog

I think C and LISP are good starting points, showing that different languages can be better suited for different tasks. I don't believe in using Haskell or Erlang for everything.

Machine code (or assembler) for a simple processor might be interesting too. I have always been happy I started with machine code on my first C64. (MOS 6510) Hands-on experience that is hard to get as an adult with limited time to "waste".

  • I have to disagree. Why would a young kid, interesting in maths, be attracted to Machine code? And why C? Assembly presumes far too much knowledge about processors. C likewise makes many requirements that are best left to someone wanting to learning serious programming: pointers, registers, scoping, types. For a first introduction to programming for such a person, something that focuses on algorithms or on applications of mathematical ideas (probability, randomness, simulations), is much better. Python, Lisp/Forth, Basic even. Bourne-shell?? Why?... Feb 25, 2013 at 20:33

To me, programming starts from wanting to "do something", a "what if?" question:

  • "I would like to make my own web site", so learn about HTML, etc.

  • "I hate that I have to click X or that I see Y on this web site every time I visit. Isn't there a way to automate that?" So you learn about bookmarklets or writing browser extensions.

  • "I want to catalog all my music and none of the tools I have seen do it in the way I want", so you learn about databases.

  • "I want to track expenses for my Math Club", so you learn about spreadsheets, programming macros, or perhaps even databases.

In order for the drive to really be there, the underlying problem has gotta come from him. I would try to find a problem he wants to solve and then choose a tool/language/system that allows him to automate/program the solution.


Haskell and Mathematica are the way to go, in my opinion. Most functional languages are good for math as well. Python is also good, check out the math documentation.

This module is always available. It provides access to the mathematical functions defined by the C standard.

These functions cannot be used with complex numbers; use the functions of the same name from the cmath module if you require support for complex numbers. The distinction between functions which support complex numbers and those which don’t is made since most users do not want to learn quite as much mathematics as required to understand complex numbers. Receiving an exception instead of a complex result allows earlier detection of the unexpected complex number used as a parameter, so that the programmer can determine how and why it was generated in the first place.

The following functions are provided by this module...

Not the answer you're looking for? Browse other questions tagged or ask your own question.