Let's keep the conversation on the list. That way, people who know more about Julia than I do can tell me when I'm wrong.
On Sat, Jan 25, 2014 at 1:29 AM, Акатер Дима <...> wrote: > Thank you. > > > The biggest advantage of Julia over Mathematica is that Julia tries > > to make its semantics obvious enough that you can reason about > performance. > > I believe this to be the matter of particular implementation, not related > to the core language. Mathematica is closed, so users mainly can't reason > about performance merely because they can't investigate the source code. > So, from the following point… > > > The biggest advantage of Julia over Mathematica is that Julia tries to > make its semantics obvious enough that you can reason about performance. > > …could you elaborate on how is this related to semantics? Do you suppose > Disassemble symbol is impossible in a language like Wolfram's due to its > semantics? Or were you not really referring to the core language here? > You're right, my comment about semantics was kind of vague. But it isn't "just an implementation issue." It's also a design/philosophy issue. What I was trying to express is that it's fairly straightforward to write low level code in Julia that maps in a simple way to the machine code that will actually be executed. You really can't say the same about Mathematica's core language. They do have facilities for compiling functions for particular types, or representing C symbolically, but those are far from the most obvious way to use the language. You can find lots of concrete examples on the Mathematica mailing list. About once a month, someone writes a "what is the fastest way to do x" post, where "x" is some reasonably simple low level thing. Here's a random one I just found: https://groups.google.com/d/topic/comp.soft-sys.math.mathematica/uiMFIOus6KU/discussion They're discussing fast ways to count how many elements of a list fall in a particular range. The high level functions like "Count" are relatively slow compared to things like mma> data = RandomReal[1.,1*^7]; min = .2; max = .3; mma> Total@Unitize@Clip[data,{min,max},{0,0}] I claim that it takes *a lot* of experience to know that that is the code that is going to be fast, compared to the other 15 approaches people bring up there, because the mapping between Mathematica's core constructs and the machine's core constructs is far more complicated and indirect than for Julia. In contrast, it doesn't take deep familiarity with Julia's standard library to come up with about the fastest way to write this operation. julia> function count_range(arr, min, max) count = 0 for elt in arr if min < elt < max count += 1 end end count end It takes more than one line to write, but it's *obvious*. My Mathematica license is expired these days, so I can't run the benchmark, but I bet it also smokes the fast solution in Mathematica. Now you might claim that this is an implementation detail, and that with a Sufficiently Smart Compiler, Mathematica could generate code that's just as fast as Julia. But because of Julia's language design, it doesn't need a Sufficiently Smart Compiler--it just needs a Smarter Than Many But Still Completely Tractable Compiler. Now you can write for loops in Mathematica too, but they often aren't that fast. Why? I don't really know, but I'm sure it has to do with Mathematica "doing the right thing" for all kinds of complicated, possibly symbolic, constructs that you might put inside the for loop; in other words, complicated semantics. > > The most important thing the two languages have in common is that > (almost?) all of the syntax maps to expressions > > This is one of the most interesting parts. How does type declaration in > Julia map to an expression? What can users do with type declarations, as > standalone objects? “RTFM” would be OK answer but I'd really prefer a > discussion. :-) Does “quote type […] end end” work? Is there a way to > investigate and edit syntax tree directly? > manual/metaprogramming<http://www.google.com/url?q=http%3A%2F%2Fdocs.julialang.org%2Fen%2Flatest%2Fmanual%2Fmetaprogramming%2F&sa=D&sntz=1&usg=AFQjCNHdvHRNqHrkBW6Upo3OJYZ6YuKyyw>does > not seem to address these questions. > Maybe someone else can weight in here, but I'm inclined to say RTFM. Then read the implementation of some macros in the standard library. > Does “quote type […] end end” work? Yes... try it. You can step through the pieces of the resulting expression by looking at the head and the args of the returned expression, and then looking at the head and the args of all the args, etc. recursively.