Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Brand Logo

agnos.is Forums

  1. Home
  2. Programmer Humor
  3. Tell me the truth ...

Tell me the truth ...

Scheduled Pinned Locked Moved Programmer Humor
programmerhumor
32 Posts 20 Posters 3 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • lucien@mander.xyzL [email protected]

    Depending on the language

    M This user is from outside of this forum
    M This user is from outside of this forum
    [email protected]
    wrote on last edited by
    #3

    And compiler. And hardware architecture. And optimization flags.

    As usual, it's some developer that knows little enough to think the walls they see around enclose the entire world.

    T 1 Reply Last reply
    2
    • cm0002@lemmy.worldC [email protected]
      This post did not contain any content.
      J This user is from outside of this forum
      J This user is from outside of this forum
      [email protected]
      wrote on last edited by
      #4

      It's far more often stored in a word, so 32-64 bytes, depending on the target architecture. At least in most languages.

      T 1 Reply Last reply
      0
      • cm0002@lemmy.worldC [email protected]
        This post did not contain any content.
        S This user is from outside of this forum
        S This user is from outside of this forum
        [email protected]
        wrote on last edited by
        #5

        Are you telling me that no compiler optimizes this? Why?

        T 1 Reply Last reply
        0
        • S [email protected]

          Are you telling me that no compiler optimizes this? Why?

          T This user is from outside of this forum
          T This user is from outside of this forum
          [email protected]
          wrote on last edited by
          #6

          Well there are containers that store booleans in single bits (e.g. std::vector<bool> - which was famously a big mistake).

          But in the general case you don't want that because it would be slower.

          E 1 Reply Last reply
          0
          • J [email protected]

            It's far more often stored in a word, so 32-64 bytes, depending on the target architecture. At least in most languages.

            T This user is from outside of this forum
            T This user is from outside of this forum
            [email protected]
            wrote on last edited by
            #7

            No it isn't. All statically typed languages I know of use a byte. Which languages store it in an entire 32 bits? That would be unnecessarily wasteful.

            A 1 Reply Last reply
            0
            • M [email protected]

              And compiler. And hardware architecture. And optimization flags.

              As usual, it's some developer that knows little enough to think the walls they see around enclose the entire world.

              T This user is from outside of this forum
              T This user is from outside of this forum
              [email protected]
              wrote on last edited by
              #8

              I don't think so. Apart from dynamically typed languages which need to store the type with the value, it's always 1 byte, and that doesn't depend on architecture (excluding ancient or exotic architectures) or optimisation flags.

              Which language/architecture/flags would not store a bool in 1 byte?

              M B 2 Replies Last reply
              0
              • T [email protected]

                I don't think so. Apart from dynamically typed languages which need to store the type with the value, it's always 1 byte, and that doesn't depend on architecture (excluding ancient or exotic architectures) or optimisation flags.

                Which language/architecture/flags would not store a bool in 1 byte?

                M This user is from outside of this forum
                M This user is from outside of this forum
                [email protected]
                wrote on last edited by
                #9

                Apart from dynamically typed languages which need to store the type with the value

                You know that depending on what your code does, the same C that people are talking upthread doesn't even need to allocate memory to store a variable, right?

                H 1 Reply Last reply
                0
                • T [email protected]

                  I don't think so. Apart from dynamically typed languages which need to store the type with the value, it's always 1 byte, and that doesn't depend on architecture (excluding ancient or exotic architectures) or optimisation flags.

                  Which language/architecture/flags would not store a bool in 1 byte?

                  B This user is from outside of this forum
                  B This user is from outside of this forum
                  [email protected]
                  wrote on last edited by
                  #10

                  things that store it as word size for alignment purposes (most common afaik), things that pack multiple books into one byte (normally only things like bool sequences/structs), etc

                  T 1 Reply Last reply
                  0
                  • T [email protected]

                    Well there are containers that store booleans in single bits (e.g. std::vector<bool> - which was famously a big mistake).

                    But in the general case you don't want that because it would be slower.

                    E This user is from outside of this forum
                    E This user is from outside of this forum
                    [email protected]
                    wrote on last edited by
                    #11

                    Why is this a big mistake? I’m not a c++ person

                    B 1 Reply Last reply
                    0
                    • E [email protected]

                      Why is this a big mistake? I’m not a c++ person

                      B This user is from outside of this forum
                      B This user is from outside of this forum
                      [email protected]
                      wrote on last edited by
                      #12

                      The mistake was that they created a type that behaves like an array in every case except for bool, for which they created a special magical version that behaves just subtly different enough that it can break things in confusing ways.

                      E 1 Reply Last reply
                      0
                      • B [email protected]

                        The mistake was that they created a type that behaves like an array in every case except for bool, for which they created a special magical version that behaves just subtly different enough that it can break things in confusing ways.

                        E This user is from outside of this forum
                        E This user is from outside of this forum
                        [email protected]
                        wrote on last edited by
                        #13

                        Could you provide an example?

                        T 1 Reply Last reply
                        0
                        • cm0002@lemmy.worldC [email protected]
                          This post did not contain any content.
                          M This user is from outside of this forum
                          M This user is from outside of this forum
                          [email protected]
                          wrote on last edited by
                          #14

                          This reminds me that I actually once made a class to store bools packed in uint8 array to save bytes.

                          Had forgotten that. I think i have to update the list of top 10 dumbest things i ever did.

                          rikudou@lemmings.worldR 1 Reply Last reply
                          0
                          • M [email protected]

                            Apart from dynamically typed languages which need to store the type with the value

                            You know that depending on what your code does, the same C that people are talking upthread doesn't even need to allocate memory to store a variable, right?

                            H This user is from outside of this forum
                            H This user is from outside of this forum
                            [email protected]
                            wrote on last edited by
                            #15

                            How does that work?

                            T 1 Reply Last reply
                            0
                            • cm0002@lemmy.worldC [email protected]
                              This post did not contain any content.
                              houseofleft@slrpnk.netH This user is from outside of this forum
                              houseofleft@slrpnk.netH This user is from outside of this forum
                              [email protected]
                              wrote on last edited by
                              #16

                              Wait till you here about every ascii letter. . .

                              A 1 Reply Last reply
                              0
                              • houseofleft@slrpnk.netH [email protected]

                                Wait till you here about every ascii letter. . .

                                A This user is from outside of this forum
                                A This user is from outside of this forum
                                [email protected]
                                wrote on last edited by
                                #17

                                what about them?

                                houseofleft@slrpnk.netH 1 Reply Last reply
                                0
                                • A [email protected]

                                  what about them?

                                  houseofleft@slrpnk.netH This user is from outside of this forum
                                  houseofleft@slrpnk.netH This user is from outside of this forum
                                  [email protected]
                                  wrote on last edited by
                                  #18

                                  Ascii needs seven bits, but is almost always encoded as bytes, so every ascii letter has a throwaway bit.

                                  V 1 Reply Last reply
                                  0
                                  • houseofleft@slrpnk.netH [email protected]

                                    Ascii needs seven bits, but is almost always encoded as bytes, so every ascii letter has a throwaway bit.

                                    V This user is from outside of this forum
                                    V This user is from outside of this forum
                                    [email protected]
                                    wrote on last edited by
                                    #19

                                    Let's store the boolean there then!!

                                    A 1 Reply Last reply
                                    0
                                    • cm0002@lemmy.worldC [email protected]
                                      This post did not contain any content.
                                      J This user is from outside of this forum
                                      J This user is from outside of this forum
                                      [email protected]
                                      wrote on last edited by
                                      #20

                                      Wait until you hear about alignment

                                      B 1 Reply Last reply
                                      0
                                      • T [email protected]

                                        No it isn't. All statically typed languages I know of use a byte. Which languages store it in an entire 32 bits? That would be unnecessarily wasteful.

                                        A This user is from outside of this forum
                                        A This user is from outside of this forum
                                        [email protected]
                                        wrote on last edited by
                                        #21

                                        It's not wasteful, it's faster. You can't read one byte, you can only read one word. Every decent compiler will turn booleans into words.

                                        T 1 Reply Last reply
                                        0
                                        • J [email protected]

                                          Wait until you hear about alignment

                                          B This user is from outside of this forum
                                          B This user is from outside of this forum
                                          [email protected]
                                          wrote on last edited by
                                          #22

                                          The alignment of the language and the alignment of the coder must be similar on at least one metric, or the coder suffers a penalty to develop for each degree of difference from the language's alignment. This is penalty stacks for each phase of the project.

                                          So, let's say that the developer is a lawful good Rust zealot Paladin, but she's developing in Python, a language she's moderately familiar with. Since Python is neutral/good, she suffers a -1 penalty for the first phase, -2 for the second, -3 for the third, etc. This is because Rust (the Paladin's native language) is lawful, and Python is neutral (one degree of difference from lawful), so she operates at a slight disadvantage. However, they are both "good", so there's no further penalty.

                                          The same penalty would occur if using C, which is lawful neutral - but the axis of order and chaos matches, and there is one degree of difference on the axis of good and evil.

                                          However, if that same developer were to code in Javascript (chaotic neutral), it would be at a -3 (-6, -9...) disadvantage, due to 2 and 1 degree of difference in alignment, respectively.

                                          Malbolge (chaotic evil), however, would be a -4 (-8, -12) plus an inherent -2 for poor toolchain availability.

                                          ..hope this helps. have fun out there!

                                          S 1 Reply Last reply
                                          0
                                          Reply
                                          • Reply as topic
                                          Log in to reply
                                          • Oldest to Newest
                                          • Newest to Oldest
                                          • Most Votes


                                          • Login

                                          • Login or register to search.
                                          • First post
                                            Last post
                                          0
                                          • Categories
                                          • Recent
                                          • Tags
                                          • Popular
                                          • World
                                          • Users
                                          • Groups