3 ms·
I think a lot of these errors can be fixed with using strict types, aka Typescript. I've had the same issues with PHP in the past too, which makes me believe t
by superasn 5y ago
I think a lot of these errors can be fixed with using strict types, aka Typescript.
I've had the same issues with PHP in the past too, which makes me believe that whosoever created these languages had ease of use as a higher priority than strictness, i.e. it's okay to assign bool, int, string to the same variable.. just get the job done.. okay.
On the other end of the spectrum is a programming language like Pascal (or object Pascal which I used for some time) where I had to write so much boiler-plate code that it made a simple job difficult. Maybe good for big projects but checking if email is valid before form submission, it may be too much boiler-plate code for some people with such traditional languages.
- jmkni 5y agoI had a similar feeling recently using Swift for a project. Pure JavaScript is definitely a bit too loose for my liking, but I thought Swift went a bit too far in the other direction.
- Aaargh20318 5y agoI had that experience with Swift for maybe the first 2 days I used it. Nowadays I really appreciate Swift’s strictness. It just helps prevent so many stupid mistakes. I worked on a high-profile project for my company under a strict deadline and Swift was a major part in ensuring we delivered a rock-solid implementation in record time.
- kalleboo 5y agoThe only part of the type system that I feel gets tedious is dealing with numbers, where you're continually casting back and forth between Int, Float, Double, CGFloat (at least the latter is being addressed). I get why it's strict about it due to loss of precision and the madness of floating-point numbers, but sometimes you just don't care
- Aaargh20318 5y agoThe number things isn't that big of an issue once you get used to considering what type your numbers should be in advance, instead of going back and forth between number types, pick one that's appropriate and stick to it.
- dan-robertson 5y agostrict types and Typescript are not synonyms. Perhaps you meant to write “for example” instead of “aka.” And furthermore there tends to be some disagreement about the meaning of the words strong/weak, static/dynamic, strict/lax when talking about type systems. Indeed Typescript is quite a weak typesystem in that type checking does not very fully guarantee useful correctness properties about your program because it allows for missing type annotations.
- goodoldneon 5y agoI love the HN comment section — one of the best I’ve seen on the web. But nitpicking this use of a.k.a. doesn’t add anything to the conversation. We all know what they meant, since virtually no one thinks that TypeScript is the only strictly typed language in existence.