Skip to content
DevMeme
4713 of 7590
Languages Post #5164 · source on Telegram

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

20
Anonymous ★ Top Pick 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
  1. Anonymous ★ Top Pick

    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

  2. Anonymous

    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."

  3. Anonymous

    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

  4. Anonymous

    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

  5. Anonymous

    Staff-level rule: enable ESLint eqeqeq and let Scala keep char-as-int math - fewer incidents than any microservice rewrite

  6. Anonymous

    Scala devs see type coercion as promotion; JS devs see it as grounds for a strict equality intervention

  7. @LeslieFn 3y

    how come 3 + 'A' == 68?

    1. @Vernyy_1947 3y

      The ascii code of A is equal to 65

      1. @LeslieFn 3y

        thanks. so scala autocasts char to integer?

        1. @deadgnom32 3y

          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.

  8. @qwnick 3y

    Yeah, but '0' != 0 in Scala, and that makes sense, cause Scala not suck, unlike js

    1. @galafm 3y

      In js we have a strict check !== 😁

      1. @Box_of_the_Fox 3y

        You also have 2 types of null, because 1 wasn't problematic enough

        1. @BotMike 3y

          When you think 2 is too many, there comes Objective-C++ with 5 null types

        2. @deadgnom32 3y

          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.

  9. @imsleeping2223 3y

    "1"-1==0 // 😭 "1"+1=="11" // 🥹

  10. @WatashiWaSeireidesu 3y

    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

    1. dev_meme 3y

      You missed the point. The joke is kinda same type coercion being perceived positive and negative just depending on language adopters preferences 😄

  11. @ArctanK 3y

    Scala is a great and enjoyable language

  12. @ArctanK 3y

    Scala is more functional. It has better implementation of algebraic data types. In all other cases (IMHO) Kotlin is better

Use J and K for navigation