• 0 Posts
  • 2 Comments
Joined 1 year ago
cake
Cake day: June 25th, 2023

help-circle
  • __LINE__ returns the line of code its on, and % 10 means “remainder 10.” Examples:

    1 % 10 == 1
    ...
    8 % 10 == 8
    9 % 10 == 9
    10 % 10 == 0 <-- loops back to 0
    11 % 10 == 1
    12 % 10 == 2
    ...
    19 % 10 == 9
    20 % 10 == 0
    21 % 10 == 1
    

    In code, 0 means false and 1 (and 2, 3, 4, …) means true.

    So, if on line 10, you say:

    int dont_delete_database = true;
    

    then it will expand to:

    int dont_delete_database = ( 10 % 10 );
    // 10 % 10 == 0 which means false
    // database dies...
    

    if you add a line before it, so that the code moves to line 11, then suddenly it works:

    // THIS COMMENT PREVENTS DATABASE FROM DYING
    int dont_delete_database = ( 11 % 10 );
    // 11 % 10 == 1, which means true
    

  • I’m not really involved in javascript land so im parroting off of what i’ve heard for “why js over ts?”

    • it reduces file size since you no longer need to ship source maps
    • ctrl+clicking stuff will take you to the definition rather than an unhelpful type declaration
    • if you spot a bug in the library, you can edit the source directly than having to recompile/reimport
    • ts adds some unnecessary type “gymnastics” (can’t speak for what this means), when all they really want is intellisense thru jsdoc

    So mainly: devs who don’t prefer strongly typed languages, and library devs who find typescript to be less transparent and more time consuming for new and old contributors than it’s worth