6 ms·
If you come from a programming background, just treat it as a Lisp with M-expressions rather than S-expressions. It all comes together quite quickly then. At i
by spitfire 12y ago
If you come from a programming background, just treat it as a Lisp with M-expressions rather than S-expressions. It all comes together quite quickly then.
At it's core Mathematica is actually a rule rewriting engine. but except for more heavyweight uses you can view it as simply a Lisp with the worlds best standard library.
- larve 12y agoit's a great language, once you get past the fact that writing code in the notebook is a horrible experience. You get a great lisp, along with pattern matching and rule replacement. I can recommend the book by Paul Welling, as well as the books by Michael Trott (very meandering). Just funking things up in the notebook is the most fun I've been having in a long time. You just get sucked into trying more and more things, adding manipulates around it, playing some more, taking the output image and running image processing on it then converting it to a mesh on which you solve differential equations.
- spitfire 12y agoI disagree, I think the notebook is one of the best interfaces I've ever found. Just not for "traditional programming". The notebook is a literate programming document. It contains my thoughts and process for creating an algorithm/piece of code along with tests and examples. This is very, very different from how people traditionally "program". However, Mathematica has some very real, very strong deficiencies if you wanted to build an application end-to-end within it. It's dynamically typed, with everything-is-a-list mentality. So you will get type errors. Unit testing (let alone combinator libraries like quick check) are only available at the higher price levels. Warning personal opinions ahead!! Wolfram employees often have have strange views on how software is built outside of Wolfram Inc. Unit tests are alien, and type checking or datatypes (Say, to make sure that order your fancy Mathematica based trading system is going to make is sane) are seen as only things dumb rails programmers need. Rather than tools to make developers more powerful. I would honestly recommend every programmer learn Mathematica. I'm sure they'll find that they can aim far higher when they have the right tools behind them. It's the same distance again from Python/Ruby as Python/Ruby are from C. Probably more.
- jfklein13 12y ago> Unit testing ... are only available at the higher price levels. Actually, this is now available for everyone, something I advocated for. VerificationTest and TestReport are the key functions there. Good implicit suggestion about QuickCheck. We've supported unit testing in our Eclipse plugin for years, and with V10 brought the MUnit package into the System context with a redesign of the essential functions.
- spitfire 12y agoYeah quickcheck (and smart check which minimizes the counterexamples) seem like places where mathematica could shine bright for software debs. I would absolutely adore seeing smart check implemented in Mathematica. Please make it so.
- taliesinb 12y agoThere's the beginnings of an algebraic type system hiding in 10 (do Get["TypeSystem`"], then try RandomData[Vector[Atom[Integer]]). So generating synthetic data for a function with a given signature is already possible. Now we need to be able to express invariants etc, and then minimize counterexamples.
- harshaw 12y agoI would add that watching someone who has mastered Mathematica use it is truly an awe inspiring moment. A coworker is a former Wolfram employee who can explore data analysis in minutes in what it would take me hours/days to do in python.
- coliveira 12y agoThe notebook is excellent for its intended domain, which is scientific exploration. It is very good to be able to create definitions and change data, having the results immediately visible. Notebooks can also be saved in its current state and exported to other formats.
- cdwhite 12y agoI found that "just using it as a lisp" was a huge pain: the fact that Mathematica is, as you say, "actually a rule rewriting engine" kept causing it to behave in ways that looked absolutely bonkers if you were trying to think Lisp. The jungle of function-definition-like expressions and the scoping constructs were particularly bad, but I also found that the language & the culture made it far too difficult to write readable code. (I find my eyes glazing over almost immediately when I try to read the Wolfram blog: it's so very hard for me to see the structure of the code.) Perhaps once you become happy with the core principles of the language all of this gets better, but I spent quite a lot of time thinking it and never really got there. Moreover, I never figured out how to do iterations quickly; even once I got the thing working, it was prohibitively slow. Ultimately I re-wrote it in Julia, which was a much better fit for the problem (exact diagonalization of a one-particle tight-binding Hamiltonian). That was a rather more pleasant experience. Now, this is in part about the problem domain: I wasn't doing any symbolic manipulation, though (IIRC) I was comparing my results with those from some symbolic calculations. (Honestly, I feel pretty stupid for having even tried to do it in Mathematica in the first place.) The lesson I learned, though, was to never use Mathematica for anything beyond basic symbolic calculations---integrals, that sort of thing. My experience with Mathematica is sort of like my experience with Fortran: if you stick to the sorts of problems for which it was developed (hard-core numerics for Fortran, symbolic manipulations for Mathematica), it's great, but if you want to do something more general you're in for a rough time. (I understand Fortran's gotten progressively better, but I don't have any experience with anything after 95, and even that was a codebase heavily inflected with 77.)
- taliesinb 12y ago> I found that "just using it as a lisp" was a huge pain: the fact that Mathematica is, as you say, "actually a rule rewriting engine" kept causing it to behave in ways that looked absolutely bonkers if you were trying to think Lisp. Can you give an example of bonkers-ness? The functional parts of Mathematica/WL (by which I mean the equivalents of fold, filter, map, etc) are pretty straightforward and should be quite easy for a Lisp programmer to pick up. See [0]. In fact the suite of functions you have available for basic list and hashmap manipulation is probably one of the richest among languages in this space. Btw, its called a "term rewriting system", not a "rule rewriting engine". > Moreover, I never figured out how to do iterations quickly; even once I got the thing working, it was prohibitively slow. It's a bit odd to criticize a functional programming language for not having super-fast 'for' loops. But you can use Compile[1] if you want to write fast procedural-style code. We also do some amount of JIT compilation. > Ultimately I re-wrote it in Julia, which was a much better fit for the problem (exact diagonalization of a one-particle tight-binding Hamiltonian). That was a rather more pleasant experience. Did you really want to write diagonalization from scratch? Why not use the superfunction Eigensystem [2], which has been honed by many experts over many years? > Now, this is in part about the problem domain: I wasn't doing any symbolic manipulation, though (IIRC) I was comparing my results with those from some symbolic calculations. (Honestly, I feel pretty stupid for having even tried to do it in Mathematica in the first place.) > The lesson I learned, though, was to never use Mathematica for anything beyond basic symbolic calculations---integrals, that sort of thing. That's basically nonsense. Wolfram|Alpha is a multi-million line Mathematica/WL system that goes far beyond symbolic manipulation. As a totally random example, take Facebook social network analysis [3]. Note to self: clearly we aren't making it easy enough to understand what WL can do, especially for people who pick it up for one specific thing. The video helps a bit, and there is the fast introduction for programmers [4]. [0] http://reference.wolfram.com/language/guide/FunctionalProgramming.html http://reference.wolfram.com/language/guide/FunctionalProgra... [1] http://reference.wolfram.com/language/ref/Compile.html http://reference.wolfram.com/language/ref/Compile.html [2] http://reference.wolfram.com/language/ref/Eigensystem http://reference.wolfram.com/language/ref/Eigensystem [3] http://www.wolframalpha.com/facebook/ http://www.wolframalpha.com/facebook/ [4] http://www.wolfram.com/language/fast-introduction-for-programmers http://www.wolfram.com/language/fast-introduction-for-progra...