cupcakezealot,
@cupcakezealot@lemmy.blahaj.zone avatar

somewhere brodie lee just threw some papers

Default_Defect,
@Default_Defect@midwest.social avatar

Evil Uno hits the floor wailing.

qwertyWarlord,

I don’t like it but God help me if I try to bring up that we shouldn’t use it. I understand it I just don’t like how it slows everything down for in my opinion is not much gain.

Presi300,
@Presi300@lemmy.world avatar

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.

Tau,

It helps for when you have a variable that’s for numbers and you use it as a string or something else, it shouts an error. In other words, it protects you from yourself

traches,

Typescript gives you better suggestions, red squiggles where you would get errors or bugs if you try to run it, more information about whatever it is you’re using that’s defined somewhere else, and some other neat stuff like project-wide renaming that works every time.

andreax,

No, it is slower than JS but it can be compiled to JS. The point of typescript is bringing static (or generally talking, predictable) types to variables, so that treating erroneously a number as a string should be more difficult. In a large codebase, it’s easy to make mistakes and debugging is not instantaneous but it needs time. Typescript helps here. You write more code but it helps you out later

Presi300,
@Presi300@lemmy.world avatar

TS syntax is still the most cursed thing I’ve ever seen

stinodes,

Then it just sounds like you’ve not written any typed languages yet

Presi300,
@Presi300@lemmy.world avatar

I have some knowledge on C# and I’ve used C++ before… I really like C# (Ik it’s not technically fully statically typed but it gets the point across), ASP.net just has too many hoops to jump through just to get a project started, it’s kinda annoying.

mea_rah,

I don’t have much experience with TS, but in other strongly typed language it goes even further than string vs number.

For example you can have two numbers Distance and TimeInSeconds and even though they are both numbers, the type system can make sure that you won’t do distance+time.

It can also let you do distance/time and return Speed type.

It will prevent many logical errors even though everything is technically a number.

ebc,

As a beginner you don’t see the benefits as it is indeed JS with extra steps. It’s not worth it for small projects and prototypes, but once you start having larger projects where you need to refactor something, you’ll see the benefits.

Also, auto-complete.

FooBarrington,

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,

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

purpleprophy,

After maintaining a huge JS codebase for years and finally upgrading it to TS, my life is so much easier. Refactoring is faster and less error-prone. I no longer have to manually document the parameter/return types for every function. I don’t have that gnawing “oh damn, what if I missed something” feeling whenever I make changes.

Yes it’s a bit more work up front but it pays dividends on larger codebases.

uis,
@uis@lemmy.world avatar

Biologists: but tomato is a berry, which is subset of fruits

zalgotext,

Also biologists: “vegetable” is purely a culinary term, and doesn’t have any significance in the world of botany

uis,
@uis@lemmy.world avatar

Exactly

CileTheSane,
@CileTheSane@lemmy.ca avatar

A vegetable is edible plant matter.

Botanically a vegetable is anything that is not the reproductive portion of the plant derived from a flower. A root or tuber such as for yam or potato are vegetables. Edible flowers could be considered a vegetable since the ovary has not expanded to contain seed.

tias,

As it happens, when we go shopping for food we have more of a culinary mindset than botanical.

Pxtl,
@Pxtl@lemmy.ca avatar

The fact that this meme makes sense to anyone demonstrates how dynamic typed programming languages cause brain damage.

atyaz,

I prefer to think of it as maybe don’t shoehorn a shitty type checker into a dynamic language. Honestly I think people who get excited about typescript should fuck off and go write java instead.

Tau,

