Hacker Newsnew | past | comments | ask | show | jobs | submitlogin
Replacing Mathematica with Python (johndcook.com)
32 points by wglb on Nov 29, 2010 | hide | past | favorite | 16 comments


Article rather under-delivers on its headline.

Summary of article: "You might be able to replace Mathematica with Python, at least for certain applications! But I don't know, I haven't tried it, I just had a quick look at some websites."


When Python's symbolic computation abilities are even at a tenth of Mathematica's (especially for discrete functions like we love in computer science), I'd be more than happy to switch over. Perhaps someone could integrate Python with Sage or Octave.


http://www.sagemath.org/

Not quite as swish as mathematica but definitely better than 1/10.


holy heck, I think I'm going to start doing things in sage. Thanks!!!


not even. I'm working on a mathematica notebook that (mathematically, not physically) simulates the action of an enzyme... It generates a 120x120 matrix of kinetic parameters, symbolically solves to make sure there aren't contradictions (mostly conservation of mass), and then solves the 120-parameter differential equation. Then it does it 1000 times and collates the data (although I'm sure python could do that).


Mathematica seems like a much cooler language than Python. Python is like a dynamic Lisp but with an emphasis on imperative programming.


Mathematica is also a lot like Lisp and Mathematica also supports imperative programming. It's also a lot faster than Python.

In fact, I would argue that the only drawback with Mathematica is the fact that you become locked in. (whether or not you care about that is your prerogative.)


What do you mean by "dynamic Lisp"?


I guess I should have been clearer. It has a focus on run-time replacement of properties on objects. Duck-typing with an object-oriented emphasis. It is a dynamic language that supports lexical scoping but does not focus on the classic functional programming stuff.


I really like both Python and Mathematica, but if I have a mathematics-based task, 90% of the time I'll choose Mathematica over Python. Why? Well, Mathematica's programming language is pleasant to work with, resembling a dialect of lisp with pattern-matching built in, but the real win is in the libraries. If you have a numerical or symbolic computing task, chances are excellent that either there's a function to do it already in the Mathematica standard library, or Mathematica will let you write it in under a page of code.


that's not to say that there aren't things to have pet peeves about mathematica. What's with array dereferencing being [[]]? Makes my head spin.


Type ESC [ [ ESC and ESC ] ] ESC, and you get "thick" square bracket characters instead, which looks less silly.

I think it's clear enough where the [[...]] came from: Wolfram wanted "a b" to mean "a times b", which means "a (b + c)" has to mean "a times (b plus c)", which means you need a different notation for function application; they chose square brackets, which means they aren't available for subscripting (because everything, functions included, is an expression, and expressions are subscriptable); so they needed something else. And {...} was already taken for list construction.

When what you're doing in Mathematica looks more like mathematics than programming, you don't need a lot of subscripts. Presumably that's why subscripting is the thing that got the ugly notation with extra characters.

(The thing I find most unpleasant about programming in Mathematica is the way it tries to use pattern-matching as the single fundamental tool. This gives Mathematica programming, for me, something of the same feel as getting a macro-expansion based system like bash or TeX to do tricky things. But I'm not all that expert with Mathematica, and it's possible that more experienced users happily internalize the details and don't get confused as I do.)


I like the way you can mix and match programming notation with mathematical expressions that look like written math. You can draw up an equation that is very readable and then wrap the whole thing in a Plot[] or Manipulate[] * statement without losing that elegant style.

* Manipulate is the coolest thing in the world.


It took me a while to be okay with For[] loops and now I can't quit using them. Crude, but effective.


Yeah, it was pretty clear to me... I'm just not sure why they couldn't make array dereferencing a function?


If you mean having a separate dereferencing function: Dereference[myArray,1,2] is surely much worse than myArray[[1]][[2]].

If you mean having function application mean dereferencing when applied to arrays, so that you'd write myArray[1][2]: they couldn't do that because you can apply the subscripting operations to any expression, so that e.g. F[x,y][[1]] evaluates to x just like {x,y}[[1]] does. (Because {x,y} is shorthand for List[x,y], which has just the same structure as F[x,y] in Mathematica.)




Consider applying for YC's Summer 2026 batch! Applications are open till May 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: