Scala has the most advanced meta-programming facilities. And Scala's MP is widely used. If you are interested in research-prototype languages, https://convergepl.org/ is interesting. But Converge is no longer under active development.
Ask HN: What metaprogrammable language do you/would like to use?
11–20 of 76 posts
Re: Ask HN: What metaprogrammable language do you/would like to use?
#12Haskell 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/t…
Re: Ask HN: What metaprogrammable language do you/would like to use?
#13Ideal for Scientific computing. ( LLVM based; Optionally typed; Dynamic )
https://docs.julialang.org/en/v1/index.html
Julia Metaprogramming:
https://docs.julialang.org/en/v1/manual/metaprogramming/inde...
Julia: "Building a Language and Compiler for Machine Learning" ( compiling to GPU; TPU )
https://julialang.org/blog/2018/12/ml-language-compiler
"Why Does Julia Work So Well?"
https://ucidatascienceinitiative.github.io/IntroToJulia/Html... ( "Core Idea: Multiple Dispatch + Type Stability => Speed + Readability" )
Re: Ask HN: What metaprogrammable language do you/would like to use?
#14Haxe 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).
Usual suspect here is any kind of "support" code, like serialization, RPC, dependency injection and such.
Re: Ask HN: What metaprogrammable language do you/would like to use?
#15Scala has the most advanced meta-programming facilities. And Scala's MP is widely used. If you are interested in research-prototype languages, https://convergepl.org/ is interesting. But Converge is no longer under active development.
Which features make it the most advanced?
Re: Ask HN: What metaprogrammable language do you/would like to use?
#16This 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.
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};
}
}Re: Ask HN: What metaprogrammable language do you/would like to use?
#17This 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}; } }
Expressions generated by your macros will be parsed by the type checked. You won't be able to do
var s:Int = StringGetter.getString();
Because you'll get a compilation error there (http://try-haxe.mrcdk.com/#48EDb).Re: Ask HN: What metaprogrammable language do you/would like to use?
#18Re: Ask HN: What metaprogrammable language do you/would like to use?
#19This 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}; } }
That is a weird statement. Haxe expression macros by definition return untyped AST to be processed further normally by the typer, just like hand-written code. And it will be type-checked. And then there's an AST node existing exactly for type-checking (or, rather, type unification) that you can generate to insert custom checks: https://haxe.org/manual/expression-type-check.html
Re: Ask HN: What metaprogrammable language do you/would like to use?
#20If 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…
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.
That said, functional programming does indeed fit well with most of the stuff you do when writing code that writes code.