4 ms·
Are there any other examples of a programming language adding a type system after the fact?
by abrookewood 3y ago
Are there any other examples of a programming language adding a type system after the fact?
- dartos 3y agoElixir (and erlang) already has a type system, it’s just dynamic. Python and typescript both added stricter typing to their respective languages
- krainboltgreene 3y agoI don't think it's actually fair to say Elixir has a type system. There are expressions that are specially handled at the compiler level, but are mostly ignored unless you invoke another separate system. It's effectively comments that have syntax.
- h0l0cube 3y agoIt has a gradual type 'system', along with a means of type checking (via Dialyzer) at compile time. However the type checking isn't enforced at compile time, and it has the possibility for some false negatives (though it isn't so bad in experience).
- krainboltgreene 3y agoOkay then by that measure comments with details about input and output are also a type system, an even easier one since there's generally only one syntax rule!
- h0l0cube 3y agoWhat is code but interpreted text? If the comments are interpretable and enforced by a logical system, then they become instruction.
- dartos 3y agoFunctions can have pattern matching and guards which act as type safety measures, granted they are runtime and not as robust as, say, rust’s type system
- dartos 3y agoElixir has a clear concept of a “type” and can’t just change one type of data to another Willy nilly. Sounds like a type system to me. It’s even stricter than JavaScript, as it doesn’t silently try to coerce everything into a string
- krainboltgreene 3y agoYes but until you run another program the type is just data that gets thrown away. It is effectively just a more syntactically strict comment.
- weatherlight 3y agoIt is a Strongly Typed language (and always has been), It's just Dynamically Typed.
- dartos 3y agoThat’s just not true. Look at function guards
- abrookewood 3y agoYes, I should have specified a Static type system
- tiffanyh 3y agoPHP
- wutwutwat 3y agoNot part of the official language spec, but Ruby has Sorbet, from a company who employs Ruby core contributors and helped with the recently released JIT additions to the language, among countless other contributions over the last couple decades. https://sorbet.org/ https://sorbet.org/
- pohuing 3y agoDart went from a full dynamic system to a statically verified traditional system with null safety.
- KevinMS 3y agotypescript?
- abrookewood 3y agoKinda ... it was built with types from the start, though I guess you could argue Typescript = Javascript + Types
- weatherlight 3y agoI presume you mean migrate from dynamic to static. check out Dart.