Live data from Hacker News

Type-Safe Printf() in TypeScript

typescriptlang.org

1–10 of 82 posts

Re: Type-Safe Printf() in TypeScript

#5
post #3

Except missing the pesky runtime implementation. We don't need though, right? As long as the types say it's right.

I think the point is safely typing the pattern of having variadic functions with a format string argument.

The function implementation itself isn’t that interesting, or “pesky” to be honest

Re: Type-Safe Printf() in TypeScript

#6
Reminds me of Idris: https://gist.github.com/chrisdone/672efcd784528b7d0b7e17ad9c...

Recently though, I've been wondering whether advanced type system stuff is the right approach. It usually becomes pretty complicated, like another language on top of the regular language. Maybe it would be easier to have some kind of framework for compiler plugins that do extra checks. Something that would make it easy to check format strings or enforce rules on custom attributes, like Linux's sparse does, using plain imperative code that's readable to the average dev. Large projects would have an extra directory for compile time checks in addition to the tests directory they have now.

But I haven't seen any language community do something like that. What am I missing?

Re: Type-Safe Printf() in TypeScript

#9
post #6

Reminds me of Idris: https://gist.github.com/chrisdone/672efcd784528b7d0b7e17ad9c... Recently though, I've been wondering whether advanced type system stuff is the right approach. It usually becomes pretty complicated, like another language on top of the regular language. Maybe it would be easier to have some kind of framework for compiler plugins that do extra checks. Something that would make it easy to check forma…

Sounds like comptime from Zig. There are a few others that does something similar, but Zig probably has most mind share right now.
Post reply on HN