Compiler Design Books Pdf Free Download

0 views
Skip to first unread message

Tisha

unread,
Aug 3, 2024, 4:49:58 PM8/3/24
to naugangmedsba

Rather than online, as mentioned in the above answer, grab yourself a copy of the Dragon book Compilers: Principles, Techniques, and Tools. A copy of the first edition shouldn't set you back too much.

Some things are not best learned on-line, and something of the complexity of compiler design is one of them. For a list of books on the subject, take a look at this question. I selected it more or less at random from a lot of similar questions - to get a list of them all, Google for

I have taken no formal Computer Science classes. I have programmed in Python and attempted C# without success. My technical vocabulary is expansive, yet scattered over a very wide range of computer science topics.

I have a very long way to go before I can get to a level where I could reasonably read a book about compiler design/theory. I am asking what steps I need to take before attempting compiler design. I have some examples here already:

Edit: I can't for the life of me see how this problem is unclear. I quite clearly bolded what I was asking. I was expecting it to be marked as biased, vague/broad, or too generalized, but certainly not unclear. Don't be afraid to say it's unconstructive (just make sure whatever it is classified under is accurate).

A compiler is a program like any other program. It takes some input, tries to make sense of it, and generates some output. Have you ever written a program which reads a text file in some format and outputs some HTML based on that text? Well, congratulations: you already have written a compiler. A very simple one, I admit, but it is a compiler.

There are several compiler design textbooks available today, but most have been written for graduate students. Here at Rowan University, our students have had difficulty reading these books. However, I felt it was not the subject matter that was the problem, but the way it was presented. I was sure that if concepts were presented at a slower pace, with sample problems and diagrams to illustrate the concepts, that our students would be able to master the concepts. This is what I have attempted to do in writing this book.

I am just an eager student that wants to learn about compilers (everything about them). Currently, I do a lot of computer vision and NLP but I am really interested in compilers and currently, I have also started with swift.

And also, I'd highly recommend just trying to contribute to Swift itself. We have a lot of bugs on bugs.swift.org marked as "Starter Bug" that you can pick from. If something seems interesting, assign it to yourself, send me a message, and I'll help you get started building the project.

It's worth pointing out that "compilers" is a very broad subject area, and its easy to feel overwhelmed at first. There are actually multiple subtopics that have little to do with each other, and together they comprise "compiler development". Examples:

Once you learn enough to gain a broad overview of the field, you should pick an area to specialize in. Even those of us that work on compilers for a living can't really hope to learn everything, so that's why on a typical team of compiler engineers you'll find experts on type theory, module systems, optimizations, debuggers, and so on.

One thing I've found is that textbooks about compilers heavily focus on parsing and optimization, but discussion of type checking is often rather minimal and the other areas are barely mentioned at all. It would be nice if someone wrote a "modern compiler frontend design" book that skipped parsing and code generation and did a deep dive on everything in between instead!

