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. How do you understand cryptic code?

How do you understand cryptic code?

Scheduled Pinned Locked Moved The Lounge
csharpc++question
40 Posts 23 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.
  • M markrlondon

    honey the codewitch wrote:

    How do you understand cryptic code?

    Very slowly, with many iterations of thinking it through, interspersed with head scratching, coffee, and experiments to see if I can mentally 'reconstruct' it.

    honey the codewitch wrote:

    It's really hard to follow C code, so I'm porting it to C# before backporting it to C++ so that I can really understand it.

    Wow, that's an interesting way but I can see why it would work. The only thing for me would be going from C# to C++. Memory management in C++ requires a lot more conscious design thought in C++ than it does in C#, I think.

    H Offline
    H Offline
    honey the codewitch
    wrote on last edited by
    #9

    It does but I have some patterns in how I craft the C# code that help it along. not "unsafe" or anything but using arrays instead of lists, and that sort of thing.

    Real programmers use butterflies

    1 Reply Last reply
    0
    • M Marc Clifton

      What I like to do is create some integration tests that exercise the code paths and then debug the code to see what it's doing. The advantage of that is, with minor changes to the integration tests, I can verify my new code. That said, I do live in a world where integration testing is probably easier.

      Latest Articles:
      Client-Side Type-Based Publisher/Subscriber, Exploring Synchronous, "Event-ed", and Worker Thread Subscriptions

      H Offline
      H Offline
      honey the codewitch
      wrote on last edited by
      #10

      If I was wiser and more disciplined that's what I would do. :laugh:

      Real programmers use butterflies

      1 Reply Last reply
      0
      • H honey the codewitch

        I'm working on the rasterizer portion of my truetype code, for which I found some public domain code that partially works - the parts I need anyway. it's really hard to follow C code, so I'm porting it to C# before backporting it to C++ so that I can really understand it. This isn't the only time I've done that. In fact, I often find myself going this route when coding something based on a codebase I don't understand at first. Do you do this? More I guess I'm curious how y'all go about decoding code that is either more complicated than you can readily understand, or too ugly to readily understand? I port. :)

        Real programmers use butterflies

        D Offline
        D Offline
        David ONeil
        wrote on last edited by
        #11

        My first step is almost always renaming variables to make the names sensible. If it was C code, I'd step through it in C to do so. Once the names are sensible, everything else comes easy. I've seldom dug into a codebase with good naming conventions to start with. Ungh!

        The Science of King David's Court | Object Oriented Programming with C++

        1 Reply Last reply
        0
        • H honey the codewitch

          I'm working on the rasterizer portion of my truetype code, for which I found some public domain code that partially works - the parts I need anyway. it's really hard to follow C code, so I'm porting it to C# before backporting it to C++ so that I can really understand it. This isn't the only time I've done that. In fact, I often find myself going this route when coding something based on a codebase I don't understand at first. Do you do this? More I guess I'm curious how y'all go about decoding code that is either more complicated than you can readily understand, or too ugly to readily understand? I port. :)

          Real programmers use butterflies

          L Offline
          L Offline
          Lost User
          wrote on last edited by
          #12

          honey the codewitch wrote:

          Do you do this?

          Rewrite.

          Bastard Programmer from Hell :suss: "If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.

          H 1 Reply Last reply
          0
          • L Lost User

            honey the codewitch wrote:

            Do you do this?

            Rewrite.

            Bastard Programmer from Hell :suss: "If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.

            H Offline
            H Offline
            honey the codewitch
            wrote on last edited by
            #13

            I usually can't understand it enough to rewrite it without porting it first, but that's me. :)

            Real programmers use butterflies

            1 Reply Last reply
            0
            • H honey the codewitch

              I'm working on the rasterizer portion of my truetype code, for which I found some public domain code that partially works - the parts I need anyway. it's really hard to follow C code, so I'm porting it to C# before backporting it to C++ so that I can really understand it. This isn't the only time I've done that. In fact, I often find myself going this route when coding something based on a codebase I don't understand at first. Do you do this? More I guess I'm curious how y'all go about decoding code that is either more complicated than you can readily understand, or too ugly to readily understand? I port. :)

              Real programmers use butterflies

              1 Offline
              1 Offline
              11917640 Member
              wrote on last edited by
              #14

              Understanding an application part - what does this code do (or tries to do). Running many times on different use cases. Adding a lot of logging/trace code and learning a logs in different use cases. Logging depends on the platform - from OutputDebugString or log file to UART-based printf on embedded device. Trying to make some simple changes and see what happens. Running and reading a logs again. And finally, all this doesn't help to understand 10 lines of code written by real C++ guru - template template parameters + traits + 10-20 crazy Boost base classes + SFINAE + RAII + design patters etc. Such code goes to Recycle Bin - it never works. Anyway, I will be in the Recycle Bin soon, so it doesn't matter...

              H 1 Reply Last reply
              0
              • 1 11917640 Member

                Understanding an application part - what does this code do (or tries to do). Running many times on different use cases. Adding a lot of logging/trace code and learning a logs in different use cases. Logging depends on the platform - from OutputDebugString or log file to UART-based printf on embedded device. Trying to make some simple changes and see what happens. Running and reading a logs again. And finally, all this doesn't help to understand 10 lines of code written by real C++ guru - template template parameters + traits + 10-20 crazy Boost base classes + SFINAE + RAII + design patters etc. Such code goes to Recycle Bin - it never works. Anyway, I will be in the Recycle Bin soon, so it doesn't matter...

                H Offline
                H Offline
                honey the codewitch
                wrote on last edited by
                #15

                11917640 Member wrote:

                template template parameters + traits + 10-20 crazy Boost base classes

                Yeah. I do a lot of generic programming (GP) instead of OOP in C++ so templates are par for the course. However, I dislike boost because of the level of abstraction. I already sideeye the STL for all the allocations it does, and I can't use it when targeting IoT because the Arduino framework doesn't make it available, probably because it can target 8 bit platforms with 8kB of RAM and 256kB of program space. So I tend to agree. Unfortunately I find myself producing code (sans boost and often sans the STL) like that in order to get the compiler to do what I need. I wish it wasn't necessary because the code becomes so abstract it's really hard to follow.

                Real programmers use butterflies

                1 Reply Last reply
                0
                • H honey the codewitch

                  I'm working on the rasterizer portion of my truetype code, for which I found some public domain code that partially works - the parts I need anyway. it's really hard to follow C code, so I'm porting it to C# before backporting it to C++ so that I can really understand it. This isn't the only time I've done that. In fact, I often find myself going this route when coding something based on a codebase I don't understand at first. Do you do this? More I guess I'm curious how y'all go about decoding code that is either more complicated than you can readily understand, or too ugly to readily understand? I port. :)

                  Real programmers use butterflies

                  C Offline
                  C Offline
                  CPallini
                  wrote on last edited by
                  #16

                  Quote:

                  it's really hard to follow C code, so I'm porting it to C# before backporting it to C++ so that I can really understand it.

                  I try to port it to C code. :) I'm doing a lot of this kind of work, with assembly-like C code.

                  "In testa che avete, Signor di Ceprano?" -- Rigoletto

                  1 Reply Last reply
                  0
                  • H honey the codewitch

                    I'm working on the rasterizer portion of my truetype code, for which I found some public domain code that partially works - the parts I need anyway. it's really hard to follow C code, so I'm porting it to C# before backporting it to C++ so that I can really understand it. This isn't the only time I've done that. In fact, I often find myself going this route when coding something based on a codebase I don't understand at first. Do you do this? More I guess I'm curious how y'all go about decoding code that is either more complicated than you can readily understand, or too ugly to readily understand? I port. :)

                    Real programmers use butterflies

                    R Offline
                    R Offline
                    Rage
                    wrote on last edited by
                    #17

                    honey the codewitch wrote:

                    I'm porting it to C# before backporting it to C++

                    That's an interesting way of addressing the understanding issue... I still think it is easier to port direct to C++, since C is probably closer to C++ than C#, but then, I do not speak C# much-

                    Do not escape reality : improve reality !

                    1 Reply Last reply
                    0
                    • H honey the codewitch

                      I'm working on the rasterizer portion of my truetype code, for which I found some public domain code that partially works - the parts I need anyway. it's really hard to follow C code, so I'm porting it to C# before backporting it to C++ so that I can really understand it. This isn't the only time I've done that. In fact, I often find myself going this route when coding something based on a codebase I don't understand at first. Do you do this? More I guess I'm curious how y'all go about decoding code that is either more complicated than you can readily understand, or too ugly to readily understand? I port. :)

                      Real programmers use butterflies

                      M Offline
                      M Offline
                      Martin ISDN
                      wrote on last edited by
                      #18

                      in my head i port c# to c++ and then to c, so i can really understand

                      1 Reply Last reply
                      0
                      • H honey the codewitch

                        I'm working on the rasterizer portion of my truetype code, for which I found some public domain code that partially works - the parts I need anyway. it's really hard to follow C code, so I'm porting it to C# before backporting it to C++ so that I can really understand it. This isn't the only time I've done that. In fact, I often find myself going this route when coding something based on a codebase I don't understand at first. Do you do this? More I guess I'm curious how y'all go about decoding code that is either more complicated than you can readily understand, or too ugly to readily understand? I port. :)

                        Real programmers use butterflies

                        U Offline
                        U Offline
                        UnchainedZA
                        wrote on last edited by
                        #19

                        I just wish to understand how C is more cryptic than C++?

                        H 1 Reply Last reply
                        0
                        • U UnchainedZA

                          I just wish to understand how C is more cryptic than C++?

                          H Offline
                          H Offline
                          honey the codewitch
                          wrote on last edited by
                          #20

                          I never said it was. :confused:

                          Real programmers use butterflies

                          U 1 Reply Last reply
                          0
                          • H honey the codewitch

                            I never said it was. :confused:

                            Real programmers use butterflies

                            U Offline
                            U Offline
                            UnchainedZA
                            wrote on last edited by
                            #21

                            No, you didn't, it just seemed that way to me. I wouldn't even bother with C# in between, but that's a personal opinion, still trying to understand the logic though.

                            H 1 Reply Last reply
                            0
                            • Greg UtasG Greg Utas

                              I've never translated code to another language to help understand it, but I've reformatted it as a way to study it line by line.

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

                              B Offline
                              B Offline
                              BryanFazekas
                              wrote on last edited by
                              #22

                              Greg Utas wrote:

                              I've never translated code to another language to help understand it, but I've reformatted it as a way to study it line by line.

                              This is what I do. If I don't understand the code, I have no idea how I'd translate it.

                              P 1 Reply Last reply
                              0
                              • U UnchainedZA

                                No, you didn't, it just seemed that way to me. I wouldn't even bother with C# in between, but that's a personal opinion, still trying to understand the logic though.

                                H Offline
                                H Offline
                                honey the codewitch
                                wrote on last edited by
                                #23

                                The reason I move it between unmanaged and managed code is it forces me to restructure it. I can't just get lazy and copypasta. In the process of restructuring it, I grok it's machinations. Furthermore, C# has a library for pretty much everything, so no matter what I'm doing in C++, there is pretty going to be the equiv in the .NET framework that I can rely on, so I can seal it off there and I don't have to import code like say, the code to do an HTTP request from C++, if that's not directly what I'm working on. I hope what I just wrote makes sense! :)

                                Real programmers use butterflies

                                U 1 Reply Last reply
                                0
                                • H honey the codewitch

                                  The reason I move it between unmanaged and managed code is it forces me to restructure it. I can't just get lazy and copypasta. In the process of restructuring it, I grok it's machinations. Furthermore, C# has a library for pretty much everything, so no matter what I'm doing in C++, there is pretty going to be the equiv in the .NET framework that I can rely on, so I can seal it off there and I don't have to import code like say, the code to do an HTTP request from C++, if that's not directly what I'm working on. I hope what I just wrote makes sense! :)

                                  Real programmers use butterflies

                                  U Offline
                                  U Offline
                                  UnchainedZA
                                  wrote on last edited by
                                  #24

                                  Ok, thanks, my bad :) I don't even think of things such as .NET, it doesn't exist in my current life. If I can't find a suitable library, I have to create the functionality. It's just a completely different environment.

                                  R H 2 Replies Last reply
                                  0
                                  • H honey the codewitch

                                    I'm working on the rasterizer portion of my truetype code, for which I found some public domain code that partially works - the parts I need anyway. it's really hard to follow C code, so I'm porting it to C# before backporting it to C++ so that I can really understand it. This isn't the only time I've done that. In fact, I often find myself going this route when coding something based on a codebase I don't understand at first. Do you do this? More I guess I'm curious how y'all go about decoding code that is either more complicated than you can readily understand, or too ugly to readily understand? I port. :)

                                    Real programmers use butterflies

                                    R Offline
                                    R Offline
                                    Rusty Bullet
                                    wrote on last edited by
                                    #25

                                    Yes. Do it often.

                                    1 Reply Last reply
                                    0
                                    • U UnchainedZA

                                      Ok, thanks, my bad :) I don't even think of things such as .NET, it doesn't exist in my current life. If I can't find a suitable library, I have to create the functionality. It's just a completely different environment.

                                      R Offline
                                      R Offline
                                      Rusty Bullet
                                      wrote on last edited by
                                      #26

                                      Besides, "cryptic" usually is a matter of who wrote it and how, not what language it happens to be in. Some of the most cryptic code I have run across was SQL written as a single line. Without parsing it, I would never have figured it out.

                                      H 1 Reply Last reply
                                      0
                                      • R Rusty Bullet

                                        Besides, "cryptic" usually is a matter of who wrote it and how, not what language it happens to be in. Some of the most cryptic code I have run across was SQL written as a single line. Without parsing it, I would never have figured it out.

                                        H Offline
                                        H Offline
                                        honey the codewitch
                                        wrote on last edited by
                                        #27

                                        Yeah. I'm not trying to imply it's a particular language that's cryptic. It's all a matter of the code.

                                        Real programmers use butterflies

                                        1 Reply Last reply
                                        0
                                        • U UnchainedZA

                                          Ok, thanks, my bad :) I don't even think of things such as .NET, it doesn't exist in my current life. If I can't find a suitable library, I have to create the functionality. It's just a completely different environment.

                                          H Offline
                                          H Offline
                                          honey the codewitch
                                          wrote on last edited by
                                          #28

                                          UnchainedZA wrote:

                                          It's just a completely different environment.

                                          That's exactly why I do it. :-D

                                          Real programmers use butterflies

                                          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