• 0 Posts
  • 20 Comments
Joined 10M ago
cake
Cake day: Nov 13, 2023

help-circle
rss

Honestly, this is why I tell developers that work with/for me to build in logging, day one. Not only will you always have clarity in every environment, but you won’t run into cases where adding logging later makes races/deadlocks “go away mysteriously.” A lot of the time, attaching a debugger to stuff in production isn’t going to fly, so “printf debugging” like this is truly your best bet.

To do this right, look into logging modules/libraries that support filtering, lazy evaluation, contexts, and JSON output for perfect SEIM compatibility (enterprise stuff like Splunk or ELK).


Heisenbugs are the worst. My condolences for being tasked with diagnosing one.


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 sourcecode1. This helped a lot with understanding what was actually going wrong. At the same time, it was ridiculous that was even necessary.
  • A style guides are 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.



The problem is that requirements refinement has been unceremoniously dumped in your lap. The failure here is organizational; maybe you have a design person involved, maybe devs are expected to do this. Either way, your job now also includes communications.

One strategy I’ve used is to draw a low-fi example of what they’re going to get - Figma is great at this these days. Then I add it to the issue and push the whole thing back for early approval in order to suss out these finer points.

Not to come off as misanthropic here, but many people are hot garbage at describing what’s in their head. Most of the time, it’s all abstract concepts up there until you start asking the real questions. They really do need a whole-ass conversation to sharpen that mental image. Or in this case, what they want that feature to look like. Incidentally, this is also the reason why therapy is a thing, and why it takes people years to make sense of themselves, and that outcome is usually far more crucial than anything we’re doing at the keyboard.


Honestly I don’t mind the indentation since C isn’t going to give us many ways to address this with as little code.

That said, with compilers that are good at inlining trivial functions, I really do appreciate the “it does what it says on the tin” approach to using functions on things like this. Even if they’re only used once. Comments would help too.

The logic in these if statements is inscrutable on a cold read like this. To me, that’s a maintenance risk; imagine seeing a snippet this size on a PR. Having functions that name what the hell is going on could only help.


In a one-liner competition, sure.

In my codebase? I’d pull a “let’s linger after standup about your PR” and have the coder sweat through a 10 minute soapbox about nothing before laying down the law.


One nit: whatever IDE is displaying single-character surrogates for == and != needs to stop. In a world where one could literally type those Unicode symbols in, and break a build, I think everyone is better off seeing the actual syntax.


Well, everything stored in plastic bottles and containers tastes a little plastic-y to me. But alcohol will dissolve all kinds of things that water can’t, so I’m pretty sure this is much worse.

The thing to consider is: what quality of distillation comes with a package that’s just a little nicer than a plastic bag?


On the one hand: kind of sad since this isn’t too far removed from some workplaces. The hardware and furniture could be sourced from any number of places.

On the other: hot damn. We can get the same kit NASA uses at home. Welcome to the future.


Fastest answer I could find was from 2021: 285GB.

https://stackoverflow.com/questions/65995150/is-it-possible-to-find-out-the-total-size-of-all-existing-npm-modules-in-the-npm

So make sure you have over half a terrabyte of free storage before you try this. These libraries can do things on install, like download and compile binaries. Then there’s overhead for inodes and such, since we’re talking about millions of files. So the impact to the filesystem is going to be much, much bigger than any figure cited like the above.


Exactly. I tell this story to remind people that cynics aren’t just old cranks on internet forums. They’re also salespeople that decided to make some cash on our way to (consumer) hell, and they’re entitled to a turn at holding the pitchfork.


Slow down there, Satan. I kid you not, I had someone approach me to help develop technology like this a long time ago. The idea was to break into video streams at the ISP and insert advertising on the fly w/o prior approval.

My reaction, after realizing this person wanted to turn the internet into an ad-encrusted wasteland*, was: “What happens when that video stream is something live with a LOT of money behind it, like the Superbowl?” The legal and professional ramifications didn’t even clock with this guy. It was squarely in the “not my problem” category.

(* More-so than it is now. I’m not saying we’re getting off light, but this guy was a-okay with making everything look like the hallway bulletin board in a college dorm.)


Nord VPN can protect you from 3rd parties* that spy on your activities and sell your data.

*Disclaimer: The Eye of Sauron does not apply. Offer not valid in Mordor.



Hot take: As a VM with only eight instructions, it’s very easy to code and securely sandbox. Maybe BF has utility as a compilation target?


For the programmer? Very no.

For saving space if run via interperter? No.

For running compiled for conventional CPUs? No.

Compared to CISC instruction sets? Absolutely no.

BF might be highly efficient if crunched down to a bit-packed representation (3 bits per instruction) and run on an FPGA that understands it.


As a consumer, I would see the presence of such a waiver as a prompt to think about what necessitated this in the first place. Perhaps this kitchen isn’t as clean as it could be, and something happened to prompt this level of (legal) caution. Yeah, it could have been an overzealous patron looking for a payday, but maybe someone had a legit case?


Just don’t tell their investors who are clearly pushing to make it a social media hub.

Edit: it’s the second-to-last place I would ever consider for that purpose. Right after Venmo.


This is a good point. My interactions with the Fediverse over the last few months has been sublime. Maybe users here are just proportionally more active?

Numbers are nice, but they’re not everything. Yeah, we could onboard 2 billion lurkers, but how would that improve anything?