this post was submitted on 02 Sep 2024
491 points (100.0% liked)

Programmer Humor

852 readers
16 users here now

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

Rules:

founded 5 years ago
MODERATORS
 

Incase it doesn't show up:

top 25 comments
sorted by: hot top controversial new old
[–] unionagainstdhmo@aussie.zone 46 points 3 weeks ago* (last edited 3 weeks ago) (4 children)

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 recipes are all third party and out of date anyways

[–] Doom4535@lemmy.sdf.org 22 points 3 weeks ago (1 children)

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 14 points 3 weeks ago (1 children)

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

[–] rimu@piefed.social 1 points 2 weeks ago

Story by a game dev who gave up on Rust after 3 years https://loglog.games/blog/leaving-rust-gamedev/

[–] boonhet@lemm.ee 6 points 3 weeks ago (1 children)

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)

[–] unionagainstdhmo@aussie.zone 3 points 3 weeks ago

I've been keeping an eye on bevy, it looks really cool. I'll probably make something with it one day when their ECS gets support for entity relationships (which appears to be in the pipeline). A really cool project though, basically looks like everything I've wanted out of a C++ engine which I can't really use due to build system mixing.

[–] magic_lobster_party@fedia.io 3 points 3 weeks ago

So things like abstract classes are mostly absent from my codebase.

I believe the consensus nowadays is that abstract classes should be avoided like the plague even in languages like Java and C#.

[–] geneva_convenience@lemmy.ml 2 points 3 weeks ago

Brackeys started a series on Godot recently. If you are writing a smaller game GDscript looks attractive and far simpler.

[–] philluminati@lemmy.ml 14 points 3 weeks 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 12 points 3 weeks ago (3 children)

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 6 points 3 weeks ago (1 children)

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.

[–] AnarchistArtificer@slrpnk.net 4 points 3 weeks ago (1 children)

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.

[–] xthexder@l.sw0.com 3 points 3 weeks ago (1 children)

Neat, thanks for sharing. Reminds me of old mainframe computers where students and researchers had to apply for processing time. Large data analysis definitely makes sense for C++, and it's pretty low risk. Presumably you'd be able to go back and reprocess stuff if something went wrong? Or is more of a live-feed that's not practical to store?

[–] AnarchistArtificer@slrpnk.net 2 points 3 weeks ago* (last edited 3 weeks ago) (1 children)

The data are stored, so it's not a live-feed problem. It is an inordinate amount of data that's stored though. I don't actually understand this well enough to explain it well, so I'm going to quote from a book [1]. Apologies for wall of text.

"Serial femtosecond crystallography [(SFX)] experiments produce mountains of data that require [Free Electron Laser (FEL)] facilities to provide many petabytes of storage space and large compute clusters for timely processing of user data. The route to reach the summit of the data mountain requires peak finding, indexing, integration, refinement, and phasing." [...]

"The main reason for [steep increase in data volumes] is simple statistics. Systematic rotation of a single crystal allows all the Bragg peaks, required for structure determination, to be swept through and recorded. Serial collection is a rather inefficient way of measuring all these Bragg peak intensities because each snapshot is from a randomly oriented crystal, and there are no systematic relationships between successive crystal orientations. [...]

Consider a game of picking a card from a deck of all 52 cards until all the cards in the deck have been seen. The rotation method could be considered as analogous to picking a card from the top of the deck, looking at it and then throwing it away before picking the next, i.e., sampling without replacement. In this analogy, the faces of the cards represent crystal orientations or Bragg reflections. Only 52 turns are required to see all the cards in this case. Serial collection is akin to randomly picking a card and then putting the card back in the deck before choosing the next card, i.e., sampling with replacement (Fig. 7.1 bottom). How many cards are needed to be drawn before all 52 have been seen? Intuitively, we can see that there is no guarantee that all cards will ever be observed. However, statistically speaking, the expected number of turns to complete the task, c, is given by: where n is the total number of cards. For large n, c converges to n*log(n). That is, for n = 52, it can reasonably be expected that all 52 cards will be observed only after about 236 turns! The problem is further exacerbated because a fraction of the images obtained in an SFX experiment will be blank because the X-ray pulse did not hit a crystal. This fraction varies depending on the sample preparation and delivery methods (see Chaps. 3–5), but is often higher than 60%. The random orientation of crystals and the random picking of this orientation on every measurement represent the primary reasons why SFX data volumes are inherently larger than rotation series data.

The second reason why SFX data volumes are so high is the high variability of many experimental parameters. [There is some randomness in the X-ray pulses themselves]. There may also be a wide variability in the crystals: their size, shape, crystalline order, and even their crystal structure. In effect, each frame in an SFX experiment is from a completely separate experiment to the others."

"The Realities of Experimental Data" "The aim of hit finding in SFX is to determine whether the snapshot contains Bragg spots or not. All the later processing stages are based on Bragg spots, and so frames which do not contain any of them are useless, at least as far as crystallographic data processing is concerned. Conceptually, hit finding seems trivial. However, in practice it can be challenging.

"In an ideal case shown in Fig. 7.5a, the peaks are intense and there is no background noise. In this case, even a simple thresholding algorithm can locate the peaks. Unfortunately, real life is not so simple"

It's very cool, I wish I knew more about this. A figure I found for approximate data rate is 5GB/s per instrument. I think that's for the European XFELS.

Citation: [1]: Yoon, C.H., White, T.A. (2018). Climbing the Data Mountain: Processing of SFX Data. In: Boutet, S., Fromme, P., Hunter, M. (eds) X-ray Free Electron Lasers. Springer, Cham. https://doi.org/10.1007/978-3-030-00551-1_7

[–] xthexder@l.sw0.com 1 points 3 weeks ago* (last edited 3 weeks ago)

That's definitely a non-trivial amount of data. Storage fast enough to read/write that isn't cheap either, so it makes perfect sense you'd want to process it and narrow it down to a smaller subset of data ASAP. The physics of it is way over my head, but I at least understand the challenge of dealing with that much data.

Thanks for the read!

[–] TonyTonyChopper@mander.xyz 3 points 3 weeks ago (1 children)

Probably makes 7 figures working for big pharma though

[–] AnarchistArtificer@slrpnk.net 3 points 3 weeks ago

Unfortunately no. I don't know any research scientists who even make 6 figures. You're lucky to break even 50k if you're in academia. Working in industry gets you better pay, but not by too much. This is true even in big pharma, at least on the biochemical/biomedical research front. Perhaps non-research roles are where the big bucks are.

[–] tiredofsametab@fedia.io 9 points 3 weeks ago (1 children)

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 4 points 3 weeks ago (1 children)

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 3 points 3 weeks 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.

[–] mokus@lemmy.blahaj.zone 7 points 3 weeks ago

I actually just started learning C++ today.

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

[–] menas@lemmy.wtf 5 points 3 weeks ago

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

[–] UpperBroccoli@lemmy.blahaj.zone 3 points 3 weeks ago

They are still using Reddit, so one has to wonder if they have not abandoned sanity and intellect a long time ago.

[–] itsmegeorge@lemmy.zip 0 points 3 weeks 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.... :((