Ask HN: Which general programming language is good for learning/exploring math?
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.
65 comments
[ 3.4 ms ] story [ 131 ms ] threadhttps://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.
https://julialang.org/
https://en.wikipedia.org/wiki/Julia_(programming_language)
I suggest J (jsoftware.com)
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?
Isn't this called science?
The fragment of uncertainty in this is typically very small and the process is very far from guessing your way through, hoping to find something new (whatever you found using such a method will most likely be either already known or incorrect).
When I first heard about the Monty Hall problem, I didn't understand it and tried it myself. It was way easier for me to understand the flawed intuition by analyzing each line as opposed to, say, for example, the explanation of Judea Pearl (which is also good).
What I wanted to emphasize is that it is not bad guessing your way through a problem you don't understand. But yeah, of course, you should have some knowledge.
Regardless, I plan to be learning until the day I drop, science or not.
However, I do think that programming can be an excellent complement and aid when understanding certain concepts. Sometimes, writing a numerical simulation of a hard to grasp concept can make things fall into place. In particular in probability theory it can be quite helpful to generate a lot of random samples to validate and clarify some counterintuitive concepts.
What do you think mathematicians do?
* basic math > algebra/trig > calculus, linear algebra, differential equations
As a non-mathematician, my impression has been that mathematicians do a lot of proof-based work since (to my impression) the goal is to make new findings, not just learn concepts and formulas that they can apply to their work like an engineer. From my limited experience with proof-based work, it seems like something where you would need guidance and discussion. Whereas when I learned things like derivatives and integrals, it was very procedural and you just needed to learn a process, which is then built on by a more advanced process, etc.
Can one realistically self-learn up to low-dimensional topology or algebraic geometry just by reading books and doing the exercises?
Luckily, there are plenty of resources available to someone self-studying online on various math forums.
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.
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.
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).
Can someone with more experience of Fortran explain if this language is still relevant today and if it makes sense to get started with it in this day and age? If so, which Fortran standard to use? Fortran 90? Which compiler implementation to use?
And a professional careful C programmer would not get to Fortran's library of numerically stable libraries for a very long time.
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.
[1] https://julialang.org/
[2] https://benchmarksgame-team.pages.debian.net/benchmarksgame/... (graph at bottom of page)
[3] https://computationalthinking.mit.edu/Fall20/
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.
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.