DEV Community

Cover image for Javascript VS TypeScript : Going Back to JavaScript and stop using TypeScript
Salah Eddine Lalami for IDURAR | Where Ai Build Software

Posted on • Originally published at idurarapp.com

Javascript VS TypeScript : Going Back to JavaScript and stop using TypeScript

In recent years, TypeScript has emerged as a popular choice for many developers due to its extra layer of static typing. However, this article will explore the reasons why you should reconsider using TypeScript and shift back to pure JavaScript. We aim to spark thought-provoking discussions and encourage users to share their opinions in the comments section.

React.js was written with Javascript

Javascript VS TypeScript

Simplicity and Flexibility:
JavaScript, being a dynamically typed language, offers a greater degree of flexibility by allowing developers to write code more intuitively without the overhead of type annotations. By reverting to JavaScript, developers can embrace the simplicity of the language, focusing solely on achieving desired outcomes rather than wrestling with complex type systems.

Rapid Prototyping:
One of the major drawbacks of TypeScript is its learning curve and initial setup time. JavaScript, on the other hand, provides an ideal environment for rapid prototyping, enabling developers to quickly iterate and experiment with different ideas. Returning to JavaScript would empower developers to hack together ideas faster and get immediate feedback.

Larger Talent Pool:
TypeScript, being a relatively new addition to the JavaScript ecosystem, limits the available talent pool of developers. By embracing JavaScript, you open up opportunities to collaborate with a larger community of developers who are proficient in the language. This advantage not only facilitates better knowledge sharing but also enhances the potential for finding skilled team members and contributors.

Reduced Code Complexity:
Although TypeScript promotes type safety and catches potential errors during compile-time, this additional layer of complexity can make the codebase harder to understand and maintain. In contrast, JavaScript's dynamic nature allows for more concise and readable code, reducing overall complexity and improving collaboration within development teams.

Vibrant Ecosystem:
JavaScript boasts an extensive ecosystem of libraries, frameworks, and tools carefully crafted over the years. While TypeScript does support JavaScript libraries, not all of them have TypeScript type definitions readily available. By transitioning back to JavaScript, developers gain access to a vast array of battle-tested resources and community-driven solutions.

We hope this article has ignited a conversation, and we eagerly await your thoughts and comments on this topic ?

Join us @ IDURAR : JS Open Source project

Top comments (39)

Collapse
 
szagi3891 profile image
Grzegorz Szeliga

These arguments are weak. You may find this out if you work on one project with several people. If you're creating a simple business card for yourself and you're the only one working on this project then maybe you can still manage without TS. For larger projects, plain js will not work. The cost of fixing errors that arise from lack of typing will be too high.

Collapse
 
lalami profile image
Salah Eddine Lalami

Wordpress they use Javascript , for their large project : github.com/WordPress/gutenberg

if you have solid design pattern , then it will easy to maintain the project

Collapse
 
theaccordance profile image
Joe Mainwaring • Edited

Keep in mind that specific project started at a time when TypeScript was still an early adopter option more than a best practice recommendation, and TypeScript is an invasive upgrade for existing JavaScript projects - so it may not be a feasible change for the team if they have other outward-facing priorities to invest their efforts in.

As far as good patterns - I'll assume that the timing for the project conception aids in this perspective. Had this project kicked off pre 2015, it would likely have less maintainable code today.

Collapse
 
noblica profile image
Dušan Perković

It's not the same. They still use JSDoc, and generate their typings for users of the library to consume.
No "solid design pattern" is going to catch all type errors.

Thread Thread
 
calinzbaenen profile image
Calin Baenen

To be fair, JSDoc doesn't let you(r IDE) catch type errors, they are more like annotations, orwith suggestions.

Collapse
 
calinzbaenen profile image
Calin Baenen • Edited

And?
Some people use C instead ov Rust — does that mean C is better?    /rt

Collapse
 
theaccordance profile image
Joe Mainwaring • Edited

^ second this. The benefits of TypeScript are seen at scale for collaboration, complexity, and maintenance, so it's not really an argument of using one or the other, but knowing which is the more appropriate solution for the task at hand. My language of choice for writing code today is TypeScript, but I don't hesitate to switch back to JavaScript if the working conditions negate the need for the additional quality controls.

I don't view TypeScript as having a smaller talent pool - unless you're going to skip an onboarding period for your engineers. TypeScript is JavaScript with extras and a compiler step. JavaScript engineers can quickly adapt.

Collapse
 
