Friday, November 4, 2011

The three worst things about Mathematica

I've been working with Mathematica quite a lot recently, and while it has some really nice features like the Manipulate[] operator which lets you create interactive plots or anything in a single line, it has a few major fuckups in my opinion. So allow me to rant about my personal top three of them for a bit.


<rant>

Place 3: Shared data among notebooks

All data among all currently opened notebooks is shared. Implicitly. Without namespaces. Thus, it's almost impossible to have two independent documents open at a time, because there will be name clashes almost for sure. And because of the sometimes non-existent or not very helpful error messages, it can take you quite a while to find out that the function you defined in the line above was overwritten by some completely unrelated document which you edited in the meantime.
This is just a question of use cases, in how many cases do I want to import data from one document into another, and in how many don't I? Why not just have something like namespaces, or an Export[] or Import[] function? Or just the possibility to turn of this share feature altogether? I don't want it.

Place 2: Brackets

Mathematica uses a whole lot of square brackets []. And if I say a lot, I mean a lot. Statements which have five or six of them closed right after each other are not uncommon, you'll even find plenty of them in the "Examples" of the documentation. What's the problem? Well, there's no bracket highlighting. It highlights them if they're mismatched, but often enough they're matched but it's still not what you want. What's so difficult about highlighting the matching opening bracket if I'm on the closing one with my cursor?
As if that wasn't bad enough, they chose "[[ ]]" as the array access operator. So if you want the first element of a, you write "a[[1]]". Holy shit. If you do things like this, you absolutely *need* bracket highlighting. Period.

And the winner is: The "undo" feature

