this post was submitted on 16 Jul 2025
77 points (93.3% liked)
Programming
21691 readers
116 users here now
Welcome to the main community in programming.dev! Feel free to post anything relating to programming here!
Cross posting is strongly encouraged in the instance. If you feel your post or another person's post makes sense in another community cross post into it.
Hope you enjoy the instance!
Rules
Rules
- Follow the programming.dev instance rules
- Keep content related to programming in some way
- If you're posting long videos try to add in some form of tldr for those who don't want to watch videos
Wormhole
Follow the wormhole through a path of communities !webdev@programming.dev
founded 2 years ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
view the rest of the comments
TS as a statically typed language is not what I would call it. It's a language with enforced type annotations but can be circumvented pretty easily. For example when receiving a JSON from an http request a string field can be just whatever.
That's nitpicking. It is statically typed. Is Dart not statically typed because it has
dynamic
.You could call it "gradually typed" if you want to be pedantic.
That means it isn't sound.
Gradually typed is a great description because it's neither fully static or dynamic. TS does allow you to circumvent the types too easily to be called statically typed.
Is ok in TS land so the type of
strings
is not really static so to speak because you can assign whatever to it. Writing this in Dart would giveif I'm not mistaken.
I get your point, but that's not a great example. Kotlin is a statically typed language, and this compiles (and runs!) just fine:
Even
val test: String = 1 as String
will compile, but at least gives you an exception at runtime, which the equivalent typescript wouldn't.That's crazy, I thought that would be an invalid cast or something.
Unfortunately not. You do get a warning that it's an unchecked cast at least.
Granted, the issue here is generic type erasure, which was a tradeoff that was decided on for backwards compatibility when generics were first introduced to Java, so it's not like an actually desirable feature of the language. But the point is that this wouldn't be reason for anyone to not call Java and Kotlin not statically typed, their type system is just a bit weaker than others in certain aspects