vote up 12 vote down
star
11

Ok I understand this might be a slightly subjective question, but I am honestly curious what programming languages are used by the mathematics community.

I would imagine that there is a group of mathematicians out there that use haskell because it might be more consistent with ideas from mathematics. Is this true?

What about APL? Do mathematicians today use APL or is that just a relic of the past?

flag
3 
This should be community wiki. – Noah Snyder Jan 8 at 2:20
2 
I agree with Noah. This is a poll question, where an upvote most likely means "this applies to me," so I'm hitting it with the wiki hammer. – Anton Geraschenko Jan 8 at 2:39
1 
Ok, so this is a totally ignorant question, but here goes. GAP and Magma are especially popular with group theorists, and Sage is very popular with number theorists. Do these count as programming languages (even though they are obviously computer algebra packages written in a 'standard' language)? – Ben Linowitz Jan 8 at 2:46
2 
In my view, absolutely. After all, Python is considered a language, even though when it is run by an interpreter written in C. Why isn't Sage a language when it is run by an interpreter written in (mostly) Python? I would say that anything Turing complete is a programming language. – David Speyer Jan 8 at 2:55
7 
In answer to Ben's question about what counts as a programming language: Languages like C++ and Haskell are general purpose programming languages. They can be useful to mathematicians but they are also useful to people in all kinds of other disciplines. GAP, Sage and TeX are also programming languages, but they are more specifically examples of Domain Specific Languages (DSLs). They may be Turing complete but they tend to be easier to use when solving problems in a specific area: like text layout or finding Groebner bases. en.wikipedia.org/wiki/Domain-specific_language – sigfpe Jan 8 at 17:12
show 4 more comments

21 Answers

vote up 22 vote down

Bryan Birch is credited with once saying that he programmed in a very high-level programming language called "graduate student".

link|flag
6 
"Undergrad" is powerful enough for many common applications, and less resource-hungry. – Mark Meckes Jan 8 at 14:40
8 
It's pretty buggy though. – Allen Knutson Jan 8 at 15:49
Lenstra liked to say that Joost Batenburg was an essential part of the "Bread and Beer" algorithm: "When we had a problem, we would put him in the computer with some bread and beer. A few hours later, he would emerge with a solution." – Scott Carnahan Jan 8 at 19:02
1 
The use of "do" psuedocode in Hilbert's problems was pretty effective. – Steve Huntsman Jan 10 at 17:39
vote up 10 vote down

Two of my favorites are Haskell and Ruby. I like Haskell because it is computable category theory and Ruby because it is really easy to write scripts and other various prototype kinds of code. Although any language that has functional programming constructs and closures is usually fun to use. Maple and Mathematica fall in this category and they are fun to use when I need heavy duty symbolic and plotting facilities.

link|flag
Out of curiosity, why was this downvoted? – David Speyer Jan 8 at 11:50
1 
I hate Haskell, and the other person who downvoted also hates haskell, but I don't name names. – fpqc Jan 9 at 15:17
2 
I don't really have an opinion about Haskell, but I upvoted to cancel out Harry's downvote. – Andy Putman Jan 10 at 3:33
3 
I have no opinion about Haskell either, but I think one should not "compensate" downvotes of people who have their own opinion. So, I downvote this to compensate Andy's compensation :-) – Boris Bukh Jan 10 at 13:48
7 
The question was not "What are good computer languages for mathematicians" or "Which programming languages do you like". Rather, it was "What computer languages do mathematicians use". In particular, the questioner wanted to know if anyone used Haskell. It thus seems a unfair to downvote the answer, which is a perfectly good answer to the question that was asked. This is especially apropos given the off-topic answers the downvoting user has contributed to this question. – Andy Putman Jan 10 at 21:02
show 1 more comment
vote up 9 vote down

Mathematica and Matlab are popular among mathematicians. R is popular among statisticians.

link|flag
vote up 8 vote down

Haskell is very popular with category theorists.

