JS vs TS?
Posted by alex_sakuta@reddit | learnprogramming | View on Reddit | 17 comments
I'm asking this here because on language specific servers I don't expect an objective answer.
I switched to learning C and hopefully maining for some time to understand a lot of stuff that alternatives to C give out of the box covering some weaknesses. The purpose was simple,
"How would I understand this weakness of C (or other langs) when I never faced this weakness in C?"
But that led me to this another thought to which I keep coming back, should I go back to JS?
Context: Started JS, made some frontend projects in it and one full stack project from a video in it. Switched to using TS and have developed 2-3 projects with TS all on my own.
I never felt the need to go back to JS. But 2 things have changed that, the one I mentioned above and another that TS is JS at runtime. I once accidentally in a real life project did something that compiled properly but let to undefined runtime behaviour. And this was because of runtime behaviour shenaningas of JavaScript. It didn't bring the type that it had to and didn't even tell me that it brought the wrong type.
I felt, if I were not using TS, maybe I would have been more careful of the data types and not just assume if it compiles it works.
The key point is, I switched to TS, without experiencing the pains/weaknesses/quirks of JS.
- So should I, use JS?
- Or should I keep using TS because the knowledge is basically transferable (mostly)?
- Also, is programming in TS a different paradigm than JS , according to you?
For anyone who is going to say, try yourself, I am gonna do that anyways, just taking opinions as well.
HumanHickory@reddit
I do not think Javascript is all that valuable to learn. You can use typescript without ever having used Javascript and a lot of companies arent using JS anymore in its raw form.
JS is verbose and frustrating which is why they made jQuery and TS.
TS has a lot of benefits, and although it is also complex, I'd recommend spending your time learning the complexities of TS rather than JS.
If youre brand brand new, id pick either React or Angular, and start doing those tutorials. You'll learn TS while you go and also get comfortable with a front end framework.
Both React and Angular are good. I see jobs for both and have used both, although I prefer Angular. I really like front end work, but a lot of people who dgaf about UI seem to like React. Take that with a grain of salt, its just what I've experienced at the jobs I've had.
You cant go wrong with either choice.
Grupith@reddit
What’s your end goal? Why are you trying to learn to program? Game dev? Web Apps? Think about it like this…
Why would I spend a year learning Spanish then say, okay I’m done, now onto German, then after that Chinese. Like what’s the point? Just to say you know languages or to actually use it to speak to people?
alex_sakuta@reddit (OP)
And I mentioned that I have made projects with TS full stack, so...I made it pretty clear I'm a web developer
My end goal is to be the best at using my tech stack, if TS is actually adding a support that is hindering stuff I would learn if I were not using TS then I should probably not start with TS.
Grupith@reddit
If I’m being honest, I didn’t spend years in vanilla JavaScript when I started learning web dev. I made a few projects and then when I ran into a problem that I heard could be implemented easier with React, then I started that.
Kind of similar to typescript. Do I know all the inner workings of JavaScript before I started using typescript? No, but it’s what everyone is using and becoming an industry standard. I think it helps me catch errors a lot more than js would.
alex_sakuta@reddit (OP)
I did the same too
Js -> React -> TS & Next.js
But this is what I am thinking is maybe potentially bad for me, getting that help. Because yes, TS was a huge help in making a robust code and I had thought never to write JS again, I even started using Deno just so I can always write TS.
BlazingFire007@reddit
I personally massively prefer using TS, but maybe you’d like JS with JSDoc?
I’m also a bit skeptical of your anecdote about the TS compiler missing some undefined behavior, I haven’t had that happen. Are you using strict rules? Did you have an
any
type? Etc?andreicodes@reddit
Honestly, both.
TS is often preferred, especially for larger projects or when multiple people are involved and you want to add a safety net.
But let's say your project needs a short script to do some work once in a while, like do some log cleanups or convert data from one format to another. Or, you open a Node or browser console because you need to play around with some library API. Or, you make a small dashboard that needs about a hundred lines of code to get it going. JavaScript is perfectly fine for those cases.
Guimedev@reddit
once you use TS you won't never go back to js
alex_sakuta@reddit (OP)
Do you realise I mentioned I used TS and I am talking about going back to JS?
rameshuber@reddit
JS teaches you how the language really works-its quirks, coercion, async behavior, etc. That pain is valuable. TS adds a safety net, but it’s still JS at runtime, and it can give a false sense of security if you don’t understand what’s happening underneath.
That bug you hit? Classic case. TS helped you write the code, but JS still ran it.
So yes, I’d recommend going back to plain JS for a bit-not forever, just enough to feel the edges. You’ll come back to TS writing better, more mindful code.
And no, TS isn’t a different paradigm-but it does shape how you think and design.
SirSpudlington@reddit
TS: JS pretending to have types
Retired_BasedMan@reddit
Dyamic language vs Static language
Static languages are better for development processes
Once you start writing Typescript you will never go back to Javascript believe me
Logical-Idea-1708@reddit
Depending on the person’s level. I wouldn’t recommend static types to any real beginners. The extra baggage distract from getting things done. When you’re not getting things done, it discourages progression.
alex_sakuta@reddit (OP)
I'm not a beginner
Naetharu@reddit
Typescript is literally just JavaScript with types.
I'm not sure you're going to get any meaningful learning value by using just JavaScript. In terms of understanding the issues - it's just the bog standard issues of a non-typed language. You're not able to validate types. You can easily mess up and pass the wrong type etc.
Ok_Spring_2384@reddit
You should use TS knowing all the benefits of a reliable type system, nothing more really.
Architecturally speaking, your dev workflow will change and become more verbose, if this is not bad to you then by all means, keep going.
I enforce TS at work because it makes the debugging, testing, implementing, documenting, and implementing things easier for MY team. Your mileage may vary. I also come from a Java and c# world, my team had no issues subscribing to my methods. It just depends.
TS is amazing, to me it makes readying codebases simpler, if you hold to this sentiment and have proper devs that appreciate that sentiment then by all means man/whatever type away!
newaccount@reddit
If you want to get a job, TS is a plus