Slashdot Mirror


Which Compiler to Extend for a Small Project?

Andreas(R) asks: "While planning the design of my small programming language, and would appreciate some lessons learned from experienced programmers which have already tried this. I was investigating whether to start from an existing compiler and extend it. The compiler will be based on yacc, or bison. The programming language will be interpreted, object oriented and have higher order programming. Perl 1 seems like a decent starting point, as it's yacc based, and 5000 lines of code. Later versions of Perl are too large to get a good understanding of the whole program in a short period of time. Perl also has the right license (GPL). Is Python out of the question for such a project, since it's not GPL? What other small languages can be used instead? How do I go about designing a small programming language in practice, using what I already know about compiler theory?"

5 of 89 comments (clear)

  1. Re:This is going to get me in trouble by SpaceLifeForm · · Score: 3, Interesting

    I can't argue your excellent points.
    I would add that (given time) that he may want to look at SmallTalk also.
    At least for inspiration.

    --
    You are being MICROattacked, from various angles, in a SOFT manner.
  2. Re:my $0.02 after a couple compiler classes by Profane+MuthaFucka · · Score: 4, Interesting

    Wow, all excellent ideas. I will add just one more: if you can possibly manage it, use a garbage collected language, or make use of the Boehm collector. If you're using a bison/yacc approach, the structure you're working in can make proper allocation and deallocation pretty complicated.

    --
    Fascism trolls keeping me up every night. When I starts a preachin', he HITS ME WITH HIS REICH!
  3. Re:Holy cow! by xp · · Score: 5, Interesting

    Or why don't you design a meta-language using which other languages can be designed -- a language that remains completely extensible -- something like MDef.

  4. Have A Look At LLVM by swagora · · Score: 3, Interesting

    Andreas(R):

    While you haven't provided enough details to comment in length, I do have some experience with what you're planning. A couple of years back I started a programming system (XPS) which was rather audacious in scope. After two years of working on it, I realized that I too needed a "back end" compilation system. I looked at various alternatives like GCC (too complex), research compilers (low quality), open source virtual machines like Mono (immature at the time). I was quite surprised when I looked at UIUC's LLVM compiler toolkit. I thought it would be just another half-baked compiler system from a University that never got finished when the Ph.D student left. Instead, I found a well designed, working, *toolkit* for compiler construction. While LLVM still lacks some features, its core is very solid and easily extensible. I've been working with it for a year now and its been quite a pleasure. Check it out at http://llvm.cs.uiuc.edu/

  5. Battery life by tepples · · Score: 3, Interesting

    It mattered with 640KB of RAM at 20MHz

    How much CPU power is in inexpensive handheld devices again? I program for one that has 384 KB of RAM at 16.8 MHz. Wouldn't overclocking a handheld device drain the battery faster?