prankurpandeyy profile image
PRANKUR PANDEY

Hello Grzegorz Szelig, Welcome to the dev community glad you are sharing your knowledge and educating others, The development of TS was done making it a super JS to prone errors before going into production. You have a valid point here .

Collapse
 
vall3y profile image
Guy Zissman • Edited

Were there no big projects before typescript? Static code analysis for javascript has gotten better as well, there's no need to use typescript

Collapse
 
patric12 profile image
Patric • Edited

I must respectfully disagree with the notion that reverting back to JavaScript from TypeScript is a beneficial move. Here's why:

  1. Type Safety: One of the standout features of TypeScript is its ability to catch errors during compile-time rather than runtime, which can potentially save developers from encountering numerous bugs and issues down the line. This type safety can significantly streamline the debugging process, making maintenance easier in the long run.

  2. Improved Developer Experience: TypeScript offers an enhanced developer experience with features like autocompletion, refactoring support, and advanced type checking, which can significantly boost productivity and code reliability.

  3. Community and Corporate Support: TypeScript has garnered substantial support from both the community and corporations. Many popular libraries and frameworks have adopted TypeScript, offering type definitions that can help developers avoid common pitfalls and write more robust code.

  4. Scalability: For large-scale projects, TypeScript's static typing system can be a boon. It helps in maintaining a structured codebase, making it easier to scale the project without getting bogged down by the complexity that dynamic typing can sometimes introduce.

  5. Interoperability: It's worth noting that TypeScript is a superset of JavaScript, meaning that all JavaScript code is valid TypeScript code. This allows for a smoother transition between the two, and developers can gradually adopt TypeScript features in their JavaScript projects without a complete overhaul.

While JavaScript's flexibility and dynamic nature have their own set of advantages, the benefits of using TypeScript, especially in larger, more complex projects, cannot be understated. I believe a more balanced approach where the strengths of both languages are utilized based on the project's specific needs would be a more prudent strategy.

Collapse
 
devdufutur profile image
Rudy Nappée

It's worth noting that TypeScript is a superset of JavaScript, meaning that all JavaScript code is valid TypeScript code.

let x = 3
x = "foobar"
is valid js but not valid ts

Collapse
 
calinzbaenen profile image
Calin Baenen

That's because ov type-inferencing — just add :any right after x.
Sure, I guess this does kind ov invalidate the whole "all JS is valid TS" statement, but it's a minor tweak to the code; usually, most people want variables to have only one type, which is why TS defaults to choosing a type.

Thread Thread
 
devdufutur profile image
Rudy Nappée

Sure but "ts is a superset of js" is spread all over the internet while it's factually incorrect

Thread Thread
 
calinzbaenen profile image
Calin Baenen

How about this for a compromise? "TypeScript is a superset ov JavaScript, but only in terms ov syntax, not in terms ov rules.".

Collapse
 
emeremikwu profile image
emeremikwu

you shouldn't be writing your code like this to begin with... The whole point of TS (from my understanding) is to improve manageability but if you're not writing good code from the get-go then you should probably focus on improving that first.

Collapse
 
lalami profile image
Salah Eddine Lalami

Thank you @patric12 for your comment,
check here how react success to write the largest & best frontend framework using just javascript without any typescript :
github.com/facebook/react

What do you think ?

typescript vs javascript

Collapse
 
giovannimazzuoccolo profile image
Giovanni Mazzuoccolo • Edited

They use Flow, as static type checking similar to typescript developed by Meta as well.

Collapse
 
calinzbaenen profile image
Calin Baenen

As @webjose pointed out, React's performance isn't really relevant here.
Additionally, you're not considering whether or not they are using some other means ov type-checking, like @giovannimazzuoccolo pointed out.

Collapse
 
patric12 profile image
Patric • Edited

@lalami It seems like you might not have extensive experience with TypeScript. In the TypeScript ecosystem, it's quite common for libraries not originally written in TypeScript to have separate type definition packages to support TypeScript development.

Image description

Collapse
 
webjose profile image
José Pablo Ramírez Vargas

React? The BEST? See these performance benchmarks. Where is React? Always to the right, in the yellows and reds.

However, saying this is just a fallacy as its performance has nothing to do with what TypeScript is meant to do.

So what do I think? I think React has already met End Of Life. It just so happens to be the #1 in popularity. Give Svelte a year or two. Everyone will be on Svelte.

Whether you go TypeScript or JsDoc is a matter of taste in good amount, but to say only JavaScript is madness.

