Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • 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
Code Project
  1. Home
  2. The Lounge
  3. Ok, so this one goes out to C...

Ok, so this one goes out to C...

Scheduled Pinned Locked Moved The Lounge
data-structuresoopperformance
14 Posts 6 Posters 0 Views 1 Watching
  • 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.
  • E englebart

    My favorite optimization is Java substring which returns “slices” which reuse the source string’s char[]. If you have a big string in memory you can pull as many substrings as needed without ever copying a char. Each substring has the storage overhead of a char* to the shared buff, offset, and length.

    J Offline
    J Offline
    Jeremy Falcon
    wrote on last edited by
    #3

    That's pretty cool.

    Jeremy Falcon

    1 Reply Last reply
    0
    • J Jeremy Falcon

      So y'all know... I'm getting my Zig on. And I come across videos about how slices are sooooooooo powerful, like Zig invented it. Basically, a slice just takes a subsection of an array with a pointer and a length. So you can focus on one part of it, in memory. Now... all you C coders know exactly what I'm about to say here... :laugh:

      int main() {
      int data[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};

      int \*slice = &data\[4\];
      \*slice = 42;
      
      // we had this since the 70s
      printf("Bruh %d", data\[4\]);
      return 0;
      

      }

      Don't get me wrong. Zig does have one nice abstraction in the fact it tracks the length for you for bounds checking. But still... come on. Gotta give props to C when talking about stuff when making it seem like this is something new. :laugh:

      Jeremy Falcon

      P Offline
      P Offline
      PIEBALDconsult
      wrote on last edited by
      #4

      Unrelated to that... After the recent discussions of C/C++, I began a bit of C refreshing today. I had forgotten so much over the past twenty years of using C#.

      J M 3 Replies Last reply
      0
      • P PIEBALDconsult

        Unrelated to that... After the recent discussions of C/C++, I began a bit of C refreshing today. I had forgotten so much over the past twenty years of using C#.

        J Offline
        J Offline
        Jeremy Falcon
        wrote on last edited by
        #5

        Yeah man, it's fun to dust off the cobwebs every now and again. Not gonna lie, I still love C and can't swear I'll never use it again. It is fun trying new stuff though. Or, in your case old new stuff. :laugh:

        Jeremy Falcon

        1 Reply Last reply
        0
        • P PIEBALDconsult

          Unrelated to that... After the recent discussions of C/C++, I began a bit of C refreshing today. I had forgotten so much over the past twenty years of using C#.

          J Offline
          J Offline
          Jeremy Falcon
          wrote on last edited by
          #6

          In case you're wondering why my sudden interest in systems coding again, for the application I'm working on I need extreme performance. So, time to get raaaaawwwwww. Muwahahahah

          Jeremy Falcon

          N 1 Reply Last reply
          0
          • E englebart

            My favorite optimization is Java substring which returns “slices” which reuse the source string’s char[]. If you have a big string in memory you can pull as many substrings as needed without ever copying a char. Each substring has the storage overhead of a char* to the shared buff, offset, and length.

            Greg UtasG Offline
            Greg UtasG Offline
            Greg Utas
            wrote on last edited by
            #7

            We had this in the proprietary language I started using in 1981. They were known as descriptors: each one contained a pointer and the number of elements, with the size of the elements determined at compile time. They could be created at run-time by specifying the first and last offset into an array.

            Robust Services Core | Software Techniques for Lemmings | Articles
            The fox knows many things, but the hedgehog knows one big thing.

            <p><a href="https://github.com/GregUtas/robust-services-core/blob/master/README.md">Robust Services Core</a>
            <em>The fox knows many things, but the hedgehog knows one big thing.</em></p>

            1 Reply Last reply
            0
            • J Jeremy Falcon

              In case you're wondering why my sudden interest in systems coding again, for the application I'm working on I need extreme performance. So, time to get raaaaawwwwww. Muwahahahah

              Jeremy Falcon

              N Offline
              N Offline
              Nelek
              wrote on last edited by
              #8

              Jeremy Falcon wrote:

              for the application I'm working on I need extreme performance

              Usual PCs or RT one? if interaction with the physical / electric world needed, current PLCs might get cycles around 100 us with a noticiable load of code (if that's fast enough for you)

              M.D.V. ;) If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about? Help me to understand what I'm saying, and I'll explain it better to you Rating helpful answers is nice, but saying thanks can be even nicer.

              J 1 Reply Last reply
              0
              • N Nelek

                Jeremy Falcon wrote:

                for the application I'm working on I need extreme performance

                Usual PCs or RT one? if interaction with the physical / electric world needed, current PLCs might get cycles around 100 us with a noticiable load of code (if that's fast enough for you)

                M.D.V. ;) If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about? Help me to understand what I'm saying, and I'll explain it better to you Rating helpful answers is nice, but saying thanks can be even nicer.

                J Offline
                J Offline
                Jeremy Falcon
                wrote on last edited by
                #9

                Nelek wrote:

                Usual PCs or RT one?

                Usual PC.

                Nelek wrote:

                if interaction with the physical / electric world needed, current PLCs might get cycles around 100 us with a noticiable load of code (if that's fast enough for you)

                Nothing like that, nor embedded. It's a financial app. I just want it running faster than my JavaScript version... because I can. :laugh:

                Jeremy Falcon

                N 1 Reply Last reply
                0
                • J Jeremy Falcon

                  Nelek wrote:

                  Usual PCs or RT one?

                  Usual PC.

                  Nelek wrote:

                  if interaction with the physical / electric world needed, current PLCs might get cycles around 100 us with a noticiable load of code (if that's fast enough for you)

                  Nothing like that, nor embedded. It's a financial app. I just want it running faster than my JavaScript version... because I can. :laugh:

                  Jeremy Falcon

                  N Offline
                  N Offline
                  Nelek
                  wrote on last edited by
                  #10

                  Jeremy Falcon wrote:

                  I just want it ... because I can.

                  That's the root of all crappy IoT devices and many other depicable actions... vade retro ;P :laugh:

                  M.D.V. ;) If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about? Help me to understand what I'm saying, and I'll explain it better to you Rating helpful answers is nice, but saying thanks can be even nicer.

                  J 1 Reply Last reply
                  0
                  • N Nelek

                    Jeremy Falcon wrote:

                    I just want it ... because I can.

                    That's the root of all crappy IoT devices and many other depicable actions... vade retro ;P :laugh:

                    M.D.V. ;) If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about? Help me to understand what I'm saying, and I'll explain it better to you Rating helpful answers is nice, but saying thanks can be even nicer.

                    J Offline
                    J Offline
                    Jeremy Falcon
                    wrote on last edited by
                    #11

                    I dunno what vade retro means, but don't take my toys away Nelek. I need my toys. :((

                    Jeremy Falcon

                    N 1 Reply Last reply
                    0
                    • P PIEBALDconsult

                      Unrelated to that... After the recent discussions of C/C++, I began a bit of C refreshing today. I had forgotten so much over the past twenty years of using C#.

                      M Offline
                      M Offline
                      Mike Hankey
                      wrote on last edited by
                      #12

                      Iwas converting a AVR C++ to ARM C and found I was trying to make it C++.

                      A home without books is a body without soul. Marcus Tullius Cicero PartsBin an Electronics Part Organizer - Release Version 1.4.0 (Many new features) JaxCoder.com Latest Article: EventAggregator

                      1 Reply Last reply
                      0
                      • J Jeremy Falcon

                        I dunno what vade retro means, but don't take my toys away Nelek. I need my toys. :((

                        Jeremy Falcon

                        N Offline
                        N Offline
                        Nelek
                        wrote on last edited by
                        #13

                        The quotation is from a film: "vade retro satanas" (I think is latin). "Vade retro" is like "step back", "walk away"

                        Jeremy Falcon wrote:

                        I need my toys. :((

                        mmmm not sure if you were a good boy this year... I'll need to ask Santa for a report :laugh: :laugh:

                        M.D.V. ;) If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about? Help me to understand what I'm saying, and I'll explain it better to you Rating helpful answers is nice, but saying thanks can be even nicer.

                        J 1 Reply Last reply
                        0
                        • N Nelek

                          The quotation is from a film: "vade retro satanas" (I think is latin). "Vade retro" is like "step back", "walk away"

                          Jeremy Falcon wrote:

                          I need my toys. :((

                          mmmm not sure if you were a good boy this year... I'll need to ask Santa for a report :laugh: :laugh:

                          M.D.V. ;) If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about? Help me to understand what I'm saying, and I'll explain it better to you Rating helpful answers is nice, but saying thanks can be even nicer.

                          J Offline
                          J Offline
                          Jeremy Falcon
                          wrote on last edited by
                          #14

                          Nelek wrote:

                          "step back", "walk away"

                          :omg:

                          Nelek wrote:

                          I'll need to ask Santa for a report

                          Good luck, I paid Santa off so he could make his sleigh electric. :suss:

                          Jeremy Falcon

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


                          • Login

                          • Don't have an account? Register

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