Dynamic interactivity in Mathematica 6

From http://www.wolfram.com/products/mathematica/newin6/

Building on two decades of world-class algorithm and software development, Mathematica 6 represents a dramatic breakthrough that immensely broadens Mathematica's scope and applicability—and redefines the very way we think about computation. Made possible by Mathematica's unique symbolic architecture, Mathematica 6 introduces a sweeping unification of language and interface concepts that makes possible a new level of automation in algorithmic computation, interactive manipulation and dynamic presentation—as well as a whole new way of interacting with the world of data.

By looking at the demos and documentation, it looks like they provide constructs to interact with functions; e.g., by being able to view or fiddle with symbolic expression parameters. This functionality seems to be tied up nicely in an interactive shell. Something to play around with.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Mathematica 6 looks incredible

I've been dying to see WRI bring the graphics side of Mathematica into the 21st century and it really looks as if they've done it.

Cheers,
Jon.

The marketing makes it looks amazing

I have to admit, even being extremely partial to the competition, that the Mathematica 6 marketing make that product look amazing. And it is not just the graphics, it really looks like it is worthy of the hoopla of a major release.

I want to try it out and see if it is as amazing in reality as it is in marketing.

great upgrade

It is great upgrade from version 5, it had taked too long time to upgrade.

Notebooks

I have always had a supreme distaste for Mathematica's interactive graphical shell, i.e. notebooks. At least in past versions, notebooks send expressions to kernels, which often mutate the environment of the kernel, instead of the environment of the notebook.

Having a separate environment per notebook would be a big step in the right direction, but even then, I wouldn't like the means of interaction... you still would not be able to tell what the environment is based on the expressions contained in the notebook.

I suppose I'll have to try the new version to see if they've fixed these problems; but somehow I'm not optimistic.

Hype

While I don't have anything against Mathematica per se (it seems to be a very useful piece of software), I really dislike the enormous quantity of hype this company puts out on a regular basis. For instance, in previous ad campaigns I've seen them pretty much claim to have invented symbolic computation (OK, not quite, but that was the strong implication). I guess it's not surprising coming from Steve Wolfram, who is known to be a rather unpleasant personality on many levels (I don't care to elaborate, but he used to be at Caltech and I've heard some pretty appalling stories about him). Anyway, looking at the demos I didn't see anything that blew me away, though a lot of the interface stuff seems quite nice.

Go read "A New Kind of Science"

or read the reactions to it. :)

focusing on the PL constructs

Man, replies to this post are either "I'm a mathematica fanboy" or "Wolfram is an evil publicity chaser." I didn't realize how polarizing Mathematica was.

At any rate, I was wondering if anyone had any opinion about the dynamic PL constructs in Mathematica 6, they seem pretty interesting and I've never seen them in a language based on symbolic computation before. One feature allows a symbol to be rebound dynamically causing dependent expressions to be recomputed, while another feature allows symbols to be easily inputted directly from the UI. Perhaps some of these features exist in other languages; e.g., using algebraic data-types in Haskell to generate input/output UIs.

PL features of mma

The first feature you describe is what Functional Reactive Programming is all about (which has been discussed here a lot). It is also quite familiar, since if you replace 'symbol' by 'cell', then you have what all spreadsheets do. It is also what MathCAD has been doing for over 15 years.

I am not sure what you mean / see as novel about "allow symbols to be inputted directly from the UI"?

Mathematica does have some (old) cool PL features: its version of pattern-matching, in particular its 'sequence variables', is interesting. Its various built-in facilities for term-rewriting based on nifty pattern-matching is interesting; however it is also problematic since you get no tools to worry about either confluence or termination of the resulting rules! Its introspection facilities are not bad.

Seems like Mathematica will

Seems like Mathematica will automatically generate an input/output widget for a symbol based on its data-type. I'm not sure if this is actually the case, but I get this impression from reading the documentation.

Short comment

Sean - See generalized input. In general there's dynamic type detection and switching with JIT compilation.

Jacques - Trace and Stack come to mind. These are old. The new v6 Monitor command offers possibilities, and the v6 debugger. Maybe these classify as mere introspection tools, not proof generators, but are proofs even possible for the untyped language?

My take

This release is epic. I've used all versions since 2.x and this is the big one. It deserves some hype. For Leon, no worries,
* separate environment per notebook
* what the state of the environment is based on the expressions
* tracked symbols
* getting environment names
Note. There's an advantage to information hiding with large expressions and arrays that otherwise sprawl across MathCAD screens, which MathCAD updates in realtime, while you twiddle. That makes twiddling nasty. Sometimes you really do want stop and go buttons.

