Hacker News new | ask | show | jobs
by zigzag312 506 days ago
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# is probably that it's not invented at Google.

5 comments

[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

.NET is huge compared to Dart and every hot reload I've seen was complete garbage compared to what you get in Flutter.

Anyone who worked with the mobile .NET and Flutter would see Dart/Flutter DX as something unreachable for .NET, it's a terrible experience like any other .NET cross compilation I've tried (Blazor, Silverlight).

I'm not a big fan of Dart as a language but it really was a great choice that allowed amazing DX, Flutter hot reload feelt better than JS/HTML.

Assuming you were looking at the language 2016ish I could see why you'd rule out C#.

That was the same year that MS first released C# core. For cross platform support mono was really the only way to go and it was second class.

MS was just starting to get out of the mindset of putting the universe into the .Net framework and instead offering first class support for a broader 3rd party ecosystem.

How Microsoft operates today with open source software really started roughly around 2016. I could see why you'd be hesitant to trust them then.

It was 2014, so even earlier than that.
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.

I am curious as well.

Despite the "not invented at Google" swipe

* TypeScript wasn't invented at Google either, but adopted heavily.

* Angular was the first major project ever to use TS.

* And interestingly enough, Anders Hejlsberg contributed heavily to both.

Typescript is great! But doesn't get you away from running in a JS interpreter or JIT, which at least on iOS is very slow. We wrote the first 3 versions of Flutter in JS but eventually had to move off due to 10s+ startup times (we wrote a ton of JS). Once we moved to an ahead-of-time compiled language we could write as much code as we wanted and the user didn't have to compile it during launch on their device. Typescript would have that problem still today, sadly.

https://www.youtube.com/watch?v=xqGAC5QCYuQ is a talk where we discuss what led to modern Flutter (including 3 attempts in JS).

Angular was originally in Dart is my understanding, but eventually forked into two projects. Angular Dart (which is really only still used internally at Google, mostly for Google AdWords which makes all the money) and Angular JS which is what has seen so much popularity more generally.

These days Hermes is the answer to the JS and iOS startup issues. Of course it's a decade too late for flutter. :P

https://github.com/facebook/hermes

https://x.com/tmikov/status/1869945330638442651

Btw that Angular history is backwards. The first versions of angular were written in JS back in ~2009. jQuery was the most popular way to build web apps, and Angular provided a (very fancy) declarative data binding framework over it. Everything ran in your browser by inspecting DOM attributes.

Later in ~2014 they built a new framework on similar principles in TypeScript, but with an AOT compiler and called it "Angular 2". Then they retconed the original framework "AngularJS" and made the 2+ framework be just "Angular". In that era some Ads folks forked the Angular 2 framework and rewrote it in Dart and the two frameworks evolved separately since.

So there's really 3 separate "angular" frameworks...

Sorry, I was unclear. I didn't mean to necessarily suggest TS as a candidate for Dart's goals. (Though there is STS...)

I meant to point out that you can't just assume a priori it was NIH syndrome, as Google's heavy adoption of TS is a counterexample.

Makes sense. Google is a very large and diverse place. (And sometimes a lot of unpleasant infighting and politicking around tech choices.)
There are lots of good examples of adoption despite non invention.

Ironically, Typescript is not the best one. I can go into great detail - i was overseeing production programming languages at Google at the time, but getting to Typescript (which was the right choice) took a lot.

For most things, even things that seem to be contentious in the broader developer world, internal developer infrastructure teams were often relatively agnostic on choice as long as we had the resources to do it right (IE deal with migrations, etc). You'd have to push people to be meaningfully objective in evaluations, but once they realized you were not going to let them get away with nonsense, you got reasonable evaluations and options. Not always (can't avoid zealots at this scale), but a lot of the time.

But Typescript vs Dart vs Closure (GWT and a few other things were in there somewhere, too) was just particularly contentious for $reasons.

I guess that at the time you started developing Flutter C#'s hot reload, source generators and NativeAOT compilation didn't yet exist or were just introduced and incomplete.
We started Flutter in 2014 and made the decision to switch to Dart in ~Jan 2015 iirc.
So before .NET Core 1.0. In 2015 C# still mainly targeted only MS platforms (ignoring Mono) and didn't have mentioned features yet.

