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.]
This discussion has been archived.
No new comments can be posted.
50 Terrible Coding Tips for a C++ Developer
|
Log In/Create an Account
| Top
| 80 comments
| Search Discussion
The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
(1)
(1)
(Score: -1, Flamebait) by Anonymous Coward on Thursday June 16 2022, @06:37AM (10 children)
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)
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)
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
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
> 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)
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
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)
And the disco dance begins.
(Score: 0) by Anonymous Coward on Saturday June 18 2022, @05:35PM
Stu, is that you?
(Score: 3, Funny) by inertnet on Thursday June 16 2022, @09:05AM (1 child)
Copy the code and start your own site.
(Score: 5, Touché) by Thexalon on Thursday June 16 2022, @12:23PM
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)
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)
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
"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)
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)
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)
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)
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)
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
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
Other forms of polymorphism are available.
I refuse to engage in a battle of wits with an unarmed opponent [wikipedia.org].
(Score: 2) by FatPhil on Thursday June 16 2022, @07:50AM (4 children)
| 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)
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)
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
Here [data]
Go there and ask her.
(Score: -1, Offtopic) by Anonymous Coward on Thursday June 16 2022, @11:02PM
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)
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)
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)
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
Non-fungible C? No flame combustion?
(Score: 3, Informative) by maxwell demon on Thursday June 16 2022, @09:55AM (3 children)
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:
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.
This clearly does not consider normalization of any kind. Different sequences correspond to different identifiers.
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
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
$ 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
$ 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
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)
> 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)
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
> 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
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)
Soviet Union experimented with cyrillic-based programming languages. All failed miserably.
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.
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)
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
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)
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)
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)
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)
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)
That sounds like Microsoft to me.
(Score: 1, Funny) by Anonymous Coward on Friday June 17 2022, @12:23AM
Yes, the similarity with Visual Basic is definitely there.
(Score: 3, Informative) by HiThere on Thursday June 16 2022, @01:13PM (2 children)
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)
> 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
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)
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)
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
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)
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
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
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
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
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)
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)
Ah but RAII.
(Score: 3, Insightful) by FatPhil on Thursday June 16 2022, @03:12PM (1 child)
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
We have a winner! :-)
(Score: -1, Troll) by Anonymous Coward on Thursday June 16 2022, @08:19AM
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)
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)
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
"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
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)
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
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
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
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)
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)
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)
Compiling code that uses templates?
I refuse to engage in a battle of wits with an unarmed opponent [wikipedia.org].
(Score: 2) by loonycyborg on Thursday June 16 2022, @11:16PM (1 child)
Only if that results in error messages. Especially if a template-heavy lib like boost.spirit is involved.
(Score: 2) by turgid on Saturday June 18 2022, @05:40PM
I had a very clever colleague once, a PhD in Artificial Intelligence type, who decided to implement some algorithm in C++ templates for a laugh. He had to leave it to compile over lunch. One day, the machine ran out of virtual memory.
I refuse to engage in a battle of wits with an unarmed opponent [wikipedia.org].
(Score: 1, Funny) by Anonymous Coward on Thursday June 16 2022, @09:32PM
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
I prefer mine
(Score: 0) by Anonymous Coward on Friday June 17 2022, @06:44AM
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
I do not code in C++, but that was hilarious.
28: 's/least/most/'
51: 's/Opps/Oops/'