Live data from Hacker News

An update on Dart macros and data serialization

medium.com

101–110 of 125 posts

Re: An update on Dart macros and data serialization

#101
post #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…

I'm pretty sure in that era Xamarin was closed source and a commerical offering. It wasn't until 2016 when MS acquired them that it became free and open source. So using .NET and C# wasn't really possible in 2014 without either paying a third party or buying the Xamarin company.

I think folks forget how long ago we made Flutter.

Re: An update on Dart macros and data serialization

#102
post #70

Earlier quoted context omitted.

"No one does it" is extremely relative. Take your closing remark about JavaScript: I don't run into JS warts very often at all, and I'm a professional web developer who works in it day in and day out. I guess my team just doesn't do dumb JS stuff? But apparently lots of other people do run into them regularly, so I believe that such things do exist. By the same token, I've heard countless reports of people struggling…

ah you misunderstand me. I don't mean "do dumb stuff", I mean I've literally never seen anyone redefine the `define` keyword in any code. With javascript, I do see people use `===` frequently. It's a wart of the language that the operator even exist. It's not "dumb" to use it - it's how frequently are you assaulted with the bugs of the language (not bugs in your code).

That’s true but I think if a major issue is having to type === instead of == then you’re probably doing okay.

Re: An update on Dart macros and data serialization

#103
post #48

Earlier quoted context omitted.

C# was Microsoft's attempt to learn from Java's mistakes, which they very much succeeded at doing.

That's not even remotely historic accurate. Sun vs Microsoft drove MS into creating C#. Please don't fan boy to the point of lying.

> Please don't fan boy to the point of lying.

You made 5 replies negative about C# in this comment section alone.

As they say, haters are fans too :)

Re: An update on Dart macros and data serialization

#104

Earlier quoted context omitted.

That's not even remotely historic accurate. Sun vs Microsoft drove MS into creating C#. Please don't fan boy to the point of lying.

> Please don't fan boy to the point of lying. You made 5 replies negative about C# in this comment section alone. As they say, haters are fans too :)

Where do you see 5 negative comments? Please link them?

Also why are you talking like cliquey high-school girl regarding a programming language. Complete with the emoji no less.

It's a tool, not a religion.

Re: An update on Dart macros and data serialization

#105

Earlier quoted context omitted.

It's much much more complicated than that. Sun refused to add many language features that Microsoft (then a cautious but also genuine user of Java) wanted. Such as refusal to add delegates/closures: https://benhutchison.wordpress.com/2009/02/14/suns-rejection... https://stackoverflow.com/questions/1973579/why-doesnt-java-... J++, which was Microsoft's Java implementation in the 90's added a few language extensions th…

The key point is that C# was happening regardless of whatever technical upsides people wanted to see out of it. C# would still exist today and still be just as popular in the Windows ecosystem even if it made all the same exact mistakes as Java.

That doesn't change that C# was designed with that philosophy in mind. The two statements aren't mutually exclusive.

Re: An update on Dart macros and data serialization

#106
post #83

Good. Dart already has good support for code-generation. It would just encourage package authors and app developers to waste their time golfing.

It is incredibly slow though. I have a project with 40k lines of code which takes a minute to generate on an m1. It's a far cry from incremental compilation. It's enough that I generally avoid adding anything new that would require generation.

I agree, Dart's public-facing codegen system (build_runner) leaves a lot to be desired. (In part the problem is that Dart uses a separate system inside Google.)

However, this is a topic of active work for the Dart team: https://github.com/dart-lang/build/issues/3800. I'm sure they would welcome your feedback, particularly if you have examples you can share.

You're also always welcome to reach out to me if you have Flutter/Dart concerns. I founded the Flutter project (and briefly led the Dart team) and care a great deal about customer success with both. eric@shorebird.dev reaches me.

Re: An update on Dart macros and data serialization

#107
post #55

Sounds like a good thing overall, my biggest annoyance when I was writing a flutter app was the codegen for annotations (which sure it's better iteratively, but the first one was taking minutes), but if you move these seconds that happen once in a while to seconds during "hot" reload, you're just losing. Honestly, I think they should try to come with a faster codegen, maybe write it in c++ or rust and fix these probl…

> I think they should try to come with a faster codegen, maybe write it in c++ or rust and fix these problems Language execution speed isn't the fundamental blocker for code generation in Dart. Dart isn't quite as fast as C++ or Rust, but it's in roughly the same ballpark as other statically typed GC languages like C#, Java, and Go. The performance challenges in code generation are more architectural and are around c…

I belive there are many low hanging fruits to improve the speed. In my project the code generation took more than 3 minutes. This is rather annoying if you have just renamed a field in a single “freezed“ class. We could speed up this process by 3x by hacking together a script which greps all .dart files for the relevant annotations like “@freezed“ and then only feeds those to the build_runner via a on-the-fly-generated config file.

Re: An update on Dart macros and data serialization

#108

Earlier quoted context omitted.

C# is a fantastic language that has, in recent years, evolved very quickly for the better. Nice mix of object and functional drawing a lot of influence from F#. It shares a lot of language constructs with TypeScript (and by extension, JS) and has been converging with each release so I'm often surprised that people hate on it or that more startups don't reach for it if they are on Node with TS. Same syntax for key lan…

The improvements are great for people who have to or want to use C# for whatever reason? But how does that move the needle from other tech-stacks that are for more capable, especially on non-Windows environments (and please don't imply that C# is truly cross-platform, it's fine for web API's, it's not fine when dealing with actual system calls). If you're within the Windows garden, those tools certainly make sense to…

> and please don't imply that C# is truly cross-platform, it's fine for web API's, it's not fine when dealing with actual system calls

What exactly do you mean by this? How are syscalls worse in C# than other languages?

My understanding is other "cross-compiled" languages have cumbersome ergonomics with syscalls. They all use System or OS libraries that hide complexity and OS differences to varying degrees of success.

Re: An update on Dart macros and data serialization

#109
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

They exist but they're still missing a lot of things you'd want in a data class like copyWith, serialization etc.

In practice in a Dart app you usually use freezed or something similar: https://pub.dev/packages/freezed

Re: An update on Dart macros and data serialization

#110
post #83

Good. Dart already has good support for code-generation. It would just encourage package authors and app developers to waste their time golfing.

It is incredibly slow though. I have a project with 40k lines of code which takes a minute to generate on an m1. It's a far cry from incremental compilation. It's enough that I generally avoid adding anything new that would require generation.

It takes a minute to build from scratch or to update when running "build_runner watch"? My app is over 40k lines and watch updates almost instantaneously.
Post reply on HN