Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

ActionScript 3 was one of my first programming languages and I used it for many years; it's also based on the ECMAScript standard and very similar to TypeScript so I should be biased to like TypeScript, but I really don't.

I was a big fan of static types for many years (I also did Java and C++) so I understand your point of view perfectly but I also understand that it is incorrect. The fact that my POV seems so bizzare suggests that you haven't considered it thoroughly before.



Your view is correct but irresponsible in practice. Validating the schema of all parameters of every method call (because you can never trust the caller in dynamic languages) would be prohibitively expensive. A compiler which injected these checks into every method preamble would have incredible correctness, but would create functionally useless code (if performance is a feature).

> C++

What happens when you call main(argc, argv) with the incorrect argc parameter? There the exact same problem that TypeScript faces at the start of every single C/++ program.

Validate your payloads with JSON schema if you don't trust the server/backend. JSON schema is designed to type-check at runtime and is therefore the correct tool for the job.

Don't curse the hammer if it is unable to loosen bolts.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: