8 ms·
A shame that it uses C though, imo, instead of being language agnostic.
by dunefox 4y ago
A shame that it uses C though, imo, instead of being language agnostic.
- episode0x01 4y agoI mean isn't C ubiquitous enough that it is essentially language agnostic? Or is your suggestion that is should be purely pseudocode?
- dunefox 4y agoWith C you need to pay attention to things like manual memory management which aren't necessary with other languages or to understand the material.
- programmer_dude 4y agoManual memory management is optional. IIRC some version of the D compiler was written assuming an infinite virtual address space (basically they just did not bother calling free() ever)!
- melony 4y agoIs that why D is so prevalent among (some) quant shops?
- duped 4y agoThere's a chapter in the book dedicated to memory layout of programs that discusses program segments, paging, implementation of malloc/free, etc that is more or less required before getting to the assembler and codegen stages. Even if you can write a compiler assuming infinite memory that generates programs that also assume it, it would be a disservice to readers to ignore that for brevity. It's an important part of understanding how programs are created.
- s_dev 4y agoAye but these lads are building a compiler. Probably shouldn't hide things like 'memory management' at the introduction stage as use of memory is inherent to all computing and programming.
- dunefox 4y agoSure, that makes sense, but you can write a compiler in languages that don't require it themselves. That's what I meant.
- arinlen 4y ago> Sure, that makes sense, but you can write a compiler in languages that don't require it themselves. I don't follow your rationale. With C the developer manages heap memory by basically calling malloc and free. This means that once you have the memory model set, all you need to do to roll your compiler is to implement the interface. A language that "don't require it themselves" is a language which provides only high level constructs and dumps all the memory management logic to the compiler/runtime, from object allocation/deallocation to lifetime management. How is that simpler to pull off by a compiler writer?
- Koshkin 4y agoThe target language generally has nothing to do with the language of the compiler, where automatic memory management is just as useful (and also helps to minimize the amount of unrelated technical detail) as anywhere else.
- programmer_dude 4y agoPseudocode can be easy to understand but you (also) need a real language to cement your understanding of the subject.
- dunefox 4y ago> you (also) need a real language to cement your understanding of the subject. That's why I'd like to use a language that I already know instead of learning a new one while also learning new material.
- programmer_dude 4y agoBasic C is not that hard. Probably one of the easiest languages to get into.
- Koshkin 4y agoSure, but it’s a hard language to write good code in.
- d_tr 4y agoWell you can. If you understand the algorithm you can write it in any language you know. Additionally, C is at basic level just loops, conditionals and function calls so it will be easy to translate from it if you need to. And then there are other books using other languages out there and people can choose.
- Koshkin 4y agoIt is also manual memory management, lack of generics, of polymorphism, and what not else. Even C++ would be a better choice.
- Koshkin 4y agoYes. Pseudocode is better for teaching than C. Plus, translating pseudocode into a language of choice is a good exercise. Another good idea is to write a compiler in the target language.
- lelanthran 4y ago> A shame that it uses C though, imo, instead of being language agnostic. What did you have in mind?
- dunefox 4y agoHonestly, I think I'd prefer pseudocode that I can read to understand the idea and then work in my language of choice rather than C.
- ethanwillis 4y agoPsuedocode means ambiguity which means misunderstandings. As soon as you remove all ambiguity any Pseudocode just becomes a language.
- dunefox 4y agoGood point, although I think it should be doable when describing input and output well enough.
- setr 4y agoThat's been delegated to the diagrams and algebra -- and there's also the usual english-psuedocode interspersed throughout the chapters (presumably more so on the theoretical chapters e.g. chapter 4)
- arinlen 4y ago> Honestly, I think I'd prefer pseudocode that I can read to understand the idea and then work in my language of choice rather than C. What stops you from understanding the idea by reading C? It's a tried-and-true language whose K&R version fits entirely in an easy to read ~180pg book which has real world applications, unlike pseudocode.
- Koshkin 4y agoC code is usually rife with unrelated technical detail like manual memory management. It also lacks ways to build useful abstractions that exist in other languages.
- metalloid 4y agoIn the introduction (1.4. What language should I use?) - the author explains why he used C. Please read it.
- chrisseaton 4y agoI think C is basically language agnostic, isn't it? Approximately everyone working at the level of a course on compilers knows C.
- dunefox 4y agoI don't know C and have no intention of learning it, so I'd prefer pseudocode that I can read without already knowing C or investing time into learning C just for this book.
- chrisseaton 4y agoI really struggle how someone can be ready to learn about compilers without already having enough context where they know C. If you know enough to be doing compilers, you can pick up C in 15 mins.
- dunefox 4y agoI don't know how this is difficult to imagine. I have no need for C and am interested in interpreters and compilers.
- chrisseaton 4y ago> have no need for C and am interested in interpreters and compilers But you do have a need for it, because it’s the lingua franca of conversations about compilers and interpreters… as you’ve just found out with this course. Like saying you want to work in the Vatican but you have no need for Latin.
- dunefox 4y ago> because it’s the lingua franca of conversations about compilers and interpreters There are many materials, compilers, and interpreters that use ocaml and haskell, for example. C isn't the only one. That's why I'd prefer pseudo code instead of C, so that I could use this book without learning a specific language only for it.
- globuous 4y agoAgreed! I would have used ML faminly languages. Of course, that implies learning ML before reading the book whereas C is definitely known by more developers as it’s been in all of our courses
- dunefox 4y agoSure, then it would be the same thing just with ML (which I pers. would prefer to C, but yeah). Pseudocode to explain the idea would be ideal, then you can work through the book in a familiar language. C is fine, it's just not ideal for me to learn C which I have no use for and learn a new skill at the same time.
- capitalsigma 4y agoML-like pseudocode would be much different from C-like or python-like pseudocode (e.g. heavy use of ADTs)
- deleted 4y ago[deleted]