Wolfram Research Incorporated marketspeak is famously over the top, no news there. That's often what happens when marketspeak is written without reference to antecedents, i.e., quasi-non-technically. It's fair of Jacques to mention FRP and patterns and spreadsheets and MathCAD. The idea that this is old stuff just misses the point a little. P.S. Jacques, I really enjoy your comments on LtU.

The salient fact for LtU is that Mathematica brings functional programming to the masses. By which I mean not the hidden kind (spreadsheets, MathCAD), but the real deal. MMA is Lisp that made it, so to speak. It's also Lisp to the Nth power, an experiment in design, largely successful if you ask me (technically - biz aside).

So now with v6 we arrive at an interesting design point: MathCAD meets Lisp. We have a slider between the two, roughly speaking. That helps two groups of people. MathCAD always frustrates my inner programmer, especially in array manipulation. I find myself longing for MMA or MATLAB instead of MathCAD. (Which tool I get often depends on the company.) But Mathematica frustrates non-programmers. They like MathCAD. Now in v6 they can use MMA more or less as MathCAD with trapdoors into Lisp.

The functional/imperative social divide manifests in CAS too, with MMA as Lisp and MATLAB as C. MATLAB programmers use a heavy imperative style. MATLAB seemingly supports little else. Once upon a time, every function mandated a stand-alone disk file, and every datum took the matrix type. People who write Mathematica with any skill use functional style. The marketplace correlation with C and Lisp is that MATLAB jobs exist and Mathematica jobs do not. If you want to make money, learn MATLAB. If you want to pay a lot of money, hire MATLAB. Today MATLAB is fantastic, no question, but so is MMA. Me, I'll work with anything, drop a line if you need temp work.

A common impression holds that MMA is for symbolics and MATLAB is for numerics. That was true until MMA v4 or v5.x. Really MMA v6 is a class by itself on both fronts. For symbolics, MMA is busy correcting published tables of integrals and generating new mathematical discoveries - and I do not mean NKS. For numerics, it even puts IMSL to shame. Credit for v6 goes mostly to corporate staff and user feedback, not S.W. He oversees like Guido, but does mostly personal research now. Besides, one can enjoy a great work no matter who produced it.

Mathematica's usefulness in straight C/C++ development surprises me. In no time MMA gives a test bench for C/C++ algorithms without framework headaches from MFC/wx/Qt/tk/GTK/etc. The MathLink API is small and fairly easy; it opens sockets and transfers strings. Once you nail down array transfers you're in show business. There is also very good Java integration and even an Eclipse integration.

Some v6 highlights of possible interest to general PL (non-CAS) people.

Visual language syntaxes
Interactive code annotation
Debugger
Forms editor
Y combinator example
Turing machine
Bitwise operations (boring but new)
Include graphics in programs (cute - and novel)
Tree plot
Sow and Reap (was new in v5)
File import-export formats and ref. (new: Flash, PDF, QuickTime, AVI, others)
Audio formats
Data sets
Automated report generation
Your teen will love you

Thanks!

Thanks for breaking it down for us. I have to say, as someone who's used Mathematica a bit and Matlab quite a lot, that despite all the hype surrounding Mathematica (which I despise), it's still an environment and language I can respect. I can't say the same about Matlab; even though Matlab doesn't have one-tenth the hype surrounding it that Mathematica does it still feels like it was designed by someone who knew absolutely nothing about programming languages (the main designer was a Fortran programmer, so draw your own conclusions about my biases). I used Matlab mostly for programmatically generating graphics (figures for papers I was writing), but I knew lots of people for whom it was their primary (or only) data analysis tool, so it's obviously done something right. It's when you want to scale your program up beyond a toy solution (for instance, when you want to use actual data structures beyond matrices) that Matlab really starts to suck hard. I teach programming languages, and quite regularly I get asked to teach Matlab; I always decline by saying that I don't want to teach a language that awful, and that anyone who learns a reasonably good language (e.g. python) should have no trouble learning Matlab on their own. But a surprisingly large number of people who can't program at all just want to learn Matlab and nothing else. That kind of makes me hate Matlab, because I know that if these people do learn it as their first language there's a good chance that they will never be able to overcome the experience and become good programmers.

Disclaimer: I haven't used Matlab in a few years. Who knows, maybe all its flaws have magically been removed by now. But I'm guessing probably not.

No luck

Matlab still sucks. I'm amazed nothing better has come along. This is really an area neglected by programming languages. I had a brief look at SciLab and R and both seem very rococo in their own way.

ASCEND

ASCEND

Overview

CS Bibliography

PDF user help