link|flag
I do all my programming in Haskell, and I strongly recommend learning it to anybody here who has an interest in programming. – Reid Barton Jan 8 at 2:41
I do almost all my programming in Haskell, and have written a few papers in it too. – Mikael Vejdemo-Johansson Jan 8 at 4:04
5 
I'd like to point out an interesting feature of Haskell. There are many programming languages that are good for doing mathematics. But Haskell is one of the few languages where the language itself is a nice piece of mathematics, as opposed to an ad hoc accretion of commands and declarations to do this and that. I'll try to keep the evangelism to a minimum by pointing here: tinyurl.com/bmdsj5 (Sorry about my bad counting.) – sigfpe Jan 8 at 17:23
What are the libraries most used for mathematical Haskell? I've heard of many (DoCon, alternative versions of Prelude, Haskell for Maths), is there a single one I should choose? – sdcvvc Jan 9 at 14:53
Don't know much about DoCon except that it does symbolic algebra. I don't know if the alternative Prelude intends to be more than a framework for building your own mathematical tools. Haskell for Maths is a bunch of fully worked out solutions to specific problems of interest to mathematicians. So I think they're serving different purposes. – sigfpe Jan 14 at 21:13
show 1 more comment
vote up 8 vote down

People in math seem to be pretty fond of Python (me included).

As an evidence, search on MathOverflow for posts where people mention the fact that they wrote a program, and it's nearly always either a special math framework (like Maple, Sage, Magma or other answers here) or Python.

And, by the way, Python is compiled to bytecode, which is run by VM. It's not much different from Java or precompiled JavaScript in that.

link|flag
I know, Watson, let's compile it for a non-native cpu, then emulate that cpu and call it platform-independence. It's brilliant! – fpqc Jan 8 at 8:34
Probably every one of these programs has a separate installer for windows, linux, and macintosh. – fpqc Jan 8 at 8:36
17 
@Harry, since I'm a polite person, I won't be describing what I think about the level of your remarks about Python; but since you're not, you can pick up one of your own typical replies to things you dislike, and imagine I said it to you. – Ilya Nikokoshev Jan 8 at 18:34
2 
Harry, I'm not sure that you completely understand the issue with Python threading. You should have a look at python.org/doc/faq/library/… since your comment is a common misconception. – fuentesjr Jan 9 at 2:57
2 
I think another reason for the fact that mathematicians use Python now at least is that SAGE (see below) is based on it. – Davidac897 Jan 10 at 1:39
show 3 more comments
vote up 5 vote down

I mostly use C, with occasional quick and dirty calculation in Mathematica. Much of the programming that I do is searching for various examples. Moreover, since the objects I tend to be interested are relatively concrete, I rarely need any libraries to support high-level mathematical function, and C provides the speed and smaller memory footprint that allows me to do bigger calculations.

When I need to do a quick and simple (usually symbolic) calculation, I reach for Mathematica because it has quite a few high-level functions, and I am already familiar with it. However, I regard the answers it gives in the same way I treat announcements of new results: likely to be true, but until I check myself, I cannot trust it. That is because I have encountered its bugs way too many times to take its answers for granted.

link|flag
vote up 4 vote down

For mathematicians which do scientific computing in the sens of numerical analysis a very good choice are the XSC languages (C-XSC and Pascal-XSC) which provide tools to solve numerical problems with a verification of the results. See U. Kulisch et alia, Springer Series in Computational Mathematics, vol. 21, for an introduction to Verified Computing and this link for the software.

link|flag
vote up 4 vote down

No one mentioned OCAML here, so I think It is my "duty" to add this language.

OCAML slightly less "extravagant" than Haskell. It allows you write partially imperative programs in a way that most "non-functional people" would understand. So it is easier to learn and after you did it -- Haskell will be a breeze for you.

OCAML also is VERY strictly typed. If you know exactly what you want then it will be nearly impossible to make a mistake. The language is very fast and has a lot of tools distributed with it. Many people consider the language as alternative for C. Last but not least -- there is a F# language -- .NET version of OCAML supported by Microsoft.

So if I need to quickly check some idea -- I use Mathematica or Haskell. But if I need to write something that should be reliable and stable, so I can share the program with others -- then I use OCAML.

link|flag
vote up 4 vote down

At least one mathematician primarily uses Maple. See Doron Zeilberger's 92nd Opinion and programs.

link|flag
vote up 3 vote down

There are lots of subject specific packages written by mathematicians out there: GAP, PARI/GP, SnapPea, Macaulay (1 and 2), Magma, Singular, etc. Sage is a new python based open-source project that is trying to absorb these, its rate of progress is better in number theory than in other subjects, but Sage is the best thing to learn if you're starting from scratch. It's also Python based.

There are also commercial programs: Mathematica, Maple, Matlab, etc. In the circles I run in Mathematica is the most popular.

Of course for things where you need serious speed people tend to use C++, Java or some other lower level language.

