this post was submitted on 14 Nov 2023
808 points (94.6% liked)

Programmer Humor

32461 readers
600 users here now

Post funny things about programming here! (Or just rant about your favourite programming language.)

Rules:

founded 5 years ago
MODERATORS
 
you are viewing a single comment's thread
view the rest of the comments
[–] Presi300@lemmy.world -2 points 1 year ago (11 children)

As someone who is relatively new to webdev stuff, I gotta ask... what is the point of typescript? Like, is it faster than JS, does it have more functions or smth? To me it just looks like JS with extra steps and a really, REALLY cursed way to declare variables.

[–] FooBarrington@lemmy.world 12 points 1 year ago* (last edited 1 year ago) (2 children)

Types help you prevent errors while writing the code instead of while running. That's a massive benefit, as it literally makes a lot of errors impossible (as long as you don't work around it) - otherwise you have to write a lot of tests to get the same guarantees, and you could always miss something by doing that.

The other benefit is that it allows other developers to understand your code very, very quickly. Types describe what your data looks like - there is nothing more important in programming than that!

When you install an NPM library and your editor gives you hints about parameter types, return types etc., that's all Typescript types at work.

[–] andreax@lemm.ee 3 points 1 year ago

Your answer and mine are complementary, they definitely complete each other! Well done!

load more comments (1 replies)
load more comments (9 replies)