Live data from Hacker News

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

news.ycombinator.com

1–10 of 76 posts

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

#1
Like many folks here, I probably spend too much time reading about, trying and contemplate using many new languages. The (overlapping) paradigms that interest me are metaprogramming, functional, and (newer) statically-typed. I decided to focus only on metaprogrammable ones from now on (as a time saver and to step up).

I made a list and ordered them by how much I would be interested in using them (which combines my curiosity with current/expected adoption).

My short-list for metaprogrammable ones are:

  Clojure
  Elixir
  Nim
  Crystal
  Rust (would be higher if I did more low-level work)
  Pony
I left most other functional ones off my list because that's an exploration in itself for another time. I was surprised that I put Clojure and Elixir first given my preference for static types. Of all the kitchen-sink features that Nim has, I can't accept camelCased == under_scored names otherwise it could have been first. Ruby is notably absent as I use it and am looking for something better/different.

For future adoption, I think interoperability is a key factor, whether it's with C or in a VM runtime (e.g. JVM, CLR, BEAM, v8).

Which metaprogrammable language do you use or are most interested in using? How compact are your programs (i.e. how extensive do you metaprogram)?

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

#2
If you are asking about learning metaprogramming as a paradigm I would rather suggest Racket. Lisps are famous for their metaprogramming capabilities and you have Clojure at the top of your list but writing macros are way easier in Racket than in Clojure. This is primarily because Racket IDE provides good debugging and tracing tools. Clojure is notorious for its cryptic error messages. This certainly doesn't help while you try to do code transformations. Once you learn the fundamentals you can apply them in (somewhat) more mainstream functional programming languages like Clojure or Rust.

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

#4
post #2

If you are asking about learning metaprogramming as a paradigm I would rather suggest Racket. Lisps are famous for their metaprogramming capabilities and you have Clojure at the top of your list but writing macros are way easier in Racket than in Clojure. This is primarily because Racket IDE provides good debugging and tracing tools. Clojure is notorious for its cryptic error messages. This certainly doesn't help whi…

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

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

#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 using functional techniques. It's no accident that Lisp is the granddaddy of both paradigms.

As for which language to use to explore these paradigms, the answer would have to be a modern Lisp, i.e. Clojure or Racket. Of those two Clojure is more about being a "pure functional" language and Racket more about meta-programming... in fact Racket has been called a "meta-language".

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

#6
Haskell with TemplateHaskell is definitely worth giving a shot.

You can find good examples of its use by searching for reverse dependencies of template-haskell package[0].

One of these is my tiny experiment that features program synthesis by given type[1]. Recently I added an ability to handle sum types and product types (a.k.a. Either and tuples) -- see 'rewrite' branch.

[0] https://packdeps.haskellers.com/reverse/template-haskell

[1] https://github.com/8084/haskell-holes-th

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

#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.

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

#8
post #4
post #2

If you are asking about learning metaprogramming as a paradigm I would rather suggest Racket. Lisps are famous for their metaprogramming capabilities and you have Clojure at the top of your list but writing macros are way easier in Racket than in Clojure. This is primarily because Racket IDE provides good debugging and tracing tools. Clojure is notorious for its cryptic error messages. This certainly doesn't help whi…

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.

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

#9
Interoperability + meta-programming? You have to go with the king, Common Lisp! There's a bunch of implementations for different platforms [0]. It's also much simpler to write macros in a homoiconic language like a lisp, than using something like Rust's elaborate macro system.

Although your phrasing ('expected/future adoption') makes it sound like you value picking a language that will have loads of jobs available. Clojure has a few solid niches (same number of users as Kotlin IIRC) and is 'symbiotic' with JVM and JS environments. Rust is growing and has supposedly 'safe' BEAM NIF support. Elixir is popular with the Ruby crowd. Although I have to say, 'meta-programming' & 'functional programming' isn't exactly the hottest job market filter.

[0] https://common-lisp.net/implementations

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

#10
Haxe has pretty good metaprogramming capabilities. It has expression macros (compile-time evaluated calls that return expressions to be inserted at call place) as well as type-building macros (build fields and/or define whole new types). Both have access to compiler and system API and information about the context (e.g. expected type).
Post reply on HN