This. Going from a compilers textbook to a project like LLVM/Clang/Swift is like building a paper airplane and then working on A320s. Nothing in my undergraduate or graduate compilers courses really prepared me for anything more than toy work. (Those courses predated Clang, so I hope modern courses try to do it a little better, but 15 weeks isn't nearly enough time.)

Compared to similar projects of size and scope, the LLVM and Swift projects are some of the cleanest, better-documented ones that I've experienced. Grab a debugger, sprinkle some breakpoints around, explore, and just start calling the dump() method on literally everything. There's a ton of useful information baked in there to figure out what's going on, and you'll probably be productive faster than you initially expected.

Can someone from their experience comment on these books, based on the technologies being used in 2019 vs what is taught in these books. Mostly, the concepts would remain the same but what technologies are being used to write compilers in 2019.

In terms of type theory specifically, how useful do you think books like Software Foundations, Practical Foundations for Programming Languages or even (gasp) Homotopy Type Theory would be? I see those being thrown around a lot, but are they practical or are they too much "out there"? (For the record, the only one I've started to look at so far is Software Foundation and while I enjoy it immensely, it also doesn't immediately seem to be applicable to anything.)

Thank you, everyone, who contributed for the awesome resources. I have made up my plan on how to study the topic, with an equal focus on theory and practical part at the same time. It is such an awesome topic to work on.

4/ Concerning, possible OCaml major features that has been discussed here and there in the past such as typed effects , modular implicits, etc. what is the situation? (requested feature, motivation of this feature, expected benefits)
Is metaOCaml planned to be incorporated in a future Ocaml distribution instead of being a set of patches (currently still to the OCaml 4.07.1 distribution)?

Which one studying first to get the big picture before starting to play with some fragments of this very large program? (with the short/medium/long terms goals to understand, suggest and participate to the OCaml compiler design and development, respectively).

A little background: I was customising the compiler to emit custom instructions for RISC-V - this meant having a fairly good grasp of the overall structure of the compiler pipeline (although not the nitty-gritty details of each transformation).

As part of my CS degree we did a Compiler Construction course (using OCaml) which constructs a very simple (mostly interpreted) language called Slang ( -G-Griffin/cc_cl_cam_ac_uk/tree/master/slang). Looking at the source-code for this might be a more digestible way of understanding the tools like the parser and lexer (.mly and .mll) than jumping in at the deep-end with the OCaml ones.

The asmcomp directory contains the code for generating assembly (the back-end of the compiler). I think writing small programs and passing the -S compiler flag and analysing the generated assembly is incredibly useful, especially if you then try tracking back up the compiler pipeline to see where the assembly came from (one good example would be the jump tables used for larger pattern matches).

Note: HACKING.adoc and CONTRIBUTING.adoc in the compiler sources are living document. If there are important things that are missing from them, we can add them. For example, there is a section on the compiler overall structure (which lists the subdirectories, mostly), which can be completed if people want to add more information. (We also want to keep the whole thing reasonably short and readable, so some things may be better branched to sub-files, but you get the idea.)

Some bugs could be prevented by certified programming in the OCaml source of the compiler, or the standard library; this sounds like it would be a lot of work. For starters, there are no formal-verification tools for OCaml programs today. (Should you port parts of the compiler in Why3, or prove them correct using CFML, or write a formal verifier for static contracts/assertions in OCaml programs? In any case, years of work ahead.)

Some bugs are in the runtime, and some of them could possibly be fixed by using a program verifier for C, or by moving parts of the runtime to a safer language (maybe Rust, but then the dependency chain would be huge, so this may be rejected for maintenability/portability reasons). Again, years of work. Some FFI bugs could be caught by a dedicated verification tool, which is less work than general program proof; see the previous work on the Saffire FFI checker, which is sadly unused today.

Last time I asked Oleg (the author and maintainer) a couple years ago, he preferred to not have BER MetaOCaml upstreamed, because he was still unsure about some design decisions. Other people may know more about the current situation.

Have you considered helping update to a more recent version of OCaml? That sounds like a great way to learn a lot about the implementation in a short amount of time. (I would guess that the easiest way to do it is to migrate one version at a time: 4.08, then 4.09, then 4.10.)

MetaOcaml integration was discussed with Oleg few months ago, and he was mostly interested in having syntactic hooks in the compiler to make porting MetaOcaml easier rather than a full blown integration.

3/ Beyond declaring issues on GitHub - ocaml/ocaml: The core OCaml system: compilers, runtime system, base libraries and fixing them as usual in OSS, is there a defined design process, especially with formal/semi-formal requirements, and is there a steering committee?

Not every change has to go through this full process, of course, but the intention is to signpost upcoming changes well ahead of time such that design issues can be worked out before substantial effort has been put into implementation.

One caveat: I would not recommend trying to implement a new syntax or feature, because those are rarely accepted (fortunately). It is easier to work on something for which there is clear consensus that we want it, such as fixing a bug, upgrading some piece of software, etc.

c80f0f1006
Reply all
Reply to author
Forward
0 new messages