Hacker News new | ask | show | jobs
by darpa_escapee 2878 days ago
Dart is a nice statically typed and compiled C-style language. If you have experience with another such language, it will feel like you already know Dart. The language compliments Flutter well, and the Flutter SDK makes it simple and easy to rapidly build a functional mobile app.

Lack of certain features, like reflection, in mobile Dart creates a rift in packages you can utilize in a Flutter app. There are a few warts in the type system, mainly around generics, and little things like the lack of union types and type aliasing.

There are also a few outstanding bugs that you might run into, which have had relatively long life since they were identified. The Dart team seems to be reluctant to add new features.

Also, managing state in Flutter is a little unclear: documents and videos from Google recommend four different ways to do so: explicitly calling setState(), Streams with StreamBuilder, scoped_model and the various third-party Dart/Flutter Flux implementations.

It definitely beats native development.

1 comments

Language with "dynamic" type can't be called "statically typed".
Most languages I can think of have this type, from void* to dyn to bounding by the root of the type hierarchy. Not all languages. However, what is c, c++, java, rust, go, if not statically typed? Ambiguously typed? Seems like not a useful distinction to make.

I argue static typing is the ability to static type up to 100% of a program, not the exclusion of a dynamic type.

Rust doesn't have such type. And type annotations in Dart are optional - when programmers are not obliged to use them, guess what will happen? They do NOT use them. People are lazy.

Dart's types exist only on compilation step. You can try to use "strong mode" in theory, in practice you will never compile it with third-party libraries.

> And type annotations in Dart are optional - when programmers are not obliged to use them, guess what will happen?

The type system will infer a static type based on the type of the initializer.

In some cases, inference may fail to infer a type. Right now, that can silently give you dynamic, but there's a flag to make that an error. I expect before too long that will be the default behavior.

Rust has both raw void* pointers (within unsafe code) and the safe std::any::Any trait: https://doc.rust-lang.org/std/any/trait.Any.html
Trait is not a type, Any is just a custom trait. Types: https://doc.rust-lang.org/book/second-edition/ch03-02-data-t... You can create trait with name "Magic" or "Fuck" and it will not mean anything. Pointers is not a type also.
Ok, type bound. You can still easily pass around data whose type is not concretely defined at the compilation step. Unless you’re arguing that the dynamic type is actually static, in which case this whole conversation seems semantically pointless.
Pointers are certainly types in Rust, and although it's of course true that the Any trait is not itself a type, a reference to an Any trait (which is what you'd actually pass around) is a type.
A pointer is absolutely a type in rust.

let i: u32 = 1;

let p_imm: const u32 = &i;

Look at the const u32 in the type position.

The rust book even refers to const and mut pointers as types.

Dart isn’t statically typed, at least not in the times i’ve used it; it’s gradually typed.
It was optionally typed. Dart 2 is statically typed.
If you have a well-thought out argument, and not a quippy one-liner, I'd earnestly like to hear it.

Dart's developers think otherwise[1]:

> Q. Is Dart a statically typed language?

> Yes, Dart 2 is statically typed. For more information, see Dart’s Type System.

> With its combination of static and runtime checks, Dart has a sound type system, which guarantees that an expression of one type cannot produce a value of another type. No surprises!

> Even with type-safe Dart, you can annotate any variable with dynamic if you need the flexibility of a dynamic language. The dynamic type itself is static, but can contain any type at runtime. Of course, that removes many of the benefits of a type-safe language for that variable.

[1] https://www.dartlang.org/faq#q-is-dart-a-statically-typed-la...

> With its combination of static and runtime checks

Do you personally use it? That "strong mode" is a theory-only thing, it doesn't work with any real code, only with code you wrote without real third-party libraries.

You are, at best, confusing Dart 2 with Dart 1; strong mode was one of several Dart 1 modes, but, yes, it's possible to run into problems because dependencies weren't designed for it.

There is no option in Dart 2; everything is the equivalent of strong mode, which eliminates ecosystem problems.

I mentioned I've only tried Dart 1.x. Glad to hear it's changed in Dart 2.
> only with code you wrote without real third-party libraries.

Your claim was true several years ago, but since then the entire ecosystem has migrated onto the new strict type system. It was a monumental amount of work, but, thanks to lots of effort from our users, we're there.

Aside from a small number of more-or-less dead packages, you should be able to use any third-party Dart packages you want while still using the new type system.

C#, Scala, Kotlin, TypeScript, et. al have a dynamic type. As long as every type isn't dynamic, I think it's reasonable to claim you have static types.
Is C# statically typed?
Yes, it is.
I don't know.
Really happy to see this absolutely honest and neutral answer downvoted. It says a lot about the level of my opponents.
It says a lot that you consider folks you're having a conversation with "opponents".
Anybody who is arguing with you is your opponent. It's not so dramatic word :)