Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
Skins
  • Light
  • 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

The New Coffee Room

  1. TNCR
  2. General Discussion
  3. Branchless Programming (Geek)

Branchless Programming (Geek)

Scheduled Pinned Locked Moved General Discussion
8 Posts 6 Posters 52 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.
  • A Away
    A Away
    Axtremus
    wrote on 4 Apr 2021, 07:49 last edited by
    #1

    At first I thought it’s an old, retro video talking about old tech and old techniques. But apparently it’s made fairly recently.

    Link to video

    Some types of programmers will appreciate this or hate this more than others. I look at it as just another tool in the toolbox.

    1 Reply Last reply
    • K Offline
      K Offline
      Klaus
      wrote on 4 Apr 2021, 08:49 last edited by
      #2

      It's silly to discuss such techniques without benchmarks.

      1 Reply Last reply
      • C Online
        C Online
        Copper
        wrote on 4 Apr 2021, 11:18 last edited by
        #3

        The time spent explaining it could wipe out the savings.

        1 Reply Last reply
        • M Offline
          M Offline
          Mik
          wrote on 4 Apr 2021, 13:11 last edited by
          #4

          Haven't watched it yet because MFR is still asleep, but on its face it would seem to take more tools out of the toolbox. Will watch later.

          “I am fond of pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals.” ~Winston S. Churchill

          1 Reply Last reply
          • M Offline
            M Offline
            Mik
            wrote on 4 Apr 2021, 13:53 last edited by
            #5

            OK, I got through the first couple examples and he has a point. The CPU will be doing more work, but less I/O, which is slower than the work.

            However, in many cases it sacrifices easy readability - the poor schmuck that comes behind you has to dig in and figure out what you were trying to do which is much more human time, unless you are a great programmer and document your routines appropriately (which I always did when there was any complexity at all).

            So you are left, as always, with the ages old choice of efficiency vs. maintainability.

            “I am fond of pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals.” ~Winston S. Churchill

            1 Reply Last reply
            • M Offline
              M Offline
              mark
              wrote on 4 Apr 2021, 14:48 last edited by mark 4 Apr 2021, 15:09
              #6

              This is nothing new. It's as old as my career in IT is long. I know this "technique" as boolean logic. We were forced to use it in our early days (early 1980s) as our development/runtime environment had no branching commands like If, etc.

              My father, brother and I, wrote an entire payroll AR/AP system using boolean logic. Not a single If statement to be found.

              1 Reply Last reply
              • A Away
                A Away
                Axtremus
                wrote on 4 Apr 2021, 14:56 last edited by
                #7

                @mark said in Branchless Programming (Geek):

                This is nothing new. It's as old as my career in IT is long.

                Exactly, that’s why when I first saw this video I thought it’s vintage old stock recently re-uploaded to YouTube. 😄

                1 Reply Last reply
                • H Online
                  H Online
                  Horace
                  wrote on 4 Apr 2021, 15:22 last edited by Horace 4 Apr 2021, 15:25
                  #8

                  Lol "Often it really pays to have a look at the assembler the compiler is producing to check whether your branchless code is giving any benefits".

                  He misspelled "this is a useless technique, of interest only out of curiosity because compilers are better than you are at this anyway. Also, if you find yourself interrogating your compiler's assembler output for efficiency, I hope you're programming for a nuclear reactor where milliseconds count, and then asking yourself why you're using some random implementation of a c++ compiler anyway".

                  That's quite a misspelling, but it can happen. The probability of it happening is the same as the probability of a branchless technique being a good idea in modern software programming.

                  I'm old enough to have used inline assembly in Borland Turbo c++, for a game I wrote that wrote directly to the VGA Mode-X graphics buffer. I bought a book by Michael Abrash that explained how.

                  Education is extremely important.

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

                  1/8

                  4 Apr 2021, 07:49


                  • Login

                  • Don't have an account? Register

                  • Login or register to search.
                  1 out of 8
                  • First post
                    1/8
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • Users
                  • Groups