Live data from Hacker News

How an Anti-TypeScript “JavaScript developer” like me became a TypeScript fan

chiragswadia.medium.com

321–330 of 400 posts

Re: How an Anti-TypeScript “JavaScript developer” like me became a TypeScript fan

#321

Earlier quoted context omitted.

Yeah as best I can tell, Coffeescript was a thing because Ruby was very popular at the time, and some Ruby devs had to write JS but they wanted to write Ruby.

I think everyone except JS devs wishes they could write something other than JS for the browser. Maybe eventually with WebAssembly...

Scala.js actually works really well. Frontend people aren't very aware of it, but if you're a backend dev who just needs to write a bit of code that has to run in the browser then I highly recommend it.

Re: How an Anti-TypeScript “JavaScript developer” like me became a TypeScript fan

#322
post #192

Earlier quoted context omitted.

JS the language isn't great but it's JS the culture that is the real problem. There is a subset of JS codebases that are good, well engineered and written by people that understand the languages faults and limitations but the list is incredibly small and even smaller still now Joyent isn't really around anymore. If there was one ecosystem I wish I never needed to touch again it would be JS but unfortunately it's beco…

It's the same thing with PHP (and Ruby). You can write reasonable code in it, the problem is that the engineering culture leaves a lot to be desired. In Java, the engineering culture is strong but stagnant. Python is toxic, it's full of scientists, the engineering is bad (but a little better than PHP because the community is of a higher calibre).

PHP's type hinting can be a nice onramp to typing, albeit runtime checks. With some linters it can be the best of both worlds for those disciplined and educated enough.

Re: How an Anti-TypeScript “JavaScript developer” like me became a TypeScript fan

#323

I think a large part of the support for Typescript comes from being able to create good tools for the language. But, I still have an aversion to front-end development itself, because it just feels too _involved_. You have to set up so much, and it has become a lot more difficult since you need to install webpack, postcss, and many other plugins just to do a hello world app. It's still bearable if you have to do all o…

I've spent the last two years writing my own framework because I hated React so damn much. It really doesn't have to be that complicated. Granted, I still use a bundler, but it's really easy to set up. I had my friend walk through it all... he seems to think it's great. I should probably release this project some day.

Any reason you forged your own versus adopting Svelte or Alpine? As a fellow React hater I'd love your take on those lighter frameworks.

Re: How an Anti-TypeScript “JavaScript developer” like me became a TypeScript fan

#324
post #141

Earlier quoted context omitted.

This feels less like a case of Hungarian Notation being a bad idea and more like a case where developers are making irresponsible updates to their code. If a variable/function/class/whatever is being updated, the naming should be updated as well, if appropriate. Blaming the original author for the actions of the maintainer is not fair.

I'd still blame the individual developer for poor naming. Naming a variable something like int_list is terrible in that it's both very specific and semantically meaningless. Either choose a semantic name like grades or part_numbers, or take a hint from ML convention and use semantically void names like "xs".

Sure, but is there anything stopping the person updating from revising the name? The original quality of the name is not relevant to my point, which is that anyone changing the code but leaving poor names behind is complicit in the debt.

Re: How an Anti-TypeScript “JavaScript developer” like me became a TypeScript fan

#325

Earlier quoted context omitted.

You can easily write your own "type guard functions" when you think TS is missing an inference from a runtime check you would like. The syntax is simple enough, it's just a slightly different return type from boolean: function isThing(value: unknown): value is Thing { return typeof value === 'object' && typeof value.name === 'string' } The `unknown` type in general is still pretty new, but will be greatly helpful for…

User-defined typeguards are just fancy ‘as string’. They are not type safe.

They localize all the unsafe type casts to one place, where you can inspect the logic, though. Much better than having `as string` sprinkled throughout your code.

Re: How an Anti-TypeScript “JavaScript developer” like me became a TypeScript fan

#326
post #297

Earlier quoted context omitted.

Senior probably means they've been doing JS for decades before TS was invented. They got along just fine without it for so many years, why rock the boat now? Or maybe it is more of a Senior person has a ton of work to do and not enough time to do it in so there isn't time left to learn a whole new way of writing JS. Or maybe many of the errors TS is meant to catch, the Senior developer has already learned over the de…

I've been programming JS for 13 years (professionally, and some more as a hobby) and I'm pretty aware of its warts. And as a firm believer of TDD, most of my code is pretty well tested. Unit tests have similar advantages to types: they catch errors early and let you refactor your code with confidence. But unit tests go even further, because they test the _correctness_ of the returned value, not just its type. And a m…

You should be testing regardless of the strength of your type system.

But testing with a weak type system isn't going to give you anywhere near the guarantees you'd get from a well-designed type system in addition to testing: https://kevinmahoney.co.uk/articles/tests-vs-types/

Re: How an Anti-TypeScript “JavaScript developer” like me became a TypeScript fan

#327
>> However, when I moved to my current role, working on JavaScript was not a choice, as all the apps I was going to work on, were written in TypeScript

Classic stockholm syndrome. It sucks but I have to use it to survive so now I love it.

>> Making impossible states impossible

Well if they're already impossible, there is no need to make them impossible.

>> exhaustive checks

There is no such thing in coding. You can never exhaustively check all possible issues.

>> Spotting bugs early

How about learning to write good tests?

>> Rich IDE support and ease of refactoring

Yes, TS makes it much easier to write and refactor spaghetti code with low cohesion and tight coupling. If you have clean code with good separation of concerns, it makes no difference to the refactoring experience at all if you're using TS or JS. Why TS developers always talk about refactorings? If you need to 'refactor' your code, it means you designed it wrong. Perhaps TypeScript encourages over-engineering which necessitates constant refactoring?

Re: How an Anti-TypeScript “JavaScript developer” like me became a TypeScript fan

#328

I like the post, but the author's original perspectives are something I was always perplexed by. There was a period in late 2000s and early 2010s where dynamic languages were all the range (Ruby, Python, CoffeScript) and static typic was seen as archaic and slow by an entire segment of development community and I never understood it. >I always felt that adding types to the functions/variables and satisfying the TypeS…

> Maybe for small scripts, static typing doesn't provide that much value (although even then I don't really buy it - why wouldn't you want to know what you're working with at any given time), but for sizable (web) applications that need to be maintained for years, it's critical.

It's common for web devs to spend a lot of time dealing with semi-documented lumps of JSON. If you don't have any guarantees about the data in the first place then static typing ends up being a lot of pain without much benefit.

Sure, the situation is far from ideal. But when you're in that situation static typing isn't solving your first problems.

Re: How an Anti-TypeScript “JavaScript developer” like me became a TypeScript fan

#329

I have noticed a lot of people who grew up only using dynamic typing languages are discovering static typing for the first time and proclaiming it to be the "new way forward" or something. Kids...

I have 15 years experience and I agree with you completely. The TS propaganda is so intense that I'm seriously wondering if Microsoft is paying people to shill TypeScript... I just can't figure out why they would do this but the degree of misinformation and downvoting is so intense that I can't think of any other explanation.
Post reply on HN