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

« this » works exactly the same in TypeScript.


I realize, but it's more of a reaction to the inanity of JS, moreover, since I've started using JS, I've never once had any issue with 'this' - the way one constructs code often in TS is simply quite different i.e. it's really not just 'JS with typing' even if you want it to be just that, usually it's not.


My TS code looks almost identical to my JS code, but with types. Some JS patterns are a little harder to express in TS, but only because they're inherently a little more difficult to implement correctly. Things like higher-order functions (and HOCs).


My TS code looks like Java or Swift. If it's more than a quick function on a web page, I'll never write JS again.


If your .ts code differs massively from your .js code you have no one to blame but yourself.


Blame? Not only is this how I want it, I think it's the obvious and natural progression of Typescript code.

Typescript is not just 'typing' for JS, it encourages much cleaner abstraction, modularization etc. than JS.

My first Typescript exposure was a re-write of several thousand lines of JS code. After a little bit of 'adding typing' I realized there were much better ways to organize information. The result was powerful - what was once a near hairball of code, was now magnificently cleaner, easier to read, easier to re-factor, easier to maintain.

That experience not only validates the existence of TS but strongly highlights the limitations of JS which has always been a deeply problematic language, full of pot holes and weirdness, and though it's fully understandable why the language evolved how it did - that's no justification for it's ugly failings which cause existential inefficiency in many situations.

Though 'adding typing to JS' might be a good start for using Typescript in any given scenario - anyone only doing that is missing a bigger opportunity.


The reason your posts in this thread are so irritating is because TS has all the same junk people hate about JS. You say things like JS is "deeply problematic" and "full of pot holes and weirdness" but you don't address how TS has fixed any of these problems. (Hint: it hasn't. Fixing the language is totally beyond the scope of TS).

Typescript provides concrete benefits. Maybe it also provide some benefits that aren't so concrete, like encouraging developers to think about how they're representing data earlier rather than later. But it doesn't "fix the language".


Not quite.

I agree TS definitely does not 'fix' JS, but in practice, it helps avoid many issues.

Example: prototype inheritance.

Now you can argue that's a 'good feature' of JS, but I'd argue it's just convoluted and difficult.

Since programming in TS ... I've basically never run into a prototype inheritance concern, and maybe a little bit daring (or lazy) to say that I've forgotten many of the details. You really don't have to know anything about prototype inheritance when you're in TS land.

Modules. Technically, that's going to be 'fixed' in a near future version of JS, but really, it's not. Modularization is cludge in JS with various versions. In TS it's fairly clear. No issues there either.

Also, annotations.

Anyhow, yes, you're right technically, but TS does obfuscate a lot of the ridiculousness to the point wherein I would say TS is borderline another layer of abstraction, not just 'types'.

It's the only thing in tech I actually talk up when I get the chance.


I think that's because TS lets you see patterns in your data and code that were "invisible" in JS. You could still write clean code in JS, you just have to be able to see all that implicit structure. Spaghetti code is spaghetti code with or without types, it's just easier without types.


That's totally true, but it's pretty much the point of a programming language - to enable and facilitate intelligent organization of logic.




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

Search: