News for hackers. Stuff that matters.
Re:Wolfram Language by coliveira on Friday May 15, 2015 @05:11PM (#9553704)
I think you would appreciate the language better if you understood that it is just Lisp with a slightly different syntax. They do everything using symbols, and all functions are decomposed into symbols for head and arguments. In my point of view, Wolfram language is a combination of many of the great concepts from Lisp and Prolog, which makes it very useful for knowledge representation.
Re:Wolfram Language by jordigh on Friday May 15, 2015 @05:22PM (#9553761)
It's just about the only living mostly lisp implemented with mexps instead of sexps.

But it sure is overhyped and it being proprietary is a huge drawback.

Re:Wolfram Language by lispm on Friday May 15, 2015 @07:39PM (#9554335)
Lisp is not a rule-based term rewrite system.
Re:Wolfram Language by tokipin on Friday May 15, 2015 @11:25PM (#9554942)
Mathematica has lisp essentially as a subset built on top of its rewrite system. In other words its rewrite system is so powerful that lisp can be naturally threaded into it.

In particular the symbolic nature of the language means that everything is first class, functions and function constructions ("functional programming") and expressions in general ("macros") being just basic cases.

Re:Wolfram Language by lispm on Saturday May 16, 2015 @03:44AM (#9555339)
> Mathematica has lisp essentially as a subset built on top of its rewrite system.

Right.

> In other words its rewrite system is so powerful that lisp can be naturally threaded into it.

a) lots of systems (turing machines, ...) can implement Lisp.

b) it's not that natural in Mathematica. The natural part comes from its symbolic nature. But if you look at the documentation and read about how they implement lexical closures, it's all vague and not that pretty. The implementation actually needs to rewrite variable names, IIRC.

I wonder why their documentation is so vague? They don't want independent implementations of their language?

Re:Wolfram Language by taliesinb on Saturday May 16, 2015 @05:40AM (#9555549)
> b) it's not that natural in Mathematica. The natural part comes from its symbolic nature. But if you look at the documentation and read about how they implement lexical closures, it's all vague and not that pretty. The implementation actually needs to rewrite variable names, IIRC.

That's indeed what Module does, and it is indeed ugly and slow. When we add parse-time macros it'll be trivial to fix this.

For now, many people use Block instead, which does dynamic scoping and is a bit cheaper. I actually really like Block, because it gives you the convenience of a couple of globals that you don't require you to keep passing them along among your backend functions, but they're properly bound to the lifetime of your function (and are re-entrant etc).

Re:Wolfram Language by tokipin on Saturday May 16, 2015 @03:19PM (#9557273)
i think you're thinking that Lispification is some kind of goal for the language, but it's not. the lispininess is just one aspect of the language, which is why i think calling it a lisp isn't fair to Mathematica -- it's more powerful/abstract/general than that (in particular because everything is essentially quoted by default - though in their raw forms i suppose both lisp and Mathematica are essentially equivalently capable). the precise character of the lispy aspects of the language (eg the language not "really" having safe-locked closures) is imo just an implementation detail.
Re:Wolfram Language by lispm on Sunday May 17, 2015 @04:44AM (#9559251)
Macsyma/Maxima is a computer algebra system written in Lisp, full 20 years older than Mathematica. It implements similar evaluation capabilities.

The book Paradigms of AI Programming by Peter Norvig shows how to implement these evaluation strategies in efficient Common Lisp.

Re:Wolfram Language by gohrt on Saturday May 16, 2015 @01:11AM (#9555125)
Can the user define a macro in Mathematica language?
Re:Wolfram Language by taliesinb on Saturday May 16, 2015 @05:26AM (#9555520)
There aren't read-time macros (yet). I'm actually in the process of designing a new package system that solves this (among many other problems).
Re:Wolfram Language by tokipin on Saturday May 16, 2015 @03:27PM (#9557301)
the concept of "macros" in Mathematica doesn't really exist as its own concept because the whole system is based on rewriting structure. for example, the ReplaceAll function[1] which is commonly used in idiomatic code is basically an in-place macro definition and execution, yet it wouldn't occur to most people that it's anything special.

if you're trying to make a traditional macro, you would implement it as a function with the HoldFirst et al attribute.

an important thing to know is that ReplaceAll uses arbitrary structural patterns. it's not a simple "turn every a into b". you can say things like "turn every application of the symbol F on an even number into an application of G on that number divided by two".

    expr /. F[n_?EvenQ] :> G[n/2]
[1] https://reference.wolfram.com/language/ref/ReplaceAll.html
Re:Wolfram Language by evanb on Saturday May 16, 2015 @01:59AM (#9555195)
It's not quite so clear as that. In Mma you can give special meanings to any patterns of symbols you like, which is very much like defining a macro.
Re:Wolfram Language by gertef on Friday May 15, 2015 @08:48PM (#9554515)
It can be, if you define the appropriate macros
Re:Wolfram Language by lispm on Saturday May 16, 2015 @03:40AM (#9555334)
'macros' don't buy you much in that case. you'll need a few functions, too.

But that's not the point anyway - you can implement lots of things on top of Lisp.

Lisp is based on a specific evaluation model. Not term rewriting. The way macros are computed is slightly related (since they take source and return source), but that's all.