7 ms·
One interesting part of this book is the language chosen is C. Now, we all know the downsides but the good part is it allows the student to understand the runti
by npalli 3y ago
One interesting part of this book is the language chosen is C. Now, we all know the downsides but the good part is it allows the student to understand the runtime efficiency, memory usage and complexity of various algorithms closer to what you can expect in the ideal case. I see a lot of books nowadays using Python, it is not clear with such a high level language you understand the tradeoffs. How much of the slowness is due to the algorithms vs the data structures you chose from Python.
Of course, no GC, segfaults and OOM are some of the downsides of C but this is not production code. You can use this knowledge to understand how various algorithms are implemented in other languages and predict behavior or chose a better one.
- 082349872349872 3y agosee also MMIX (and its predecessor, MIX)
- Arainach 3y agoC is a much more appropriate choice in my opinion. It expresses 99.9% of the same concepts while being orders of magnitude faster to read. Most people I know who have tried to read (some of) Knuth cited MMIX among their reasons for eventually growing tired and abandoning the effort.
- kazinator 3y ago> It expresses 99.9% of the same concepts while being orders of magnitude faster to read. Knuth thinks so, or did at some point. "I think C has a lot of features that are very important. The way C handles pointers, for example, was a brilliant innovation; it solved a lot of problems that we had before in data structuring and made the programs look good afterwards. C isn't the perfect language, no language is, but I think it has a lot of virtues, and you can avoid the parts you don't like. I do like C as a language, especially because it blends in with the operating system (if you're using UNIX, for example). All through my life, I've always used the programming language that blended best with the debugging system and operating system that I'm using. If I had a better debugger for language X, and if X went well with the operating system, I would be using that." Dec 7, 1993, Computer Literacy Bookshops Interview.
- jevoten 3y ago> The way C handles pointers, for example, was a brilliant innovation; How were pointers handled before?
- globular-toast 3y agoWhat he's talking about is pointer arithmetic. In assembly you have to "know" what is being pointed at such that you can access an element in an array or a component of a composite type, for example. The computer only knows about bytes. In C you can just do stuff like `(p + 6)->t` and the compiler knows how many bytes "+6" is because it knows what `p` is pointing at.
- layer8 3y agoLike integers that you could decide to interpret as a memory address and thus use like a char * (char pointer). As in machine code, basically. C made pointer arithmetics work like array indexing. Also, the combined dereferencing and member lookup operator (->).
- kazinator 3y ago> Also, the combined dereferencing and member lookup operator (->). That's actually a dud. The motivation was likely caused by the silly choice of the dereference operator being unary/prefix, requiring parentheses in (*ptr).memb. Compare with Pascal's ptr^.member where no parentheses are required. But ptr.memb can just work as well as value.memb. The operator statically knows whether the left operand is a pointer to a struct/union or a struct/union value.
- Affric 3y agoWhen we teach students we have to balance employability, pedagogical utility, interest, and learning curve. The majority of students won’t need to know C to be employable. Teaching an Algos course in JS helps web dev. In Python helps data science. Java is still pretty popular for enterprise. The majority of students will find it quite difficult compared to most languages they use. C does not reflect a truly low level machine. You might be able to teach them the same thing with an assembly language. The kids who want to know C will teach themselves. And they will be taught some in operating systems.
- deleted 3y ago[deleted]
- dartos 3y agoI learned much more about the low level machinations writing LC3 assembly in school than I did writing C. JMP (and the conditional variants) and MOV were eye openers for me. But it’d probably be harder to learn some basic algorithms in LC3 than C.
- rudedogg 3y agoI think knowing C makes you stand out, and demonstrates you understand how a computer fundamentally works. https://pll.harvard.edu/course/cs50-introduction-computer-science https://pll.harvard.edu/course/cs50-introduction-computer-sc... is mostly C too. I don't know C for what it's worth, but learned a different low-level language and found the experience to be enlightening, even after programming most of my life.
- bmitc 3y agoI think it's best to teach in a high-level, multi-paradigm language that isn't one of the popular languages. It resets the playing field, provides a nice language to have in their tool belt, and still allows easy transition to other languages.
- deleted 3y ago[deleted]