I know that Dart started as an alternative to JS, but it seems like JS target is now (unnecessarily) limiting Dart language in a way. I would be nice to be able to use lists of structs or a proper uint64 when needed. As a language it needs to expand in both directions to compete: high level productivity features and low level performance features. It has potential, but it's not there yet.

If Dart would find more use cases besides Flutter, it would make more sense to invest in its ecosystem.

I think you're not wrong about JS target being unnecessarily limiting. The problem is that a 250B/year business is written on top of Dart's JS transpiler (Google Ads) so it seems unlikely to be removed from the language anytime soon (maybe Dart2Wasm could allow that?).

It's pretty neat that Dart's JS support means you can take your code (e.g Flutter app) to the web, but I think that whole aspect of the ecosystem is underexplored/underdeveloped as of yet.

I don't think C# would've been a good fit for flutter in its early days, but definitely Flutter should no longer be tied to a single language like Dart. I think you should definitely consider stronger cross-language support.
I'm not sure what that would look like. Flutter mostly written in Dart itself (the framework, tooling, etc). The Flutter Engine (C++) is probably less than 1/3rd of Flutter, but could certainly be made portable to other languages if that were useful, but I suspect said languages would just fork it or write their own.
I'm not going to log in to Xitter to read the rest of his tweets, but it doesn't seem like Miguel regrets using C# or is particularly in love with Dart.

He's very complimentary of the goals and governance of Flutter, which is certainly more important than a language choice between two respectable languages.

I do think C# is by far the best mainstream language, but good IDE support and library ecosystem are the dealmakers/breakers for me when choosing a stack for a project.

    > I do think C# is by far the best mainstream language
C# is a hugely underrated language that I feel like often gets overlooked when teams look to move beyond JS/TS. The language has a pretty tight syntactic congruency to JS/TS[0], Entity Framework is pretty amazing in terms of DX/perf/maturity, and it seems like we should see more C#/.NET it in the wild than we actually do.

My sense is that there are some legitimate reasons to pick something like Kotlin (JVM ecosystem), but a lot of folks that might have worked with C# in passing in the .NET Framework days simply haven't given the ecosystem another look. It's productive, stable, performant, and secure.

VS Code support is really good and Rider has a community license available.

[0] https://github.com/CharlieDigital/js-ts-csharp

JVM probably has a better ecosystem, so Kotlin wins in that regard. I would also say there's a huge and painful difference between C# and TypeScript, which is that C# has nominal typing (no equivalency between types unless they're literally the same) and TS has structural/duck typing (if the members of two objects are the same, they're equivalent).

That makes sense because C# can be much lower level and has its own set of priorities during compilation, so I'm not really complaining. But ergonomically, you really miss the TS type system when you don't have it.

We're not there yet, but if you squint, named tuples kinda interesting because it's also shape-based: https://www.reddit.com/r/csharp/comments/164w8l1/how_do_yall...
I think C# is just too associated to .Net like how Ruby is tied to Rails. Plus it's a Microsoft managed language, and if you're looking to move out of JS / TS, then you probably don't trust Microsoft's management of languages...
I mean, .NET is what makes C# so good. You also get to use F#, you get to target all these platforms and a very flexible deployment/compilation model for your applications - something that e.g. neither Go nor Java offer to the same extent.

There is also a greater selection of IDEs and LS's.

>They should have just use C# for Flutter.

Dear lord no. We don't need more C# in the world.

>It supports ahead-of-time compilation and hot-reload.

In name only. Doesn't really well in practice. Go and just look for "C# hot reload not working" in any search engine and look at the variety of contexts it just simply does not work with no resolution.

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 language constructs like async-await, try-catch-finally, generics, etc.

Hot reload works pretty well (at least in the contexts that I use .NET (backend APIs)); a lot of the issues were from the early days. `dotnet watch` has been very much usable for the last few years.

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 use. But if you're not, there just simply isn't a reason to burden your app/platform with them.

To be clear, there's nothing wrong with C#, but the advocacy for it tends to be quite loud and passionate without much technical clarity in what it brings to the table that's lacking in other ecosystems. And again, you might be in for a world of hurt depending on how complex your needs are.

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

What do you mean that it's not truly cross-platform?

https://developers.redhat.com/blog/2016/09/14/pinvoke-in-net...

https://developers.redhat.com/blog/2019/03/25/using-net-pinv...

> without much technical clarity in what it brings to the table that's lacking in other ecosystems

What other GC language offers such levels of both high level expressiveness and low level control and also has a big ecosystem?

I'm not advocating it for every use case, I'm advocating it for use cases where it's a good fit (e.g. web APIs, backends where there's a need for multi-threaded code). For teams that need to move up from Node/JS/TS or augment Node/JS/TS, it's likely a better choice than say Rust or Go (nothing wrong with Go, but C# is going to be an easier ramp than Go for JS/TS devs IMO)

