Hacker News new | ask | show | jobs
by cageface 878 days ago
After years of working in Typescript I've been doing a Dart project for the last 6 months or so. Overall it's a great language but one of the clunky aspects is the use of code generation for so many things. If this can reduce or even eliminate that it will be a big step forward for devX.
3 comments

I'm curious what aspect of the code generation you find clunky. When I used Dart, my issue with the code generation was that it didn't "just happen". With C#, anything that's being generated just happens without any involvement from me and it happens basically instantly. With Dart, I was left running their build_runner manually. Plus common things like json_serializable then require you to add methods to wire up the generated methods (partly because you can't have a factory constructors outside of the class definition, but I don't know why they don't just wire up toJson() as an extension method).

I guess I'm trying to figure out if you just dislike having generated files (where you can see the code) or if you dislike how Dart does it (where it's a bit of a clunky process).

It works well enough. It's a bit of a hassle to set up and you have to always run the file watcher and add the `part "blah.g.dart"` imports. I wouldn't say it's held me back but I'd be happier if the language itself was flexible enough to eliminate the need for this. I'd also be defining my own macros if it was easier to do.
That's a Google-ism for sure.

(Go, Dart/Flutter, Angular, Bazel)

What kind of idiomatic code generation is there in Go?
`go generate` is built right into the language:

https://go.dev/blog/generate

It's quite common to generate code that way.

I mean, they weren't exactly shy about it: https://go.dev/blog/generate
> one of the clunky aspects is the use of code generation

Yeah, I’ve been trying to stay away from it but it feels inevitable!

I do not want to deal with code generation.

It's not a big deal in practice but it would be nice if it wasn't necessary.