There have been multiple accounts created with the sole purpose of posting advertisement posts or replies containing unsolicited advertising.

Accounts which solely post advertisements, or persistently post them may be terminated.

programmerhumor

This magazine is from a federated server and may be incomplete. Browse more on the original instance.

uranibaba , in My debugging experience today: Quantum Debugging

I once had a bug in a C# program I wrote. It made a HTTP request and if the user agent was left to default (whatever that was), the server just gave back an empty string as a reply. I took way to long until I understood what was going on and I kept chasing async, thinking I had messed it up some how.

mvirts , in My debugging experience today: Quantum Debugging

I found the solution, we’re running debug builds in prod from now on

gravitas_deficiency , in My debugging experience today: Quantum Debugging

Haha, heisenbugs, always a fun time.

More seriously, I’d be surprised if this wasn’t a classic race condition

BlueKey OP ,
@BlueKey@fedia.io avatar

It wasn't :D
See my comments below.

mcmodknower ,

Well, technically it was a race condition. Just one between two different programs.

vithigar , in My debugging experience today: Quantum Debugging

For those of you who’ve never experienced the joy of PowerBuilder, this could often happen in their IDE due to debug mode actually altering the state of some variables.

More specifically, if you watched a variable or property then it would be initialised to a default value by the debugger if it didn’t already exist, so any errors that were happening due to null values/references would just magically stop.

Another fun one that made debugging difficult, “local” scoping is shared between multiple instances of the same event. So if you had, say, a mouse move event that fired ten times as the cursor transited a row and in that event you set something like integer li_current_x = xpos the most recent assignment would quash the value of li_current_x in every instance of that event that was currently executing.

airbreather , in My debugging experience today: Quantum Debugging

The term is Heisenbug

Nighed , in My debugging experience today: Quantum Debugging
@Nighed@sffa.community avatar

Someone has a compiler if statement left somewhere in their code (… probably)

Quacksalber , in My debugging experience today: Quantum Debugging

Aren’t those almost always race condition bugs? The debugger slows execution, so the bug won’t appear when debugging.

anhkagi ,
@anhkagi@jlai.lu avatar

sometimes it’s also bugs caused by optimizations.

xthexder ,
@xthexder@l.sw0.com avatar

And that’s where Release with debug symbols comes in. Definitely harder to track down what’s going on when it skips 10 lines of code in one step though. Usually my code ends up the other way though, because debug mode has extra assertions to catch things like uninitialized memory or access-after-free (I think specifically MSVC sets memory to 0xcdcdcdcd on free in debug mode).

BlueKey OP ,
@BlueKey@fedia.io avatar

Turned out that the bug ocurred randomly. The first tries I just had the "luck" that it only happened when the breakpoints were on.
Fixed it by now btw.

Skullgrid ,
@Skullgrid@lemmy.world avatar

bug ocurred randomly.

Fixed it by now btw.

someone’s not sharing the actual root cause.

BlueKey OP ,
@BlueKey@fedia.io avatar

I'm new to Go and wanted to copy some text-data from a stream into the outputstream of the HTTP response.
I was copying the data to and from a []byte with a single Read() and Write() call and expexted everything to be copied as the buffer is always the size of the while data.
Turns out Read() sometimes fills the whole buffer and sometimes don't.
Now I'm using io.Copy().

dunz ,
@dunz@feddit.nu avatar

I had a bug like that today . A system showed 404, but about 50% of the time. Turns out I had two vhosts with the same name, and it hit them roughly evenly 😃

vortexsurfer ,

Had a similar thing at work not long ago.

A newly deployed version of a component in our system was only partially working, and the failures seemed to be random. It’s a distributed system, so the error could be in many places. After reading the logs for a while I realized that only some messages were coming through (via a message queue) to this component, which made no sense. The old version (on a different server) had been stopped, I had verified it myself days earlier.

Turns out that the server with the old version had been rebooted in the meantime, therefore the old component had started running again, and was listening to the same message queue! So it was fairly random which one actually received each message in the queue 😂

Problem solved by stopping the old container again and removing it completely so it wouldn’t start again at the next boot.

ExtraMedicated ,

I had one years ago with internet explorer that ended up being because “console.log” was not defined in that browser unless you had the console window open. That was fun to troublshoot.

Treczoks , in The C++ learning process

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 ,
@xthexder@l.sw0.com avatar

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 ,

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 ,
@xthexder@l.sw0.com avatar

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…

Treczoks ,

Yes, I have my share of coworkers asking me when they run into problems, too. They even ask me when they have Windows problems. And I don’t do Windows - I do Linux and embedded systems.

locuester ,

