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. *cries in C++*

*cries in C++*

Scheduled Pinned Locked Moved The Lounge
c++cssquestion
57 Posts 26 Posters 1 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.
  • L Lost User

    How long do I need to wait for it to finish? :confused:

    E Offline
    E Offline
    englebart
    wrote on last edited by
    #20

    It will stop when it has guessed your password and emailed it. [I have no idea what it does]

    1 Reply Last reply
    0
    • M Memtha

      C++ is my favorite language because it does not force you to do anything. That does include making it readable, which is the original author's fault not the language. Languages that force you to make your code readable will inevitably loose some (potentially very useful) features in order to make that happen, like #define for example. I admit I am guilty of intentionally making code less readable, only because I am forced to run it through a painfully awful "security" code scanner. The program is a web api in c# and the only way we can take any kind of data from the db and return it to the caller without the scanner whining is to store the data in a dictionary (dynamic) and then retrieve it back again, so that's been wrapped up in a pair of methods: return obfuscator.get(obfuscator.insert(db.runProc("ProcName", args, or, whatever)))

      E Offline
      E Offline
      englebart
      wrote on last edited by
      #21

      #ifndef SCANNER_LIVE

      doInjection(args);

      #endif

      M 1 Reply Last reply
      0
      • E englebart

        #ifndef SCANNER_LIVE

        doInjection(args);

        #endif

        M Offline
        M Offline
        Memtha
        wrote on last edited by
        #22

        Unfortunately the scanner isn't intelligent enough to know what ifdef means. We just took all the unit tests out of the repo because it was complaining about using assert, among other things. So now jenkins has to pull 2 repos to run the tests.

        1 Reply Last reply
        0
        • H honey the codewitch

          I love this language except when it's used cryptically. You can produce more incomprehensible code with C++ than I think you can in any other major language. I'm poring over C code right now - C really isn't that much better, but fortunately you can do less with it. The code is evil. It's absolutely terrible to read, almost as if they were *trying* to hide intent. Porting it to C++ is my fresh hell. I love this language, but would it kill people to write readable code, or at least comment it with something *helpful*? Anyway, I guess what I'm saying is C++ is both my favorite and least favorite language. It's weird like that.

          Real programmers use butterflies

          G Offline
          G Offline
          Gary R Wheeler
          wrote on last edited by
          #23

          honey the codewitch wrote:

          The code is evil. It's absolutely terrible to read, almost as if they were *trying* to hide intent.

          I am now responsible for a piece of code that's been part of our business for over thirty years. This software handles rendering our proprietary printer language into bitmaps, and then shipping those bitmaps out to be printed. It was originally written by a guy who I'll call BK. BK worked on this one code base for 25 years. It had been 'stable' (bugs are features at that point) for quite a while, and they tried to reassign BK to another project. After six months of doing absolutely nothing he decided to retire when he was confronted. When this landed in my lap, we had not even recompiled this stuff in over ten years. I looked through the source code a few times to answer questions, but hadn't needed to really understand it. Last fall we had a piece of customer-specific hardware go obsolete so we needed to design a replacement. I started looking through the code to see what would need changed. Good :elephant:ing grief. This code was written explicitly so that only a single person could maintain it. It was in C. Function prototypes weren't used. Header files didn't define the functions or data in the corresponding .C source file. There were numerous global structs, variables, and #define's with 3, 2, and yes even 1! character names. I think the best bit of numb:elephant:ery was a group of #define's he'd added before #include <windows.h> which changed the definition of a number of values in the Windows headers which his comment (one of the few) claimed "Microsoft got wrong". I spent over 100 manhours identifying precisely the changes I needed to make and where. My replacement took less than a day from the time I started writing it to when it was compiled, tested, and ready for a trial on customer equipment. This code is [in]famous for something else. I'm a vulgar man, and I swear a lot in casual conversation with people I know, including my coworkers. That said, I've never cussed or used foul language in my source code. It just didn't seem professional. Until. This. Crap. There is now a comment block in this code following my modifications which looks something like this:

          // ====================================================================
          // USELESS SHIT LEFT OVER FROM THE ORIGINAL IMPLEMENTATION
          // =======================================

          J 1 Reply Last reply
          0
          • H honey the codewitch

            I love this language except when it's used cryptically. You can produce more incomprehensible code with C++ than I think you can in any other major language. I'm poring over C code right now - C really isn't that much better, but fortunately you can do less with it. The code is evil. It's absolutely terrible to read, almost as if they were *trying* to hide intent. Porting it to C++ is my fresh hell. I love this language, but would it kill people to write readable code, or at least comment it with something *helpful*? Anyway, I guess what I'm saying is C++ is both my favorite and least favorite language. It's weird like that.

            Real programmers use butterflies

            M Offline
            M Offline
            Member 9167057
            wrote on last edited by
            #24

            C gets you rather close to the machine, but it keeps you there. Meaning there isn't really a way in C NOT to hide intent as you'd be rather busy spelling out mechanics of the "how" explicitly, burying the intent. I very much agree with you on C++ making it way easier to spell out the intent, letting the library do the how, or at least abstracting it away.

            H 1 Reply Last reply
            0
            • H honey the codewitch

              I love this language except when it's used cryptically. You can produce more incomprehensible code with C++ than I think you can in any other major language. I'm poring over C code right now - C really isn't that much better, but fortunately you can do less with it. The code is evil. It's absolutely terrible to read, almost as if they were *trying* to hide intent. Porting it to C++ is my fresh hell. I love this language, but would it kill people to write readable code, or at least comment it with something *helpful*? Anyway, I guess what I'm saying is C++ is both my favorite and least favorite language. It's weird like that.

              Real programmers use butterflies

              U Offline
              U Offline
              User 13269747
              wrote on last edited by
              #25

              Quote:

              I'm poring over C code right now - C really isn't that much better, but fortunately you can do less with it. The code is evil. It's absolutely terrible to read, almost as if they were *trying* to hide intent.

              How do you hide intent in C? No overloaded operators, no overloaded functions, no implicit calls to constructors that need explicit calls to destructors, no symbols with identical names in different namespaces ... The amount of "magic happens implicitly behind the scenes" things in C is ridiculously small.

              H 1 Reply Last reply
              0
              • U User 13269747

                Quote:

                I'm poring over C code right now - C really isn't that much better, but fortunately you can do less with it. The code is evil. It's absolutely terrible to read, almost as if they were *trying* to hide intent.

                How do you hide intent in C? No overloaded operators, no overloaded functions, no implicit calls to constructors that need explicit calls to destructors, no symbols with identical names in different namespaces ... The amount of "magic happens implicitly behind the scenes" things in C is ridiculously small.

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

                By making your code do something that is non-obvious.

                Real programmers use butterflies

                C 1 Reply Last reply
                0
                • M Member 9167057

                  C gets you rather close to the machine, but it keeps you there. Meaning there isn't really a way in C NOT to hide intent as you'd be rather busy spelling out mechanics of the "how" explicitly, burying the intent. I very much agree with you on C++ making it way easier to spell out the intent, letting the library do the how, or at least abstracting it away.

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

                  The one line C contest is holding on line 1. It would like a word.

                  Real programmers use butterflies

                  1 Reply Last reply
                  0
                  • O obermd

                    TECO was the same way. TECO was used to write the first version of Emacs and is a string processing language. One of the challenges TECO coders would do is write a one liner and challenge their counterparts to write the result of putting their name in the function.

                    M Offline
                    M Offline
                    Mike Winiberg
                    wrote on last edited by
                    #28

                    I remember TECO - had a port of it as my first desktop computer editor! Took some learning, but boy was it powerful when all you had was a line editor...

                    1 Reply Last reply
                    0
                    • H honey the codewitch

                      I love this language except when it's used cryptically. You can produce more incomprehensible code with C++ than I think you can in any other major language. I'm poring over C code right now - C really isn't that much better, but fortunately you can do less with it. The code is evil. It's absolutely terrible to read, almost as if they were *trying* to hide intent. Porting it to C++ is my fresh hell. I love this language, but would it kill people to write readable code, or at least comment it with something *helpful*? Anyway, I guess what I'm saying is C++ is both my favorite and least favorite language. It's weird like that.

                      Real programmers use butterflies

                      C Offline
                      C Offline
                      Cpichols
                      wrote on last edited by
                      #29

                      I totally get the love/hate relationship with any code, frankly. I work with legacy code, so loving and hating is an everyday thing for me :laugh: You are doing a good work. Keep it up :java:

                      1 Reply Last reply
                      0
                      • OriginalGriffO OriginalGriff

                        honey the codewitch wrote:

                        You can produce more incomprehensible code with C++ than I think you can in any other major language

                        Hahahahaha ... not even close. Work this out:

                        ⎕←(~A∊A∘.×A)/A←1↓⍳N

                        or this:

                        life ← {⊃1 ⍵ ∨.∧ 3 4 = +/ +⌿ ¯1 0 1 ∘.⊖ ¯1 0 1 ⌽¨ ⊂⍵}

                        C++ can't even come close to APL for code density or incomprehensibility! :laugh: The first one is the Sieve of Eratosthenes, the second is the Game of Life.

                        "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt AntiTwitter: @DalekDave is now a follower!

                        M Offline
                        M Offline
                        mischasan
                        wrote on last edited by
                        #30

                        APL was my first language; in high school, then in university co-op work. Yes, it's dense, and uses symbols you don't see on a regular kbd. But it really changes how you think, for the good. Functional programming (!) Expressions on data collections, rather than rat-holing on iterators. It was great for analytics of the first (StatsCan) time-series database. After APL, I worked in C, ZOPL, PL/I, Algol, POP2, VB, perl, C++ and more Every one added new bits for understanding the next one down the line; some of them on what to avoid (I'm looking at *you*, C++20). But APL was the strongest and cleanest. Now JPMorgan uses it (well K), because it is superfast for solving complex problems, and surprisingly straightforward. Everyone has fun with the primes and GameOfLife oneliners :0) They don't get to see the full applications. Sigh. My2¢

                        J 1 Reply Last reply
                        0
                        • H honey the codewitch

                          I love this language except when it's used cryptically. You can produce more incomprehensible code with C++ than I think you can in any other major language. I'm poring over C code right now - C really isn't that much better, but fortunately you can do less with it. The code is evil. It's absolutely terrible to read, almost as if they were *trying* to hide intent. Porting it to C++ is my fresh hell. I love this language, but would it kill people to write readable code, or at least comment it with something *helpful*? Anyway, I guess what I'm saying is C++ is both my favorite and least favorite language. It's weird like that.

                          Real programmers use butterflies

                          J Offline
                          J Offline
                          JP Reyes
                          wrote on last edited by
                          #31

                          Well I think all midway languages (which to me is any compiled language between FORTRAN's readability and Assembler) is that readability will always be second to performance...although that should mean that a proportional amount of comments should be added to the code (at least a full page for the dark arts). Some of the coolest code I've seen uses pointer arithmetic like hell to bypass C++ permissions (this was a videogame engine) and the only comment it had was:

                          /* Do not change this code or ponies will cry */

                          I had been tracing the source code through 7 different files when I was rewarded with a hearty laugh there. I don't know how readable it was to any other person, but since then, I knew that game engines, compilers and O.S. source code is never going to be readily accessible to just anyone (Despite our best comments). That is the nature of language, human, computer or otherwise.

                          H 1 Reply Last reply
                          0
                          • J JP Reyes

                            Well I think all midway languages (which to me is any compiled language between FORTRAN's readability and Assembler) is that readability will always be second to performance...although that should mean that a proportional amount of comments should be added to the code (at least a full page for the dark arts). Some of the coolest code I've seen uses pointer arithmetic like hell to bypass C++ permissions (this was a videogame engine) and the only comment it had was:

                            /* Do not change this code or ponies will cry */

                            I had been tracing the source code through 7 different files when I was rewarded with a hearty laugh there. I don't know how readable it was to any other person, but since then, I knew that game engines, compilers and O.S. source code is never going to be readily accessible to just anyone (Despite our best comments). That is the nature of language, human, computer or otherwise.

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

                            Breaking encapsulation by offsetting from a classes base address seems like bad form, even for a game engine. That's what the "friend" keyword is for. :) Of course I have some nasty nasty code in my SPI bus code because it interacts with the ESP32's SPI hardware registers directly for performance. It hurts.

                            Real programmers use butterflies

                            J C 2 Replies Last reply
                            0
                            • H honey the codewitch

                              Breaking encapsulation by offsetting from a classes base address seems like bad form, even for a game engine. That's what the "friend" keyword is for. :) Of course I have some nasty nasty code in my SPI bus code because it interacts with the ESP32's SPI hardware registers directly for performance. It hurts.

                              Real programmers use butterflies

                              J Offline
                              J Offline
                              JP Reyes
                              wrote on last edited by
                              #33

                              Lol For the time it was written it was most certainly a hack. That portion was still in C++ 98 and the pointer redirection was for a scripting language internal to the engine (to directly call any method from any class in the engine) SPI bus code...you reminded me of assembler code I found in our main Nintendo DSi Engine (we called coldbits) to directly write to the buffer of the image processor. It was not child's play but I don't think the use of the keyword asm in C++ is hackish (more like "Here be dragons" kinda warning)

                              H 1 Reply Last reply
                              0
                              • H honey the codewitch

                                By making your code do something that is non-obvious.

                                Real programmers use butterflies

                                C Offline
                                C Offline
                                charlieg
                                wrote on last edited by
                                #34

                                but to be honest, that can be done in any language. I'm reading through "learning python" and just hit the description of formatting strings. I don't know what that guy was smoking when they came up with their approach, but I want some.

                                Charlie Gilley “They who can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety.” BF, 1759 Has never been more appropriate.

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

                                  Breaking encapsulation by offsetting from a classes base address seems like bad form, even for a game engine. That's what the "friend" keyword is for. :) Of course I have some nasty nasty code in my SPI bus code because it interacts with the ESP32's SPI hardware registers directly for performance. It hurts.

                                  Real programmers use butterflies

                                  C Offline
                                  C Offline
                                  charlieg
                                  wrote on last edited by
                                  #35

                                  After having lived with Microsoft's version of C++, and the C++ source code of applications written by C developers, I have come to the point that I like encapsulation but inheritance is a multi headed hydra and usually not worth the effort. My experience has been that if you go past one level of inheritance, you are elephanting doomed. Reading about objects and what not sounds nice, but when you get your nice inheritance hierarchy set up, in maintenance you realize that you have an inverted pyramid. Touch one base class, and it all falls down. Now I would agree with you - if you are sharing pointers amongst objects, you have design issues.

                                  Charlie Gilley “They who can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety.” BF, 1759 Has never been more appropriate.

                                  H 1 Reply Last reply
                                  0
                                  • C charlieg

                                    After having lived with Microsoft's version of C++, and the C++ source code of applications written by C developers, I have come to the point that I like encapsulation but inheritance is a multi headed hydra and usually not worth the effort. My experience has been that if you go past one level of inheritance, you are elephanting doomed. Reading about objects and what not sounds nice, but when you get your nice inheritance hierarchy set up, in maintenance you realize that you have an inverted pyramid. Touch one base class, and it all falls down. Now I would agree with you - if you are sharing pointers amongst objects, you have design issues.

                                    Charlie Gilley “They who can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety.” BF, 1759 Has never been more appropriate.

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

                                    These days I don't use inheritance that much except for doing compile-time computation tricks. I usually use templates rather than have strict base classes. In GFX I expose a "caps" template structure that indicates the capabilities of an object. GFX calls certain methods on that object based on the values in that template structure, so for example, it can determine if the object supports reading, or certain optimized operations. Normally, you'd inherit from a base class to do this, but you can do similar using templates. Code size can get to be in issue depending on what you're doing though, but I like the flexibility.

                                    Real programmers use butterflies

                                    C 1 Reply Last reply
                                    0
                                    • J JP Reyes

                                      Lol For the time it was written it was most certainly a hack. That portion was still in C++ 98 and the pointer redirection was for a scripting language internal to the engine (to directly call any method from any class in the engine) SPI bus code...you reminded me of assembler code I found in our main Nintendo DSi Engine (we called coldbits) to directly write to the buffer of the image processor. It was not child's play but I don't think the use of the keyword asm in C++ is hackish (more like "Here be dragons" kinda warning)

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

                                      The reason I don't like the asm keyword is I like my C++ code to be portable. I target a lot of IoT, and those devices come in a variety of architectures, even among the same lines of chips. I've studied the output of GCC in many cases to where I can structure my C++ code to generate the asm I want while maintaining its higher level structure. Of course that doesn't work if you need to set specific registers and such. Still, I use a lot of compile-time tricks to achieve my goals in the real world, but the result tends to be a best of both worlds scenario - you get efficient, highly structured code.

                                      Real programmers use butterflies

                                      1 Reply Last reply
                                      0
                                      • H honey the codewitch

                                        These days I don't use inheritance that much except for doing compile-time computation tricks. I usually use templates rather than have strict base classes. In GFX I expose a "caps" template structure that indicates the capabilities of an object. GFX calls certain methods on that object based on the values in that template structure, so for example, it can determine if the object supports reading, or certain optimized operations. Normally, you'd inherit from a base class to do this, but you can do similar using templates. Code size can get to be in issue depending on what you're doing though, but I like the flexibility.

                                        Real programmers use butterflies

                                        C Offline
                                        C Offline
                                        charlieg
                                        wrote on last edited by
                                        #38

                                        Inheritance for me mainly works best in a very contained environment. I suppose if I were responsible for a core set of code that would apply to multiple applications (like a GUI control set), it might make sense. My career has been spent developing one application after another, and rarely do they inherit from each other. Maybe basic concepts, but as soon as some other team member does not understand something, they code up their own solution and off we go. Inheritance broken. Templates - well there be magic, but in fact, yet again, the ivory tower folks seem to come up with a pristine solution, and the folks that are shoveling $^&&^& in Dixie code something up they understand to get the job done.

                                        Charlie Gilley “They who can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety.” BF, 1759 Has never been more appropriate.

                                        H 1 Reply Last reply
                                        0
                                        • H honey the codewitch

                                          I love this language except when it's used cryptically. You can produce more incomprehensible code with C++ than I think you can in any other major language. I'm poring over C code right now - C really isn't that much better, but fortunately you can do less with it. The code is evil. It's absolutely terrible to read, almost as if they were *trying* to hide intent. Porting it to C++ is my fresh hell. I love this language, but would it kill people to write readable code, or at least comment it with something *helpful*? Anyway, I guess what I'm saying is C++ is both my favorite and least favorite language. It's weird like that.

                                          Real programmers use butterflies

                                          J Offline
                                          J Offline
                                          jschell
                                          wrote on last edited by
                                          #39

                                          honey the codewitch wrote:

                                          but would it kill people to write readable code, or at least comment it with something *helpful*?

                                          In my experience and based on the cries of anguish, gnashing of teething and pulling out of hair when I even suggest that comments have a place in code I am guessing that the answer is that yes it would kill them.

                                          H 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