Collapse
 
miketalbot profile image
Mike Talbot ⭐ • Edited

I think (2) has long been fixed. Our project is core is JS only with JSDoc and autocompletion is just fine in JetBrains IDEs and VSCode. As are type notifications etc without the need for a compiler.

I see real benefits for TS is very large projects with many teams, though the architectural patterns we use in our project separate concerns and team interactions well. We support modules and micro front ends built in either. We have JSDoc and typedefs for the key functions.

Collapse
 
wraith profile image
Jake Lundberg • Edited

I can see from your perspective that JS may seem like a better choice when limiting the context of the argument between TS and JS. Unfortunately, the context is significantly larger than your argument considers.

I would love to hear your thoughts on how JS is a better choice at scale. Or for different project types. I know there have been successful projects built without TS, so I'm not just looking for examples of people who didn't use it. But instead, I would like to hear your thoughts and perspective.

For example, one problem I consistently run into without TS is identifying data structures. If I'm trying to reuse someone else's function or component, figuring out the required structure of an object is unnecessarily complicated and often requires a lot of time investigating. This can be solved with the addition of JSDocs, but since you did not include that in your argument, I assume you are not using it...but if you are, there is also a learning curve to proper JSDoc format, so it's more of a tradeoff. Do you have thoughts on how JS makes this sort of thing easier without the need for other tools?

Additionally, I know there have been several large projects recently dropping the use of TS (Svelte for example), but before making a sweeping declaration that "if these teams are dropping it, so should everyone" we must first consider the reason why they are doing so. Many of the example projects people bring up in this regard are packages and libraries meant to be used within applications. Building a package/library is vastly different than building an application. They have different requirements, considerations, skillsets, serve different needs, and have different audiences. Could you share your thoughts on why TS should not be used for any project, rather than it being used as a tool for specific jobs for which it's best suited?

I look forward to hearing your thoughts here!

Collapse
 
carvilsi profile image
Carvilsi [Char]

I agree with most of your arguments; simplicity and flexibility of JS vs TS, could be that there is a larger talent pool for JS than TS. I do not agree 100% about the learning curve if the leaner has good base on different OOP languages (apart of JS) and do not agree about that the initial setup time is larger for TS than JS, depend of what are you building, for complex projects the set up time is very similar (Unless you are saying that you can not write TS on a web-console from your browser). About that JS is better for prototyping, hacking, and do PoCs I agree. But for complex projects, that has lot of components and parts, and lot of developers involved, TS is a winner, reduces the errors and misinterpretations when you are using a component that wrote another one.

Also I must admit that for the last 7 years I was developing at services at the backend and could be that the point of view of a fronted dev could be more JS oriented.

Collapse
 
thevnilva profile image
Tori Hevnilva

I see you've been scrolling through Twitter lol

Collapse
 
calinzbaenen profile image
Calin Baenen

And...?
How is that relevant?

Collapse
 
am77 profile image
Mohamed Amine Griche • Edited

I have to disagree with you on this one, working with plain JS on a large project within a team is super hard and most of the time end up as a mess, you might increase the development pace and make the code look cleaner, but maintaining the code will get harder over time and if you are not super careful you will get regression bugs everywhere and Uncaught TypeError: undefined is not a function.

Collapse
 
noblica profile image
Dušan Perković • Edited

If you're writing a library and having issues with TS, you should consider JSDoc.
If you're just writing apps, don't switch back to vanilla JS. It's a terrible idea to ditch static typing, and all the benefits it brings, just because "code looks cleaner".

Collapse
 
wraith profile image
Jake Lundberg

Well said, I came here to say this exactly!

There are a lot of arguments being made that packages are dropping TS. What I see frequently is people failing to realize that building a package/library is not at all the same thing as building an application. It's like the difference of working on a car's engine vs working on a car's interior. Both are important jobs, but they both require different tools.

At the end of the day, TS is a tool. It's not the only tool. And we should always try to choose the right tool for the job.

Collapse
 
zirkelc profile image
Chris Cook

I think mentioning React as an example here is a bit ironic. While it's true that it has been written in pure JS, they have also created Flow, which is quite similar to TypeScript, and React PropTypes. So I assume they clearly saw a strong demand for types.

Collapse
 
fernando_rodrigues profile image
Fernando

oh wow, Thank you for the good article!

Collapse
 
lalami profile image
Salah Eddine Lalami

here another nice article : Turbo 8 is dropping TypeScript