-
Notifications
You must be signed in to change notification settings - Fork 205
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Review increasing number of code generation use cases to understand potential missing capabilities of the language #1458
Comments
Yes! We are looking into static metaprogramming features this year. No promises or detailed designs yet, but it's a priority.
We have collected quite a few use cases already but we're always happy to have more, yes. |
This is great news! I’m sure people will love this. Not knowing which use cases you have makes a bit difficult to suggest. But one that comes to mind is adding fromMap toMap methods in class models for serialization. How to solve for that. I’ll try to add more. |
Here's a few, although it's been included in many discussions already (namely #1482):
|
Some reference packages for the above:
Going through pub.dev, there's a couple other code processing categories that look popular:
The other popular packages are usually processing some external asset, like language jsons or svg files. |
@munificent |
I don't know about the plans for implementing records but I proposed an implementation/syntax for metaprogramming at #1565 and while it would be a pretty big change to restrict it to just one specific use-case, I don't think it would be such a major change in general. It's based on writing Strings into Dart files with code. I included an example of dataclasses in there, feel free to check it out. |
I'm specifically talking about data class without static metaprogramming as the scope of metaprogramming is bigger and the more example I see of it, the less I see advantages over a tool that would do such things like a built_values package (which I don't use, because I don't like writing code like that). |
The advantage is that there are currently a lot of proposals for small features like records, |
That would be already possible with a build runner it doesn't happen at compile time and you have to type extras but its possible. In all honesty, the more example I see, the more I understand a comment I originally downvoted that said that this would make code less readable. |
It's a possibility, but my hope is that we can design a sufficiently expressive static metaprogramming system that "data classes" could be implemented at the library level using it. Kotlin-style data classes are basically taking a somewhat arbitrary set of policies (immutability, copying, value equality, etc.) and baking them into the language. The problem is that policy preferences change more rapidly than languages. A few years from now when users decide that instead of immutable value types they want persistent data structures, we can end up with essentially deadweight language features like XML literals in Scala. |
Is that a certainty though ? javascript serialization is easy to use and no one bothered changing that. Furthermore having to maintain toString, copyWith and serialization is already out of date. I agree that meta programing would solve the issue but I hope the team is going to be careful onto what problems it needs to solve and what the language itself needs to solve. I feel like it can get ugly fast. You know better than me, but it makes me a bit uneasy. I just want to counter weight the hype |
I mean, we definitely have users using protobufs, Flatpack, and plenty of other serialization formats too. |
Questions
Deliverable
A list of use cases of code generation and how other languages tackle the problem.
The text was updated successfully, but these errors were encountered: