this post was submitted on 14 Nov 2023
5 points (100.0% liked)

Programmer Humor

32415 readers
253 users here now

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

Rules:

founded 5 years ago
MODERATORS
 
top 18 comments
sorted by: hot top controversial new old
[–] Pxtl@lemmy.ca 0 points 1 year ago (1 children)

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

[–] atyaz@reddthat.com 0 points 1 year ago (1 children)

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.

[–] Pxtl@lemmy.ca 0 points 1 year ago* (last edited 1 year ago) (1 children)

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@feddit.de 0 points 1 year ago

Tell that to the NodeJS people...

[–] callyral@pawb.social 0 points 1 year ago* (last edited 1 year ago) (1 children)

tomatoes are fruits that are often used as vegetables and are botanically classified as berries*

*according to wikipedia and my interpretation of it

[–] frezik@midwest.social 0 points 1 year ago (1 children)

I once saw a little blurb at a sandwich shop stating that tomatoes are fruit, but if you pair them on a sandwich with jalapenos, you're getting both fruits and vegetables. I demand better scientific accuracy in restaurant marketing signs.

[–] Bene7rddso@feddit.de 0 points 1 year ago

Now I wonder if jalapenos are fruit too (scientifically)

[–] scorpionix@feddit.de 0 points 1 year ago (1 children)

Am I missing the joke? Tomatoes are fruits.

[–] hypertown@lemmy.world 0 points 1 year ago (1 children)

Well, that depends on definition. But the joke is why on earth would you want to write types on your shopping list? Like this:

  • tomatos (vegetable)
  • apples (fruit)

Etc.

[–] scorpionix@feddit.de 0 points 1 year ago

Well, I can't think of an English example from the top of my head, but in German the words for Pear and (light) bulb are the same. So there are some exotic use cases.

[–] JakenVeina@lemm.ee 0 points 1 year ago (1 children)

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.

[–] DrM@feddit.de 0 points 1 year ago (1 children)

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

[–] CanadaPlus@lemmy.sdf.org 0 points 1 year ago (1 children)

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

[–] DrM@feddit.de 0 points 1 year ago* (last edited 1 year ago) (1 children)

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:

@Get('valueOfMyBoolean')
@ApiQuery(
  {
    name: 'myBoolean',
    type: boolean,
  }
)
myBooleanFunction(
  @Query('myBoolean') myBoolean: boolean
){
  if(myBoolean){
    return 'myBoolean is true';
  }
  return 'myBoolean is false';
}

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.

[–] CanadaPlus@lemmy.sdf.org 0 points 1 year ago (1 children)

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@sh.itjust.works 0 points 1 year ago* (last edited 1 year ago) (1 children)

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

https://github.com/DefinitelyTyped/DefinitelyTyped

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

[–] CanadaPlus@lemmy.sdf.org 0 points 11 months ago* (last edited 11 months ago) (1 children)

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@feddit.de 0 points 11 months ago

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