In Mathematica, you can undo one operation, and there's no redo. Let me repeat this: You can undo exactly ONE operation, and there's NO redo feature at all. Wow. They managed to create an application which is worse than Microsoft notepad in one point, and that really means something. Even the most basic usecase of undo -- I type a line, hit two wrong keys, and hit Ctrl+Z to undo them -- is broken by this unholy implementation, because it's likely to undo your typing the *whole line* or so. And you can't redo it, so you have to type it all over. So you better don't use it at all.
The reason for this seems to be that it can be complicated to implement a proper undo for notebooks which are fed with dynamic data. Well, I don't care about that. I just want to undo what I typed, I don't give a f*ck about the output (which, in almost every case, can easily be re-created from the input, even if it's lost in the process). I'd also be fine with a warning dialog or anything. It can't be difficult to find a solution which is better than this one, really.
Fact is: There's no valid excuse for not having a proper undo feature.


</rant>

But, to say something positive in the end: Their linux port is okay. It has an installer which works, and overall, it's not painful to use under Linux with its Qt based interface.

18 comments:

  1. If any free software that is spread like Mathematica would lack your demanded features, someone would implement them in days. I wouldn't have expected this from a company that runs Wolfram Alpha. Wolfram Research, are you serious?

    BTW: I guess the free alternatives won't really cut it?

    ReplyDelete
  2. Well, wxmaxima is quite good. It has a very friendly UI, too. However it doesn't have the "modern" kind of features mathematica has, so I wanted to look at both of them. Most of those are pretty useless for me anyways (freeform input, sounds great, but it just takes me longer to find something it understands than it takes me to just look up stuff in the manual) but some, like the Manipulate operator I mentioned, are extremely useful. Maxima is great if you just want to do some calculations, but for visualizing data I found it quite difficult to use.

    ReplyDelete
  3. i agree with Brackets problem it should highlight when we position the cursor near a bracket, this is like a palace with a poor door.
    another way (not simple) is to position the cursor near the bracket then press ctrl+shift+B and the [...] or {...} or (...) will be highlighted also triple click will do the same. the same with ctrl+. twice

    ReplyDelete
  4. The third place is not a problem. If you don't need data sharing between notebooks you should connect them to different kernels.
    The recipe is following:

    1. Add new kernel in Evaluation/Kernel configuration options/
    2. Select the kernel you've created via Evaluation/Notebook's kernel

    And yep, the undo is veryveryvery terrible...

    ReplyDelete
    Replies
    1. Or you can just open different instances of software and work on each independent document.

      Delete
  5. Have you considered SymPy? It's a CAS written in Python (and I see you use Python) and it compares favorably in some aspects even to proprietary CASes. No interactive plots, though (last time I checked).

    ReplyDelete
  6. SAGE is definitely the way to go.

    ReplyDelete
  7. Guys, I was searching whether there is any useful solution with this weird undo in Mathematica.
    I've came across to this petition: undo-for-mathematica.alaifari.com
    a whole website is made :)

    ReplyDelete
  8. These really are the three worst things about Mathematica. I hate the fucking brackets. There are so many of them you start to lose your mind. And if you erase one by accident and evaluate and it screws up? Well you're fucked, because you can't undo it!

    The lack of an undo and redo feature is primitive. The fact that Mathematica can solve systems of PDEs, evaluate nonelementary integrals, and perform repeated calculations on thousands, even millions of data elements has contributed vastly to science. But they can't put in an undo feature?

    I have Mathematica 8.0. Let me tell you, had I paid for it, I would be steaming hot. Thankfully I don't give my money to companies that don't have their shit together.

    ReplyDelete
  9. A couple notes: there are "namespaces" in Mathematica, they're called Contexts. Furthermore, you can run multiple Kernels which do not share variables. Assign one notebook to one kernel, another notebook to another kernel.

    There is syntax highlighting for brackets. Plus, if you use Map, Apply, postfix, infix, prefixes to your advantage, you can reduce the number of brackets you need.

    As for Undo, there's really no excuse

    ReplyDelete
    Replies
    1. Yes, the multiple kernels thing has been mentioned a few times. I change my complaint to "it should behave like that by default because it's what the user expects".

      The syntax highlighting for brackets was added after this article was written.

      Delete
  10. On the matter of free software mathematics software, btw: for numerical calculations, I find myself using ipython-notebook (with embedded matplotlib) a lot recently. It's very nice, and also quite fast.

    ReplyDelete
  11. I came here just to feel better about how much I hate the undo problems. You'd think they could do something about that before bothering with free form input and wolfram alpha integration.

    Also, I discovered a couple days ago that mathematica lacks any autosaving as well. I had a moment when I saw it was crashing that I could have taken a screenshot, but I hesitated, and then it was gone...

    ReplyDelete
    Replies
    1. If you don't need the interactive stuff, you could consider using kate to write mathematica code. Since recently (or rather, in 4.13), it even has basic code completion for mathematica (see http://scummos.blogspot.de/2014/02/kate-intelligent-code-completion-for.html).

      Delete
  12. This comment has been removed by a blog administrator.

    ReplyDelete
  13. I use mathematica a lot and I have given up on the graphical interface a long time ago. Just use your favourite text editor to write your mathematica code and execute on the terminal with math -script myfile.m. On the few occasions where I need graphics I can export to pdf. I only open the graphical interface for debugging/profiling or to look at the documentation when I'm offline.

    ReplyDelete
  14. I'm not sure when it was added, but in Mathematica 9.0, you can use
    Evaluation->Notebook's Default Context->Unique to this Notebook
    to prevent sharing variables between notebooks. But I agree, this should probably be the default - sticking stuff in Global is something that most modern languages avoid.

    Bracket highlighting does happen a little, now, so if your cursor is next to a bracket it will highlight the pair. But I'd rather have 'rainbow brackets', like lisp users prefer. In general, the user interface for Mathematica is awfully barebones.

    The lack of an undo history is very annoying - but not actually all that surprising, because just changing a cell can potentially have major, essentially irreversible side-effects. With the Dynamic command, it'd be possible to write something that erased the user's filesystem if they edited a cell (they wouldn't even have to execute it!). Of course, cell-dependent Dynamic commands aren't all that common, much less ones with major side-effects, so it's not really a very good reason to avoid Undo.

    ReplyDelete

Note: Only a member of this blog may post a comment.