“Give it six months”
It only needed 3!
Post funny things about programming here! (Or just rant about your favourite programming language.)
“Give it six months”
It only needed 3!
That's because C++ is such a high performance language, it gets things done faster
After you've done some languages, they all look the same. Yes, some have interesting features like the indent-based blocking of Python, and I'll have to look up if the new language has "else if", "elsif", "elif", or whatever, but als long as it is coming from the family of ALGOL-like languages, it does not matter much. You'll learn the basic functions needed to get around, and off you go.
Just a few weeks ago, I started learning Python. Yes, this indenting takes some time to get used to. My son does Python for about a year now - he started with it at university. Maybe ten days after I started learning, I invited him to have a look at my first Python program. I have no idea what he expected. A "Hello, World" with a few extra features, maybe? Definitely not the 2.5k lines app I had written in my spare time, with GUI, databases, harvesting data from a web site with caching, and creating PDF files with optimized layout for the data I processed. In the end, it was just another programming language.
I guess you've never seen some of the 10-page template errors C++ compilers will generate. I don't think anything prepares you for that.
I've seen way worse. Imagine a project that uses C preprocessor structures to make a C-compiler provide a kind-of C++. Macros that are pages long, and if you forget a single bracket anywhere, your ten pages look like a romance novel.
Or VHDL synthesis messages. You've got no real control over them, 99.9% of the warnings are completely irrelevant, but one line in a 50k lines output could hint at a problem - if you only found it.
So far, the output of C or C++ compilers (except for the above-mentioned project) has not been a problem or me, but I'm doing this for about 40 years now, so I've got a bit of experience.
Yep, sadly I've been exposed to a few such codebases before. I certainly learned a lot about how NOT to design a project.
You've been at it longer than I have, but I've already had coworkers look at me like I'm a wizard for decoding their error message. You do get a feel for where the important parts of the error actually are over time. So much scrolling though...
Yeah this only really applies to Algol style imperative languages. Dependent types and say stack languages like idris and apl are dramatically different in their underlying axioms.
Jokes aside, I struggle more with abominations like JavaScript and even Python.
Do you have a minute for our lord and savoir TypeScript?
As long as it can distinguish between int and uint - yesss!
TypeScript is still built on JavaScript, all numbers are IEEE-754 doubles 🙃
Edit: Actually I lied, there are BigInts which are arbitrarily precise integers but I don't think there's a way to make them unsigned. There also might be a byte-array object that stores uint8 values but I'm not completely sure if I'm remembering that correctly.
Not only is there a UInt8Array, there's also a bunch of others: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray#typedarray_objects
Python has its quirks, but it’s much much cleaner than js or c++, not fair to drag it down with them imo
I think the thing with C++ is they have tried to maintain backward compatibility from Day 1. You can take a C++ program from the 80s (or heck, even a straight up C program), and there's a good chance it will compile as-is, which is rather astonishing considering modern C++ feels like a different language.
But I think this is what leads to a lot of the complexity as it stands? By contrast, I started Python in the Python 2 era, and when they switched to 3, I was like "Wow, did they just break hello world?" It's a different philosophy and has its trade-offs. By reinventing itself, it can get rid of the legacy cruft that never worked well or required hacky workarounds, but old code will not simply run under the new interpreter. You have to hope your migration tools are up to the task.
even a straight up C program
There were breaking changes between C and C++ (and some divergent evolution since the initial split) as well as breaking changes between different releases of C++ itself. I am not saying these never happened, but the powers that be controlling the standard have worked hard to minimize these for better or worse.
If I took one of my earliest ANSI C programs from the 80s and ran it through a C++23 compiler, I would probably need to remove a bunch of register
statements and maybe check if an assumption of 16-bit int
is going to land me in some trouble, but otherwise, I think it would build as long as it's not linking in any 3rd party libraries.
C is dangerous like your uncle who drinks and smokes. Y'wanna make a weedwhacker-powered skateboard? Bitchin'! Nail that fucker on there good, she'll be right. Get a bunch of C folks together and they'll avoid all the stupid easy ways to kill somebody, in service to building something properly dangerous. They'll raise the stakes from "accident" to "disaster." Whether or not it works, it's gonna blow people away.
C++ is dangerous like a quiet librarian who knows exactly which forbidden tomes you're looking for. He and his... associates... will gladly share all the dark magic you know how to ask about. They'll assure you, oh no no no, the power cosmic would never turn someone inside-out, without sufficient warning. They don't question why a loving god would allow the powers you crave. They will show you which runes to carve, and then, they will hand you the knife.
This is so believable. You copy a few examples out of a textbook using cout and cin and it seems reasonably inline with other languages.
A friend of mine whose research group works on high throughout X-ray Crystallography had to learn C++ for his work, and he says that it was like "wrangling an unhappy horse".
I'm not sure how I feel about someone controlling an X-ray machine with C++ when they haven't used the language before... At least it's not for use on humans.
He doesn't directly control anything with C++ — it's just the data processing. The gist of X-ray Crystallography is that we can shoot some X-rays at a crystallised protein, that will scatter the X-rays due to diffraction, then we can take the diffraction pattern formed and do some mathemagic to figure out the electron density of the crystallised protein and from there, work out the protein's structure
C++ helps with the mathemagic part of that, especially because by "high throughput", I mean that the research facility has a particle accelerator that's over 1km long, which cost multiple billions because it can shoot super bright X-rays at a rate of up to 27,000 per second. It's the kind of place that's used by many research groups, and you have to apply for "beam time". The sample is piped in front of the beam and the result is thousands of diffraction patterns that need to be matched to particular crystals. That's where the challenge comes in.
I am probably explaining this badly because it's pretty cutting edge stuff that's adjacent to what I know, but I know some of the software used is called CrystFEL. My understanding is that learning C++ was necessary for extending or modifying existing software tools, and for troubleshooting anomalous results.
Last time I did anything on the job with C++ was about 8 years ago. Here's what I learned. It may still be relevant.
const
, constexpr
, inline
, volatile
, are all about steering the compiler to generate the code you want. As a consequence, you spend a lot more of your time troubleshooting code generation and compilation errors than with other languages.valgrind
or at least a really good IDE that's dialed in for your process and target platform. Letting the rest of the team get away without these tools will negatively impact the team's ability to fix serious problems.1 - I borrowed this idea from working on J2EE apps, of all places, where stack traces get so huge/deep that there are plugins designed to filter out method calls (sometimes, entire libraries) that are just noise. The idea of post-processing errors just kind of stuck after that - it's just more data, after all.
Reminds me of the joke about the guy falling from the top of the Empire State Building who, half way down, was heard saying: "Well, so far, so good"
In my country C++ is taught as a base language along with Scratch(not a language, but yk what I mean). I recently started learning Kotlin with Jetpack Compose (the only sane way to learn Kotlin) and I realized I wasted two years of my life learning C++, with 5 more to come as it is mandatory in ICT classes.... :((
Which programming language would you like to teach if you were a teacher? P.D I also learned C++ as my first language
I started to learn C++ once, had semester and couldn't wrap my head around the object oriented part. At some point I looked at learning objective C on my own, though I didn't really use it. I had a 1000x better understanding after an hour.
I learned c from a book from the 80s and then skipped to rust.
The only time I touched c++ was modding games in the early aughts and to try it for a couple coding challenges. I've heard templates are a thing of note when it comes to complications but not sure.
As for c# ... We don't talk about that (jk. I had to do it for one or two projects and played with unity a bit ages ago)
I actually just started learning C++ today.
If Lovecraft were alive today one of his stories would start with this line.
Instructions unclear, attempted to learn JS
We used C++ based software. Who need sanity ? Clearly overrated
The image doesn't open for me. But I guess the joke still works in a way.