News for hackers. Stuff that matters.
Re:Show HN: A SQL database implemented purely in TypeScript ... by mypalmike on Monday September 28, 2020 @02:58PM (#24620101)
Why do you need runtime type checks if the compiler already checked the type?

IMO, runtime type analysis is a code smell. There are few scenarios where the simpler and more efficient solution involves querying type metadata at runtime. Particularly in a language that directly supports dynamic dispatch, you should think hard before adding anything resembling an "if typeof(mything)" check.

Re:Show HN: A SQL database implemented purely in TypeScript ... by wolfgang42 on Monday September 28, 2020 @03:14PM (#24620247)
The obvious use case is the interface between something that’s not type-checked by the compiler and something that is. It’d be useful to be able to do `runtime_cast<Foo>(JSON.parse(foo_json))` on, say, the response to an API call and know that the result was definitely a valid Foo without having to write a bunch of boilerplate to validate that by hand.

(Reading through the thread, there’s apparently some libraries that can do this; I’ll have to try them out next time I need this.)

Re:Show HN: A SQL database implemented purely in TypeScript ... by int_19h on Monday September 28, 2020 @08:30PM (#24622834)
Because there's no guarantee that compiler did that. Even if you do this in your code, the moment it gets called from pure JS, all bets are off. With proper runtime checks, you could get consistent behavior out of that.