That’s what WASM is for, but it’s not there yet :(

And you still have to use js for hooks and stuff

Pxtl,
@Pxtl@lemmy.ca avatar

JS is the one that’s built into the browser. If JS wasn’t built into the browser, it would go onto the trashbin of bad old languages that only survived because of their platform like VBA and ActionScript and .bat batch scripting. You can’t compare JS to any other language because JS is the one you don’t get a choice on.

Bene7rddso,

Tell that to the NodeJS people…

jubilationtcornpone,

I’ve heard it said that the longer you work with JavaScript, the more you hate it. I’m not gonna lie, I really miss working on ASP.Net Core backends. Switching from that to NodeJS was a huge downgrade.

Pxtl,
@Pxtl@lemmy.ca avatar

Stockholm syndrome.

atyaz,

Fine but whatever you think about js, dynamic languages have certain advantages, and trying to turn it into another java or c# is a stupid endeavor. You’re not “fixing” javascript by making it more like java.

Witchfire,
@Witchfire@lemmy.world avatar

The type checker is actually pretty smart and can handle a lot of weird use cases, especially in strict mode (if you mark everything as Any type, that’s on you). The fact that the underlying language is very dynamic can be both good and bad. It’s good because you can be flexible when you need to be, but it also won’t prevent you from writing really shitty code, which lends it its reputation.

I don’t know if you’ve ever tried writing frontends in Java, but it is terrible, especially if you want to make dynamic and accessible UIs. You don’t use a power drill when you need to hammer a nail.

atyaz,

My comment was obviously devoid of any nuance, I am on programmer humor after all. I actually do use typescript, but I think fixing issues in application code that isn’t used by other code is a waste of time. I also think there are lots of advantages of a very dynamic language, like usable REPLs and much easier debugging. We can take these advantages way further by embracing the dynamic nature of javascript, like how lisps do it for example. But instead, everyone is happy going down the route of turning it into another c# (nothing against c# but we don’t need all languages to be c# and java).

JakenVeina,

I like TypeScript less for its ability to categorize my grocery list and more for its ability to stop anyone from putting cyanide on it.

AngryCommieKender,

Two questions immediately come to mind. 1) Would you buy the cyanide if it was on the list. 2) Where does one casually buy cyanide? I can’t imagine a case where I’d need some, but it would be handy to know if I ever did.

XTornado,

Just one word: Apples.

CanadaPlus,

I know you used to be able to get it for pest control, but maybe not anymore. You could also make it the old-fashioned way with molten washing soda. It can be used to make Prussian blue, for one thing.

Obviously take all necessary precautions, especially keeping NaCN away from acids.

DrM,

I hate Typescript for promising me that nobody can put cyanide on the list, but in reality it disallows ME from putting cyanide on the list, but everyone else from the outside is still allowed to do so by using the API which is plain JavaScript again

JakenVeina,

Fair enough.

CanadaPlus,

Honestly, programming is great for teaching you that you are the stupid one. This is still a feature.

DrM,

The main problem with JavaScript and TypeScript is that there is such a little entrybarrier to it, that way too many people use it without understanding it. The amount of times that we had major issues in production because someone doesn’t understand TypeScript is not countable anymore and our project went live only 4 months ago.

For example, when you use nest.js and want to use a boolean value as a query parameter.

As an example:


<span style="color:#323232;">@Get('valueOfMyBoolean')
</span><span style="color:#323232;">@ApiQuery(
</span><span style="color:#323232;">  {
</span><span style="color:#323232;">    name: 'myBoolean',
</span><span style="color:#323232;">    type: boolean,
</span><span style="color:#323232;">  }
</span><span style="color:#323232;">)
</span><span style="color:#323232;">myBooleanFunction(
</span><span style="color:#323232;">  @Query('myBoolean') myBoolean: boolean
</span><span style="color:#323232;">){
</span><span style="color:#323232;">  if(myBoolean){
</span><span style="color:#323232;">    return 'myBoolean is true';
</span><span style="color:#323232;">  }
</span><span style="color:#323232;">  return 'myBoolean is false';
</span><span style="color:#323232;">}
</span>

You see this code. You don’t see anything wrong with it. The architect looks at it in code review and doesn’t see anything wrong with it. But then you do a GET https://something.com/valueOfMyBoolean?myBoolean=false and you get “myBoolean is true” and if you do typeOf(myBoolean) you will see that, despite you declaring it twice, myBoolean is not a boolean but a string. But when running the unit-tests, myBoolean is a boolean.

jpeps,

Typically when creating API interfaces you’d be better off marking the inputs as unknown, and then using something like Zod to validate the types

CanadaPlus,

I’ve never used TS, and I’m not exactly sure what nest.js even does, but building a TypeScript project on top of a JavaScript library not designed for it seems like asking for trouble. Is that standard practice?

sloppy_diffuser,

Yes. As of this writing there are 7,738 type definitions in a central repo maintained by users for plain JavaScript packages.

github.com/DefinitelyTyped/DefinitelyTyped

Many package owners write type definitions included with their package that is written in JavaScript also.

CanadaPlus, (edited )

Web dev continues to be cursed, I guess.

If I really needed to use a JS library in TS, I’d have to build some sort of adapter between the two that crashes whenever the JS library (that doesn’t know anything about your types) breaks the typing rules. Anything else will inevitably lead to the above “fun” kind of bugs.

DrM,

I don’t think that this would work, there are no types anymore during runtime because everything is translated into plain js on build. TypeScript only exists during development

uis,
@uis@lemmy.world avatar

return ‘myBoolean is true’;

I instantly noticed this line. Shitcode is so fun.

shasta,