ASCEND can replace MATLAB in many applications. Its unit system includes an oft-neglected one, money, critical for tradeoff studies - dollars per square foot, cents per mile, etc. There are Python hooks. GPL.

(MMA 6 is clearly superior to ASCEND, even in ASCEND's specific strength categories. Of course MMA 6 lacks units, as do MATLAB, ANSYS, and most other pacakges.)

Inverse ratio

MMA hype is both justified and unsuccessful (cf. Lisp). In the universe of hype we're far more victims of MATLAB ad blitzes than WRI. Please distinguish hype surrounding people (S.W.) and their personalities (insert adjective here) and endeavors (NKS) from products (MMA) and their marketing.

The problem with WRI marketing isn't hype but misfocus. It fails to address working engineers and scientists. MATLAB ads keep engineers drooling. I read a dozen trade magazines. MATLAB ads run everywhere, outpacing Mathematica ads by 10x. MATLAB hype is far more skilled and omnipresent.

WRI's strategic mistake is to monetize everything. Instead they need to leverage the language power itself. CAS is a niche market and CAS-based engineering apps are niches within it. They compete against dedicated stand-alone apps. A good solid GPL'd Mathematica application like, say, circuit simulation, or thermal analysis, would do far more to sell Mathematica than hype about extensible general-purpose environments.

If I ran WRI then v6 would be my excuse to foster a language ecosystem. WRI's "application packs" would all go GPL to promote base package sales. User conferences would drop the stiff entrance fees. Users would get free web hosting for GPL projects, with free online kernel runs (time-constrained) for people who don't own Mathematica, but might grow interersted upon seeing their specialty niche being served.

impressions

I've played around with it for a couple of weeks, and the dynamic interactivity features indeed look useful. Not without the downsides though -- I found it easy to freeze the front-end by mistakenly putting a calculation that takes too long for some parameters. Because it's the front-end that gets frozen, you have to kill Mathematica and lose any unsaved work.

The several improvements that stand out:
1) Decent optimization algorithms. The old system was next to useless for functions with more than a dozen variables, but current system seems to work as well as netlib's BFGS/conjugate gradient procedures for the few examples I tried

2) Help system seems much more complete. There are many more examples, and tutorials linked from relevant pages.

3) Both 2d and 3d plots look nicer. 2d plots now seem to use anti-aliasing, 3D plots can be rotated by mouse. Rotation is slightly buggy though (sometimes there's flickering, or object disappears completely)

4) There's now context sensitive syntax highlighting, so you can see if you are trying to reuse a variable that's been already assigned, which is a common source of errors

One downside is that there is still no multiple undo

dynamic!

This tool is appropriate to mention here (I couldn't find it when thread originally started): soulver

It looks like a very simple calculator...apparently for people who find normal calculators too difficult. However, the way expressions are parsed and interpreted incrementally is beautifully simple.

(I have no affiliation with this software)

yaroslavvb's impressions

"Slow Evaluations inside Dynamic" covers front end lockup (bottom of page). Not all computations lend themselves to interaction. Optimization strikes me as one of them. However you can play with these tuning knobs and switches:
TimeConstrained, MemoryConstrained, tuning and debugging
OutputSizeLimit
UpdateInterval, Refresh
NotebookAutoSave
NotebookEventActions (try save-on-close?)

The Linux front end now uses Trolltech Qt, by the way. The other OS ports use GDI+ and Quartz directly.

I Googled some optimization links.
Constrained Optimization
Optimization s/w
KNITRO

Undo is a puzzle, but you can collect expressions that were generated in the course of the evaluation. The utility here is backtracking (undo) with memoization. You can also issue Undo programmatically, FrontEndExecute[FrontEndToken["Undo"]]. Probably these give not quite what you want, but still.

Mathematica is long-lived, so please, critiques should include version numbers; example from operations research. Sometimes hands wave in a way that is vaguely true but irrelevant (present company excluded). Across 20 years one can find bugs and missing functionality in anything. CAS packages are volatile and MMA is hardly the only one with Lisp underpinnings.

( Michael - Re "learning" MATLAB, of course you're right, but personnel departments won't hear it, even from a computer science professor like you. "How many years of XYZ?" is the usual question. )

( falcon - huh? Waving hands here, that looks like about 50 lines of MMA or Lisp code )

Multiple undo's

I've asked about multiple Undo's during the Senior Developer Q&A, and the answer was that they are "working on it, but there is a lot of issues", for instance they need to "figure out what exactly it means to to undo an operation in a dynamic environment." I have a feeling that they set some high internal requirements for this feature, ie, to be able to undo kernel state, as opposed to simple text editing undo