Here is what I am looking for from the programming language:
* Good standard library that helps in exploring math concepts. Python fits this bill. Python's standard library has functions like math.comb(), math.gcd(), math.factorial(), etc. They make it easy to write down many closed-form expressions without reinventing the wheel.
* Speed. If I am exploring a new concept and I want to test a conjecture for large numbers, such iterate-and-test loops in Python run 30 times slower than equivalent loops in C++. Here C/C++ fits the bill and Python does not.
* Expressibility. While I am exploring mathematics, it should not feel like I am fighting the syntax of the language. Python and Java fit the bill due to their simplicity. C++ is manageable. Rust feels like too much work for quick and dirty hacks to test conjectures.
* Longevity. The language should be stable and not prone to too many breaking changes. Some code I write now should run without modifications ten years later. C, C++, Go fit the bill. Python does not.
* Open source implementations. The language must have popular free and open source implementations. I don't want to be paying large sums of money for something like MATLAB or Mathematica. Most languages popular here on Hacker News like Python, Go, Rust, etc. fit the bill.
Now if there is no language that do not meet all the requirements above, that is fine. Something that comes to close to supporting most of the features above is going to be okay.
You may be interested in a free online MIT course about 'computational thinking' that's being run right now using Julia. [3]
In not affiliated with Julia or anything, just think it's a really good language.
[2] https://benchmarksgame-team.pages.debian.net/benchmarksgame/... (graph at bottom of page)
You can definitely explore mathematics experimentally, we all do - computer or not, but to really learn the mathematics just read the books and do the exercises.
Being able to work things out symbolically on paper is probably one of the biggest skills you can have beyond your usual repertoire of programming skills - is there any worse feeling that guessing your way through a problem you don't understand?
If you are interested in something similar to Mathematica or Matlab, then probably Python, because it is used as a language in SageMath: https://www.sagemath.org/
If you're interested in numerical computing, then there might be other choices such as Julia.
If you're interested in theory programming languages, logic or category theory, then Haskell or even more esoteric language (theorem prover) like Coq or Lean could be interesting for you.
I partially disagree with you on longevity since not much math-heavy code would have been hit by the breaking changes in Python 3.
In the ML domain I also disagree with your take on performance since there are plenty good enough GPU accelerated libraries for Python.
Python also has the advantage of knowledge reuse in gainful employment since it's the preferred language for ML.
While I think it doesn’t check most of your boxes, it’s one of a kind in that it lets you write mathematical proofs for your functions.
It pushes the limits of type driven development. As I understand, the big idea is that tests can only show a program is faulty, not that it’s correct. On the other hand mathematical proofs can actually prove your program is correct.
That said I’ve never used it myself but I know a close-knit community of extremely smart mathematicians/programmers using it. It’s certainly a language with huge potential. I plan to play with it / learn it some day.
What makes SymPy great for learning is the API it provides closely matches the math verbs: expand, factor, simplify, etc. so it feel very similar to what doing math on paper would be like.
There is an online shell[1] you can use to try out some commands, and I've written a tutorial[2] that showcases some of the most useful commands.
[1] https://live.sympy.org/ [2] https://minireference.com/static/tutorials/sympy_tutorial.pd...
Or if you want to go all in you can try a proof assistant like Lean which is being developed with a focus toward application in mathematics rather than CS/logic.
https://www.gnu.org/software/octave/index
and take a look at Julia as well.
I don't have experience with it myself, but it looks like it should have the properties you're mentioning.
If you’re more interested in pure mathematics—things like (non-analytic) number theory, algebra, combinatorics—I would recommend Haskell. I find the type system helps a lot for algebra and the freedom to express computations in more natural and functional ways helps with things like number theory.
Both languages are fast enough. The thing you should mostly care about is the speed of writing correct programs rather than execution on large datasets anyway. Julia is in many ways like python except you don’t need numpy because the built in arrays and for loops (and auto broadcasting) are fast enough.
If you want a proof assistant then I don’t know enough about the available options to make a good suggestion
If you wanted (for example) to learn about group theory, the best tool is gap (https://www.gap-system.org). It satisfies your requirements -- an open source system, with a language which hasn't broken backwards compatbility in over 20 years.
I suggest J (jsoftware.com)
- fixed-size integers (signed and unsigned)
- big integers
- rationals with big integer numerators and denominators
You also want all of them to be fast, especially if you’re going to explore things.
If you’re going to do exact polynomials, you’ll want the ability to represent radicals (square root of 2, third root of (square root of 2 plus 1), etc). That gets you to a computer algebra system (https://en.wikipedia.org/wiki/Computer_algebra_system) that will also help in doing exact analysis.
If you want your system to be extensible, you’ll want operator overloading (if you implement addition mod n, you will want to write it using ‘+’). You’ll also need extensibility if you’re going to hunt for counterexamples, as you’ll need it for performance.
On the other hand, if you want to do proofs, you may want an automated theorem prover (https://en.wikipedia.org/wiki/Automated_theorem_proving) or a proof assistant (https://en.wikipedia.org/wiki/Proof_assistant)
I don’t think you can get all of the above in one system. That’s why you have to decide what kind of math you want to do before picking the system.
- Complicated plots take some fiddling to get right, especially when you start adding dimensions or want to do anything nonstandard. I still don't have a volume rendering solution I'm totally happy with. This is something that "just works" for a much broader variety of plots in some environments like Mathematica.
- This doesn't usually matter for me since exploratory code rarely does more than a few billion things, so even in Python my experiments are instantaneous, but to get good performance I do have to call into an external library (numpy, networkx, etc) or drop down and cdef everything so that cython can make it fast. That isn't especially arduous (and I don't do a ton of Monte Carlo or anything where that would matter), but I've heard that's supposed to be a point Julia improves on.
- Theorem proving is only kind of okay. You have simple things like hooks into SMT solvers and whatnot, or some weak first order theorem provers, but last I checked that part of the ecosystem is underdeveloped. I wind up writing something bespoke and tailored to the problem at hand every time something like this crops up. That's not really what you want from a system helping guide your exploration of a problem.
Whichever solution you go with, I strongly recommend picking something with notebooks available. Jupyter and Mathematica really excel in this regard, and it makes interactive explorations painless in a way that even REPLs lack.
If you're keen on using higher level language features such as generics, you can make use of them easily. Otherwise they'll stay out of your way. In terms of progressive disclosure of complexity, it is the best language I've used. And I've used many.
There are also many[1][2][3][4][5] open source projects to peruse. Even if you're not on Mac, there is Linux and Windows support, though I don't have direct experience with them.
The language itself is now fairly stable with a fixed ABI, relatively fast, and is open source so you can modify it if that's something you're interested in down the road. Despite the commentary, it's not an Apple-only language, though when you're outside the Apple ecosystem things are more bottom-up and hence the experience can be inconsistent at times.
I credit Swift with revitalizing my own interest in mathematics. It made re-learning the stuff I'd forgot from college fun and interactive.
[1] https://github.com/apple/swift-numerics
[2] https://github.com/phlegmaticprogrammer/LANumerics
[3] https://github.com/apple/swift-algorithms
Learning and exploring maths will involve theorems, deriving stuff, solving textbook problems, that kind of thing. Not much of this will involve actual numbers or explicitly calculating anything. In any case, the calculation is very often the "easy" bit, without much to be gained knowledge-wise unless you know why you're doing what you're doing.
And then Julia is probably your best bet. I'll also recommend R, just because nobody else has. It's got all the advantages of Julia with the added benefits of being a much slower and quirkier language. It does do a good job of getting out of the way when you just want to do explore some math concept though.
If you actually want to learn math, then I would recommend to take courses and do the homework. You will notice how rarely you need the computer for it. I cannot remember that we used a computer even once in the first few semesters of studying math (I am physicist but we shared courses with actual math students. We just had less math courses than they did).
In terms of longevity, I don't think Python is going to repeat the 2/3 shenanigans any time soon so with python 3 you should be ok, and in terms of speed, numpy is used in many HPC applications: if applied correctly and depending on use case, writing C/C++ code that performs on par with it will be quite hard.
Why would you use anything else.
That said math is by absolut3 far better explored with a pen and a book. Computer are not really anything but an annoyance to learn math properly.
Julia sounds intriguing though