Stories
Slash Boxes
Comments

SoylentNews is people

posted by janrinok on Thursday June 16 2022, @06:03AM   Printer-friendly
from the bringing-back-nasty-memories dept.

I wrote an "anti-article". I always write about how to perfect C++ code. But this time I'm on the dark side. So, here are "50 terrible coding tips for a C++ developer". Be careful — there's evil in there. I warned you :).

However, some developers may disagree that all these tips are terrible. Therefore, I wrote an overview of the most ambiguous tips in advance. I think everyone has a teammate who should read all this :).

Enjoy!

[Ed's comment - this is a light-hearted view of coding in C++. The thing is, many of us will have seen code like this.... Share your own memories.]


Original Submission

This discussion has been archived. No new comments can be posted.
Display Options Threshold/Breakthrough Mark All as Read Mark All as Unread
The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
(1)
  • (Score: -1, Flamebait) by Anonymous Coward on Thursday June 16 2022, @06:37AM (10 children)

    by Anonymous Coward on Thursday June 16 2022, @06:37AM (#1253596)

    [Ed's comment - this is a light-hearted view of coding in C++. The thing is, many of us will have seen code like this.... Share your own memories.]

    Light-hearted, from a site without a programmer in perl that can fix minor bugs? This will be the end of SoylentNews. We are one fatal bug away from, well, being dead. I predict it will be within 21 days.

    • (Score: 5, Touché) by janrinok on Thursday June 16 2022, @07:14AM (7 children)

      by janrinok (52) Subscriber Badge on Thursday June 16 2022, @07:14AM (#1253604) Journal

      You have nothing intelligent to add to the discussion and so you will resort to whinging and whining again. You have been forecasting the demise of the site for over 4 years now. Keep going, one day you are bound to be right,,,,,

      But what will you do then? Who else will have you? Who else would want you? Anyway, why do you care? You claim that you don't like it here, yet strangely you remain. You simply have nowhere else to go.

      If we have come this far with a dormant 'fatal' bug, then we will simply reinstall the software and start it running again. We might get another 8 years out of it.....

      • (Score: -1, Troll) by Anonymous Coward on Thursday June 16 2022, @08:16AM (1 child)

        by Anonymous Coward on Thursday June 16 2022, @08:16AM (#1253618)

        20 days, now, janrinok. Who are you talking too? Don't you see that you yourself are responsible for the prophecy being fulfilled? You poor, poor bastard! Satan will punish you for protecting the Runaway1956. Did you ever see the Movie, "Angelheart"? Ever think that Runaway could be Mickey Rourke in that movie? No? Buckle up, buttercup!

        • (Score: 0) by Anonymous Coward on Thursday June 16 2022, @05:04PM

          by Anonymous Coward on Thursday June 16 2022, @05:04PM (#1253716)

          I shall look forward to you checking back with us in 20 days to tell us all that you were wrong.

      • (Score: 1, Touché) by Anonymous Coward on Thursday June 16 2022, @08:41PM

        by Anonymous Coward on Thursday June 16 2022, @08:41PM (#1253775)

        > whinging and whining

        Sounds like a C++ programmer... God, shut the hell up with 50 bullet point bullshit complaining. Programmers complaining about programmers, give me a fucking shotgun to shoot my ears off so I don't have to hear any more of it.

      • (Score: 0) by Anonymous Coward on Friday June 17 2022, @08:14AM (3 children)

        by Anonymous Coward on Friday June 17 2022, @08:14AM (#1253946)

        Is this a real thing about not having a perl developer? Who do I contact if I want to help out? I've got decades of perl and linux sysadmin experience

        • (Score: 3, Informative) by janrinok on Friday June 17 2022, @09:52AM

          by janrinok (52) Subscriber Badge on Friday June 17 2022, @09:52AM (#1253954) Journal

          In the first instance you can contact admin [at] soylentnews.org. We will need a point of contact for you of course and we will put you in touch with those responsible for keeping the site operational.

          If you want to have a look at the code then I suggest that you take a look at " rel="url2html-26952">https://github.com/SoylentNews,

        • (Score: 1, Funny) by Anonymous Coward on Friday June 17 2022, @08:37PM (1 child)

          by Anonymous Coward on Friday June 17 2022, @08:37PM (#1254073)

          And the disco dance begins.

          • (Score: 0) by Anonymous Coward on Saturday June 18 2022, @05:35PM

            by Anonymous Coward on Saturday June 18 2022, @05:35PM (#1254237)

            Stu, is that you?

    • (Score: 3, Funny) by inertnet on Thursday June 16 2022, @09:05AM (1 child)

      by inertnet (4071) Subscriber Badge on Thursday June 16 2022, @09:05AM (#1253631) Journal

      Copy the code and start your own site.

      • (Score: 5, Touché) by Thexalon on Thursday June 16 2022, @12:23PM

        by Thexalon (636) Subscriber Badge on Thursday June 16 2022, @12:23PM (#1253654)

        With blackjack! And hookers!

        --
        The only thing that stops a bad guy with a compiler is a good guy with a compiler.
  • (Score: 2) by istartedi on Thursday June 16 2022, @07:06AM (2 children)

    by istartedi (123) on Thursday June 16 2022, @07:06AM (#1253603) Journal

    Not exactly the same thing, but I once had to deal with a library that read in an environment variable. This led to a devil of a "works on my machine" debugging problem, until somebody who knew the library's inner workings told me about it. I was as thankful to them as I was furious at the developer of that lib.

    --
    Appended to the end of comments you post. Max: 120 chars.
    • (Score: 2) by janrinok on Thursday June 16 2022, @07:16AM (1 child)

      by janrinok (52) Subscriber Badge on Thursday June 16 2022, @07:16AM (#1253605) Journal

      I can imagine how frustrating that must have been. Undocumented 'tricks' such as this can be an annoying waste of a lot of time.

      • (Score: 1, Funny) by Anonymous Coward on Thursday June 16 2022, @08:44PM

        by Anonymous Coward on Thursday June 16 2022, @08:44PM (#1253779)

        "Work" is basically a set of undocumented tricks. Notice how the dicks always get promoted while the useful people get shat on? The latter wasted their time reading the manual. Sure, your rights are inviolable and everybody has the same opportunities for advancement... SUCKA!

  • (Score: 4, Funny) by PinkyGigglebrain on Thursday June 16 2022, @07:16AM (11 children)

    by PinkyGigglebrain (4458) on Thursday June 16 2022, @07:16AM (#1253606)

    Tip #1: use C++

    --
    "Beware those who would deny you Knowledge, For in their hearts they dream themselves your Master."
    • (Score: 2, Funny) by Anonymous Coward on Thursday June 16 2022, @07:33AM (5 children)

      by Anonymous Coward on Thursday June 16 2022, @07:33AM (#1253607)

      Tip #2. If it's not templated everywhere, it's not c++

      • (Score: 2) by maxwell demon on Thursday June 16 2022, @07:54AM (4 children)

        by maxwell demon (1608) Subscriber Badge on Thursday June 16 2022, @07:54AM (#1253612) Journal

        Tip #3: Avoid templates at all costs. Better write a dozen almost identical functions than a single template. Don't worry if the user might want to use the function on a type you didn't cover; they simply can copy the code and adapt it.

        --
        The Tao of math: The numbers you can count are not the real numbers.
        • (Score: 3, Informative) by FatPhil on Thursday June 16 2022, @08:15AM (2 children)

          by FatPhil (863) <{pc-soylent} {at} {asdf.fi}> on Thursday June 16 2022, @08:15AM (#1253617) Homepage
          You can avoid templates at all costs and still not do what you sardonically sugggest - generics exist now.
          --
          Great minds discuss ideas; average minds discuss events; small minds discuss people; the smallest discuss themselves
          • (Score: 2) by maxwell demon on Thursday June 16 2022, @08:30AM (1 child)

            by maxwell demon (1608) Subscriber Badge on Thursday June 16 2022, @08:30AM (#1253622) Journal

            I assume you refer to _Generic from C11, right? Did that even make its way into C++?

            Anyway, from my understanding, it is only useful in conjunction with macros. You do not really suggest that macros are a better alternative to templates, do you?

            --
            The Tao of math: The numbers you can count are not the real numbers.
            • (Score: 3, Interesting) by FatPhil on Thursday June 16 2022, @02:33PM

              by FatPhil (863) <{pc-soylent} {at} {asdf.fi}> on Thursday June 16 2022, @02:33PM (#1253674) Homepage
              To be honest, I stopped following C++ decades ago, and C over a decade ago, maybe I misremembered what has cross-polinated from where to where. The thing that I remember looks like it never got standardised and the C11 _Generic is what they settled on instead, and indeed does look a bit ugly.

              However, macros are just syntactic sugar - there's nothing wrong with them when they make the code more maintainable.
              --
              Great minds discuss ideas; average minds discuss events; small minds discuss people; the smallest discuss themselves
        • (Score: 2) by turgid on Thursday June 16 2022, @01:30PM

          by turgid (4318) Subscriber Badge on Thursday June 16 2022, @01:30PM (#1253665) Journal

          Other forms of polymorphism are available.

    • (Score: 2) by FatPhil on Thursday June 16 2022, @07:50AM (4 children)

      by FatPhil (863) <{pc-soylent} {at} {asdf.fi}> on Thursday June 16 2022, @07:50AM (#1253611) Homepage
      Dude, you're just a copy-cat!

      | Story: posted by janrinok on Thursday June 16, @06:03AM
      | Your post: by PinkyGigglebrain (4458) Friend of Friend on Thursday June 16, @07:16AM (#1253606)

      So 1h13m after the story was posted.

      But in IRC (in my UTC+3 timezone)

      | 09:18 < Bender> [SoylentNews] - 50 Terrible Coding Tips for a C++ Developer - https://sylnt.us/jvn - bringing-back-nasty-memories
      | 09:19 <@FatPhil> 1) Program in C++.

      OK, Bender was 15 minutes delayed, but still, you're about an hour late.

      And I notice someone else has followed up to you with basically a regurgitation of my follow-up:

      | 09:20 <@FatPhil> 2) Ensure your templates are so complex and nested that when trying to identify a function, the compiler error messages are 2 screensful long.
      | 09:20 <@FatPhil> but that's just part of (1) really.
      --
      Great minds discuss ideas; average minds discuss events; small minds discuss people; the smallest discuss themselves
      • (Score: -1, Flamebait) by Anonymous Coward on Thursday June 16 2022, @08:28AM (3 children)

        by Anonymous Coward on Thursday June 16 2022, @08:28AM (#1253621)

        FatPhil, did it cross your mind not everyone is on IRC everytime? No? Was it a bullet, then?

        • (Score: 0) by Anonymous Coward on Thursday June 16 2022, @08:36AM (2 children)

          by Anonymous Coward on Thursday June 16 2022, @08:36AM (#1253623)

          What is IRC, and why is FatPhil always "on" it? Truly, SN is a confusing place!

          • (Score: -1, Troll) by Anonymous Coward on Thursday June 16 2022, @09:09AM

            by Anonymous Coward on Thursday June 16 2022, @09:09AM (#1253632)

            What is IRC,

            Here [data]

            and why is FatPhil always "on" it

            Go there and ask her.

          • (Score: -1, Offtopic) by Anonymous Coward on Thursday June 16 2022, @11:02PM

            by Anonymous Coward on Thursday June 16 2022, @11:02PM (#1253823)

            IRC, (if I recall correctly) IRC (Internet Relay Chat) is mostly about Runaway's hatreds, squash and pickled chilis, and FatPhil's minority investment in a brewpub. Oh, and texting of janrinok's bots, of some sort.

  • (Score: 4, Interesting) by FatPhil on Thursday June 16 2022, @07:43AM (31 children)

    by FatPhil (863) <{pc-soylent} {at} {asdf.fi}> on Thursday June 16 2022, @07:43AM (#1253610) Homepage
    Blame the language designers. E.g.
    7. Use invisible characters in your code. Let your code work like magic. How cool is that?

    Everything turned to shit once people started being all inclusive and accepting non-ASCII basically everywhere. There are some places where only ASCII makes sense, because that's what the protocols and standards were originally designed for. Shoehorning what's effectively clipart into such places can only introduce more "problems" than it "solves", and is retarded. I'm a Brit living in the EU, and I don't even accept pound or euro symbols in my active character set in almost all contexts. There's no hypocrisy here.

    Can someone with modern C/C++ experience inform me - are the NFD and NFD forms of a symbol considered the same symbol? What about LTR and RTL pairs? What about the 8 million other idiotic contrived things that I could think up simply because the language designers wanted to be all inclusive and permit unicode/utf8 everywhere?
    --
    Great minds discuss ideas; average minds discuss events; small minds discuss people; the smallest discuss themselves
    • (Score: 3, Touché) by maxwell demon on Thursday June 16 2022, @08:00AM (6 children)

      by maxwell demon (1608) Subscriber Badge on Thursday June 16 2022, @08:00AM (#1253613) Journal

      are the NFD and NFD forms of a symbol considered the same symbol?

      I have no idea what you are talking about here, but still I'm pretty sure that you meant one of the NFD's to be something different. In any case, you can't expect all people here to be Unicode experts, and therefore you should have used the long form instead of the abbreviation (well, I at least assume it's an abbreviation).

      --
      The Tao of math: The numbers you can count are not the real numbers.
      • (Score: 2) by FatPhil on Thursday June 16 2022, @08:13AM (5 children)

        by FatPhil (863) <{pc-soylent} {at} {asdf.fi}> on Thursday June 16 2022, @08:13AM (#1253616) Homepage
        Typo - one of them was supposed to be NFC. How appropriate that acronym is.

        The only people who would be able to answer the question would already be familiar with NFC and NFD, and the K variants thereof. Blow your mind - dive right in: https://unicode.org/reports/tr15/
        --
        Great minds discuss ideas; average minds discuss events; small minds discuss people; the smallest discuss themselves
        • (Score: 1, Touché) by Anonymous Coward on Thursday June 16 2022, @09:13AM

          by Anonymous Coward on Thursday June 16 2022, @09:13AM (#1253633)

          Typo - one of them was supposed to be NFC

          Non-fungible C? No flame combustion?

        • (Score: 3, Informative) by maxwell demon on Thursday June 16 2022, @09:55AM (3 children)

          by maxwell demon (1608) Subscriber Badge on Thursday June 16 2022, @09:55AM (#1253638) Journal

          Well, I looked into a publicly available draft of the C++ standard from 2013 [open-std.org] and as far as I can tell, it doesn't say anything of normalization.

          The relevant parts are, as far as I can tell:

          • 2.2 [lex.phases]/1

            Physical source file characters are mapped, in an implementation-defined manner, to the basic source
            character set (introducing new-line characters for end-of-line indicators) if necessary. The set of phys-
            ical source file characters accepted is implementation-defined. Trigraph sequences (2.4) are replaced
            by corresponding single-character internal representations. Any source file character not in the basic
            source character set (2.3) is replaced by the universal-character-name that designates that charac-
            ter. (An implementation may use any internal encoding, so long as an actual extended character
            encountered in the source file, and the same extended character expressed in the source file as a
            universal-character-name (i.e., using the \uXXXX notation), are handled equivalently except where this
            replacement is reverted in a raw string literal.)

            This definitely does not require any form of normalization. Whether it allows normalization is not entirely clear to me, but if it does, it obviously would be implementation defined.

          • 2.1 [lex.names]/1

            An identifier is an arbitrarily long sequence of letters and digits. Each universal-character-name in an
            identifier shall designate a character whose encoding in ISO 10646 falls into one of the ranges specified
            in E.1. The initial element shall not be a universal-character-name designating a character whose encoding
            falls into one of the ranges specified in E.2. Upper- and lower-case letters are different. All characters are
            significant

            This clearly does not consider normalization of any kind. Different sequences correspond to different identifiers.

          • E.1 [charnames.allowed]

            00A8, 00AA, 00AD, 00AF, 00B2-00B5, 00B7-00BA, 00BC-00BE, 00C0-00D6, 00D8-00F6, 00F8-00FF
            0100-167F, 1681-180D, 180F-1FFF
            200B-200D, 202A-202E, 203F-2040, 2054, 2060-206F
            2070-218F, 2460-24FF, 2776-2793, 2C00-2DFF, 2E80-2FFF
            3004-3007, 3021-302F, 3031-303F
            3040-D7FF
            F900-FD3D, FD40-FDCF, FDF0-FE44, FE47-FFFD
            10000-1FFFD, 20000-2FFFD, 30000-3FFFD, 40000-4FFFD, 50000-5FFFD,
            60000-6FFFD, 70000-7FFFD, 80000-8FFFD, 90000-9FFFD, A0000-AFFFD,
            B0000-BFFFD, C0000-CFFFD, D0000-DFFFD, E0000-EFFFD

            This definitely includes combining characters and directionality markers.

          Thus unless this has been changed since that draft (which of course is possible; I don't have access to the actual standard), I conclude that

          • either different variants of the same character lead to different identifiers
          • or it is implementation defined whether those variants are considered the same (via the implementation-defined mapping at the beginning).

          I also tested with clang on tio.run, [tio.run] that one treats Ä and Ä as separate identifiers.

          --
          The Tao of math: The numbers you can count are not the real numbers.
          • (Score: 3, Informative) by FatPhil on Thursday June 16 2022, @03:07PM

            by FatPhil (863) <{pc-soylent} {at} {asdf.fi}> on Thursday June 16 2022, @03:07PM (#1253683) Homepage
            > I also tested with clang on tio.run, [tio.run] that one treats Ä and Ä as separate identifiers.

            $ od -tc
            Ä
            0000000 303 204 \n
            0000003
            $ od -tc
            Ä
            0000000 A 314 210 \n
            0000004

            That supports the quote from 2.1 you so kindly included. And has reinforced my feeling that I didn't leave the C++ world a moment too soon.

            Thanks for your effort!
            --
            Great minds discuss ideas; average minds discuss events; small minds discuss people; the smallest discuss themselves
          • (Score: 0) by Anonymous Coward on Thursday June 16 2022, @07:18PM

            by Anonymous Coward on Thursday June 16 2022, @07:18PM (#1253754)

            $ unichars Ä and Ä
            U+196 (U+0xc4) => LATIN CAPITAL LETTER A WITH DIAERESIS
            U+97 (U+0x61) => LATIN SMALL LETTER A
            U+110 (U+0x6e) => LATIN SMALL LETTER N
            U+100 (U+0x64) => LATIN SMALL LETTER D
            U+65 (U+0x41) => LATIN CAPITAL LETTER A
            U+776 (U+0x308) => COMBINING DIAERESIS

            unichars is a Perl script. mainly used to turn unrecognisable emojis into semi-recognisable names.

          • (Score: 1, Insightful) by Anonymous Coward on Thursday June 16 2022, @09:37PM

            by Anonymous Coward on Thursday June 16 2022, @09:37PM (#1253802)

            I don't know which is worse. The idea that the C++ compiler doesn't eat its own dogfood by being written in C++ or it is and violates their Unicode handling rules for strings. Of course, whenever we do Unicode against user input we always normalize it first since explicit is better than implicit.

    • (Score: 3, Informative) by PiMuNu on Thursday June 16 2022, @08:36AM (22 children)

      by PiMuNu (3823) on Thursday June 16 2022, @08:36AM (#1253624)

      > what's effectively clipart

      Note that two thirds of the world don't have english alphabet in their first language. Many of those who do also have non-standard characters (e.g. accents). Are you mandating that the world learn english? How well do you think that will go?

      • (Score: 2, Insightful) by Anonymous Coward on Thursday June 16 2022, @09:20AM (2 children)

        by Anonymous Coward on Thursday June 16 2022, @09:20AM (#1253634)

        Are you mandating that the world learn english?

        May 二郎神 [google.com] make you maintain a 1000-files codebase written in mandarin-C++!

        • (Score: 2) by PiMuNu on Thursday June 16 2022, @03:21PM

          by PiMuNu (3823) on Thursday June 16 2022, @03:21PM (#1253691)

          > May 二郎神 [google.com] make you maintain a 1000-files codebase written in mandarin-C++!

          Presumably as tough as asking a Chinese person to maintain a 1000-files codebase written in American-C++

        • (Score: 2) by Mojibake Tengu on Thursday June 16 2022, @06:57PM

          by Mojibake Tengu (8598) on Thursday June 16 2022, @06:57PM (#1253750) Journal

          I humbly respect your spirit mastery over code beasts, 师傅.

          --
          The edge of 太玄 cannot be defined, for it is beyond every aspect of design
      • (Score: 5, Interesting) by Anonymous Coward on Thursday June 16 2022, @12:08PM (8 children)

        by Anonymous Coward on Thursday June 16 2022, @12:08PM (#1253651)

        Soviet Union experimented with cyrillic-based programming languages. All failed miserably.

        Are you mandating that the world learn english?

        YES.
        English is THE language of international communicaton, and programming IS an international field of work.
        No one is forcing any rabid nationalists to work with languages and softwares made by evil foreigners. They are welcome to gird their loins and remake everything from the ground up in their holy native fashion.

        How well do you think that will go?

        Quite easily. Here in Riga, schoolchildren are chattering between themselves in a three-language mix, switching from Latvian to Russian to English mid-sentence. So they obviously DO survive learning two more languages, and consider them fun to use.

        The myth of "foreign languages are hard" is invented by totalitarian governments seeking to hobble their subjects from running away. It is perpetrated by just plain sabotaging foreign language education in schools for their commoners. Note the native Russians in Latvia learning two extra languages in school just as easily as the native Latvians do, while the Russians in Russia bitch and moan about being unable to learn even one.

        • (Score: 4, Interesting) by Mojibake Tengu on Thursday June 16 2022, @07:28PM (1 child)

          by Mojibake Tengu (8598) on Thursday June 16 2022, @07:28PM (#1253756) Journal

          Soviet Union experimented with cyrillic-based programming languages. All failed miserably.

          I strongly disagree with that unsubstantiated propaganda. All current Russian weapon systems up to fully autonomous robotic SU-57 are coded in Avtokod (Autocode) for Elbrus platform.

          This is why you can't directly hack anything theirs on the battlefield. If you hack their Linux by your fancy kernel backdoors (and I very doubt any weapon runs this, maybe some office equipment), you will stay contained inside emulated Intel code only, still far from the real machine core.

          I looked specifically into their compilers mechanics long time ago because I was interested how it does code parallelization directly into VLIW instruction set. My hobby is assemblers and my motivation to study this specific was a simple sentence by a random Russian programmer in a talk: "We do not need a GPU, for we have VLIW instead".
          I convinced myself he was right.

          Just declaring an enemy failed is not sufficient strategy to overwhelm him in real.

          --
          The edge of 太玄 cannot be defined, for it is beyond every aspect of design
          • (Score: 3, Informative) by Anonymous Coward on Thursday June 16 2022, @09:37PM

            by Anonymous Coward on Thursday June 16 2022, @09:37PM (#1253803)

            Your gullibility is telling. "Автокод" всего лишь старый советский термин для ассемблера. "Autocode" is merely an old Soviet term for assembly language. And "Автокод Эль-76" is nothing more than a high-level assembly, an unholy bastardization of russified Algol-68.
            Programming VLIW in assembly is just not done, as we know since the advent of the Itanic. Since those same times, we also do know the continentwide gap between the inflated promises of VLIW, and the underwhelming reality of that Intel's failure. For a person professing knowledge of compiler mechanics and such, being ignorant of those facts is quite funny.
            The Elbrus performance emulating Intel is no better than Itanium doing the same, i.e. atrocious. Combine that with the mediocre performance of the chip itself, and the natural conclusion is that any tall tales of "emulated Intel code" on necessarily realtime avionics systems are so much stupid bullshit. Bullshit is THE mode of existence of Russian government-fed enterprises, and the foundation of their business model, which is pocketing budget money.

            Go and be enlightened.

        • (Score: 2) by loonycyborg on Thursday June 16 2022, @07:32PM (5 children)

          by loonycyborg (6905) on Thursday June 16 2022, @07:32PM (#1253759)

          Why do you think they failed? Language used by 1C Enterprise is in cyrillic script. And it's quite popular. There's nothing magic a particular script. You just use whatever is convenient for people.

          • (Score: 0) by Anonymous Coward on Thursday June 16 2022, @10:04PM (4 children)

            by Anonymous Coward on Thursday June 16 2022, @10:04PM (#1253808)

            Language used by 1C Enterprise is in cyrillic script. And it's quite popular.

            All its popularity is because of government ties of 1C granting them a de facto monopoly on accounting software in Russia. And the fact that being an "1C programmer" is a stigma, believed to be a mark of the worst of the worst, of those below the Javascript jockeys, is rather telling, isn't it? My own past experience with those talking apes and the code they shit out, definitely supports the notion.

            • (Score: 3, Insightful) by loonycyborg on Thursday June 16 2022, @10:15PM (3 children)

              by loonycyborg (6905) on Thursday June 16 2022, @10:15PM (#1253810)

              Random insults against a category of people doesn't hide the fact that you lied about "failure" of cyrilic base languages. 99% of everyone is crap anyway. I bet at least half of them are better than you. But the point is you can have keywords in any language, be it latin, russian or arabic, depending on target audience. I bet arabic code would look really cool.

              • (Score: 0) by Anonymous Coward on Thursday June 16 2022, @10:34PM (2 children)

                by Anonymous Coward on Thursday June 16 2022, @10:34PM (#1253814)

                The one lying here is you.
                Calling the internal, non-optional language of a monopolist's system "popular" is same as calling Gulag gruel "popular". Yeah it is - behind the razor wire fence. Slurp it and be happy, inmate.

                • (Score: 3, Touché) by loonycyborg on Thursday June 16 2022, @11:21PM (1 child)

                  by loonycyborg (6905) on Thursday June 16 2022, @11:21PM (#1253832)

                  That sounds like Microsoft to me.

                  • (Score: 1, Funny) by Anonymous Coward on Friday June 17 2022, @12:23AM

                    by Anonymous Coward on Friday June 17 2022, @12:23AM (#1253852)

                    Yes, the similarity with Visual Basic is definitely there.

      • (Score: 3, Informative) by HiThere on Thursday June 16 2022, @01:13PM (2 children)

        by HiThere (866) on Thursday June 16 2022, @01:13PM (#1253660) Journal

        You don't have to learn English to use a restricted set of tokens. And it's pretty easy to build an automatic translator for such into something that takes you native symbols and emits ASCII-7.

        I really do think that computer languages should be restricted to 7-bit chars for the program, and that each language (or even dialect) could have it's own mapping into ASCII-7. And that the ASCII-7 emitted should mean the same thing everywhere.

        FWIW, there is no computer language where the terms used by the code mean the same thing as they do in the exterior language. In English/C++ there's a relationship, but it sure isn't an identity.

        --
        Javascript is what you use to allow unknown third parties to run software you have no idea about on your computer.
        • (Score: 2) by PiMuNu on Thursday June 16 2022, @01:54PM (1 child)

          by PiMuNu (3823) on Thursday June 16 2022, @01:54PM (#1253667)

          > takes you native symbols and emits ASCII-7.

          Say, for example, a unicode to ascii converter?

          https://onlineunicodetools.com/convert-unicode-to-ascii [onlineunicodetools.com]

          > FWIW, there is no computer language where the terms used by the code mean the same thing

          Indeed, this is even a recommendation in TFA

          > 5. Use one or two letters to name variables.

          • (Score: 2) by HiThere on Thursday June 16 2022, @04:49PM

            by HiThere (866) on Thursday June 16 2022, @04:49PM (#1253710) Journal

            Convert *A SUBSET* of unicode into ascii-7. Yeah, a unicode to ascii-7 translator would be possible, but I don't think it would be desirable. You'ld end up with a single char mapping to multiple chars.

            What you do instead is pick a bunch of local words and map them 1:1 onto the C++ standard words, and you pick a bunch of local chars and map them 1:1 onto the C++ standard chars for variable names and operators. This gives you an easy two way translator. There's a problem that you'd need special tools to do debugging, which is already quite annoying, but it would eliminate the normal objections, and it's a simple two-way isomorphism (not actually a canonical isomorphism though).

            --
            Javascript is what you use to allow unknown third parties to run software you have no idea about on your computer.
      • (Score: 2) by FatPhil on Thursday June 16 2022, @03:00PM (5 children)

        by FatPhil (863) <{pc-soylent} {at} {asdf.fi}> on Thursday June 16 2022, @03:00PM (#1253679) Homepage
        What's 'main' in Mandarin?
        What's 'double' in Russian?
        What's 'switch' in Xhosa?
        What's 'return' in Chiplaqutl?

        If they don't want to use English, I suggest they don't program in C or C++.

        Sorry, we got there first. That's just a fact.
        --
        Great minds discuss ideas; average minds discuss events; small minds discuss people; the smallest discuss themselves
        • (Score: 2) by HiThere on Thursday June 16 2022, @04:55PM (3 children)

          by HiThere (866) on Thursday June 16 2022, @04:55PM (#1253711) Journal

          Did you ever program in Mortran? RatFor? It's easy to do reasonable mapping from one dialect to another, and even if you use a different symbol for "main", as long as you're consistent the conversion is easy (if a bit annoying).

          The real international problem is that the variable names wouldn't make any sense. Possibly not even in the local language, because one is only using a subset of unicode that can be mapped 1:1 into ASCII-7 except for reserved words, which can be anything that you can fit into uft-8, but are all predefined so you can use a lookup table.

          --
          Javascript is what you use to allow unknown third parties to run software you have no idea about on your computer.
          • (Score: 1, Insightful) by Anonymous Coward on Thursday June 16 2022, @06:01PM

            by Anonymous Coward on Thursday June 16 2022, @06:01PM (#1253734)

            The real international problem is that the variable names wouldn't make any sense. Possibly not even in the local language,

            People everywhere have found their ways to cope long, long, loooong ago.
            https://en.wikipedia.org/wiki/Translit [wikipedia.org]
            https://en.wikipedia.org/wiki/Latvian_orthography#Computer_encoding [wikipedia.org]
            https://en.wikipedia.org/wiki/Greeklish [wikipedia.org]
            https://en.wikipedia.org/wiki/Arabic_chat_alphabet [wikipedia.org]

            Regular people are quite well capable of solving communication problems on their own, without political animals pushing their disgusting snouts in.

          • (Score: 2) by FatPhil on Friday June 17 2022, @07:21AM (1 child)

            by FatPhil (863) <{pc-soylent} {at} {asdf.fi}> on Friday June 17 2022, @07:21AM (#1253940) Homepage
            > The real international problem is that the variable names wouldn't make any sense.

            Yes, you're so right. That's because foreigners are stupid, aren't they? Long live the empire, eh, what, what. Where's my brandy, I need breakfast. Damn darkies are too slow. should get one of those mexicans instead, I hear they're terrible efficient.
            --
            Great minds discuss ideas; average minds discuss events; small minds discuss people; the smallest discuss themselves
            • (Score: 2) by HiThere on Friday June 17 2022, @01:20PM

              by HiThere (866) on Friday June 17 2022, @01:20PM (#1253994) Journal

              No. It's because the unicode subset mapping would cause one to need to write variables with names like "phlgstn" before the mapping, which wouldn't make sense even in the native language of the programmer. It's more or less OK in languages with only a few characters, like most Latin-1 languages. It doesn't work nearly as well when you're picking an arbitrary uinque ideogram : roman-alphabet(52 chars) mapping. But it's reasonably possible. And it lets one have programs that where the source code is (*EASILY*) auto-translatable between dialects and compiles to exactly the same code.

              --
              Javascript is what you use to allow unknown third parties to run software you have no idea about on your computer.
        • (Score: 1, Funny) by Anonymous Coward on Thursday June 16 2022, @10:51PM

          by Anonymous Coward on Thursday June 16 2022, @10:51PM (#1253820)

          Huh? I thought C stands for Chinese and C++ stands for Chinese++ programming language

          Now you're telling me it doesn't support Chinese characters??? WTF man, W T F!!!!

      • (Score: 2) by PiMuNu on Friday June 17 2022, @12:00PM

        by PiMuNu (3823) on Friday June 17 2022, @12:00PM (#1253971)

        ps: reading the responses below, I realise I have probably been misunderstood. The discussion started with the concept of unicode allowed in C++ source code. I believe that means allowing non-ascii variable names. Obviously one can't change the name of C++ reserved words, without developing a different language.

    • (Score: 1, Informative) by Anonymous Coward on Thursday June 16 2022, @09:22AM

      by Anonymous Coward on Thursday June 16 2022, @09:22AM (#1253636)

      Unicode support is not required, only a subset of ASCII. Optionally, you can enable it only for strings and string literals. If you do enable Unicode support, only ISO/IEC 10646 support is required. By extension, if you enable any form of Unicode, anything that has an identical canonical form should compare equal. Therefore, NFC, NFD, or randomly distributed should compare equal. Compatibility (i.e. NFKC or NFKD) are not required to compare equal.

  • (Score: 1, Insightful) by Anonymous Coward on Thursday June 16 2022, @08:17AM (3 children)

    by Anonymous Coward on Thursday June 16 2022, @08:17AM (#1253619)

    Not sure about tip 35, reading his explanation, I'm still not really convinced. I understand why he prefers it that way, and what (little) benefits it gives, but I think it's mostly a design choice and not terrible coding.

    • (Score: 0) by Anonymous Coward on Thursday June 16 2022, @01:28PM (2 children)

      by Anonymous Coward on Thursday June 16 2022, @01:28PM (#1253663)

      Ah but RAII.

      • (Score: 3, Insightful) by FatPhil on Thursday June 16 2022, @03:12PM (1 child)

        by FatPhil (863) <{pc-soylent} {at} {asdf.fi}> on Thursday June 16 2022, @03:12PM (#1253687) Homepage
        Except it isn't, because exceptions fucked that right royally over, despite the fact that exceptions were designed singularly to make that easier - all the unwinding will be done automatically!

        Just bin the language. It's stillborn, we just didn't realise that until it had been around for 20 years.
        --
        Great minds discuss ideas; average minds discuss events; small minds discuss people; the smallest discuss themselves
        • (Score: 0) by Anonymous Coward on Thursday June 16 2022, @08:36PM

          by Anonymous Coward on Thursday June 16 2022, @08:36PM (#1253772)

          We have a winner! :-)

  • (Score: -1, Troll) by Anonymous Coward on Thursday June 16 2022, @08:19AM

    by Anonymous Coward on Thursday June 16 2022, @08:19AM (#1253620)

    I just love it when we get to see both janrinok and FatPhil insanity in one and the same story! Keep it up, boys, and say "Hi" to Runaway!

  • (Score: 2) by looorg on Thursday June 16 2022, @10:58AM (5 children)

    by looorg (578) on Thursday June 16 2022, @10:58AM (#1253644)

    I use number 6 all the time. You are not supposed to be looking at my code. I don't care what you think. I know what the fucking numbers mean ... until I don't and then it gets all weird. But I'm hardcore until that time!

    The terrible tip no really clearly mentioned, unless I skipped it over in my mind which can't be ruled out, is ALL THE FUCKING LIBRARIES AND INCLUDES! So many of them. For every single little thing ... There is a library for that, lets include that ... Doing it once is probably ok but when they just keep adding more and more and more and more of them. Gigantic libraries included just to do one trivial little thing. But then I guess it's the backside of the now massive surplus of system resources, there is always gigabytes of ram and cpu available.

    A lot of the tips tho appear to come in two flavors, either this is a problem for communal programming or they want to sell you a code analyzer to detect all the horrible little bugs you just included in your program. Preferably both.

    • (Score: 2) by JoeMerchant on Thursday June 16 2022, @12:11PM (4 children)

      by JoeMerchant (3937) on Thursday June 16 2022, @12:11PM (#1253653)

      Libraries are a necessary evil. I would write a page of code to avoid a lib include, but sometimes there is just too much already done for you to ignore the allure.

      I cringe mightily when teammates get excited about licensing a big new library into the project. SOUP plus license maintenance issues, what fun!

      --
      Україна досі не є частиною Росії Слава Україні🌻 https://news.stanford.edu/2023/02/17/will-russia-ukraine-war-end
      • (Score: 0) by Anonymous Coward on Thursday June 16 2022, @02:09PM

        by Anonymous Coward on Thursday June 16 2022, @02:09PM (#1253670)

        "Libraries are a necessary evil. "

        so is dependency Hell and library writers saying fsck you to backwards compatibility

      • (Score: 3, Funny) by FatPhil on Thursday June 16 2022, @03:20PM

        by FatPhil (863) <{pc-soylent} {at} {asdf.fi}> on Thursday June 16 2022, @03:20PM (#1253690) Homepage
        I was once offered the choice between 2000 lines of perl module, or simply lifting the *two lines* from within it that I actually needed.

        Apparently they wanted an introspective, but completely bling-covered, moose to perform the simple task for me. I read every line in the perl module just to be sure, and for everything apart from those two lines I said "don't need that", "want to avoid that", ... . Maddeningly, those two lines were in the man pages, yet the man pages said "we recommend you use this module instead", which is why I hunted for the module in the first place. I think I swore in every language I know once that loop, which was an utter waste of time, had been completed.
        --
        Great minds discuss ideas; average minds discuss events; small minds discuss people; the smallest discuss themselves
      • (Score: 2) by DannyB on Thursday June 16 2022, @07:01PM (1 child)

        by DannyB (5839) Subscriber Badge on Thursday June 16 2022, @07:01PM (#1253752) Journal

        Libraries are okay if used in moderation. Don't be quick to use a library unless it brings a lot of functionality that would be expensive or error prone to develop.

        If you code in almost any high level language above assembler it is likely you are at minimum using a runtime library for that language's compiler to make calls into.

        --
        How often should I have my memory checked? I used to know but...
        • (Score: 2) by JoeMerchant on Thursday June 16 2022, @07:31PM

          by JoeMerchant (3937) on Thursday June 16 2022, @07:31PM (#1253758)

          I start most projects with Qt - and very often a specific application will want one other library for its specific functionality. Our system has a half dozen applications that are built with Qt + one other library, all communicating through a message broker. This amounts to some risk mitigation: if one of these libraries flakes out, it (usually) only takes out the application it is in, the rest soldier on. However - I was coerced to include a couple of standalone "agents" (well named) developed for us by a contractor into our system. First time one of the certificates they use expired, then went into a rapid memory leak loop and actually crashed the whole system (with 16GB of RAM) within 5 minutes of starting, every single time we restarted until I got wise and started checking all their certificates for expiration before starting their agents.

          --
          Україна досі не є частиною Росії Слава Україні🌻 https://news.stanford.edu/2023/02/17/will-russia-ukraine-war-end
  • (Score: 2, Insightful) by Anonymous Coward on Thursday June 16 2022, @02:48PM

    by Anonymous Coward on Thursday June 16 2022, @02:48PM (#1253677)

    That is the main problem with it. People use it instead of C.

  • (Score: 3, Insightful) by acid andy on Thursday June 16 2022, @03:19PM

    by acid andy (1683) Subscriber Badge on Thursday June 16 2022, @03:19PM (#1253688) Homepage Journal

    I just wrote in my journal about inexperienced coding. Your article has cheered me up, thanks. It's reminded just how much worse it can be! =)

    --
    Master of the science of the art of the science of art.
  • (Score: 5, Funny) by DannyB on Thursday June 16 2022, @06:57PM (6 children)

    by DannyB (5839) Subscriber Badge on Thursday June 16 2022, @06:57PM (#1253751) Journal

    I have found two powerful optimizations for all C and C++ programs. Simply insert these two lines . . .

    #define while if // makes code run faster
    #define struct union // uses less memory

    This will give you faster code that uses less memory!

    --
    How often should I have my memory checked? I used to know but...
    • (Score: 3, Touché) by istartedi on Thursday June 16 2022, @08:19PM (4 children)

      by istartedi (123) on Thursday June 16 2022, @08:19PM (#1253767) Journal

      Meh. Memory is cheap. Don't waste time writing destructors or calling free(). Even phones have 16 gigs of RAM. How could you possibly run out?

      --
      Appended to the end of comments you post. Max: 120 chars.
      • (Score: 3, Informative) by turgid on Thursday June 16 2022, @09:30PM (2 children)

        by turgid (4318) Subscriber Badge on Thursday June 16 2022, @09:30PM (#1253798) Journal

        Compiling code that uses templates?

        • (Score: 2) by loonycyborg on Thursday June 16 2022, @11:16PM (1 child)

          by loonycyborg (6905) on Thursday June 16 2022, @11:16PM (#1253828)

          Only if that results in error messages. Especially if a template-heavy lib like boost.spirit is involved.

      • (Score: 1, Funny) by Anonymous Coward on Thursday June 16 2022, @09:32PM

        by Anonymous Coward on Thursday June 16 2022, @09:32PM (#1253799)

        I can't get the joke exactly, but it was something like: "I used to have memory problems because I freed it too often. After deleting all the free calls I don't have any memory problems at all."

    • (Score: 0) by Anonymous Coward on Thursday June 16 2022, @10:55PM

      by Anonymous Coward on Thursday June 16 2022, @10:55PM (#1253822)

      I prefer mine

      #define aladeen if
      #define aladeen union

  • (Score: 0) by Anonymous Coward on Friday June 17 2022, @06:44AM

    by Anonymous Coward on Friday June 17 2022, @06:44AM (#1253931)

    Namely the floating point comparison thing. Dick almighty, I understand why, but I am lucky that I don’t have to deal with floating point Math much.

  • (Score: 1) by jman on Friday June 17 2022, @12:55PM

    by jman (6085) Subscriber Badge on Friday June 17 2022, @12:55PM (#1253989) Homepage

    I do not code in C++, but that was hilarious.

    28: 's/least/most/'

    51: 's/Opps/Oops/'

(1)