Live data from Hacker News

An update on Dart macros and data serialization

medium.com

31–40 of 125 posts

Re: An update on Dart macros and data serialization

#31
I think after reading through the blog post the reasons they have made a whole lot of sense and sounded like that of a mature engineering team to me.

There are a bunch of other interesting approaches here they can look at. Improving the code generation story more generally, shopping the augmentations feature (basically C#’s partial classes) and getting more serious about serialization all feel like sensible directions from here.

There is a really interesting community proposal at the moment on the serialization front that I think would solve a lot of the issues that got people so excited about macros in the first place here: https://github.com/schultek/codable/blob/main/docs/rfc.md

Re: An update on Dart macros and data serialization

#32
post #22

Earlier quoted context omitted.

And Microsoft should have just used Java.

And Java should have just been C++ with a really nice garbage collector

And C++ should have just been Objective-C with saner invocation syntax.

Re: An update on Dart macros and data serialization

#33
post #29
post #22

Earlier quoted context omitted.

And Microsoft should have just used Java.

Genuine question, is this comparison really apples to apples? Microsoft wanted to compete with sun right? Does google want to compete with programming languages like this? My gut tells me this is NIH not wanting to compete.

It is apples to apples.

Microsoft didn't want to compete with Sun so much as have an application development language with a garbage collector that wasn't owned by Sun.

You don't make much money off programming languages inherently.

This also elides an obvious riposte (so you mean they should have just used Mono? how did all that work out?) and a metric ton of differences between what C# targets and what Dart targets.

Re: An update on Dart macros and data serialization

#35

They should have just use C# for Flutter. Without investing significant time, like they did with Dart, they would have a language with a much bigger ecosystem that is faster, already has compile time code generation and better support for data than Dart. It supports ahead-of-time compilation and hot-reload. The only feature missing in C# is compilation to JS, but with WASM is that really needed? Biggest downside of C…

[Flutter founder here.]

I'm pretty sure we did look at C# (and certainly a whole bunch of other languages). I don't actually recall why we didn't use C# at the time. I remember Go binaries were waaay to big, JS (what we originally wrote Flutter in) startup time was way too slow on iOS, Swift was too deeply tied to Apple (the standard library was closed source at that time), etc. It's possible that C# was too verbose or didn't have a path to hot reload? But that's just a guess. I'm not a C# expert, and Adam Barth drove most of the language evals at the time.

That said, I'm also not sure Miguel (creator of Xamarin) would agree. He's a Flutter fan now (and backer of Shorebird, my company).

Past discussions: https://x.com/migueldeicaza/status/1778759403451081159 https://x.com/migueldeicaza/status/1559898665350832128

Re: An update on Dart macros and data serialization

#36
post #24
post #4

This is good news. The dart language has been getting more complicated without corresponding quality of life improvements. A first class record object without messing around with macros would be a great start.

Why is it that many languages, at the start, don't have support for records/plain structs?

Because it's arguably syntactic sugar and, IMHO, it's worked out better for developers for Dart to model it as a 3rd party library problem. i.e. have a JSONSerializable protocol, and enable easy code generation by libraries.

i.e. I annotate my models with @freezed, which also affords you config of the N different things people differ on with json (are fields snake case? camel case? pascal case?) and if a new N+1 became critical, I could hack it in myself in 2-4 hours.

I'm interested to see how this'd integrate with the language while affording the same functionality. Or maybe that's the point: it won't, but you can always continue using the 3rd party libraries. But now it's built into the language, so it is easier to get from 0 to 1.

Re: An update on Dart macros and data serialization

#37

They should have just use C# for Flutter. Without investing significant time, like they did with Dart, they would have a language with a much bigger ecosystem that is faster, already has compile time code generation and better support for data than Dart. It supports ahead-of-time compilation and hot-reload. The only feature missing in C# is compilation to JS, but with WASM is that really needed? Biggest downside of C…

I think Go would have been the most logical choice, given that it's Google.

Re: An update on Dart macros and data serialization

#38
post #4

This is good news. The dart language has been getting more complicated without corresponding quality of life improvements. A first class record object without messing around with macros would be a great start.

I might be missing something here, don't records already exist? https://dart.dev/language/records

Re: An update on Dart macros and data serialization

#39
post #9

Why is it that Lisp family macros are easy to implement and use, but not so in other languages?

in Scheme you can redefine `define` to be number 5. Easy to implement, but a nightmare in real world scenarios [0]. That's why languages like Go became popular, they're trashy, boring, and dumb, but that's exactly what's needed in big projects. [0]: imagine your colleague wrote a macro that redefines for loops because at the time, it made life easier for him.

You might have been misled by a CS professor's enthusiasm about what they thought was neat, or was a good way to communicate something.

But I don't recall seeing someone re-define `define` in real life.

Nor do I recall seeing any problematic redefinitions in Scheme in real life.

That said, if you wanted to make a language variant in which `define` did something different than normal (say, for instrumentation, or for different semantics for variable syntax), then you'd probably use Racket, and you'd probably define your own `#lang`, so that the first line of files using your language would be something like `#lang myfunkylang`.

You can randomly sample code in https://pkgs.racket-lang.org/>, and look for people doing anything other than `#lang racket/base` or `#lang typed/racket/base`.

Re: An update on Dart macros and data serialization

#40

They should have just use C# for Flutter. Without investing significant time, like they did with Dart, they would have a language with a much bigger ecosystem that is faster, already has compile time code generation and better support for data than Dart. It supports ahead-of-time compilation and hot-reload. The only feature missing in C# is compilation to JS, but with WASM is that really needed? Biggest downside of C…

Dart's awesome. I'm sure C# is too. I've been unlucky enough to have many years in on both iOS and Android, and Dart is a fantastic language, far better than both incumbents. I worry about judging it as a whole, based solely on their ability to launch pre-compile time code generation that is faster than their current approach. Macros seemed really cool + really difficult to improve past the current codegen. I have a…

Yeah. Dart's over-rotation on generated code is a googlism. They have a fancy build setup internally which is very good at generated code and caching it.

I know that the build_runner authors are looking into perf as we speak, and I'd be happy to put you in touch with them if you'd like to speak with them about debugging your case: https://github.com/dart-lang/build/issues/3800

eric@shorebird.dev reaches me (for this or any other Flutter/Shorebird issue).

Post reply on HN