3 ms·
Can anyone offer a concrete summary of what Wolfram Language and Mathematica are, from a technical perspective? The marketing material alone makes it difficult
by haberman 4y ago
Can anyone offer a concrete summary of what Wolfram Language and Mathematica are, from a technical perspective? The marketing material alone makes it difficult for me to situate them in the landscape of languages.
- Is "Wolfram Language" the language used in Mathematica notebooks? Or is Mathematica a separate language, implemented using Wolfram Language? What does Mathematica add to Wolfram Language?
- I assume the Mathematica language is interpreted (not compiled) so it can be used in interactive notebooks. Any info about what its interpreter is like? I'm guessing it is compiled to byte code prior to being interpreted?
- How are symbolic expressions represented? Are symbolic expressions a distinct data type? Can you write a function that takes a symbolic expression and computes the derivative (I'm sure such a function is built in, but does the language let you implement a thing like this yourself?)
- Is there any kind of static typing, or is everything dynamically typed?
- 7thaccount 4y agoMathematica is a computational environment based off of a notebook like interface (think Jupyter Notebooks). It's programmed using the Wolfram language which is seriously cool and powerful. You can also just write Wolfram language scripts if you don't need to graph stuff. You can literally take a screenshot of something on your computer and copy paste it into a Mathematica function for image recognition or whatever and it will take it. It's a lot like a lisp machine in some ways. You can do advanced symbolic calculus, optimization, ML, 3D visualizations, audio processing, geographic visualizations, it has an import function that can handle practically anything, connect to databases...etc etc, all in a consistent way. Worth a look.
- eschaton 4y agoWolfram Language is essentially Lisp with M-expressions instead of S-expressions, coupled with a clone of MIT’s MACSYMA symbolic mathematics system built around term rewriting. Mathematica is the Wolfram Language plus a user interface similar to the Symbolics Dynamic Listener that acted as your command line front end. Jupyter Notebooks are quite similar since the idea of a scientist’s or engineer’s notebook where content is “live” is a pretty common one.
- lispm 4y agoThough Lisp does not use the kind of a rule-based term rewrite system for computation, like Mathematica.
- eschaton 4y agoThat depends entirely on your definitions when you’re dealing with a listener, especially a sophisticated one like the Symbolics Dynamic Listener or the CLIM Listener. If you want the forms entered to go through term rewriting before or as part or evaluation, that’s entirely feasible.
- lispm 4y agoOne can develop rule-based term rewriting systems in Lisp (and integrate them) and there are some, but itself is not defined or implemented as such. That can be seen by the clumsy implementation of lexical scope (renaming vars, etc.) in Mathematica or the limited compilation of the Mathematica language.
- qubex 4y ago1: “Wolfram Language” is the language that is used in Mathematica notebooks, but can also be used on Wolfram Alpha and on the Wolfram Engine. 2: It is usually interpreted but can be compiled. If you RTFA there’s plenty of information about new compiler functions. 3: All expressions in Mathematica have the same form. For example 1+2 is just shorthand for Add[1, 2]. Think of them as M-expressions from LISP (kind of). These can be evaluated or manipulated. Symbolic expressions are not fundamentally different from other types of expressions. Indeed everything is a “symbolic expression”. 4: Wolfram Language/Mathematica goes to great lengths to hide this from you. Indeed again if RTFA you’d have read mentions of this with reference to interfacing with C code.
- chobytes 4y agoThe wolfram language is kind of irrelevant. I dont think anyone outside of HN and programming language people care about it or how its done. Mathematica is the star of the show. Its a large collection of specialty libraries and tools, with (mostly) very nice documentation, that all interoperate together well.
- ianbicking 4y agoDitto, I'd love to hear more of this talk. It feels like Wolfram/Mathematica has its own terminology, but I'd love to hear it interpreted in more mainstream programming language terms. The symbolic evaluation is pretty novel. I assume it's not _just_ an AST. What do those structures look like? What is the scoping? It feels like the emphasis is on global variables everywhere, but is it more subtle than that? Are the data structures what we expect? Just in this post, Threaded implies some abstractions there. I would assume that some kind of "deferred" values are pretty typical throughout, is there a formal notion of that? A lot of it is deliberately hidden in the language, but I assume you can write code that handles that stuff directly. Speaking of derivatives, I assume you can indicate how to take the derivative of new kinds of functions. How does that work? Generic functions, object oriented, ad hoc registries, or something else?
- carry_bit 4y agoScoping: Symbols belong to "contexts" (namespaces). You get lexical scope using With and Module, and dynamic scope with Block. The variables in Module are replaced with a uniquely named temporary symbol (removed when all references go away), so they can be returned from the Module expression and acted upon (though they'll appear ugly). Data structures: you have special syntax for lists and "associations" (dictionaries/maps/hashtables). Those are immutable objects, but in at least some cases the implementation has an optimization where it'll directly mutate the object if there is only one reference to it. There are other data structures with no special syntax in the language, for example numeric and sparse arrays. A number of mutable data structures have also been recently introduced: https://reference.wolfram.com/language/guide/DataStructures.html https://reference.wolfram.com/language/guide/DataStructures.... One thing that you might expect to be a special data structure but actually isn't are "pure functions" (anonymous functions). There are actually just the unevaluated expression, so you could programmatically inspect the body if you so wanted to. Deferred values: You can apply the HoldFirst/HoldRest/HoldAll/HoldAllComplete attributes so during evaluation they receive the corresponding arguments unevaluated. You might think this would make metaprogramming be easy, but it's actually tricky because of the "infinite evaluation" (it keeps evaluating until a fixed point is reached) of the language. Derivatives: It's a term rewriting language, so you just provide the rewrite rules like you would with any other user function. f /: D[f[x_]] := x^2 will define the derivative of f(x) to be x^2, and associates that definition with f so that rule won't have to be checked for all usages of D (this also saves you from having to unprotect D to add the rule).