News for hackers. Stuff that matters.
Re:Introduction to Compilers and Language Design (2021) by dunefox on Wednesday May 18, 2022 @08:24AM (#31421878)
I 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.
Re:Introduction to Compilers and Language Design (2021) by chrisseaton on Wednesday May 18, 2022 @08:29AM (#31421932)
I 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.
Re:Introduction to Compilers and Language Design (2021) by dunefox on Wednesday May 18, 2022 @08:38AM (#31422010)
I don't know how this is difficult to imagine. I have no need for C and am interested in interpreters and compilers.
Re:Introduction to Compilers and Language Design (2021) by chrisseaton on Wednesday May 18, 2022 @08:45AM (#31422063)
> 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.

Re:Introduction to Compilers and Language Design (2021) by dunefox on Wednesday May 18, 2022 @08:55AM (#31422153)
> 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.

Re:Introduction to Compilers and Language Design (2021) by chrisseaton on Wednesday May 18, 2022 @09:05AM (#31422267)
I really don’t understand what you’re planning to do the first time someone says to ‘check the header file’ to understand how some system call works.
Re:Introduction to Compilers and Language Design (2021) by rhn_mk1 on Wednesday May 18, 2022 @09:40AM (#31422626)
For that, you don't need to know C the language, but C the calling convention https://gankra.github.io/blah/c-isnt-a-language/
Re:Introduction to Compilers and Language Design (2021) by chrisseaton on Wednesday May 18, 2022 @09:46AM (#31422690)
This doesn't make any sense. Even you knew the C calling convention, but not C, where are you going to get documentation for system calls that doesn't use C code? The Linux, macOS, etc documentation uses C.
Re:Introduction to Compilers and Language Design (2021) by t-3 on Wednesday May 18, 2022 @12:46PM (#31424908)
Reading the headers and prototypes in the man pages doesn't require "knowing" C. You just need to know the very simple subset of C's syntactical rules and the calling conventions. Anyway, reading C is far easier than writing C, most popular languages use the same syntax and operators.
Re:Introduction to Compilers and Language Design (2021) by dunefox on Wednesday May 18, 2022 @09:47AM (#31422715)
I don't know what that has to do with learning about compilers and interpreters.
Re:Introduction to Compilers and Language Design (2021) by chrisseaton on Wednesday May 18, 2022 @10:09AM (#31422976)
> I don't know what that has to do with learning about compilers and interpreters.

Compilers and interpreters, unless they're running on bare metal, which is very niche, talk to the operating system using something called 'system calls' to ask for resources that they can't provide themselves, like virtual memory space and IO. These system calls are documented in C.

For example I wrote a Ruby compiler in Ruby, but I still need to know about the mmap system call, which is documented in C, to allocate my memory.

https://github.com/chrisseaton/rhizome/blob/main/doc/memory....

https://man7.org/linux/man-pages/man2/mmap.2.html

https://github.com/chrisseaton/rhizome/blob/main/lib/rhizome...

Re:Introduction to Compilers and Language Design (2021) by dunefox on Wednesday May 18, 2022 @10:47AM (#31423460)
Now I can finally reply: that makes sense, and in hindsight is quite obvious, thanks. My general lack of knowledge in this area is a part of why I'd like to study it more, but preferably I'd like to use a language I'm already comfortable with. C is just very far removed from everything I have use for and am interested in.
Re:Introduction to Compilers and Language Design (2021) by Koshkin on Wednesday May 18, 2022 @08:09PM (#31429151)
> These system calls are documented in C.

Sure, but the compiler will still have to generate machine code for those.

Re:Introduction to Compilers and Language Design (2021) by ethanwillis on Wednesday May 18, 2022 @10:04AM (#31422916)
Well, the author shouldn't have to potentially learn another language just to write a book on compilers and interpreters.

Maybe... MAYBE you don't have to read this book.

Re:Introduction to Compilers and Language Design (2021) by dunefox on Wednesday May 18, 2022 @10:48AM (#31423482)
> Maybe... MAYBE you don't have to read this book.

Where did I say I have to read it or that the author should learn another language? Nowhere. I said I wish it wasn't using C so that I could read it more easily.

Re:Introduction to Compilers and Language Design (2021) by d_tr on Wednesday May 18, 2022 @11:36AM (#31424080)
You will have to learn whatever it is you do not like about C anyway if you want to generate machine code.