I would not, for example, advocate it for web UIs or any UIs except for Windows desktop UIs (and even there, I might advocate for JS based options).

>I'm advocating it for use cases where it's a good fit

>I would not, for example, advocate it for web UIs or any UIs except for Windows desktop UIs

Well, the GP was talking about using C# for Flutter, a cross-platform product from desktop to web lol.

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 35K LOC "main" code base that generates 670K lines of code under the current approach. It takes 52 seconds for a cold generation of all 670K. Seconds for warm. shrugs (sounds great to me)

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

And Microsoft should have just used Java.
They did. They called in J++ and gave it extensions, leading to a schooyard scuffle with Sun. When the school principal said Sun were right, they went off sulking and made Dot Net.
Microsoft had an underlying operating system that they wanted to rewrite substantially in C# on the .NET VM. They had a decent motivation for not having a core piece of Windows dependent on a product from another vendor that was competing in some of the same markets as their core product.

Google by contrast isn't nearly as invested in Dart as Microsoft was (and still is) in C#/.NET. Perhaps a better objection is that they should have just used Go — or a Go-binary-compatible language built on some of the same toolchain. (See also: Vala and Guile still don't play nice together as well as they should for two languages from the same project.)

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.

MS wanted to fracture the Java ecosystem. The Microsoft Java VM was an attempt to lockin developers to MS Java and not sun Java. They created J# and C# because of the sun lawsuit they lost.

They still wanted a Java like ecosystem but they would be sure it only ran on Windows servers.

MS spent years being hostile to open source software. It's only in about the past decade that they've turned a corner.

Here's a famous email from Bill Gates about Java and how to stop it.

https://web.archive.org/web/20220630223035/https://www.teche...

Unrelated to the discussion, but wow, the Nathan Myhrvold email seems prescient on so many levels.
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.

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 that were clearly not Sun-approved, but driven by internal engineering feedback at MS. C# having struct and class keywords, allowing you to define your own value types, is clearly a result of that missing in Java, which still in 2025 has no such equivalent yet.

Also Java's then native code interop solution, JNI, was and still remains complete garbage, and it's flaws were a huge guide for Microsoft when they deveoped .NET and it's native interop equivalent, PI (platform invoke).

Thankfully, Java now have FFM [foreign function and memory APIs](https://docs.oracle.com/en/java/javase/21/core/foreign-funct...) APIs (and also JNA which is community driven), which are much better than JNI.

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

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.
And Objective-C should have just been Smalltalk without the C baggage

(is this the root NIH syndrome?! I'm guessing no, I'm only 36. maybe LISP enters the picture here?)

I think Go would have been the most logical choice, given that it's Google.
We considered Go! At the time it was much more designed for servers than mobile devices. If I recall correctly the minimum binary size was like 30mb or something.
I think you are missing the fact that Dart is actually an incredibly nice language to work with in a way that Go absolutely is not.
The problem is that it’s yet another language. It’s the cognitive load and the inability to easily reuse code across a project.
That seems more like an argument against Go. Dart is the language more familiar to the average dev, and you're gonna have an easier time translating that to Java/C# than you are Go.