3 ms·
It looks like you think writing your program in the language used to express types will magically remove "runtime bugs" If the language is powerful enough to b
by d0mine 3y ago
It looks like you think writing your program in the language used to express types will magically remove "runtime bugs"
If the language is powerful enough to be able to write ordinary programs, it is powerful enough to produce bugs.
Static typing can be effective at catching certain types of bug, not all. It can improve readability sometimes (as a DSL for static unit tests/executable docs).
In general, dynamic languages are more agile and you can write more tests easier. Some of the tests you wouldn't need to write in a statically typed language, therefore typing is still useful though not as universally effective as one might believe.
- the_af 3y ago> In general, dynamic languages are more agile and you can write more tests easier. Where's the evidence of this? Be wary of speaking from "common sense", this kind of assertions are deceptive. Maybe statically typed languages are better prototyping languages? (E.g. there's evidence from an early experiment by Paul Hudak that Haskell is actually a good and fast language for prototyping, beating other languages in the experiment!).
- tipiirai 3y agoSomeone here commented that it takes 2.39s for tsc to check types for `console.log('Hello, world!')` [1] (esbuild does not check types). [1]: https://news.ycombinator.com/item?id=37765713 https://news.ycombinator.com/item?id=37765713
- richbell 3y agoThat seems like more of a tooling issue than a reflection of static vs dynamic typing.
- sensanaty 3y agoWhy do people keep using hello world as good examples of anything? I'm not a TS zealot at all, but my work project which is around 2000 TS/Vue files (some of them hundreds of lines long and even breaking into the thousands for a lot of them) manages to get checked in around 3 seconds if there's a cache, and no-cache runs take 10s or so (which also involves actually transpiling the files)
- tipiirai 3y agoThe parent was looking for evidence for why someone could write tests easier with dynamic languages. A long waiting time for type checking to finish came to my mind first. I think hello world is a valid example when talking about unit tests.
- the_af 3y agoI don't think Hello World is a good example for anything; all you can do with it is microbenchmark, which is not particularly interesting. There are also no meaningful unit tests to write with Hello World. With tiny examples, compile/tooling times tend to dominate. More interesting would be a larger, non-toy prototype, where the tests and prototyping effort are meaningful.
- the_af 3y agoThis is more of a reflection on tsc, but also, Hello World is not a good example because it's not a real world prototype. For conclusions about rapid prototyping you'd need to do this experiment: - Prototype something real, not a tiny toy example like "Hello, world". - Go end to end with your experiment, so instead of focusing on how long it takes to run the typechecker (which makes no sense, since dynamic languages don't have this step), measure how long it takes you to iterate your prototype from start to a finish (including everything: failed attempts, code does not do what you want, writing tests, troubleshooting stuff, and the final working demo). Again, I must ask: where is the evidence that dynamic languages are faster for prototyping? This paper by Paul Hudak, "An Experiment in Software Prototyping Productivity" [1] has multiple flaws you could argue, but what's amazing is that Haskell beat all other languages in the list (none under discussion here, sadly -- that's one of the flaws) for fast prototyping! -- [1] https://www.cs.yale.edu/publications/techreports/tr1049.pdf https://www.cs.yale.edu/publications/techreports/tr1049.pdf
- deterministic 3y agoSeL4 and CompCert are examples of software that is proven correct using a very strong type system.