Live data from Hacker News

Ask HN: What metaprogrammable language do you/would like to use?

news.ycombinator.com

21–30 of 76 posts

Re: Ask HN: What metaprogrammable language do you/would like to use?

#21
I use Common Lisp for its really insane metaprogrammability (reader macros, compiler macros, ordinary macros, and the MOP to edit the object system) and the ability to bend to the problem that I am trying to solve. It has decent interoperability via its CFFI interface.

Re: Ask HN: What metaprogrammable language do you/would like to use?

#22
post #8
post #4

Earlier quoted context omitted.

But Racket doesn't have macros a la Common Lisp, which are the most powerful way to achieve metaprogramming in the Lisp family.

Nonsense. Racket has hygienic macros just like CL.

CL doesn't have hygienic macros.

Re: Ask HN: What metaprogrammable language do you/would like to use?

#23
post #16
post #7

This list is missing Haxe, which is strictly-typed (with type inferencing), supports object-oriented, generic, and functional programming and is highly extensible thanks to meta-programming (macros). Interoperability is where it excels, since it compiles to to multiple language targets/platforms, including VM bytecode.

Note: Haxe does not typecheck macros. See https://haxe.org/manual/macro-ExprOf.html For example, this seemingly ill-typed definition (which should return Int as suggested by the type paramater, but in fact returns a string) successfully typechecks: class StringGetter { public static macro function getString():haxe.macro.Expr.ExprOf { var s:String = ""; return macro $v{s}; } }

Incorrect. To quote the page you've linked: "For the most part, this type is identical to Expr, but it allows constraining the type of accepted expressions." or otherwise put: ExprOf only affects macro arguments, not return value. What you want is this:

  class StringGetter {
    public static macro function getString() {
      var s:String = "";
      return macro ($v{s} : Int);
    }
  }

Re: Ask HN: What metaprogrammable language do you/would like to use?

#24

Earlier quoted context omitted.

Which features make it the most advanced?

Compile-time MP and run-time MP. Support for AST and quasi-quote MP, and support for LMS (= lightweight modular staging).

You haven't seen any Lisp yet, have you?

Compile and run-time MP and quasiquoting are basic features; I'd argue that a language without these doesn't even qualify as "supporting metaprogramming".

Re: Ask HN: What metaprogrammable language do you/would like to use?

#25

Earlier quoted context omitted.

Which features make it the most advanced?

Compile-time MP and run-time MP. Support for AST and quasi-quote MP, and support for LMS (= lightweight modular staging).

Cool, I wasn't aware of Scala's LMS. Thanks for sharing!

Re: Ask HN: What metaprogrammable language do you/would like to use?

#26
post #5

If you're interested in functional programming and meta-programming as paradigms, then you should really focus on functional first. The reason is that functional is all about transformation of data structures as a whole (as opposed to altering them bit by bit as in procedural programming) and meta-programming is about treating programs as data and transforming them. You really can only do advanced meta-programming us…

> You really can only do advanced meta-programming using functional techniques. My `loop for (symbol value) on bindings by #'cddr` and "push onto list in a loop, nreverse and return at the end" macros beg to disagree. Metaprogramming is just like any other programming, except that the output is fed to the compiler. The way Lisp is compiled, you can even use code generated by code in code that generates other code. Th…

[deleted]

Re: Ask HN: What metaprogrammable language do you/would like to use?

#27
Considering only production code here.

Do use: Common Lisp, Racket, Python, Ruby

Would like to use: Julia, Rust, Elixir

I metaprogram when I see I have already built a mini-language/pattern in my code. Even when writing Lisp, I begin with simple code without extending the language, and only when I have written a bit do I consider looking for patterns.

Re: Ask HN: What metaprogrammable language do you/would like to use?

#28
Definitely take a look at Forth: each word in the language can have separate compile-time and run-time behavior, and the compiler is simple enough that it's easy to extend it with your own compile-time words. https://www.forth.com/starting-forth/11-forth-compiler-defin... is a good overview.

Re: Ask HN: What metaprogrammable language do you/would like to use?

#29
I would recommend that you definitely look into Scala. The language that was fundamentally designed to be "scalable" with and/for frameworks. Check this resource for more information.

- https://scalameta.org/

- https://speakerdeck.com/itakeshi/metaprogramming-in-scala-th...

- https://geirsson.com/post/2016/02/scalameta/

- https://github.com/milessabin/shapeless

- https://vimeo.com/217863345

Post reply on HN