Skip to content
DevMeme
5081 of 7590
Languages Post #5561 · source on Telegram

JavaScript Trauma Fuels Static Typing Obsession

Description

This is a two-panel meme using the 'Principal Skinner's Pathetic Fallacy' format from The Simpsons. In the first panel, Principal Skinner is looking thoughtfully out a window with the text: 'COULD IT BE THAT MY OBSESSION WITH STATIC TYPING IS ACTUALLY A KNEE-JERK REACTION TO TRAUMA CAUSED BY JS?'. In the second panel, he has a moment of realization and quickly dismisses the thought, saying, 'NO, ALL DYNAMIC TYPING MUST BE BAD'. The meme humorously captures the sentiment of developers who have experienced the pitfalls of JavaScript's dynamic and loosely-typed nature, such as unexpected runtime errors. It suggests that their strong preference for static typing (found in languages like TypeScript) is less a purely objective choice and more of an emotional overcorrection born from the 'trauma' of debugging JavaScript

Comments

98
Anonymous ★ Top Pick The five stages of JS grief: denial, anger, bargaining for a lodash function, depression when you see '[] + {}', and finally, acceptance... of TypeScript
  1. Anonymous ★ Top Pick

    The five stages of JS grief: denial, anger, bargaining for a lodash function, depression when you see '[] + {}', and finally, acceptance... of TypeScript

  2. Anonymous

    I swear I’m not anti-dynamic… it’s just that every time I remember chasing “undefined is not a function” at 2 a.m. on Node 0.12, my fight-or-flight response autogenerates 300 lines of TypeScript generics

  3. Anonymous

    After spending three days debugging a production issue caused by '[] + {} === '[object Object]', you too would start treating every untyped variable like it's carrying a ticking time bomb. The real trauma isn't the dynamic typing - it's explaining to the CTO why a simple equality check brought down the payment service

  4. Anonymous

    After years of debugging 'undefined is not a function' at 3 AM in production, many senior engineers develop what psychologists call 'JavaScript PTSD' - a condition where the mere sight of 'any' in TypeScript triggers fight-or-flight responses. The real irony? We've now created type systems so complex that the type errors are harder to debug than the runtime errors we were trying to avoid. Perhaps the real trauma was the friends we made along the way... in the #typescript-help channel

  5. Anonymous

    JS trauma so real, static typing feels like compile-time bail bondsman for your runtime felonies

  6. Anonymous

    After enough JS, you realize static types are prepaid incident credits: a compiler screaming “Type ‘never’ is not assignable” beats prod screaming “undefined is not a function.”

  7. Anonymous

    Policy update: after double-equals took prod down, we encode invariants in the type system - and politely ignore that TypeScript erases them at runtime

  8. @JManray 2y

    JS is disgusting

  9. @JManray 2y

    Full stop

  10. @deadgnom32 2y

    it's trauma caused by Java

    1. @dsmagikswsa 2y

      Java-Script

    2. @JManray 2y

      I'm a Java dev and I fucking hate Java. I would still rather be in Java than JS. Shits gross

      1. @RiedleroD 2y

        as a dev who (forcibly) uses java and javascript, yea

      2. @deadgnom32 2y

        it depends on the use case. I preach often, that JS is like mathematics, you must take care yourself, to not apply some operator to a wrong entity.

        1. @JManray 2y

          Imma be real chief, there is no use case for JS to me. It's cringe and should be eradicated

          1. @deadgnom32 2y

            let's say matrix multiplication. it's meaningless by itself it gains a meaning depending on case with square matrices, aka. linear operators, multiplication works like function composition. with adjacency matrices it shows common neighbors of two systems. but a diablo 1 map can also be displayed as 2D array, aka. matrix. if you multiply 2 maps you will get trash in result, even though interface can be applied. the same is with JS. you need to think what you do. not all can do it, many programmers can only scroll through hundreds of methods looking for one doing exactly the task they want to solve.

          2. @callofvoid0 2y

            then how would html5 games work ?

            1. @RiedleroD 2y

              wasm

          3. Deleted Account 2y

            for scripting it's better then lua

  11. @qwnick 2y

    They are all bad, tho

    1. Yuri 2y

      If they are all bad, maybe the problem is not with them...

      1. @qwnick 2y

        with them, cause static type PLs are not all bad

        1. @deadgnom32 2y

          ofc are they not. but you need static typing, where you need static typing, and you need dynamic typing, where you need dynamic. you don't need to generate hundreds of temlated classes where you just could use dynamic types.

          1. Deleted Account 2y

            just use agda haskell

            1. @deadgnom32 2y

              yes

            2. @deadgnom32 2y

              they help you do your work at least, instead of punching you in the stomach telling you something like "I know what you meant to do, but write it more explicit with more bloat code" oh yeah, great, the compiler understands me, but don't wanna be friends with meee

              1. @qwnick 2y

                Lol, and also you have to make sure that each method that accept string(or any other data type) will cut all other possible data types. gl with that

                1. @deadgnom32 2y

                  what?

                  1. @qwnick 2y

                    you wrote a method that compare 2 strings, user sent a integer and class into it, how will you handle it?

                    1. @deadgnom32 2y

                      throw an error. dude

                      1. @qwnick 2y

                        throw an error for what case?

                        1. @deadgnom32 2y

                          just fail fast ever heard of it?

                          1. @qwnick 2y

                            how much code do you need to write to decide is this error or not, and can it be casted in the string correctly?

                            1. @deadgnom32 2y

                              0

                              1. @qwnick 2y

                                bullshit XD

                                1. @deadgnom32 2y

                                  you just don't get how to do it

                                  1. @qwnick 2y

                                    tell me then

                2. @deadgnom32 2y

                  you misplaced it with Java

  12. @RiedleroD 2y

    …there's autocompletion for regular js too, yknow

    1. @x4erem6a 2y

      Yeah, powered by the typescript language server

      1. @RiedleroD 2y

        yep, but that doesn't mean you have to use ts

        1. @x4erem6a 2y

          You don't have to but if you're still relying on ts tooling there's little difference. The only advantage of using js is not having a build step, which is probably pointless because you will still use some kind of bundler/transpiler most of the time.

          1. @RiedleroD 2y

            will I though? what for. My php+nginx website runs good as is

  13. @RiedleroD 2y

    still exists for regular js, in my experience

  14. @RiedleroD 2y

    odd

  15. @Araalith 2y

    I use static typing because 'dynamic' is a type.

  16. @x4erem6a 2y

    Typescript compiler can typecheck js just as good as ts, it supports special jsdoc syntax for type annotations in comments.

  17. @RiedleroD 2y

    again, odd. It does work for me 🤷‍♂️

  18. @x4erem6a 2y

    Just create a tsconfig and set it to something like allowJS: true checkJS: true strict: true

    1. @RiedleroD 2y

      I don't have a tsconfig…

  19. @RiedleroD 2y

    kate with the regular ts LSP

    1. @RiedleroD 2y

      it's preconfigured, you just gotta get it to find your project root

  20. @x4erem6a 2y

    Your data is any, there's nothing to suggest. You should give it a type, just like in ts.

  21. @RiedleroD 2y

    because data is of type any here, obv you won't get far with js here. I get what you mean now, but that's not really a problem for me because of how I usually program js

  22. @RiedleroD 2y

    fair

  23. @pwnzkk 2y

    Both js and ts are cool. There are cases though when typing becomes too overcomplicated for some tricky functions and it doesn’t work, so I would say it’s cool to use typescript when typing and fighting with compilation errors is not 90% of your coding. Personally I love ts for its type system and js for flexibility, so just choose your poison :)

    1. @Araalith 2y

      For 'overcomplicated' cases (lets pretend they are real) you can resort to 'any'.

      1. @pwnzkk 2y

        right, you can always rely on any as a last resort

    2. @NaNmber 2y

      as unknown, then pass to typeguards / inline checks to narrow down type (without making runtime vulnerable)

  24. @anilakar 2y

    My coworker can't open other people's Python code without spending four hours writing type hints

  25. @deadgnom32 2y

    don't put number where string is expected

  26. @deadgnom32 2y

    let the service die in such case

  27. @deadgnom32 2y

    easy

  28. @deadgnom32 2y

    I did already

    1. @qwnick 2y

      you did not, you said that you will write 0 code to handle other data types

      1. @deadgnom32 2y

        you just don't handle them. you will get a compile error a forehead, and fix it, by not putting other data types into a function expecting string

        1. @qwnick 2y

          why would you get compile error?

          1. @deadgnom32 2y

            bc you put a number where none belongs to

  29. @deadgnom32 2y

    you just don't get it

  30. @qwnick 2y

    which is obviously bs

  31. @deadgnom32 2y

    that's it

  32. @qwnick 2y

    you don't have types to get compile error

    1. @deadgnom32 2y

      in haskell?

      1. @qwnick 2y

        no, I was talking about js

        1. @deadgnom32 2y

          https://t.me/dev_meme/5561?comment=93488

    2. @deadgnom32 2y

      dude. that's just funny

  33. @qwnick 2y

    or any other dynamic type in function definition language

  34. @deadgnom32 2y

    look precisely

  35. @deadgnom32 2y

    it's about haskell

    1. @qwnick 2y

      sry than, I meant that js suck, not haskell

      1. @deadgnom32 2y

        well. according JS why the hell should user do anything with code?

      2. @deadgnom32 2y

        it still can by weakly casted to something and executed somehow, but result will be trash if you dont put strings into it. the problem is not JS, it's a programmer

        1. @qwnick 2y

          There is bugs in any programmers code. Difference that it is much easier to catch if it's static typed language, compile error is much more comfortable to work with, unlike runtime error in prod

          1. @deadgnom32 2y

            this is pointless. yeah. you are right. that's why all the data scientists and engineers use pandas. they are just masochistic bastards who love to suffer. I get it.

          2. @deadgnom32 2y

            your cumfort is just bent to your use cases, until you run into one, where you will need to handle hundreds of types by hand, where just a generic Anything type is needed

            1. @qwnick 2y

              -> handle hundreds of types by hand what do you mean?

              1. @deadgnom32 2y

                if your interface is so abstract, that it can handle every or nearly every type in statically typed language you just use workarounds like upcast to a generic object or templating sugar, which generates every version of statically typed function bloating the binary. just take a dynamically typed language instead

                1. @qwnick 2y

                  took, you still have to handle hundreds of types by hand, but now you don't have compile error if you made a mistake somewhere XD

                  1. @deadgnom32 2y

                    no you don't

                  2. @deadgnom32 2y

                    you know, what invariants are for?

              2. @deadgnom32 2y

                ima data engineer, I do work with hella a lot of types on very few interfaces. static typing is just a lot of needless work. because oftentimes I just need the layout of the data independently of the type. I just don't care

                1. @deadgnom32 2y

                  if I do care, I can explicitly cast it to some type ensuring it invariantness, and then I just know, a string is a string. and never a number or anything. what can't be converted either makes the service instance die, that it intended and handled elsewhere, or just left out of the data set with a warning

          3. @deadgnom32 2y

            just use right tools for the right purpose

          4. @deadgnom32 2y

            and lastly, no. not every program has bugs there are methods to write mathematically probable algorithms. they always work correctly.

  36. @deadgnom32 2y

    you write function to compare 2 strings and put a number there well, why?

  37. @deadgnom32 2y

    if you don't, then let it be the end of the conversation, bc it's just pointless without knowing how to use invariants

  38. @ColonelPhantom 2y

    I never used JS and I'm still obsessed with static typing, checkmate atheists

  39. @golergka 2y

    It’s love caused by Haskell

Use J and K for navigation