5 ms·
Concise: A full compiler for ChocoPy be implemented in about 12 weeks by undergraduate students of computer science. This can be a hugely rewarding exercise for
by userbinator 7y ago
Concise: A full compiler for ChocoPy be implemented in about 12 weeks by undergraduate students of computer science. This can be a hugely rewarding exercise for students.
Written in itself, and thus self-compiling? IMHO that's one of the biggest advantages of using C/C-subset compilers, that it's relatively easy to do so, and I think writing a self-compiling compiler is especially important in a course because it really drives home the point that a compiler is just another piece of software.
- pjmlp 7y agoAgreed, however there are plenty of languages one can use for bootstraping, I don't see it as advantage from C/C++, rather how many lectures are lazy in how they build their curriculum. This one here is a great alternative approach, specially to dispel the idea C or C++ are required to be anywhere in a compiler stack.
- userbinator 7y agospecially to dispel the idea C or C++ are required to be anywhere in a compiler stack. According to the sibling comment, the compiler is written in Java. The Java compiler is written in Java and runs in a JVM which is itself written in C/C++, and we all know how C compilers were created...
- pjmlp 7y agoAlmost there, then a wrong turn. Java has multiple implementations, some of them happen to be fully done in Java, like JikesRVM, MaximeVM and Graal. Naturally you might say, that you only care about OpenJDK, which incidentally now has the Project Metropolis with the long term roadmap to use Graal and SubstrateVM to replace those C/C++ parts. As for C, many probably aren't aware that BCPL was originally designed to bootstrap CPL, a memory safe systems programming language based on Algol, which due to mismanagement never took off, while BCPL bare bones as it was, took a life of its own. Also well into the mid 90's there were quite a few OSes where C was still far from doing its mark, thus it was not even an idea to use it when bootstrapping a compiler.
- coldtea 7y ago>Java has multiple implementations, some of them happen to be fully done in Java, like JikesRVM, MaximeVM and Graal. Yes, but most of them, including Graal atm, are insignificant curiosities (as far as developers working with them are concerned. If they were a different language, they wouldn't even be on TIOBE 100, whereas Java in C/C++ is in the top 5). So pointing them out gives mainly "well, actually" pedantic points, than illuminates any real importance they have.
- pjmlp 7y agoJava the programming language is in the TIOBE top 5, not OpenJDK. Just like we don't have gcc, clang, msvc, whatever-cc on the TIOBE top 5. Apparently mixing languages with implementations keeps being a thing. Maybe we should also start arguing that C requires C++ to be implemented, given that all major mainstream C compilers are now written in C++.
- coldtea 7y ago>Java the programming language is in the TIOBE top 5, not OpenJDK. Yes, I'm obviously familiar with the distinction between language and implementation. My point is that regarding Java, it doesn't matter, as there's a single (well, 2 if you count Oracle - OpenJDK as different) and an insignificant assortment of others. The concrete implementation of "Java the programming language" actually used by enough people to put it in the TIOBE index is the Oracle/OpenJDK one. If we took all the other Java implementations mentioned, called them a different name (e.g. Jakarta) and added their users together, the new "language" user-base wise, they wouldn't even have made it to the Top 100. (Google's Java-copied Android APIs aside of course -- those do have tons of users and matter) >Apparently mixing languages with implementations keeps being a thing. Apparently the distinction between language and implementation is pedantic in most cases, where the alternative implementations are niche products and hobby projects, and as far as one is concerned Java is 99.9% a specific implementation.
- pjmlp 7y ago
- p4bl0 7y agoNo, they seem to write the compiler in Java. The thing with actually self-compiling is that you need language features such as file management, which are not trivial and would take time that we don't have in a compiler course to cover. There is already so much to be said about compilation, and generally the course must also cover assembly language and hardware architecture at least.
- tom_mellior 7y ago> The thing with actually self-compiling is that you need language features such as file management You should be able to "just" use the C library if your compiler uses a C-compatible calling convention (which is a good idea anyway) and allows a C-compatible representation of strings (for file names) and characters (for fgetc). File management is then mostly just passing opaque FILE * pointers around. IIRC the compiler course I took at university did this. That said, your parent's point is bogus: The act of writing a compiler in not-C is sufficient to drive home the point that a compiler is just another piece of software. On the contrary, writing a compiler in C because of self-hosting reinforces the misconception that compilers and C are somehow special.
- nickpsecurity 7y ago"because of self-hosting" Although I follow Bootstrapping projects, I think the self-hosting focus itself is a bad idea. PreScheme, a systems language, was easier to parse, more productive than, and compiled to C. The latter to leverage its optimizing compilers but showed it was not necessary to give up Scheme benefits to do it all in C. Likewise, many of these compilers would iterate faster with more correctness if written in a higher-level language instead of being self-hosting just because. The libraries will already test the language in a variety of situations. So, that excuse doesn't fly for me if trading away productivity and/or maintainability of the better language for the compiler/interpreter.
- tasogare 7y ago> because it really drives home the point that a compiler is just another piece of software This fact is already conveyed conveniently by writing the compiler itself in any language. The important this is the transformation from structure to structure and the recursive nature of grammar rules. Having wrote an assembler, a linker and for another project a sort of compiler with Flex & Bison (FsLexYacc actually) I think emphasis should be on how close writing a parser and compiler are (because one task include the other ). Thus, understanding the main ideas in compilers can be reused for real tasks such as data parser, where is can solve problems more eloquently than ad hoc coding.