You do get a feel for where the important parts of the error actually are

Yes, after decades of scanning large pages of text - code, errors, logs, search results, etc - a programmers ability to apply pattern recognition to screens of letters can be truly remarkable.

xthexder ,
@xthexder@l.sw0.com avatar

All I see now is blonde, brunette, redhead.

  • Cypher, The Matrix
dizzy ,
@dizzy@lemmy.ml avatar

I had to do a module programming in VHDL for my EE degree.

Every time I see it mentioned anywhere I have a compulsion to scream: FUCK VHDL AND ITS FUCKING ERRORS! NO YOUR ANALYSIS & SYNTHESIS IS UNSUCCESSFUL!

I did not pursue a career in electronics…

Treczoks ,

One of the key problems of learning VHDL at universities is that most teachers there are amazingly clueless about the language. Not only do you need a bit of a different mindset (you do not program, you define), but their knowledge of language and systems is stuck in the last century.

When I was a regular in a VHDL group on the site we don’t mention here, we regularly had students who got taught techniques that are obsolete or at least deprecated since 1989.

fushuan , (edited )

I’ve not had those while working with concurrent programs with c++ for over a year. Pointers, QT programming, non-qt backend programming, coding an engine to work with computer vision runners (openvino mostly), image management (more pointers)… Idk, this is gonna sound rude but just code better? Most of my errors were segfaults, I have had to plug the debugger and/or tons of prints and I made it work.

If you want to see giant error logs, check pyspark errors. But even those have the relevant line of info and then all the rest of the garbage info that no one really needs, like any other language.

xthexder ,
@xthexder@l.sw0.com avatar

It really depends what you’re doing. The last big project I did with C++ templates was using them to make a lot of compile-time guarantees about concurrency locks so they don’t need to be checked at runtime (thus trading my development time for faster performance). I was able to hide the majority of the templates from users of the library, and spent extra time writing custom static_assert messages.

C++ templates are in fact a compile-time turing complete language, as crazy as that sounds.

MonkderVierte , (edited )

Definitely not the 2.5k lines app

MVC can be a great experience, especially with python dictionaries.

Treczoks ,

Learning how to get models and views together took some time, but after the second refactoring that week I managed to have neat objects for each MVC with clean interfaces. My biggest source in the app defines a requester with three columns of lists: a global category, then parts from that category, and finally the available colors for that part. Each of those views is an object, their interacting logic is an object, and finally the actual requester is an object, and this makes thing easy to handle.

MonkderVierte ,

Great!

explodicle ,

I didn’t even know about the Python indentation thing until I was practically done learning it! I’m just used to copying whatever indentation scheme my coworkers are using, for consistency.

dependencyinjection ,

I’m interested in specifically what your first program did?

Like what data is it harvesting and how is it showing that in PDFs or should I say why?

Treczoks ,

The software gets data from a website named bricklink.com, where one can buy and sell LEGO bricks and sets.

The main view holds a list of bricks I’ve selected from the large range available. In a requester to add parts, I can select a certain brick from the list of existing bricks by first chosing a category (e.g. “Bricks”) in the leftmost column, then chosing it’s shape (e.g. “Brick 2x4”) in the middle one, and then selecting the color (of the known existing colors for this brick, e.g. “Black”) in the right column. On all three selections I can multi-select and sort, which allows me to select e.g. a number of different Bricks, then sort the last view by color, and multiselect those bricks in the color I need. OK’ing the requester add the part(s) to my list.

The list that shows all the properties (including when this part was in production, how much a single brick of it weighs, as well as mold codes and article numbers). From there, I can choose some bricks (usually 15 in a go) to print, which produces a PDF with 15 labels on a double-sided A4-paper with cut-marks on one side. I cut them along the cut marks and put them into the bag with the coresponding part. This is quite helpful, if you consider a box with bags all containing e.g. black parts and bad lighting conditions in the storage room. Alternatively, I can print a double-sided paper with four larger cards to cut, which I laminate and use for marking boxes when I have larger amounts of one brick shape and color.

I can (and do) export those bricks to an export folder as CSV once I’ve printed the labels. In a future version of the software, I will be able to take a bag or box of parts from my collection, select it in my software via it’s article number, and derive an approximate count by weighing them (therefor the parts weight) to get an approximate inventory.

dependencyinjection ,

Hey, thanks for explaining the project for me. That sounds fascinating, is it public? Not that I want to steal it, I never got into Lego, just would like to see exactly how it works.

It also begs the question of how much Lego you actually have lol.

I’ve been thinking of building Lego when I’m sad but it seems so expensive.

Treczoks ,

No, the project is still in its early stages, far from what I would publish.

Regarding the amount of LEGO, well, if I write a resource management and inventory system, you can imagine that it is a bit more than a handfull. My current estimates are around one million bricks, give or take a few hundred k. One of the reason to inventorize it…

dependencyinjection ,

Thanks again.

Do you make money with Lego or is it purely a hobby. Apologies for the questions I’m inherently curious and this is very interesting.

Treczoks ,

I don’t make money with it, on the contrary - my son is a bit more direct here and claims I’m wasting money ;-) It is just a hobby. OK, a big one. I build my own models for fun and exhibit them at shows and events.

And: Curiosity is good. It kept the human race advancing.

dependencyinjection ,

Thanks again.

I would say that it isn’t wasted money if it’s something you enjoy and brings you pleasure or satisfaction.

mitchty ,

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.

Treczoks ,

Indeed. I have done languages like Prolog and Forth, too, and have actually written a bit in APL ages ago. Yes, they are different, but in the end, it just adds a little bit of complexity. The underlying algorithms are universal, just the methods and structures to achieve them differ. Actually, the first programming language I have written was a simplified Forth derivate - in 6510 Assembler.

ambitiousslab , in My debugging experience today: Quantum Debugging
@ambitiousslab@lemmy.ml avatar

Perfect, now you just have to wrap your program inside a debugger in production!

henfredemars , (edited )

We test AND develop in production. Get on my level.

leisesprecher ,

One of our customers does that. It happened multiple times already that one dev fixed an issue in production, and the next regular deployment overwrote everything.

But fortunately, it’s just critical infrastructure and nothing important.

henfredemars ,

When I left my last job they were using the zip file method for version control and one creative developer managed to link two versions of libc at the same time.

Software is so useful that the standard for utility is extremely low.

ChickenLadyLovesLife ,

There’s a name for that: DEVELOPMESTUCTION

AnarchistArtificer , in The C++ learning process

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 ,
@xthexder@l.sw0.com avatar

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 ,
xthexder ,
@xthexder@l.sw0.com avatar

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

AnarchistArtificer ,

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 https://slrpnk.net/pictrs/image/51ac8404-4e22-486b-b220-efe33f75d69d.png

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 ,
@xthexder@l.sw0.com avatar

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 , (edited )

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: https://slrpnk.net/pictrs/image/0fdbd723-cb7f-49bf-834f-e1fb634ee0bb.jpegwhere 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”

https://slrpnk.net/pictrs/image/83b1ed30-3120-4ded-a887-e7bc6c69cab2.webp

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. doi.org/10.1007/978-3-030-00551-1_7

xthexder , (edited )
@xthexder@l.sw0.com avatar

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 ,
@TonyTonyChopper@mander.xyz avatar

Probably makes 7 figures working for big pharma though

AnarchistArtificer ,

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.

MonkderVierte ,
Aceticon , in The C++ learning process

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”

foo ,

Reminds me of the start of La Haine.
youtu.be/4rD05HsmtIU

Aceticon ,

I suspect indirectly both variants come from the same source or maybe even it’s the La Haine that’s indirectly the source for my variant (though I learned this joke a long time ago, possibly before 1995).

By the way, that’s excellent film intro.

tiredofsametab , in The C++ learning process

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 OP ,
@unionagainstdhmo@aussie.zone avatar

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 ,

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.

TheHarpyEagle , (edited )

Honestly C# has grown on me quite a bit. Shakes off some of the bloat of Java and linq is pretty handy. God knows if I can’t tell you what the distinction is between C# and .NET Core and whatever the hell ASP is.

unique_hemp ,
  • C# = Java (the language itself)
  • .NET (Core) = Oracle JDK (a runtime and std lib implementation for the language)
  • ASP.NET = Spring boot (the default web framework)
TheHarpyEagle ,

Thank you!!

menas , in The C++ learning process

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

dgmib , in As seen in Apollo 11 code

My favourite thing ever seen in source code was a comment that read “this code is temporary” with developer initials and a date that was at the time about 5 years ago.

Followed by another dated comment from about 3 years later that read “Temporary my ass”

😂

sunshine , in I may not be the brightest

I’ve gone back and forth between a common bashrc file in my Dropbox folder that is symlinked to ~/.bashrc on my devices, and one that is imported from a regular bashrc instead, and recently it ended up in a state where it accidentally tried to do both, resulting in an endless loop. I discovered this on my Pop!_OS PC, which reacted to this situation by crashing on login lol. What??

  • All
  • Subscribed
  • Moderated
  • Favorites
  • [email protected]
  • random
  • lifeLocal
  • goranko
  • All magazines