-
What are the plans for Val and metaprogramming?In my time programming, I have ended doing a fair amount of metaprogramming (mainly using reflection and code generation in languages like Java and C#), as it is sometimes the only elegant solution to a problem, avoiding issues such as code duplication, multiple sources of truth*, or runtime introspection (potentially abysmal for performance). A powerful metaprogramming solution which is easy for developers to utilize can go a long way in letting a language outgrow its original scope (something like sqlx is a great example). On the flip side metaprogramming can lead to opaque code bases, or simply ones which are very hard to understand, or straight up new language dialects when metaprogramming goes as far as it can in lisp. I understand this may be a feature which is going to come much farther down the line, but early consideration could save effort and time, or lead to more powerful ergonomic metaprogramming system, and I was just wondering where the thought process is at now. * By multiple sources of truth I mean a situation like following: you have a data structure representing something which must be serialized. Without any metaprogramming you must define the serialization and deserialization routines separately from the data structure itself, and this leads to many programming mistakes and high effort for refactorization. This is solved by something such as serde. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 9 replies
-
You're right that it's a bit early; we have a lot of fundamentals to put in place first. We're not at all opposed to metaprogramming—I wrote a whole book about it—but we're not very happy with most of the language designs we've seen for supporting it, and we don't want to rush into adding specific metaprogramming features until we're sure we have the right design. About all we've decided is that we want to be able to run any ordinary Hylo code at compile time if the context demands it, without ceremony. But that only scratches the surface of a more complete metaprogramming picture. HTH. |
Beta Was this translation helpful? Give feedback.
-
Have you thought about adopting dependent types? They are not only very conductive to meta-programming, but also enable further safety checks |
Beta Was this translation helpful? Give feedback.
You're right that it's a bit early; we have a lot of fundamentals to put in place first. We're not at all opposed to metaprogramming—I wrote a whole book about it—but we're not very happy with most of the language designs we've seen for supporting it, and we don't want to rush into adding specific metaprogramming features until we're sure we have the right design. About all we've decided is that we want to be able to run any ordinary Hylo code at compile time if the context demands it, without ceremony. But that only scratches the surface of a more complete metaprogramming picture. HTH.