Personal computing discussed
Moderators: renee, SecretSquirrel, just brew it!
Buub wrote:WordAmateur night and multi-threaded are phrases that shouldn't go together in the same sentence.
UberGerbil wrote:So out of curiosity, what was your chosen solution -- a thread-safe replacement for ctime, or locks around the call?
Waco wrote:Once upon a time I had faith that all developers at least gave their application a cursory run through helgrind prior to deploying anything.
just brew it! wrote:Waco wrote:Once upon a time I had faith that all developers at least gave their application a cursory run through helgrind prior to deploying anything.
Working in the industry for 30+ years will convince you beyond a shadow of a doubt that at least 50% of software developers don't have a f*cking clue what they are doing.
Waco wrote:just brew it! wrote:Working in the industry for 30+ years will convince you beyond a shadow of a doubt that at least 50% of software developers don't have a f*cking clue what they are doing.
I've been in it for just over a decade now...and I'm pretty sure it's closer to 95%.
Waco wrote:On one hand, finding C developers these days is difficult. On the other, they tend to be self motivated and good at what they do (since it's no longer taught in many many CompSci programs).
Waco wrote:Memory and thread management is a foreign concept to all too many "developers".
just brew it! wrote:...if you try to write a real-time system in Java
Waco wrote:just brew it! wrote:...if you try to write a real-time system in Java
Thanks for making me nearly spit coffee at my monitor.
chuckula wrote:In the developer's defense, it would be nice if the C API didn't require you to select different functions to perform the same operation based solely on thread safety or lack thereof.
The glibc documentation only refers to the thread-safety difference between the two functions in a flag: https://www.gnu.org/software/libc/manual/pdf/libc.pdf
The four functions asctime(), ctime(), gmtime() and localtime() return a pointer to static data and hence are not thread-safe. Thread-safe versions asctime_r(), ctime_r(), gmtime_r() and localtime_r() are specified by SUSv2, and available since libc 5.2.5.
chuckula wrote:Did this guy know he was writing multi-threaded code from the outset and blindly ignore thread safety or was this some old code that got copied in without being rewritten?
just brew it! wrote:There was also code in the same module which was attempting to clear a buffer (the address of which had been passed in as a pointer) by doing a "memset(buffer, 0, sizeof(buffer));"... anyone whose done much C programming knows that sizeof(buffer) in this case would be the size of the pointer, not the size of the thing it points to. IOW, this is just going to clear the first 8 bytes of the buffer (on a 64-bit CPU).
just brew it! wrote:Waco wrote:On one hand, finding C developers these days is difficult. On the other, they tend to be self motivated and good at what they do (since it's no longer taught in many many CompSci programs).
A lot of them tend to be older too. I think there will be a pretty severe shortage a few years down the road as more of my cohort starts hitting retirement age.
DragonDaddyBear wrote:This thread makes me appreciate you C-types even more. I wanted to get into programming and I didn't because every degree program I could find wanted 1) lots of calculus and 2) Java or some other higher-level language focus. I wanted to actually get into a program where I learned the CPU, assembly, etc. To be fair, I didn't look all that hard. But, while i was OK at math back in the day, I don't feel like relearning a bunch to do calc just to have a piece of paper that says I can write code.
SecretSquirrel wrote:DragonDaddyBear wrote:This thread makes me appreciate you C-types even more. I wanted to get into programming and I didn't because every degree program I could find wanted 1) lots of calculus and 2) Java or some other higher-level language focus. I wanted to actually get into a program where I learned the CPU, assembly, etc. To be fair, I didn't look all that hard. But, while i was OK at math back in the day, I don't feel like relearning a bunch to do calc just to have a piece of paper that says I can write code.
Look for a Computer Engineering program, if you can find one. It won't get you out of the Calculus, but they tend to focus more on the low levels of computers. The trick is to find one that isn't just a renamed CompSci program or a renamed EE program.
--SS
SecretSquirrel wrote:Look for a Computer Engineering program, if you can find one. It won't get you out of the Calculus, but they tend to focus more on the low levels of computers. The trick is to find one that isn't just a renamed CompSci program or a renamed EE program.
SecretSquirrel wrote:I'm kinda looking forward to it, being one of them there "C" programmers. Should nicely fund my "retirement".
FlamingSpaceJunk wrote:SecretSquirrel wrote:Look for a Computer Engineering program, if you can find one. It won't get you out of the Calculus, but they tend to focus more on the low levels of computers. The trick is to find one that isn't just a renamed CompSci program or a renamed EE program.
I usually tell people to get an EE if they want to get into the guts of electronics. There are EE jobs all over the place out there.
FlamingSpaceJunk wrote:SecretSquirrel wrote:I'm kinda looking forward to it, being one of them there "C" programmers. Should nicely fund my "retirement".
I had the same thought about Cobol.
just brew it! wrote:CPUs have gotten fast enough, and compilers good enough, that there is rarely a need to do anything in assembly language any more. C is used pretty much everywhere that assembly language would've been used "back in the day" -- OS kernels, device drivers, embedded systems, real-time.
The rare exceptions where assembly is still used are things like the optimized strncpy() I mentioned a few posts back. A frequently used library function like that can have a big effect on application performance, so it is worthwhile to provide code paths which are hand-optimized for specific instruction sets.
In hindsight, the secret to its continued success is the fact that it provides enough abstraction to be portable across architectures (if you code carefully), but still allows direct access to the hardware. In effect, it is almost a "high level assembly language".
chuckula wrote:In fact, hand-optimized assembly can be good for a while, but then might not perform as well over time as the CPU architectures change.
Case in point: recent optimization work in glibc that improves performance noticeably by moving away from old hand-optimized assembly that was good on old CPUs but doesn't translate to modern (and by "modern" I mean Sandy Bridge even) processors: https://www.phoronix.com/scan.php?page= ... -POWF-LOGF
chuckula wrote:In the developer's defense, it would be nice if the C API didn't require you to select different functions to perform the same operation based solely on thread safety or lack thereof.
notfred wrote:Not just the Linux kernel, most kernels are in C.
chuckula wrote:just brew it! wrote:CPUs have gotten fast enough, and compilers good enough, that there is rarely a need to do anything in assembly language any more. C is used pretty much everywhere that assembly language would've been used "back in the day" -- OS kernels, device drivers, embedded systems, real-time.
The rare exceptions where assembly is still used are things like the optimized strncpy() I mentioned a few posts back. A frequently used library function like that can have a big effect on application performance, so it is worthwhile to provide code paths which are hand-optimized for specific instruction sets.
Buub wrote:chuckula wrote:In the developer's defense, it would be nice if the C API didn't require you to select different functions to perform the same operation based solely on thread safety or lack thereof.
The C community is loathe to change the way things have always been.
The APIs, IMHO, are much more sane in C++, at least from this perspective. I'm not sure anyone willingly gets into templates, but at least they're logically consistent and can largely be approached from a consumption-only basis unless you're writing APIs or libraries.
just brew it! wrote:Buub wrote:chuckula wrote:In the developer's defense, it would be nice if the C API didn't require you to select different functions to perform the same operation based solely on thread safety or lack thereof.
The C community is loathe to change the way things have always been.
The APIs, IMHO, are much more sane in C++, at least from this perspective. I'm not sure anyone willingly gets into templates, but at least they're logically consistent and can largely be approached from a consumption-only basis unless you're writing APIs or libraries.
The Boost library and C++11 (and later) rely very heavily on templates for the newer language features. It's really powerful stuff (and I'm still trying to wrap my head around it). C++11 code that takes full advantage of the new language features doesn't even look like "classic" C++ code any more; it is effectively a new language which just happens to be backward-compatible.