This is more a condemnation of nest.js than ts. It seems great in theory. I like the architecture and the ability to share models and interfaces between front and backend, but it’s objectively makes everything more complicated. It adds layers of abstraction that should not be necessary and it’s such a niche/unpopular framework for backend systems that you generally have to jump through hoops to do anything moderately complex. Not only do new devs have to learn typescript to use it, they have to learn the nest architecture to know how to do things “the right way” and you still end up in situations like this which looks perfectly valid but isn’t. Typescript was never meant to be used for backend, and trying to make it do so and then complaining about it is like jogging while carrying a gun, shooting yourself in the foot, and blaming the gun.

zalgotext,

the ability to share models and interfaces between front and backend

On the other hand, this can be considered a downside because it locks you into using JS/TS on the front and backends.

Alternatively, if you define your models and interface with an Open API spec, you can write the front and backends in whatever language you want.

aeharding,
@aeharding@lemmy.world avatar

Report -> I’m in this picture and I don’t like it

ShroOmeric,

I swear to god, sometimes I really don’t know what Typescript really wants from me. It’s like some old god: you know it needs a sacrifice but the god is not telling you exactly what he wants. So you can only try and pray.

MashedTech,

Idk, I find it pretty easy to understand

herrvogel,

The "return type <5 paragraphs of various word salads> is not compatible with " error messages are anything but easy to understand in my opinion.

gornius,

Yeah I don’t get why it spits out whole types instead of only differences between them. Like “function expects non-null ‘some.param.in.object’ of type ‘string’ in argument ‘someArgument’, which is missing in passed argument”.

traches,

Typescript got a lot easier for me when I stopped even trying to read the error messages

yoast,

I’ve seen versions of this meme before but I just noticed what he’s wearing. Is that a Mortal Kombat shirt?

independantiste,
@independantiste@sh.itjust.works avatar

Tomato: Any

lorty,
@lorty@lemmy.ml avatar

Guess it’s not only Typescript that likes to argue with the developer while missing the entire point…

schaeferpp,
@schaeferpp@discuss.tchncs.de avatar

I’m a bit disappointed that nobody mentioned Rust yet.

aluminium,

I’d say its more like the gas tank telling you that you aren’t allowed to pour in brake fluid as that could lead to runtime errors.

TrickDacy,

So much funnier

hansl,

<span style="color:#323232;">tank.pour(brakeFluid as Any); // do not remove this for some reason will break prod
</span>
Cysioland,
@Cysioland@lemmygrad.ml avatar

Intelligence is knowing that tomato is a fruit, wisdom is not putting it in a fruit salad

ares35,
ares35 avatar

but 'ketchup goes on anything!'
-my grampa

gbuttersnaps,

Charisma is being able to sell a fruit salad with tomatoes in it.

bjoern_tantau,
@bjoern_tantau@swg-empire.de avatar

Dexterity is hacking everything into nice looking pieces.

tetris11,
@tetris11@lemmy.ml avatar

Malovelence is scooping the entire oily thing with your hands and shoving it into the nearest hole.

PoolloverNathan,

Strength is cutting the cutting board in half while you’re cutting up the tomatoes.

bestusername,
@bestusername@aussie.zone avatar

Yeah… What?

Tomatoes are fruits.

fl42v,

Aren’t they berries, tho?

V0lD,

Botanically they are. Culinary they are not.

Some languages split the word “fruit” up in those two cases. In Dutch for example, the botanical definition of fruit translates to “vrucht” whereas the culinary definition translates to “fruit”.

So, a tomato is a “vrucht” but it’s not “fruit”

dan,
@dan@upvote.au avatar

Some languages split the word “fruit” up in those two cases

I wish English did this more. There’s way too many words with an overly large number of meanings.

The word “free” meaning both “freedom” and “doesn’t cost money” can be confusing - some languages use “gratis” or an equivalent word for the latter definition. Sure, you can use it as a Latin loan word in English, but that’s not common.

FlyingSquid,
@FlyingSquid@lemmy.world avatar

Would you put a tomato in a fruit salad?

  • All
  • Subscribed
  • Moderated
  • Favorites
  • programmerhumor@lemmy.ml
  • ngwrru68w68
  • DreamBathrooms
  • thenastyranch
  • magazineikmin
  • InstantRegret
  • GTA5RPClips
  • Youngstown
  • everett
  • slotface
  • rosin
  • osvaldo12
  • mdbf
  • kavyap
  • cubers
  • megavids
  • modclub
  • normalnudes
  • tester
  • khanakhh
  • Durango
  • ethstaker
  • tacticalgear
  • Leos
  • provamag3
  • anitta
  • cisconetworking
  • JUstTest
  • lostlight
  • All magazines