890

Incase it doesn't show up:

top 50 comments
sorted by: hot top controversial new old
[-] breadsmasher@lemmy.world 142 points 1 month ago

“Give it six months”

It only needed 3!

[-] kirk781@discuss.tchncs.de 93 points 1 month ago* (last edited 1 month ago)
[-] Ephera@lemmy.ml 56 points 1 month ago

Particularly unexpected, because 3! = 6.

[-] boonhet@lemm.ee 27 points 1 month ago

That's because C++ is such a high performance language, it gets things done faster

load more comments (3 replies)
[-] unionagainstdhmo@aussie.zone 65 points 1 month ago* (last edited 1 month ago)

Disclaimer: I actually like C++ the language, I'm reasonably comfortable with it and enjoy it as an upgrade from C. I don't use much OOP stuff as I'm writing a game using the flecs ECS. So things like abstract classes are mostly absent from my codebase.

What has been driving me up the wall the last month has been build systems and dependencies: don't get me wrong; meson is great but the problem is not everyone uses meson. All I want to do is add some library built with cmake as a dependency without needing to rewrite the build system or install it on my OS. Apparently that is too much to ask!

I'm seriously considering dropping everything and jumping to Rust because of Cargo. Yes I've tried setting up conan but not having much fun since the packages are all third party and out of date anyways

[-] Doom4535@lemmy.sdf.org 33 points 1 month ago

Rust's cargo is great, I'd say it would be best to make the switch sooner rather than later once your code base is established. The build system and tooling alone is a great reason to switch

[-] unionagainstdhmo@aussie.zone 18 points 1 month ago

What sucks is I've been working on this hobby project for nearly 4 years now. It started in C#, moved to C, now C++. It's at the stage where a lot of basic functionality has been implemented, with the largest component, the Vulkan based renderer being maybe 1/4 implemented. The core game stuff is ECS based and flecs has a rust binding so migrating that will be easy. Renderer will just become even further from completion. I'm worried that there will be new problems that are maybe more inhibiting, but this is meant to be a fun project and build systems aren't fun. It's a difficult balance and I'm not the only person involved, the other person isn't as convinced by cargo as they haven't spent days working on the build system

[-] CptBread@lemmy.world 14 points 1 month ago* (last edited 1 month ago)

I'm a gameplay programmer who have worked with Unity and Unreal and I've experiment with Rust for gamedev(though only for hobby projects) and for regular code. My conclusions so far is that Rust sucks for gameplay code, for most other things it's kinda nice.

The biggest reason is that it's much harder to write prototype code to test out an idea to see if it's feasible and feels/looks good enough. I don't want to be forced to fully plan out my code and deal with borrowing issues before I even have an idea of if this is a good path or not.

I would say though that because you are using ECS stuff it is at least plausible to do in Rust but at least for my coding/development style it still isn't a good fit.

load more comments (6 replies)
load more comments (1 replies)
[-] boonhet@lemm.ee 10 points 1 month ago

I’m seriously considering dropping everything and jumping to Rust because of Cargo.

Well if you're into game dev, ECS and Rust, there's like a 99% chance you know of it, but just in case you don't: We have bevy, now with an extra full-time dev (Alice, who'd been working hard at it for years, I think she's a bigger contributor than the author himself at this point lol)

load more comments (1 replies)
load more comments (29 replies)
[-] Treczoks@lemmy.world 35 points 1 month ago

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.

[-] xthexder@l.sw0.com 23 points 1 month ago

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.

[-] Treczoks@lemmy.world 7 points 1 month ago

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.

[-] xthexder@l.sw0.com 7 points 1 month ago

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

load more comments (3 replies)
load more comments (2 replies)
load more comments (2 replies)
[-] mitchty@lemmy.sdf.org 5 points 1 month ago

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.

load more comments (1 replies)
load more comments (11 replies)
[-] n3cr0@lemmy.world 34 points 1 month ago

Jokes aside, I struggle more with abominations like JavaScript and even Python.

[-] mogoh@lemmy.ml 24 points 1 month ago

Do you have a minute for our lord and savoir TypeScript?

[-] n3cr0@lemmy.world 12 points 1 month ago

As long as it can distinguish between int and uint - yesss!

[-] Zangoose@lemmy.world 19 points 1 month ago* (last edited 1 month ago)

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.

[-] void_star@lemmy.world 12 points 1 month ago

Python has its quirks, but it’s much much cleaner than js or c++, not fair to drag it down with them imo

[-] tunetardis@lemmy.ca 10 points 1 month ago

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.

load more comments (2 replies)
load more comments (1 replies)
[-] unionagainstdhmo@aussie.zone 5 points 1 month ago

Yeah JavaScript is a bit weird, semicolons being optional and compulsory at the same time: I remember trying to build an electron example ~5yrs ago and it didn't work unless I put in the semicolons which the developers omitted.

Python is just glorified shell scripting. Libraries like numpy are cool but I don't like the indentation crap, I'm getting used to it because University likes it.

load more comments (4 replies)
[-] mindbleach@sh.itjust.works 33 points 1 month ago

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.

[-] philluminati@lemmy.ml 26 points 1 month ago

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.

[-] AnarchistArtificer@slrpnk.net 16 points 1 month ago

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

[-] xthexder@l.sw0.com 7 points 1 month ago

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.

[-] humorlessrepost@lemmy.world 10 points 1 month ago
[-] xthexder@l.sw0.com 4 points 1 month ago

Yep, I learned about this exact case when I got my engineering degree.