link|flag
Really, Java? Java's as slow as molasses! – fpqc Jan 8 at 4:44
4 
Actaully, this is totally untrue. In the olden days of crappy VMs running applets in browsers, yes, Java was slow as molasses. Ignoring the high level libraries, low-level stuff in Java should run at at least 2/3 the speed of the "corresponding" code in C et al. (I do everything in mathematica, dropping through to Java or scala when I need to be closer to the metal.) – Scott Morrison Jan 8 at 10:33
2 
I have found that Java is essentially as fast as C for most numerics. And the gap continues to close. – Steve Huntsman Jan 8 at 15:36
vote up 3 vote down

I still use Lisp occasionally!

I use Maple if I need anything symbolic (and I have a decent little library of code for what I need; otherwise I'd switch), but one of the annoying things I find about Maple is that its functional programming constructs are remarkably clunky (and apparently poorly implemented).

link|flag
vote up 3 vote down

One language I still use is PostScript. I probably need to defend that.

  1. Its syntax is elegant. In fact, no language I've seen has more uniform syntax: a complete program is syntactically identical to almost any fragment of a program. There are no keywords and very few special cases.

  2. It can be a lot of fun, and you can make pretty pictures.

  3. It has very few data types, but some of the ones it does have are surprisingly useful. Dictionaries come to mind immediately. Also, "arrays" (which would be called "lists" in any other language) are extremely flexible. They automatically support comprehensions, not as a separate feature, but as an obvious consequence of the syntax. Functional programmers shouldn't be surprised that procedures are useful as a type; actually, due to the simplicity of the syntax and lack of keywords, any nontrivial program has to work with procedures as data.

Unfortunately, it has many drawbacks that prevent it from really being useful. Its handling of strings is abominable. Also, it has no facilities for user interaction. Its console I/O is crippled. Things like that could in principle be fixed by appropriate third-party packages, but unfortunately, to my knowledge, there are no third-party packages at all (at least for general programming). Finally, it can be very hard to debug; actually, it is more difficult to debug than any other language I know except assembly. All of those things combine to make it one of the most programmer-unfriendly languages out there. Nevertheless, some of my best work is implemented directly in PostScript, and I have done some real work in it. (Also, let's be fair: PostScript was never intended for general-purpose programming! Using a page-description language for any serious computation at all is some sort of achievement.)

(Language: PostScript. Mathematical interest: its syntax is simple enough to be interesting as a mathematical construction. It's easy to produce some mathematical illustrations, like many types of fractals.)

For real mathematical figures (such as for inclusion in papers), I use MetaPost. PostScript can be used for this purpose, but MetaPost is much better suited for this and is very TeX-friendly.

(Language: MetaPost. Mathematical interest: it's great for making mathematical figures suitable for inclusion in a LaTeX document.)

Another language that I use mostly for fun, not serious work, is x86 assembly language. In contrast to PostScript, it's an ugly language, but strangely, I think I use assembly for some of the same reasons that draw me to PostScript.

(Language: Assembly. Mathematical interest: its execution model is very simple, so expressing algorithms in it is an interesting challenge that mathematicians may enjoy.)

The rest of the languages I use need no introduction: C, C++, Python, Ruby, Java.

(Languages: C, C++, Python, Ruby, Java. Mathematical interest: none in particular, but they're useful in general programming, including mathematical programs.)

I used to use Octave, but apparently most of the world uses Matlab, and Octave has just enough incompatibilities with Matlab to make it annoying to try to use other people's code. Also, it seems to have pretty poor support for sparse matrix computations.

(Language: Octave. Mathematical interest: free approximate-clone of Matlab. It has simple syntax for matrix-centric computation.)

I used to use PHP a lot. Actually, PHP and assembly are sort of an odd couple. A while ago, for no good reason, I tried to come up with the fastest code to print out all the permutations of a string. My best solution (for strings of ~10 or more characters, IIRC) was a combination of PHP and x86 assembly. To be fair, the PHP part could have been done in another language, but PHP was almost the right tool for the job.

(Language: PHP. Mathematical interest: none in particular, but it's great for designing websites with server-side scripting, which is no less useful to mathematicians than it is to other programmers.)

I like Haskell, but I don't use it much.

(Language: Haskell. Mathematical interest: sigfpe said it.)

There are other languages I find interesting but never learned properly, like Lisp, Fortran, and Forth.

If anyone's looking for a recommendation, I don't recommend any of those. But learn all of them, and then go off into a dark corner of the universe and come back with the One Language that will rule us all.

link|flag
1 
PostScript is handy for precise mathematical illustrations. – lhf Jan 30 at 22:13
vote up 2 vote down

It seems most software used by low-dimensional topologists is written in things like C, C++ and Python. SnapPea, Regina, Orb, GAP, etc.

I don't think I've ever heard of APL before. Haskell I have heard about but it was only in passing -- I think a thread (here) on programming languages that are structured in a category-friendly way.

link|flag
vote up 2 vote down

APL as such is probably less in use nowadays - but it's ASCII sibling J is quite usable, and has interesting grammatic and mathematical constructions.

link|flag
vote up 1 vote down

Having an industrial focus for most of my career, I personally find MATLAB to be very useful. It is only on very rare occasions that I find Maple (or Mathematica) to be that helpful (the last time I recall using symbolic code for more than convenience was in confirming my calculations for Haar measures for a non-unimodular Lie group some years ago).

One of the nicest things about using something like MATLAB (or Octave) is that using a numerical environment forces you to be careful in a way that symbolic ones don't, while allowing you to gloss over details that would be very time consuming in other languages. Often times using Boolean variables or clever use of primes allows a considerable amount of "symbolic" computation that is much easier to translate into practical code. It's not Grobner bases or whatever but it's usually pretty effective.

I have made it a standard practice for most of my company's code to be prototyped in MATLAB, whether it's mathematically oriented or not. This is also very helpful for validating outputs against C or Java code as well as checking that graphs using Swing, OpenGL, etc. are displaying properly.

link|flag
vote up 1 vote down

For large-scale optimization, GAMS [1] should be considered. For automated proof checking, there are several packages out there, see e.g. [2].

However, I voted up Mathematica and R, since that are the tools I use.

[1] http://de.wikipedia.org/wiki/General_Algebraic_Modeling_System

[2] http://en.wikipedia.org/wiki/Automated_proof_checking

link|flag
vote up 1 vote down

I like mathematica for most things. Particularly version 7. Scheme is a great way to think about computing in general. I think procedural languages are too mechanistic, as a mathematician I tend to think in terms of mappings.

link|flag
vote up 1 vote down

What language a mathematician uses is highly dependent on the field. I know of algebraists who use Maple, Magma, and Sage. I know numericists who use Fortran (even 77 ><), some who use Matlab, some who use C++ and some who use C (overlapping in many cases). I know of some mathematicians who use Python. I personally like functional languages, thought I am not familiar personally with any mathematicians who use them regularly (by this I mean purely functional languages... the few, the proud). I have seen some people use Mathematica, though I myself don't use it. I know of many mathematicians who try to avoid computers and programming languages.

link|flag
vote up 0 vote down

For self-education, I have used a wide variety of languages, including BASIC, APL, Pascal, python, and bash. For computer search and verification, I have used bc and awk: bc primarily for "small" bignum computations and awk for its nice handling of defaults and recasting between string and integer types. Awk is also similar to python in that a user can rapidly prototype with it.

Gerhard "Ask Me About System Design" Paseman, 2010.02.22

link|flag
vote up 0 vote down

I will take the original poster's question broadly to include, "What software systems or aids do mathematicians use?", in order to avoid the debate on what exactly constitutes a programming language.

During my previous life as a software developer (mostly embedded software for monitor and control of telecom/datacom gear) I programmed mostly in C, C++, and assembly language for production code, and at times used Forth on the lab bench. I also made fairly extensive use of Unix tools such as sed, awk, and shell scripting for constructing tools for our software development environments (not the target code itself).

Nowadays as an instructor, I occasionally use Mathematica when designing examples for lectures or questions for exams and quizzes. However, I do not write programs in Mathematica. I'm sure Maple or Matlab would suit my needs in this regard just as well as Mathematica does.

As a researcher, I usually write software in Caml (or Ocaml), which, like Haskell, is in the ML family of languages. If I ever come across a problem where speed is crucial, I would probably resort to C++. I dabbled with Sage a couple of years ago, and I will likely do so again someday, assuming that their code base has stabilized a bit since last I used it. (Too many things were in flux at the time for me to feel comfortable using it in earnest.)

And like most everyone these days, I use Latex for my documentation needs, though I have not dug into the depths of Tex. I.e. I am a Latex user, not a Tex programmer.

link|flag
vote up -4 vote down

BASIC! Gotta love the "goto" command.

link|flag
3 
I think mathematicians are more likely to enjoy languages with support for "COME FROM". (Google it.) – Scott Morrison Jan 8 at 10:34

Your Answer

Get an OpenID
or

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