Typescript vs Javascript | New Stack

57d8fb91 450c1b44 shutterstock 1923522845


There are no easy answers to decisions regarding the Typescript vs. JavaScript debate. The answer depends a lot on your organization’s needs, as well as your personal preferences and the expertise of the developer/technical person you work directly with.

When considering Typescript and JavaScript, start by looking at specific organizations and use cases rather than general comparison charts on the web. “For example, we heavily use JavaScript on the front-end and back-end, but our back-end systems also leverage other technology stacks, primarily .NET and Java. developers) are developing microservices and need the ability for different people to maintain the same code from sprint to sprint.

Abrams explained that Optimove’s developers are familiar with the typing of the language, and test methodologies that rely on basics such as null references and uninitialized variables are handled by the compiler rather than by developers by hand. Did. “That is why we have standardized on Typescript for most of our services. Small or one-off services are still developed in JavaScript to speed up POC execution and hypothesis testing. is already doing a gradual code migration to TypeScript, which is a simple process (usually improving the code and revealing some hidden bugs).”

Read related: The power of TypeScript and statically typed languages

Abrams adds: In JavaScript it’s easy to confuse units/types and get nonsensical results without notice. I’ve also found that it puts good discipline on developers to use the good parts of JavaScript in real code and leave out the idiosyncrasies. ”

Typescript and JavaScript challenges

Andrew Pierno, Director of Engineering at Veritone, believes there are challenges to both answers in the TypeScript vs. JavaScript debate.

JavaScript is confusing, frustrating, and seemingly easy to get started, but impossible to master, Pierno explains. It’s very flexible, so it’s easy to tie a knot. There are countless ways to do things, and new tools appear every day, but for as long as it has existed, it has been the ugly stepchild of programming languages.

According to Pierno, the advantage of JavaScript is that it’s readily available for web apps, desktop apps, and even blockchain-related uses. TypeScript solves the problem of JavaScript having “weird” types.

“But in my experience, it’s not really a problem,” Pierno said. “I have never had a TypeScript issue bring down a production system. It gives people coming from programming languages ​​the comfort of a strongly typed language, and you can add it to most applications and introduce it little by little into the most important parts of your application.”

Pierno said Typescript further protects large teams by introducing bugs that compilers would normally catch in other languages, but not in regular JavaScript without TypeScript.

Small differences between TypeScript and JavaScript

“If you’re already using application frameworks and components, or have existing code that’s based on JavaScript, especially if your developers and support people have expertise in JavaScript and not TypeScript, then TypeScript There can be big problems with converting to ,” said Jacob Ansari. , Schellman Security Advocate and Emerging Cyber ​​Trends Analyst. With no convincing winner in the Typescript vs. JavaScript debate, the situational advantages gained by switching languages ​​can come at a significant cost in terms of testing functionality and retraining people.

“Making such a move on an existing codebase for security reasons isn’t worth much unless you suddenly get a new development team with a lot of expertise in the new language and an aversion to the old language. I think so,” added Ansari. “Most organizations would be better off fully understanding the security trade-offs that languages, toolsets, and technologies offer, and basing their design and implementation decisions on those factors. Do you (and why)?”

TypeScript example

While Ansari insists on staying with what you have now, Raven Code Limited co-founder and full-stack developer Carl Saunders argues that TypeScript is the clear winner in this debate. doing.

“TypeScript is the only one you should use because it transcompiles to JavaScript,” said Saunder. “Most of the time you don’t even need to write TypeScript. Modern editors like Visual Studio Code and WebStorm infer types (integrate with TypeScript) out of the box. This is a big plus. IntelliSense support , the code will be auto-completed and even highlighted if the developer is doing something wrong (type checking), this alone will catch most errors before any code review is run You can prevent it from being committed to your codebase.”

TypeScript makes it easier for developers to write clean, maintainable code, so they can focus on writing functionality, Saunders said. Another advantage of TypeScript is that developers can adopt early proposals for his ECMAScript specification before it is released to the public. TypeScript polyfills these functions behind the scenes.

“TypeScript can also be used as a command line interface (CLI),” added Saunders. “This means developers can run it within background tasks as part of their developer workflow, and more importantly, as part of their continuous integration (CI) build pipeline. allows you to catch errors even before the code is deployed to your users.”

Which should I use?

Choosing between Typescript and JavaScript obviously comes down to whether you’re already using one or the other and are comfortable with it. If so, read through the discussion above and see if there are compelling reasons to switch.

If you’re starting from scratch, read the instructions above and play around a bit to see which one is better suited for your organization.

group Created by sketch.


Source link

What do you think?

Leave a Reply

GIPHY App Key not set. Please check settings

    pexels negative space 160107

    How to use CSS modules to style React components

    MHI CCS Logo 800px

    Mitsubishi Heavy Industries’ Conveying and Sorting Systems (CSS) Industry Group Adds 10 New Employees