Live data from Hacker News

Dart/Flutter now has macros/metaprogramming

github.com

31–40 of 129 posts

Re: Dart/Flutter now has macros/metaprogramming

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

Re: Dart/Flutter now has macros/metaprogramming

#33

Earlier quoted context omitted.

I'm not really sure where it slots in in a world with a lot of programming language choices. Why would I use it over something like Rust, Go, or even JavaScript?

>Why would I use it over something like Rust, Go, or even JavaScript? Honestly, mainly for flutter. But if you do chose flutter for your project, you will suddenly wish everyone was using dart for everything else instead of Java on android, or c#/Swift on ios ect. if that makes sense. If sound type checking is truly feasible on the web then I'd say dart should be there too. But I can't say if that's really the case.…

I think Dart really suffered from missteps in the early days. Originally, Dart didn't seem like anything special and it kinda wasn't. It was a dynamic language where optional type hints were suggestions and it'd be run in a VM just like JS and seemed like JS with some slight differences.

It feels like Dart became a completely different language that just happens to have the same name. It's now statically typed, has AOT compilation, null safety, etc.

I think that left Dart in a weird place in terms of mindshare. A lot of people likely looked at Dart 1, didn't see a real place for it, and haven't gone back to it. Google was also highly ambivalent about Dart for a while and most of the mindshare went to Go (despite the fact that I suspect most would prefer Dart).

In the end, it feels like Dart is lacking the ecosystem that other languages have. There's so much written for JS or Python or C# by comparison and so much of Dart seems to be in order to support Flutter.

Rust somewhat occupies its own place in the universe: people who want something a lot stricter than ordinary static languages where there's still a GC and still some runtime stuff. However, I think if Dart got more momentum it could be seen as a nice alternative to Java, JS/TS, C#, Python, etc. Note: I'm not saying that Dart has no momentum, but as you note it's mainly for Flutter.

Re: Dart/Flutter now has macros/metaprogramming

#34

Earlier quoted context omitted.

I'm not really sure where it slots in in a world with a lot of programming language choices. Why would I use it over something like Rust, Go, or even JavaScript?

>Why would I use it over something like Rust, Go, or even JavaScript? Honestly, mainly for flutter. But if you do chose flutter for your project, you will suddenly wish everyone was using dart for everything else instead of Java on android, or c#/Swift on ios ect. if that makes sense. If sound type checking is truly feasible on the web then I'd say dart should be there too. But I can't say if that's really the case.…

As someone who has written plenty of Java and JavaScript, Dart feels way more enjoyable to write. It just does. Maybe it's because I was less experienced when starting with Java and JavaScript, but it felt like there was a much smaller learning curve with Dart, too. I imagine it helps that I'm writing it in Android Studio, a JetBrains product, but I find the ergonomics better than even Kotlin. If you want to use it outside Flutter, you probably will wish it had a larger ecosystem, depending on what you're trying to write.

Re: Dart/Flutter now has macros/metaprogramming

#35

I hope Dart gets more support, I really want alternatives to TypeScript for developing webapps which aren't super "bulky" (slow startup, buggy and hard to debug) and support mobile apps. Dart seems to be the best at both although I haven't used it much. It also seems reasonable (one of the reasons I don't like TypeScript is because it still has some quirks from JavaScript like `===`, also because the types are occasi…

> webapps which aren't super "bulky" (slow startup, buggy and hard to debug)

All good things.

Hot take to think Dart is superior in that respect.

Re: Dart/Flutter now has macros/metaprogramming

#36

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.

That's a Google-ism for sure.

(Go, Dart/Flutter, Angular, Bazel)

Re: Dart/Flutter now has macros/metaprogramming

#37
post #30

Earlier quoted context omitted.

>Why would I use it over something like Rust, Go, or even JavaScript? Honestly, mainly for flutter. But if you do chose flutter for your project, you will suddenly wish everyone was using dart for everything else instead of Java on android, or c#/Swift on ios ect. if that makes sense. If sound type checking is truly feasible on the web then I'd say dart should be there too. But I can't say if that's really the case.…

> Java on android You mean Kotlin? Nah. Dart is ok. It doesn't perform as well as those peer languages. It's nice its FFI story is good, but the ecosystem is very weak even compared to Javascript. As for the tooling. It's decent. I wouldn't call it amazing, unless you come from systems that were anemic to begin with, then it seems pretty amazing. As for flutter. I recently installed it again. A test app with a single…

> consumes 45% of an Intel core on a linux desktop

Like for 1ms? For a second? Eternally?

Re: Dart/Flutter now has macros/metaprogramming

#38
post #30

Earlier quoted context omitted.

> Java on android You mean Kotlin? Nah. Dart is ok. It doesn't perform as well as those peer languages. It's nice its FFI story is good, but the ecosystem is very weak even compared to Javascript. As for the tooling. It's decent. I wouldn't call it amazing, unless you come from systems that were anemic to begin with, then it seems pretty amazing. As for flutter. I recently installed it again. A test app with a single…

> consumes 45% of an Intel core on a linux desktop Like for 1ms? For a second? Eternally?

Eternally, as long as that text field has focus with the animation of a blinking cursor. I'm not telling my customers to make sure they're not "holding it wrong" by deigning to leave the app in the foreground and killing their battery.

Re: Dart/Flutter now has macros/metaprogramming

#39

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.

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

Re: Dart/Flutter now has macros/metaprogramming

#40
post #39

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.

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…

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.
Post reply on HN