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 2 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.
  • 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!

    O Offline
    O Offline
    obermd
    wrote on last edited by
    #11

    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 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

      P Offline
      P Offline
      Peter_in_2780
      wrote on last edited by
      #12

      If you've got a system that supports dc, try this:

      dc -e '2p3p[dl!d2+s!%0=@l!l^!<#]s#[s/0ds^]s@[p]s&[ddvs^3s!l#x0<&2+l.x]ds.x'

      Software rusts. Simon Stephenson, ca 1994. So does this signature. me, 2012

      L R 2 Replies 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

        Mike HankeyM Offline
        Mike HankeyM Offline
        Mike Hankey
        wrote on last edited by
        #13

        I don't have a problem converting C to C++ except when it comes to interrupt handlers, they're a bit tricky. But then again I'm not converting very complicated code...AVR devices are pretty simple.

        The less you need, the more you have. Even a blind squirrel gets a nut...occasionally. JaxCoder.com

        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
          Matthew Dennis
          wrote on last edited by
          #14

          The Eureka moment with C++ is when you understand what features you really don't want to use because they make the code less comprehensible. like multiple inheritance from multiple classes with a common base class. That being said, I once wrote a co-operative multitasking OS for an embedded system in less than 15K of binary in Turbo C++. All the task and timer lists were automatically set up by the class initializers at startup. Just link it in and it got scheduled.

          "Time flies like an arrow. Fruit flies like a banana."

          H 1 Reply Last reply
          0
          • P Peter_in_2780

            If you've got a system that supports dc, try this:

            dc -e '2p3p[dl!d2+s!%0=@l!l^!<#]s#[s/0ds^]s@[p]s&[ddvs^3s!l#x0<&2+l.x]ds.x'

            Software rusts. Simon Stephenson, ca 1994. So does this signature. me, 2012

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

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

            E P 2 Replies Last reply
            0
            • M Matthew Dennis

              The Eureka moment with C++ is when you understand what features you really don't want to use because they make the code less comprehensible. like multiple inheritance from multiple classes with a common base class. That being said, I once wrote a co-operative multitasking OS for an embedded system in less than 15K of binary in Turbo C++. All the task and timer lists were automatically set up by the class initializers at startup. Just link it in and it got scheduled.

              "Time flies like an arrow. Fruit flies like a banana."

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

              My issue comes largely from my finicky-ness. I do a lot of C++ programming, and while I hesitate to say I'm proficient at C++, on balance I'd be lying if I said I didn't think I was. What I mean by being picky is that I don't keep C-isms in my C++ code. I port macros to ifs on constexpr values, and I use templates a lot, like for pin assignments in this case, but it means restructuring code, which means understanding it.

              Real programmers use butterflies

              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
                Memtha
                wrote on last edited by
                #17

                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)))

                H E J 3 Replies 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)))

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

                  I agree with you. I would say my complaint - if anything - I mean, I LOVE C++, is that it makes it easy to do The Wrong Thing(TM), and that includes hiding intent. Showing intent is everything, particularly in C++ where there are a billion ways to skin a million cats. However, that takes practice, is not always possible without comments, and is easy to ignore if you get lazy.

                  Real programmers use butterflies

                  D 1 Reply Last reply
                  0
                  • H honey the codewitch

                    I agree with you. I would say my complaint - if anything - I mean, I LOVE C++, is that it makes it easy to do The Wrong Thing(TM), and that includes hiding intent. Showing intent is everything, particularly in C++ where there are a billion ways to skin a million cats. However, that takes practice, is not always possible without comments, and is easy to ignore if you get lazy.

                    Real programmers use butterflies

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

                    I would say that the PEEKs and POKEs, segmented memory addressing, and gotos in my youthful program studies, were more intent-hiding than almost any of the C++ code I've seen since then! Some early Basic programs had me head scratching a lot!

                    Our Forgotten Astronomy | Object Oriented Programming with C++

                    1 Reply Last reply
                    0
                    • 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
                                          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