Swole Doge vs Cheems shows Scala vs JavaScript type-coercion woes
Description
Two Doge meme panels illustrate language quirks: on the left, a hyper-muscular Doge labeled "Scala devs" stands proudly, captioned "3 + 'A' is equal to 68? What a great language!" On the right, a sad, slumped Doge labeled "JS devs" laments, "Oh no, 0 is equal to '0', this ruins my whole day. I hate this language so much." The image contrasts Scala’s implicit char-to-ASCII numeric addition with JavaScript’s loose equality coercion, poking fun at how different type systems and equality rules affect developer happiness. The visual uses the popular "Swole Doge vs Cheems" format, highlighting ongoing debates among senior engineers about strong vs weak typing, language design trade-offs, and daily developer experience
Comments
20Comment deleted
Scala’s implicit Numeric[Char] turns 3 + 'A' into 68 with chest-day confidence, while JavaScript’s 0 == '0' just reminds me that lenient coercion is basically Stockholm syndrome in curly braces
Scala devs explaining type coercion: "It's just ASCII arithmetic." JS devs explaining type coercion: "So we wrote a 47-page ESLint config and three custom Babel plugins to make === the default, but somehow null still isn't an object except when it is."
The real irony here is that both examples are technically runtime behaviors - Scala's implicit conversions can be just as surprising when you accidentally import the wrong scope, and seasoned JS devs learned to use === in 2010. But sure, let's pretend the language choice is what separates the 10x engineers from the rest of us mortals still debugging production at 2 AM regardless of our type system
Scala: Char is numerically widened, so 3 + 'A' = 68; JavaScript: abstract equality does ToNumber, so 0 == '0' = true - prefer === unless you enjoy on-call archaeology
Staff-level rule: enable ESLint eqeqeq and let Scala keep char-as-int math - fewer incidents than any microservice rewrite
Scala devs see type coercion as promotion; JS devs see it as grounds for a strict equality intervention
how come 3 + 'A' == 68? Comment deleted
The ascii code of A is equal to 65 Comment deleted
thanks. so scala autocasts char to integer? Comment deleted
char is a number, you don't need to cast it. it's just 1 byte of numbers from the very beginning. letters are just visual interpretation. Comment deleted
Yeah, but '0' != 0 in Scala, and that makes sense, cause Scala not suck, unlike js Comment deleted
In js we have a strict check !== 😁 Comment deleted
You also have 2 types of null, because 1 wasn't problematic enough Comment deleted
When you think 2 is too many, there comes Objective-C++ with 5 null types Comment deleted
well, 1 is undefined and it means you forgot to define result null is no result. but also you can easily implement a Maybe monad and then redefine types such as undefined and null means the same and in your code there is only a value or Nothing. by encountering a undefined or null return, you know it IS undefined indeed and needs a proper monadic return. Comment deleted
"1"-1==0 // 😭 "1"+1=="11" // 🥹 Comment deleted
People that doesn’t understand type coercion all around In JS 0 is not equal to ‘0’ unless you use type coercion to compare, which you shouldn’t unless you know what you are doing. Just use strict comparison otherwise and by default Comment deleted
You missed the point. The joke is kinda same type coercion being perceived positive and negative just depending on language adopters preferences 😄 Comment deleted
Scala is a great and enjoyable language Comment deleted
Scala is more functional. It has better implementation of algebraic data types. In all other cases (IMHO) Kotlin is better Comment deleted