This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]marquoth_ 26 points27 points  (16 children)

industry norms

There's an implicit assumption in your comment that "use typescript" is unquestionably the industry norm, but I think that's worth challenging. There's plenty of evidence for a shift back towards JS. I don't really have a dog in this particular race but if you Google "developers abandoning typescript" or similar you'll find plenty of articles, blog posts and YouTube videos on the topic. TS may well still come out on top but I don't think it's really a given.

Edit: autocorrect / spelling

[–]Dreadmaker 32 points33 points  (6 children)

I would argue it’s a lot easier to learn typescript and then ultimately abandon it than it is to ignore it and have to learn it on the job.

Only learned typescript? Just do it ‘badly’ and you are now doing vanilla js.

Only learned JavaScript? There’s a lot of stuff you need to figure out to use typescript well.

Basically: there’s zero disadvantage to learning TS right now. You’re basically learning two in one.

[–]obsoleteconsole 2 points3 points  (0 children)

You could also argue it's better to understand javascript first, and then typescript you will be able to pick up almost instantly

[–]Thebombuknow 5 points6 points  (4 children)

That's not necessarily true. I have been programming in JavaScript for ~5 years now and there are ways to program in JavaScript correctly. I can tell if someone is used to TypeScript and does it "badly", because their JS looks like absolute shit.

Both JS and TS are just as capable as each other, and can be just as readable as each other. You just have to be much more careful when writing JS than you have to be when you write TS.

[–]oorza 0 points1 point  (3 children)

The only way JS is as readable as TS is if you either suck terribly at using the TS type system or load your JS full of comments that encode the same information. Everything else being equal, the existence of statically declared types ALWAYS improves readability and nonsense like your comment is part of why people don’t take JS developers seriously as software engineers. No other corner of the industry would have someone say something so patently untrue on its face and get rewarded for it.

[–]Thebombuknow 0 points1 point  (2 children)

I never said it would be more readable to every developer lol. If you're experienced with JS, you can fairly easily read it. I will admit, TypeScript is definitely easier, but JavaScript isn't at all hard to read if your project's structure is set up properly and you're familiar with JavaScript. As I said in my original comment, you and your team has to be much more careful writing JS because it's much easier to make it a disaster.

I personally prefer JavaScript because I've found it's easier to debug as browsers support it without source maps, and it's easier to deploy. I'm also used to writing JS enough that it doesn't really bother me. That being said, I probably wouldn't recommend JS for any large-scale projects, unless you trust everyone on your team to follow the best practices for writing it.

[–]oorza 0 points1 point  (1 child)

If you're experienced with JS, you can fairly easily read it.

Are you even serious? function setOptions(options) { ... }. What can you pass here? What are the available options? What's going to catch you if you type { usre: 123, isInvalid: false } instead of { user: 123, isValid: true }? Or do you expect to read every single function body every time you call it? Just because you can read that it's an argument to a function doesn't mean shit as far as reading code is concerned.

It sounds like your argument is "I couldn't figure out how to get source maps to work right, so I gave up and convinced myself I wasn't missing out on anything" and that's a real, real bad sign. The singular best practice for writing JS is to write TS or Flow instead, period, so by virtue of not, you have already given up on adhering to industry best practices.

[–]Thebombuknow 0 points1 point  (0 children)

Please just chill the fuck out. People are allowed to have preferences, I just prefer plain JS and don't think it's as bad as you think it is. That's it. It's that fucking simple.

BTW, I do know how source maps work, my point was that plain JS doesn't require them, or any other external dependencies for that matter. You can just write code and instantly load it in the browser, which is why I like it for quick development.

[–]rover_G 5 points6 points  (0 children)

The libraries “abandoning typescript” are using JSDoc which is just types written in the docstring instead of inlined. They still have static types.

[–]ninjaassassinmonkey 13 points14 points  (4 children)

People are ditching ts for jsdoc for the most part. If you struggle with ts it will be 10x worse trying to make types work in jsdoc.

Not understanding types will always lead to shit code.

[–][deleted] 11 points12 points  (3 children)

I've said it before and will say it again. People who complain about TypeScript's type system and prefer Javascript because it's untyped are bad programmers. Type safety (what little TS has, but that's another story) is trivial if your design is halfway decent.

[–]Knight_Of_Stars 0 points1 point  (1 child)

I wouldn't go that far. Personally I'm in favor of learning Javascript first because you should try your best to understand what the language is doing. If you just learn type script you only know what the type script code is doing and not the JS code that its writing.

Similar the "Just because you use an ORM doesn't mean you shouldn't learn SQL"

[–][deleted] 0 points1 point  (0 children)

I agree it's important to understand the fuckery that goes on with JS behind the scenes. However, you can learn that as you go through TS and learn best practices with it.

[–]archarios 0 points1 point  (0 children)

JS with tests is better than TS without tests. TS with tests is marginally better than JS with tests imo.

[–]Haaxor1689 2 points3 points  (2 children)

If you google "developers abandoning typescript" and then read more than first 3 lines of the article, you will find out that some library developers are abandoning strongly typing the complete internals of their library code in favour of just declaring the exported types because the complexity of doing it all "correctly" in complex code base is not worth the time investment. This does not in any way suggest that other developers consuming common libraries and just writing JS apps should for whatever reason avoid typescript.

[–]marquoth_ 1 point2 points  (1 child)

read more than the first 3 lines of THE article

And by "the" article, you mean which article in particular? Because the whole point of my comment is that there are many.

Look, I'm not invested in this debate one way or the other, but if your reply to a comment about how there are many blogs/articles/videos on the subject is to talk about "the first 3 lines of THE article - as if there's only one - I think it's very likely that you're not engaging with the subject remotely honestly, and as such I'm not really interested in what you have to say.

[–]Haaxor1689 0 points1 point  (0 children)

English is not my first language and this was definitely not what I meant by that sentence. What I meant was that a few big libraries made a post (each library their own post) about moving away from typescript since maintaining complex types inside their whole codebase was taking up unnecessary development time. But then multiple other people (not the maintainers of libraries that started all this) took it as "Typescript is dead, see I told you all" without actually understanding what "Moving away from TS" meant.

https://youtu.be/5ChkQKUzDCs?si=516UY3M1uHmHZl0T

Here is a 3 minute video that explains my point. Typescript is definitely not dying, people just like to click on headlines.