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
98Comment deleted
The five stages of JS grief: denial, anger, bargaining for a lodash function, depression when you see '[] + {}', and finally, acceptance... of TypeScript
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
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
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
JS trauma so real, static typing feels like compile-time bail bondsman for your runtime felonies
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.”
Policy update: after double-equals took prod down, we encode invariants in the type system - and politely ignore that TypeScript erases them at runtime
JS is disgusting Comment deleted
Full stop Comment deleted
it's trauma caused by Java Comment deleted
Java-Script Comment deleted
I'm a Java dev and I fucking hate Java. I would still rather be in Java than JS. Shits gross Comment deleted
as a dev who (forcibly) uses java and javascript, yea Comment deleted
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. Comment deleted
Imma be real chief, there is no use case for JS to me. It's cringe and should be eradicated Comment deleted
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. Comment deleted
then how would html5 games work ? Comment deleted
wasm Comment deleted
for scripting it's better then lua Comment deleted
They are all bad, tho Comment deleted
If they are all bad, maybe the problem is not with them... Comment deleted
with them, cause static type PLs are not all bad Comment deleted
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. Comment deleted
just use agda haskell Comment deleted
yes Comment deleted
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 Comment deleted
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 Comment deleted
what? Comment deleted
you wrote a method that compare 2 strings, user sent a integer and class into it, how will you handle it? Comment deleted
throw an error. dude Comment deleted
throw an error for what case? Comment deleted
just fail fast ever heard of it? Comment deleted
how much code do you need to write to decide is this error or not, and can it be casted in the string correctly? Comment deleted
0 Comment deleted
bullshit XD Comment deleted
you just don't get how to do it Comment deleted
tell me then Comment deleted
you misplaced it with Java Comment deleted
…there's autocompletion for regular js too, yknow Comment deleted
Yeah, powered by the typescript language server Comment deleted
yep, but that doesn't mean you have to use ts Comment deleted
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. Comment deleted
will I though? what for. My php+nginx website runs good as is Comment deleted
still exists for regular js, in my experience Comment deleted
odd Comment deleted
I use static typing because 'dynamic' is a type. Comment deleted
Typescript compiler can typecheck js just as good as ts, it supports special jsdoc syntax for type annotations in comments. Comment deleted
again, odd. It does work for me 🤷♂️ Comment deleted
Just create a tsconfig and set it to something like allowJS: true checkJS: true strict: true Comment deleted
I don't have a tsconfig… Comment deleted
kate with the regular ts LSP Comment deleted
it's preconfigured, you just gotta get it to find your project root Comment deleted
Your data is any, there's nothing to suggest. You should give it a type, just like in ts. Comment deleted
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 Comment deleted
fair Comment deleted
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 :) Comment deleted
For 'overcomplicated' cases (lets pretend they are real) you can resort to 'any'. Comment deleted
right, you can always rely on any as a last resort Comment deleted
as unknown, then pass to typeguards / inline checks to narrow down type (without making runtime vulnerable) Comment deleted
My coworker can't open other people's Python code without spending four hours writing type hints Comment deleted
don't put number where string is expected Comment deleted
let the service die in such case Comment deleted
easy Comment deleted
I did already Comment deleted
you did not, you said that you will write 0 code to handle other data types Comment deleted
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 Comment deleted
why would you get compile error? Comment deleted
bc you put a number where none belongs to Comment deleted
you just don't get it Comment deleted
which is obviously bs Comment deleted
that's it Comment deleted
you don't have types to get compile error Comment deleted
in haskell? Comment deleted
no, I was talking about js Comment deleted
https://t.me/dev_meme/5561?comment=93488 Comment deleted
dude. that's just funny Comment deleted
or any other dynamic type in function definition language Comment deleted
look precisely Comment deleted
it's about haskell Comment deleted
sry than, I meant that js suck, not haskell Comment deleted
well. according JS why the hell should user do anything with code? Comment deleted
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 Comment deleted
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 Comment deleted
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. Comment deleted
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 Comment deleted
-> handle hundreds of types by hand what do you mean? Comment deleted
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 Comment deleted
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 Comment deleted
no you don't Comment deleted
you know, what invariants are for? Comment deleted
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 Comment deleted
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 Comment deleted
just use right tools for the right purpose Comment deleted
and lastly, no. not every program has bugs there are methods to write mathematically probable algorithms. they always work correctly. Comment deleted
you write function to compare 2 strings and put a number there well, why? Comment deleted
if you don't, then let it be the end of the conversation, bc it's just pointless without knowing how to use invariants Comment deleted
I never used JS and I'm still obsessed with static typing, checkmate atheists Comment deleted
It’s love caused by Haskell Comment deleted