DEV Community

Discussion on: What is the ONE language/framework you refuse to use? But...WHY???

Collapse
 
chlorophyllkid profile image
Christopher Voigt

TypeScript … and I don’t really know why. My main concern is, that will make frontend work more complicated (defining types and weird looking syntax)

Collapse
 
brense profile image
Rense Bakker

It's the same syntax as Javascript though? Except for the types syntax ofcourse since Javascript is missing any kind of type safety.

Collapse
 
davefellow profile image
David Fuentes

Typescript is way more than just types tho... It's interfaces, encapsulation, enums, tuples, etc, etc. It literally changes everything regarding app architecture and code "shape"... Oc one can just use one of the features and forget about the others but just using static typing can be worked around using strict JavaScript and linter anyway...

Thread Thread
 
brense profile image
Rense Bakker

It's still the same syntax, the same way to define variables, functions, for loops... You have access to the same built-in functions and objects like Math.random(). So saying the syntax looks weird seems a little weird to me. Interfaces and enums you dont have to use, they're just there to aid in making good typings. Tuples you definitely have in javascript: const myTuple = ['one', 1] is valid javascript code.

Collapse
 
_moehab profile image
Mahmoud Ehab • Edited

Writing big projects in JS (or any typeless/dynamic language) will lead us to a miserable fragile (soft)ware. "The parentheses because it is no longer soft :("

Collapse
 
tmchuynh profile image
Tina Huynh

Interesting...I'm definitely seeing both sides. People are saying TypeScript is helping a lot! And then there are those saying that with the developments of j
Javascript, you don't really need to use TypeScript.

Collapse
 
dumboprogrammer profile image
Tawhid • Edited

Let me add something:
Typically low level or staticly typed language users like typescript because they like to work strongly typed pattern.(personally I like it too because I mostly work with C++ and C#)
on the other hand Typical web developers who mostly used javascript doesn't like typescript because compared to javascript, typescript looks scary and weird .They don't want to do the same thing with extra steps, you get the idea.

Collapse
 
menottiricardo profile image
menottiRicardo

I tried TypeScript in a small app two years ago and haven't used javascript since then...

Thread Thread
 
tmchuynh profile image
Tina Huynh

I thought TypeScript isn't optimal for all projects. Correct me if I'm wrong. I haven't looked into it as much as I would like

Thread Thread
 
aeryle profile image
Aeryle

For very very small projects, I doubt Typescript is worth the additional time. Of course Typescript brings alot of advantages to projects, but sometimes using it for something very small just isn't worth it. But most of the time I'd say that it really is a good thing to have.

Thread Thread
 
joelbonetr profile image
JoelBonetR 🥇 • Edited

@tmchuynh @chlorophyllkid
It depends on the "logic load" you are going to add.
On average you'll prefer to have business logic in the backend. Thus it will depend on the needs of this logic and the architecture.

Let's add some examples as explanation:

If it's a microservice running in Node JS that exposes a CRUD through an endpoint, it will probably be a tinny one with few lines of code for each HTTP verb handler thus, even is OK to have some TS features it's not a real need.

On the other side, if it's a big service that deals with multiple instances or that deals with a third party (even being a single one) you may prefer to have TS to end up with a more robust code. It's all about robustness.

Last but not least, you must not couple business logic into the frontend: i.e. You can have a frontend in Angular but maybe in 2 or 3 years angular is dead and you need to migrate to a different tech, if you couple business logic on it, it will be a hell of a process, plus most of the time you need direct access to the DB to ensure data reliablility, referential integrity and so on.

So doing the right thing, the only logic you'll handle in your frontend is interaction logic (i.e. The submit button is disabled till you don't fill this form required inputs...)

If you apply SOLID and KISS, TS is not a need -usually- (some projects can grow in overcomplicated ways I still can't understand 😂)

So, even doing a microservice or a frontend (let's say a React one), adding TS or an extra check for documenting and basic typechecking as contingency wall it's preferred (Robustness).

Take a look at this post to understand better what I'm trying to say.

Hope it helps somehow.

Collapse
 
coryjamescrook profile image
Cory Crook

I develop with typescript on a daily basis. I work in a pretty large codebase, and the static typing has been invaluable in maintaining and growing the codebase in a safe way and has caught many instances where we likely would have run into runtime errors. One less thing to worry about.

That being said, for a small project though, I wouldn't choose to use it most likely. The overhead of properly managing the typing correctly, correct configuration, etc... It can be a lot of work for a much smaller benefit.

This is just my take on it, however. I know people that hate it, and others that swear by it. It really just depends on the context imo

Collapse
 
fjones profile image
FJones

Unsurprisingly, the replies you're getting are full of people defending TypeScript. That may be one of the main reasons why I avoid TypeScript like the plague: It's hailed as the Second Coming, and almost always with a mix of "but it's really just JavaScript!" and "JavaScript without TypeScript is so bad!" (pick your line, people...).

TypeScript has unintelligible syntax at the best of times (go on, tell me how the standard implementation of something as simple as a higher-order arrow function doesn't look absolutely bonkers). It still has a lot of the idiosyncracies of JavaScript (by necessity). It gives a hugely false sense of security (no, just because you declare your response model doesn't mean that UUID the API is giving you is actually a number). And people get incredibly preachy about the benefits of types, to the point that no one seems to stop and look at what the actual effects are: I can't name the last time I actually thought "oh, TS would've prevented this" (and I'm pretty sure most of the cases I remember at all were things that any half-decent linter would have picked up, too, it just would have also thrown a compile error in TS).

Collapse
 
mdovn profile image
mdovn

For me. I don't think that i would like to code in plain js anymore. Even for simple pet project.
Ts offer so much benefits with just a small cost. It prevent me from stupid mistakes. Which sometimes take several hours to debug. With TS, I can even finish a task without having to manual test it. Of course I still write test, but only the valuable part. Not wasting time verifying input type, null value... Etc