4 ms·
Statically typed languages are going the other way to. Like focusing on ergonomics for dealing with key-value data with heterogeneous types (like JSON objects),
by jononor 6y ago
Statically typed languages are going the other way to. Like focusing on ergonomics for dealing with key-value data with heterogeneous types (like JSON objects), to generics/traits not needing a specific baseclass, and structural typing more generally, and type inference to avoid having to specify types.
So I think we are more seeing an ongoing convergence on combined static/dynamic typing approaches.
- morei 6y agoI think the convergence here is toward 'automatically discoverable types'. For python et al this means type annotation (because it's extremely difficult for discover types otherwise). For C++ et al this is things like the 'auto' keyword that allow skipping the type specification where the compiler can work it out. The end-game is specifying just enough type information that it's still understandable to both humans and compilers.
- throwaway189262 6y agoTypescript is extremely good at this. Rust is pretty good. Even Java is okay now. I firmly believe type inference is the future. Most objects in dynamic languages are statically typed anyways, the type just isn't exposed at compile time.
- hhas01 6y agoType inference is good, but it’s not a full answer. For instance, how often do you declare a variable as `int`, when what you really want to say is “an integer in the range 0...100”? A few languages (e.g. Eiffel) provide a formal mechanism for declaring these sorts of constraints, but most don’t, and you end up putting what should be declarative type-level information into the body of your code instead. And then there’s “cutting-edge” stuff like dependent types, where you really want to express one argument’s type in terms of another argument’s, a classic example being an array indexing method, where you really want to declare the index at compile time as an integer in the range `0..<array.length`, and let the type system propagate that rule and its implications throughout the code that uses it. Whereas most “modern” languages chuck a run-time error if you’re lucky; or just ralph and dump stack like some antiquated 1970s throwback (yeah, looking at you, Apple’s Swift). 3/10 Could do much better.
- smichel17 6y agoHuh. I generally enjoy Typescript, but have been frustrated by its inference at times, particularly with regard to generics -- there are places where it will do fine if you pass an arrow function directly, but if you pull it out into a const, the compiler will no longer be able to infer types (and thus fails to compile if you have noImplicitAny enabled).
- throwaway189262 6y agoI've found it's inference to be great, but the error messages GCC-like
- throwaway189262 6y agoStatic languages are going all in on type inference. Types aren't annoying if they're hardly ever specified. It's largely a win-win. Even Java has decent type inference on newer versions