What helped me straighten it out was to evaluate the examples here with Trace: http://reference.wolfram.com/mathematica/tutorial/BlocksComp...
In[1]:= m=i^2
Out[1]= i^2
In[2]:= Block[{i=a},i+m]
Out[2]= a+a^2
In[3]:= Module[{i=a},i+m]
Out[3]= a+i^2
In[4]:= Block[{i=a},i + m] // Trace
Out[4]= {Block[{i=a},i+m],{i=a,a},{{i,a},{m,i^2,{i,a},a^2},a+a^2},a+a^2}
In[5]:= Module[{i=a},i+m]//Trace
Out[5]= {Module[{i=a},i+m],{i$5592=a,a},{{i$5592,a},{m,i^2},a+i^2},a+i^2}
It's a bit dense to read through but with Block, "i" has been assigned the value "a", but still remains in the form "i" throughout the evaluation, and once "m" is replaced with "i^2", the "i" is seen and replaced with "a", acting as normal dynamic scoping.In Module, however, "i" is replaced by a temporary variable with the form "i$5592", which does not have a definition anywhere in Mathematica, so when "m" is evaluated, "i" is left alone, which is how lexical scoping acts.
I dislike forgetting parts of languages in the ones I use. C# is full of things whose behavior I have to look up, as is javascript, python, and especially while I'm learning them: clojure and cljs.
But what's nice about this language is that these two concepts, Module and Block, while having different meaning, have the same form.
> Long viewed as an important theoretical idea, functional programming finally became truly convenient and practical
> with the introduction of the Wolfram Language. Treating expressions like as both symbolic data and the application
> of a function provides a uniquely powerful way to integrate structure and function—and an efficient, elegant
> representation of many common computations.
I see nothing on the reference page that could be said to make Wolfram's FP constructs more convenient or practical. They make it sound like FP was a long lost dream but then Wolfram came along and actually made it happen. They're seemingly using the exact same constructs as everyone else.
What you do actually get from the reference page, though, is that they went the Haskell route and decided the FP stuff shouldn't be readable by anyone who hasn't used the language before. This is all fine and dandy, really; it's a model as good as any other, since it at least gives writability where it loses readability... They aren't doing anything new, from the looks of it, though. They seem to be doing precisely the opposite... In exactly the same way.
[0] - https://reference.wolfram.com/language/guide/FunctionalProgr...
Luckily I have a totally revamped debugging and logging system that will put us ahead of the curve here (imagine DTrace at a program level). Probably a point release of V10.
Same goes with multiple undo and retina support -- we know how embarrassing their absence is, and we've luckily been able to fix these for v10. I've been in design meetings where the multiple undo has bumped several other desirable features off our roadmap.
Unless it's the same kind of curve Go is judged against (aka the curve of 30 years ago), that's a very tall order. Are you working on something better than a time-traveling debugger?
> imagine DTrace at a program level
so... DTrace?
I'd kill for hashmaps, some sort of records and strong typing in Mathematica.
https://reference.wolfram.com/language/guide/Associations.ht...
So now there's just strong types and something like records left for me for general purpose development.
obj["a"] = 1;
obj["b"] = 2;
Print[obj["a"]]
or obj = { "a" -> 1, "b" -> 2 };
Print["a" /. obj]
?As for the REPL and general editing, if I were you, I'd quickly go towards LightTable integration — it should be doable, and the effects could be spectacular.
Still, would be interesting to try. I have great enthusiasm for what Chris Granger is doing.
From a long-time Mathematica user: this is not a language I like. I use it, but there is little to no fun. Many things aren't immediately clear or become problematic if you stop using the language for a while. As an example, quick, what is the difference between Module[], Block[] and With[]? Even if you remember that With[] is a lexical scoping construct, Module[] and Block[] can be confusing.
It doesn't help that Mathematica is absolutely horrible for debugging code. I don't know why they put so little emphasis on their REPL, but it's way behind the times. Even mismatched parentheses can cause serious pain (and I hate the fact that things move around when I edit parentheses).
That said, I have a lot of respect for Mathematica as a complete system. It is incredibly useful, most mathematical tools you will ever need are there. It is also a great tool for explorative data analysis. Have a pile of data you'd like to see patterns in? Load it up, mash it into shape with high-level functions, then quickly produce great-looking graphics. Nothing even comes close to the flexibility of Mathematica here.