• 0 Posts
  • 23 Comments
Joined 6 months ago
cake
Cake day: March 22nd, 2025

help-circle


  • I was on a project a while back that used Ruby, and what I concluded was that cute things like that look good at first glance if you’re skim-reading some already-correct code, but are pretty much a net wash in terms of writing or debugging code.

    It’s not unusual for people to think that code would be better if it scanned like regular English, but the problem is that English is woefully imprecise and doesn’t always correlate to what kind of operations get run by the code, and so you still end up having to learn all that syntax and mentally process it like any other programming language anyway, but now you’ve also got a bunch of false friends tricking you into thinking they do one thing but actually they do another.

    (also, the bulk of the text in that python example is the import statement, which is like… ok so what, it’s not like Ruby doesn’t have its own dependency hell problems)





  • skisnow@lemmy.catoFunny@sh.itjust.worksCall of Daddy
    link
    fedilink
    English
    arrow-up
    5
    arrow-down
    3
    ·
    edit-2
    28 days ago

    This is what they call the exception proving the rule; you think you’ve countered them, but by explaining that it’s literally one of three army surplus shops you have to go to and not just the local Wal-Mart equivalent (EDIT: or whatever clothing store, the size of the chain isn’t relevant), you’ve proven their point quite well.



  • skisnow@lemmy.catoMemes@lemmy.mlThe ratings would be through the roof.
    link
    fedilink
    English
    arrow-up
    17
    arrow-down
    1
    ·
    2 months ago

    Total annual healthcare cost: $4.9 trillion

    Guess why that number is so much higher per capita, than it is in countries with universal healthcare.

    Also, spending their money isn’t the only benefit to boiling them in lead. You also get the benefit of them not using that money to corrupt democracy, or fund propaganda designed to turn the working class against itself.





  • Yeah, some of the bandwagonny replies I’m seeing in this thread do not make their posters sound like someone you’d want to spend your working life sat next to.

    You don’t have to show interest in the company to help the CEO get richer, but you should probably show an interest in the company because it’s where you’re going to be spending 1/3rd of your entire waking hours from now on, and you’re going to have a fucking miserable time of it if you’ve already decided to mentally check out before you’ve even got to the interview. Have some self-respect.







  • The code is a set of preprocessor macros to stuff loads of booleans into one int (or similar), in this case named ‘myFlags’. The preprocessor is a simple (some argue too simple) step at the start of compilation that modifies the source code on its way to the real compiler by substituting #defines, prepending #include’d files, etc.

    If myFlags is equal to, e.g. 67, that’s 01000011, meaning that BV00, BV01, and BV07 are all TRUE and the others are FALSE.

    The first part is just for convenience and readability. BV00 represents the 0th bit, BV01 is the first etc. (1 << 3) means 00000001, bit shifted left three times so it becomes 00001000 (aka 8).

    The middle chunk defines macros to make bit operations more human-readable.

    SET_BIT(myFlags, MY_FIRST_BOOLEAN) gets turned into ((myFlags) |= ((1 << 0))) , which could be simplified as myFlags = myFlags | 00000001 . (Ignore the flood of parentheses, they’re there for safety due to the loaded shotgun nature of the preprocessor.)


  • Back in the day when it mattered, we did it like

    #define BV00		(1 <<  0)
    #define BV01		(1 <<  1)
    #define BV02		(1 <<  2)
    #define BV03		(1 <<  3)
    ...etc
    
    #define IS_SET(flag, bit)	((flag) & (bit))
    #define SET_BIT(var, bit)	((var) |= (bit))
    #define REMOVE_BIT(var, bit)	((var) &= ~(bit))
    #define TOGGLE_BIT(var, bit)	((var) ^= (bit))
    
    ....then...
    #define MY_FIRST_BOOLEAN BV00
    SET_BIT(myFlags, MY_FIRST_BOOLEAN)