Earlier quoted context omitted.
> What that means is that most C operations can be easily translated into the machine code equivalents and that makes debugging of compiled code so much easier. A disassembly of many binaries will reveal their C roots by function calls being equivalent to jump statements, as an example. If you have the C source then you can usually figure out what's going on. This is very much not true in my experience. Optimization…
Why would you turn on optimization while debugging?
Should you learn C to “learn how the computer works”?
341–350 of 381 posts
Re: Should you learn C to “learn how the computer works”?
#342Earlier quoted context omitted.
Addition, subtraction, and stack-relative addressing are, in most architectures I'm familiar with, generic- stack-relative addressing ends up just being a special case of register-relative addressing, and addition and subtraction are rather important instructions in their own right. PUSH/POP are more obviously "hey store your locals on the stack, kids", but on, say, x64, how often do you actually see a push instead o…
There's a reason 32-bit ARM has 'move base register down and then do some stores' and 'do loads and then move base register up' (stmdb and ldmia) rather than just plain old ldm and stm, and I'm pretty sure it's because it makes the entry and exit sequences for function calls with a stack shorter. (The ARM ISA doesn't privilege a downward growing stack, so you can use stmib and ldmda if you want your stack to grow upw…
Re: Should you learn C to “learn how the computer works”?
#343Earlier quoted context omitted.
Arguably those problems did not exist before the C-era as software wasn't large or complicated enough. C++ directly attempts to improve over C by providing new mechanisms to solve problems encountered by C developers every day. Point is that out of context, a lot of the things modern languages provide seem superfluous. Why have objects? Why have templates, closures, or lambdas? For a novice programmer, these are many…
When I see templates, I run in the opposite direction at a dead sprint. C++ has added very little of value to the language and templates are one of their worst offerings. Metaprogramming is an antipattern in C.
Yet we often see passionate arguments in its favor, as for instance from Sústrik (http://250bpm.com/blog:56) and Tatham (https://www.chiark.greenend.org.uk/~sgtatham/mp/) and a person on the internet who recommends replacing LAPACK with preprocessor macros (http://wordsandbuttons.online/outperforming_lapack_with_c_me...). Would you care to comment on its enduring popularity?
Re: Should you learn C to “learn how the computer works”?
#344Earlier quoted context omitted.
When I see templates, I run in the opposite direction at a dead sprint. C++ has added very little of value to the language and templates are one of their worst offerings. Metaprogramming is an antipattern in C.
> Metaprogramming is an antipattern in C. Yet we often see passionate arguments in its favor, as for instance from Sústrik ( http://250bpm.com/blog:56 ) and Tatham ( https://www.chiark.greenend.org.uk/~sgtatham/mp/ ) and a person on the internet who recommends replacing LAPACK with preprocessor macros ( http://wordsandbuttons.online/outperforming_lapack_with_c_me... ). Would you care to comment on its enduring popula…
Re: Should you learn C to “learn how the computer works”?
#345Earlier quoted context omitted.
My point was that C programmers aren't experts at their craft, just experts at C, and all the habits that were possibly good in C carry over, making them less than good at Python. Also, I think your comment is a great example of the mentality that C programmers I've worked with brought to the table (partially because it's true for C but untrue for other language, particularly python); that if you can write code that…
C is their craft and they're experts so what's not to like? I'm not sure what this 'good enough' angle is and why you think it's specific to C. It's an issue to other language more than C as those other languages are often used by shops without proper software engineering practices in place. All the places I've worked which use C enforce those SW practices but it's not clear to me that the same could be said for othe…
There are literally no habits in your mind that could be good in C but bad in Python?
Re: Should you learn C to “learn how the computer works”?
#346What really made computers click to me was reading a book that had the premise: "learn just enough assembly to be able to implement C features by hand; we'll show you how". Sadly, I don't remember the title. Another revelation much later on, was, as discussed here, the realisation that C is indeed defined over an abstract machine. I think much of those realisations were because of reading about how crazy compiler opt…
I have to ask, because I've wondered for a couple years now, is your name a One Piece reference?
Re: Should you learn C to “learn how the computer works”?
#347Earlier quoted context omitted.
I have to ask, because I've wondered for a couple years now, is your name a One Piece reference?
Yes it is! Thank you for noticing!
I will say, waiting until he was capable and willing to read the subbed version was probably the right choice. Dubbed shows of any genre drive me nuts, and I'm not sure he would have the patience for the series if he was younger (the Alabasta arc was still taxing...). I do take a perverse pleasure in hinting about how crazy stuff becomes later, while also convincing him to not ruin it for himself by looking it up. ;)
Re: Should you learn C to “learn how the computer works”?
#348Earlier quoted context omitted.
It would be valid, though. A computer programmer must understand how a computer works lest she or he write slow, bloated, inefficient software.
Given how many person-years have been saved and how much value has been produced by "slow, bloated, inefficient software", I must disagree in the strongest possible terms. Producing "slow, bloated, inefficient software" is far, far preferable to not producing software at all.
Re: Should you learn C to “learn how the computer works”?
#349Earlier quoted context omitted.
Register renaming was invented to give assembler code generated from C enough variables in the forms of processor registers, so that calling functions wouldn't incur as much of a performance penalty. The UltraSPARC processor is a stereotypical example, a RISC processor designed to cater to a C compiler as much as possible: with register renaming, it has 256 virtual registers!
Why do you claim that local variables and function calls are specific to C? They seem to be very popular among programming languages in general.
Re: Should you learn C to “learn how the computer works”?
#350Earlier quoted context omitted.
There are many languages which have undefined behavior. C does have a lot of it, and it can be anywhere. In many languages, you can cause undefined behavior through its FFI. Some languages, like Rust, have UB, but only in well-defined places (a module containing unsafe code, in its case).
If a language lets you cause undefined behaviour via FFI into C, I think it's fair to say that that remains a problem created by C. I do take your point about Rust, but I'd see that as deriving from LLVM's undefined behaviour which in turn descends from C; I'm not aware of any pre-C languages having C-style exploding undefined behaviour or of any subsequent languages inventing it independently.
FFI isn't into "C", it's into your operating system's binary format. And since no two systems behave the same, it's UB however you look at it.