3 ms·
For those of you who took it - does it go into detail how to do advanced LALR languages, including handling semantics and types? Can I use the knowledge to make
by bitL 9y ago
For those of you who took it - does it go into detail how to do advanced LALR languages, including handling semantics and types? Can I use the knowledge to make my own OOP + FP language right away (Scala/Kotlin-like), or do I need to study much much more than what is covered in this course? Thanks!
- jfoutz 9y agoI didn't take this course. I have taken compiler classes. Short answer, yes. Longer answer, compilers of any sort are hard, because there's both a lot of special cases and also pressure to be algorithmically efficient. Writing any kind of compiler is going to force you to do stuff with the parse tree. It's up to you to decide if float a = 1 is an error or not. doing things like constant value evaluation int a = 1 + 2 + 3 => int a = 6 will get you a feel for all the different ways you can transform the parse tree. It's going to feel frustrating, because it's not the language you want to work on. But building up the skills to shuffle ast nodes is really really helpful. Making your own language is hard. if your goal is a working language, i'd suggest building an interpreter first, so you can really nail down the semantics. at the end of that you're going to have a call that looks like eval(ast, context). you can do a simple compiler by just reimplementing eval, rather than doing the work, spit out the code that would do the work. also, if you have an adequate interpreter, you can you can write your compiler in your own language.
- tom_mellior 9y ago> Can I use the knowledge to make my own OOP + FP language right away I didn't take this course, but from the syllabus posted above it looks like garbage collection is not covered at all. That's pretty much a requirement for FP languages, and it makes OOP languages easier too. So you'd have to look at other resources for that. A simple semispace collector should be relatively easy to write even if you don't want to get too deep into the matter. For a very first version of your language, you can of course just allocate memory without ever freeing it. That's good enough to experiment with simple programs. Another point that I think isn't covered in this course, and that is relevant for (many) functional languages, is pattern matching and the representation of algebraic datatypes.
- tomku 9y agoI took the course several years ago and finished it. It's focused on the basic concepts of compiler implementation with the example language (COOL) being pretty traditionally object-oriented. It's absolutely not a how-to course on how to implement advanced language features.