Hacker News new | ask | show | jobs
by blopker 491 days ago
Dart is crazy because it runs on every platform, compiles to native, has real parallelism via isolates, native async, and native type safety.

There's not really a backend that takes advantage of all that. In theory, one server binary could handle REST, web sockets, background workers, and have generated type safe client packages for every platform. Dart also has a great Rust ffi story. It would be great to see that leveraged.

ServerPod is a great start, but it's really Flutter focused. The web apis feel like second class.

Additionally, database management isn't a solved problem yet. ServerPod uses yaml to define models, and the other main option is just a Prisma wrapper. Dart needs something like Drizzle.

2 comments

You could state the same thing as your first sentence for e.g. Rust or many other languages, I personally only see Dart being useful if you already have a Flutter app and you don't want to learn another language, and to have shared types easily, similar to fullstack web devs using TypeScript for their React and Node apps.

I personally use Rust backends and Flutter frontends for my apps. I'd use pure Rust for the entire thing but Rust frontends are nowhere near the capabilities and maturity as Flutter, but I use FFI like flutter_rust_bridge and rinf at least, as you mention.

I actually can't think of another language that has all of that built in. Rust doesn't, it needs a run time for async. JavaScript doesn't, it needs typescript and it doesn't compile to native.
That's true about Rust but that's a feature not a bug as you can swap out async runtime if needed and if you do add it, it is still as or more efficient than Dart.
Kotlin Native has every one of those features.
Hahahaha, by a long shot not.

Kotlin Native is a toy for JetBrains to eat some of that Apple pie and capture teams that want to share logic between their mobile codebases.

Kotlin Native has no std, they cut down platform support with K2, performance and compilation speed are atrocious and there are no plans to improve any of that short term.

Kotlin without JVM can’t hold a candle to Dart. Which is a real shame for Dart, because Dart has improved dramatically last couple years while Kotlin has not introduced anything major last 5 years since release of coroutines.

Their K2 compiler, that was supposed to promise major compilation speed improvements, was mostly a flop and we are yet to see if they’ll do anything good with it. Context receivers are not even close, pattern matching is not even on a roadmap and they’re refusing to consider union types. Kotlin lives on a borrowed time.

The listed features are:

1. runs on every platform (KNative runs natively on Linux, Mac, Windows, Android, iOS. It can also run under the JVM non-natively, and anywhere Javascript runs non-natively. The native code can build for a variety of architectures including ARM and x86)

2. compiles to native (As above, compiles to native on Linux/Mac/Windows/Android/iOS)

3. has real parallelism via isolates (Kotlin can spawn and interact with full processes, OS threads, and/or green threads in any admixture)

4. native async (Kotlin has native async/await support via coroutines, which work under KNative)

5. native type safety (Kotlin has a strong static type system which is available for native code as well and encompasses native types interactive with Kotlin code in either direction)

I don't think anything you said pertains to the listed five features. Especially complaining about compile speed is a strange thing to be doing in the context of this conversation.

While KNative does have these things it still does not have a standard library or ecosystem. Without another runtime KNative is practically useless.
What made you think the K2 compiler is a flop?
On the topic of databases, I think https://drift.simonbinder.eu/ might interest you. I've been using it in a Flutter app with SQLite, but my understanding is that you could use it on the server too. I recall them having support for at least SQLite and Postgres.