Live data from Hacker News

Type-Safe Printf() in TypeScript

typescriptlang.org

11–20 of 82 posts

Re: Type-Safe Printf() in TypeScript

#11
post #10

[flagged]

> If JavaScript was a failure

By almost any reasonable measure it is one of the strongest candidates for “biggest success ever as a programming language”. Sure, you can argue that the reasons for that aren’t mainly language design related, but it is absolutely not anything like a failure.

Re: Type-Safe Printf() in TypeScript

#12
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…

I wonder if we should have a kind of "hidden type system", where we still take advantage of having a single type system to reason about, but the extra-specific "weird-ish" types can be hidden, almost like private variables, where visibility is literally hidden from the programmer unless obtained from debug modes or errors.

Re: Type-Safe Printf() in TypeScript

#13
post #10

[flagged]

> If JavaScript was a failure By almost any reasonable measure it is one of the strongest candidates for “biggest success ever as a programming language”. Sure, you can argue that the reasons for that aren’t mainly language design related, but it is absolutely not anything like a failure.

Pretty easy to succeed when it's the only language a browser supports.

Re: Type-Safe Printf() in TypeScript

#15
post #13

Earlier quoted context omitted.

> If JavaScript was a failure By almost any reasonable measure it is one of the strongest candidates for “biggest success ever as a programming language”. Sure, you can argue that the reasons for that aren’t mainly language design related, but it is absolutely not anything like a failure.

Pretty easy to succeed when it's the only language a browser supports.

“JavaScript’s success is unfair”, sure, whatever.

But that’s not the same as “JavaScript is a failure”.

Re: Type-Safe Printf() in TypeScript

#16
post #10

[flagged]

> If JavaScript was a failure By almost any reasonable measure it is one of the strongest candidates for “biggest success ever as a programming language”. Sure, you can argue that the reasons for that aren’t mainly language design related, but it is absolutely not anything like a failure.

It only succeeded because it literally couldn’t fail. It had plenty of competitors and all of them had one critical flaw: not being built in to the browser.

Re: Type-Safe Printf() in TypeScript

#17
post #13

Earlier quoted context omitted.

Pretty easy to succeed when it's the only language a browser supports.

“JavaScript’s success is unfair”, sure, whatever. But that’s not the same as “JavaScript is a failure”.

The point is that success sure tastes bitter.

Re: Type-Safe Printf() in TypeScript

#18
post #13

Earlier quoted context omitted.

> If JavaScript was a failure By almost any reasonable measure it is one of the strongest candidates for “biggest success ever as a programming language”. Sure, you can argue that the reasons for that aren’t mainly language design related, but it is absolutely not anything like a failure.

Pretty easy to succeed when it's the only language a browser supports.

It wasn't the only language browsers (vbscript was allowed client side in early ie) supported and also isn't anymore with wasm

Re: Type-Safe Printf() in TypeScript

#19
post #8
post #3

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

The static types depicted in typescript are entirely fictitious. Any similarity to runtime types is purely coincidental.

This is such a cynical take. The point is to model what types exist at runtime in the type system, so that you can reason about those same runtime types statically. They’re only “fictitious” if they’re defined incorrectly, or if the type system can’t sufficiently express certain of their nuances. The former is usually only the case when developers intentionally work around the safety provided by the type system; the latter is possible, but at this point it’s usually only ever the case for patterns that are hard to reason about regardless of the type system or even the presence of types at all.

Re: Type-Safe Printf() in TypeScript

#20
post #8
post #3

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

The static types depicted in typescript are entirely fictitious. Any similarity to runtime types is purely coincidental.

Yeah. I see a lot of "typescript is more readable" arguments out there, but I find this code dense and verbose. The more words you use to explain something the more likely you are to be misunderstood. What we're looking at here is basically a restricted wrapper for console.log and a regex implementation meant to simulate a logger in another language. Why not just write a cross-compiler for that language? There's no learning curve for the syntax then, only the target platform.

The invention, support and defense of Typescript baffles me. It feels like an intensely wasteful work-around for poorly written interpreter error messages concocted by comp-sci grads who think compiled languages are superior to interpreted ones in all situations and they want to bring this wisdom to developers of loosely typed languages.

Post reply on HN