News for hackers. Stuff that matters.
Re:Elixir, a functional metaprogramming-aware language built... by rayiner on Saturday April 27, 2013 @10:38AM (#5617871)
> 4) Almost every "old" computer language has slowly moved away from unprincipled metaprogramming precisely because it's difficult to reason about, for both humans and computers. (C, JavaScript, and Python, to name a few, all have unprincipled metaprogramming facilities, which have been, over time, relegated to specific use patterns to maintain coder sanity.) What do we hope to gain from a new language whose raison d'être is based on this feature?

This complaint makes little sense, because macros are expanded entirely at compile-time. Reasoning about a macro is no harder than reasoning about a higher-order function: you reason about the macro function (which is a simple transformation on some tree data structure), and the generated function. Because a macro is always expanded at compile-time, you can always expand it and inspect the generated function.

I wouldn't use Javascript and Python as examples here--those languages, suffering from their lack of meta-programming, instead encourage heinous things like monkey-patching and runtime introspection, which are insanely difficult to reason about.

Compare: what I might do in Common Lisp by writing a set of macros (and checking the expansions--just a hotkey away in my IDE) I'd do in Python by adding fields and methods to objects at runtime.

Re:Elixir, a functional metaprogramming-aware language built... by colanderman on Saturday April 27, 2013 @02:12PM (#5618533)
Reasoning about a macro is no harder than reasoning about a higher-order function: you reason about the macro function (which is a simple transformation on some tree data structure), and the generated function.

Except that C-style macro functions aren't "simple transformations on some tree data structure". They are textual transformations. Hygienic macros (à la Racket) I agree are useful and easy to reason about.

I wouldn't use Javascript and Python as examples here--those languages, suffering from their lack of meta-programming, instead encourage heinous things like monkey-patching and runtime introspection, which are insanely difficult to reason about.

I agree that the mechanism underlying their meta-programming facilities is treacherous. What I mean (and didn't state clearly) is that over the decades, these languages have developed patterns for reining in the power of their facilities (decorators in Python, and a fairly standard pattern for emulating class-bassed OO in Javascript).

Re:Elixir, a functional metaprogramming-aware language built... by kaonashi on Saturday April 27, 2013 @03:20PM (#5618768)
> Except that C-style macro functions aren't "simple transformations on some tree data structure". They are textual transformations. Hygienic macros (à la Racket) I agree are useful and easy to reason about.

Elixir uses the latter; am I missing something?