4 ms·
The programming language of Sage is indeed imperative (Python) rather than functional. Python's approach is much better than Mathematica's for some kinds of ma
by williamstein 6y ago
The programming language of Sage is indeed imperative (Python) rather than functional. Python's approach is much better than Mathematica's for some kinds of mathematics, and much worse for others. This is more generally true of imperative versus functional programming -- each is good for some classes of problems and terrible for others.
Regarding examples, currently there are 50,283 functions defined in the Sage library, and 96.8% of these functions have documentation that is illustrated with working tested examples. Also, you can read the source code of 100% of these functions (unlike with Mathematica) in case something isn't clear. Much of the Sage reference manual (find it here: https://doc.sagemath.org/ https://doc.sagemath.org/) is autogenerated from the sagemath library source code; that's why there are 1,287,666 source lines of comments in sage, versus 636,899 lines of non-comment code.
- smabie 6y agoWhat stuff is functional programming bad at? You can just introduce loops and mutation with tail recursion and get all the "benefits" of imperative code.
- carlob 6y agoNot OP. First of all I wanna say that Mathematica/Wolfram Language is not just functional and certainly not purely functional. Thus said, I feel trying to be purely functional has its drawbacks whenever you have to keep track of a lot of stuff that requires state: for example if you have to declare that some of your constants are real you end up having to use Assuming or Assumptions a lot and that can get verbose quickly. Setting the $Assumptions global makes for terser code. If you wanna dig more into the differences of the two approaches in the same language you can look at the xAct package vs. the built-in symbolic tensors: xAct has many more features but feels less idiomatic, because you have to set they type of your symbols beforehand and expressions are not really self-contained.
- abdullahkhalids 6y agoThe reference site here https://doc.sagemath.org/html/en/reference/index.html https://doc.sagemath.org/html/en/reference/index.html is a travesty. As I said above, it is indeed complete, but it is a pain to find something in it. Pages are long, and you have to keep scrolling, hoping that the function you are looking for exists and is somewhere on this page. One of the best features of Mathematica documentation (https://reference.wolfram.com/ https://reference.wolfram.com/) is that every function has its own page, and there are helpful links to related functions. I have found so many functions via these links. I really wish Sage had something like this.
- leephillips 6y ago“you can read the source code of 100% of these functions (unlike with Mathematica)” This is an important observation. The source is the ultimate documentation, and, in many cases (in my experience) the only correct documentation for a software system. If you can’t see the source, you don’t know what the program does, you only know what someone says it does (aside from exhaustive experimentation).