[-] AnarchistArtificer@slrpnk.net 5 points 1 month ago

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.

load more comments (3 replies)
[-] TonyTonyChopper@mander.xyz 4 points 1 month ago

Probably makes 7 figures working for big pharma though

load more comments (1 replies)
[-] dejected_warp_core@lemmy.world 15 points 1 month ago* (last edited 1 month ago)

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.

  • C++14 was alright, but still wasn't everything you need. The language has improved a lot since, so take this with a grain of salt. We had to use Boost to really make the most of things and avoid stupid memory management problems through use of smart (ref-counted) pointers. The overhead was worth it.
  • C++ relies heavily on idioms for good code quality that can only be learned from a book and/or the community. "RAII" is a good example here. The language itself is simply too flexible and low-level to force that kind of behavior on you. To make matters worse, idiomatic practices wind up adding substantial weight to manual code review, since there's no other way to enforce them or check for their absence.
  • I wound up writing a post-processor to make sense of template errors since it had a habit of completely exploding any template use to the fullest possible expression expansion; it was like typedefs didn't exist. My tool replaced common patterns with expressions that more closely resembled our sourcecode^1^. This helped a lot with understanding what was actually going wrong. At the same time, it was ridiculous that was even necessary.
  • A team style guide is a hard must with C++. The language spec is so mindbogglingly huge that no two "C++ programmers" possess the same experience with the language. Yes, their skillsets will overlap, but the non-overlapping areas can be quite large and have profound ramifications on coding preferences. This is why my team got into serious disagreements with style and approach without one: there was no tie-breaker to end disagreement. We eventually adopted one after a lot of lost effort and hurt feelings.
  • Coding C++ is less like having a conversation with the target CPU and more like a conversation with the compiler. Templates, 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.
  • At some point you will need 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.
  • C++ assumes that CPU performance and memory management are your biggest problems. You absolutely have to be aware of stack allocation, heap allocation, copies, copy-free, references, pointers, and v-tables, which are needed to navigate the nuances of code generation and how it impacts run-time and memory.
  • Multithreading in C++14 was made approachable through Boost and some primitives built on top of pthreads. Deadlocks and races were a programmer problem; the language has nothing to help you here. My recommendation: take a page from Go's book. Use a really good threadsafe mutable queue, copy (no references/pointers) everything into it, and use it for moving mutable state between threads until performance benchmarks tell you to do otherwise.
  • Test-driven design and DevOps best-practice is needed to make any C++ project of scale manageable. I cannot stress this enough. Use every automated quality gate you can to catch errors before live/integration testing, as using valgrind and other in-situ tools can be painful (if not impossible).

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.

[-] Aceticon@lemmy.world 13 points 1 month ago

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"

load more comments (2 replies)
[-] tiredofsametab@fedia.io 11 points 1 month ago

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)

[-] unionagainstdhmo@aussie.zone 7 points 1 month ago

Was that "The C Programming Language"? I learned C from that after a bit of C++ and it made everything make so much sense. C is refreshingly simple.

I’ve heard templates are a thing of note when it comes to complications but not sure

It's funny because that is the one feature I really wish C had, I can live without member functions but templates or even a good generics system would be great. I did some C# with MonoGame and FNA. Language has gotten better as of late but idk about performance, way better than VB.

[-] tiredofsametab@fedia.io 4 points 1 month ago

Probably. I think I still have the book in storage back in the US. At some point, I also got "learn c in 24 hours" or something as well.

load more comments (3 replies)
[-] RedWeasel@lemmy.world 11 points 1 month ago

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.

load more comments (4 replies)
[-] itsmegeorge@lemmy.zip 11 points 1 month ago

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.... :((

[-] huzzahunimpressively@lemmy.world 7 points 1 month ago

Which programming language would you like to teach if you were a teacher? P.D I also learned C++ as my first language

load more comments (3 replies)
load more comments (1 replies)
[-] mokus@lemmy.blahaj.zone 9 points 1 month ago

I actually just started learning C++ today.

If Lovecraft were alive today one of his stories would start with this line.

[-] Skullgrid@lemmy.world 9 points 1 month ago

Instructions unclear, attempted to learn JS

[-] menas@lemmy.wtf 7 points 1 month ago

We used C++ based software. Who need sanity ? Clearly overrated

[-] Tyfud@lemmy.world 4 points 1 month ago

Unfortunately, those of us that make games in Unreal Engine are stuck writing a lot of C++, unless we want to do everything in BPs (no thanks, they're fine, but it's not coding, and it's difficult to maintain and refactor for complicated projects, they're good for taking C++ components and building bigger components out of the base C++ functionality though).

With that said, UE's support for C++ is decent. Which is, that as long as you tag all your fields, properties, methods, classes, etc. with some UnrealEngine attribute filter (like UCLASS or UPROPERTY), Unreal will handle the memory management of those constructs for you. Which is nice.

Unfortunately it has some other limitations to the C++ language that you can't work around, like disallowing pure abstracts because every C++ derivative class based on any UE construct (Actor, Character, Pawn, etc.) has to be instantiatable in the editor. So no pure abstracts and such.

In general, I'd give it a 6/10.

It's still mostly C++, but some of the things suck less.

load more comments
view more: next ›
this post was submitted on 02 Sep 2024
890 points (99.0% liked)

Programmer Humor

32225 readers
686 users here now

Post funny things about programming here! (Or just rant about your favourite programming language.)

Rules:

founded 5 years ago
MODERATORS