News for hackers. Stuff that matters.
Re:C++ vs. Lisp by yummyfajitas on Tuesday May 04, 2010 @01:18PM (#1318683)
To some degree, I feel that syntactic abstraction is a premature optimization. Many (most?) benefits of macros can be replaced by a combination of lazy evaluation and functional programming. Most of the performance benefits can be obtained by a sufficiently smart compiler which does partial evaluation. I use macros in lisp a lot, and I often wish I had them in Python/Java/C++.

In Haskell, I can only think of one very narrow use for them which has never actually come up for me in practical use (automatically generating instances for combined monads).

Out of curiosity, can anyone provide a more common use of macros which can't easily be done in Haskell with HOF/Lazy evaluation?

Re:C++ vs. Lisp by lukev on Tuesday May 04, 2010 @01:31PM (#1318718)
The only things I can think of are things that wouldn't enter the head of a Haskell programmer to begin with, such as syntactic shortcuts for complicated side effects.

So you're right, lazy evaluation can do just about anything in a purely functional environment. But now count the number of programming languages that provide a purely functional environment...

The rest of us need macros.

Re:C++ vs. Lisp by yummyfajitas on Tuesday May 04, 2010 @01:46PM (#1318762)
...such as syntactic shortcuts for complicated side effects.

I can think of a couple of examples where I've done such things in lisp (mostly elisp, sometimes Clojure), but I don't see a good reason why I couldn't do them in Haskell. In fact, a function f: a -> M d (with M = IO, Writer or State if you want side effects) almost serves the same purpose: it turns a value into a set of actions to perform.

I'm really curious, could you give an example of such a task/macro?

(Note: I'm not trying to engage in a language war, I'm honestly curious. If I'm treating Haskell as Blub, I'd like to know about it.)