Beggining the compiler journey

Discussion in 'Ruby' started by Rafael Rosa, Dec 13, 2008.

  1. Rafael Rosa

    Rafael Rosa Guest

    Hi,

    I've being working with computer's for 13+ years, but I classify myself
    as a good high-level (as in high abstraction) programmer, with a
    business logic focus. As such I don't have any relevant knowledge about
    low level stuff, except the big picture ideas like what's a compiler,
    bytecode, process, threads, etc, I never studied the actual
    implementation of those things.

    Now I wish to take a dive and learn this stuff, but I'm having a hard
    time finding a good global guide. I'm looking for a book, a tutorial, or
    anything like that, that can explain the differences between the
    architecture for a language used with a VM and another without, what's
    the impact of these choices when building a compiler, how low level
    memory management works, what's the current trend, etc.

    I've navigated Wikipedia and Google, and started to read Jack Crenshaw's
    compiler tutorial, and though I like the hands-on approach (specially
    the use of Pascal), and think that's it's a nice first-timer stuff, it
    assumes the reader knows how to read assembly language and how to work
    with stack stuff. Another thing is that it's not designed to work with
    pré-8080 processors and I'm pretty sure there's a world of differences
    between that and current technologies, like multi-core processors.

    I've also started to read Niklaus Wirth "Compiler Construction" and it's
    really, really nice, but it also assumes the reader knows a lot of stuff
    that I don't. I can understand the basics of it, but can't understand
    the details, so I need more info.

    Anyway, I'm looking for a good guide to help me find my way. I'm not
    planning to become a compiler expert or really understand the complex
    math behind all of it, I just want to have a geek hobby and have a
    understanding of what's going on behind the curtains. If anyone can
    recommend me a good companion for Wirth's work, I'd be very happy. Stuff
    in Portuguese, French or Spanish, and of course English, is welcome.

    By the way, I'm asking this kind of stuff on a Ruby list because I want
    to play with Ruby language stuff, so I thought it would be better to be
    around the appropriate folks. I've even downloaded Ruby's source but I
    have no idea of where to start reading it :)

    Thanks a lot,
    Rafael.
    --
    Posted via http://www.ruby-forum.com/.
     
    Rafael Rosa, Dec 13, 2008
    #1
    1. Advertising

  2. Rafael Rosa

    Jens Wille Guest

    hi rafael!

    Rafael Rosa [2008-12-13 16:58]:
    > Now I wish to take a dive and learn this stuff, but I'm having a
    > hard time finding a good global guide. I'm looking for a book, a
    > tutorial, or anything like that, that can explain the differences
    > between the architecture for a language used with a VM and
    > another without, what's the impact of these choices when building
    > a compiler, how low level memory management works, what's the
    > current trend, etc.

    maybe "Programming Language Pragmatics" by Michael L. Scott can give
    you some hints. it might not be a perfect fit for your needs,
    though. just thought i'd throw it in... i'm coming from a totally
    different background but i really enjoy reading it.

    <http://www.cs.rochester.edu/~scott/pragmatics/>

    > By the way, I'm asking this kind of stuff on a Ruby list because
    > I want to play with Ruby language stuff, so I thought it would be
    > better to be around the appropriate folks. I've even downloaded
    > Ruby's source but I have no idea of where to start reading it :)

    the README.EXT file might be a good starting point.

    cheers
    jens

    --
    Jens Wille, Dipl.-Bibl. (FH)
    prometheus - Das verteilte digitale Bildarchiv für Forschung & Lehre
    Kunsthistorisches Institut der Universität zu Köln
    Albertus-Magnus-Platz, D-50923 Köln
    Tel.: +49 (0)221 470-6668, E-Mail:
    http://www.prometheus-bildarchiv.de/
     
    Jens Wille, Dec 13, 2008
    #2
    1. Advertising

  3. Rafael Rosa

    Rafael Rosa Guest

    Hi Jens.

    Thanks for the link, I've read the Preface and the took a peek on the
    index and it seems to be very very close to what I'm looking for, thanks
    a lot.

    As for the readme, I did read it, but it didn't explain how to
    understand how the compiler code is organized, and I didn't expect it to
    do so :) Without understanding how things should be arranged is very
    hard to look at all those C files and make sense of what's going on,
    specially when you don't know C :)

    I've also found some interesting stuff at http://www.antlr.org/, even a
    Ruby command dictionary, very nice. It will be even more interesting
    when I know what to do next :)

    Thanks a lot, I keep studding.
    Rafael.
    --
    Posted via http://www.ruby-forum.com/.
     
    Rafael Rosa, Dec 13, 2008
    #3
  4. Rafael Rosa

    Jens Wille Guest

    Rafael Rosa [2008-12-14 00:42]:
    > Thanks for the link, I've read the Preface and the took a peek on
    > the index and it seems to be very very close to what I'm looking
    > for, thanks a lot.

    great.

    > As for the readme, I did read it, but it didn't explain how to
    > understand how the compiler code is organized, and I didn't
    > expect it to do so :) Without understanding how things should be
    > arranged is very hard to look at all those C files and make sense
    > of what's going on,

    yeah, sure. but i had the impression that it provides some places to
    start with among the many files there are. btw, do you know the Ruby
    Hacking Guide?

    <http://rhg.rubyforge.org/>

    and the Integrated Ruby Hacker's Guide

    <http://www.hawthorne-press.com/WebPage_RHG.html>

    > specially when you don't know C :)

    i can feel that ;-)

    > I've also found some interesting stuff at http://www.antlr.org/,
    > even a Ruby command dictionary, very nice. It will be even more
    > interesting when I know what to do next :)

    unfortunately, i'm probably not the right person to help you there,
    sorry. but i'm interested in whatever more experienced people might
    have to tell you about it.

    cheers
    jens
     
    Jens Wille, Dec 13, 2008
    #4
  5. On Sat, Dec 13, 2008 at 9:28 PM, Rafael Rosa <> wrote:
    >
    > Now I wish to take a dive and learn this stuff, but I'm having a hard
    > time finding a good global guide. I'm looking for a book, a tutorial, or
    > anything like that, that can explain the differences between the
    > architecture for a language used with a VM and another without, what's
    > the impact of these choices when building a compiler, how low level
    > memory management works, what's the current trend, etc.
    >


    Take a look at http://www.hokstad.com/writing-a-compiler-in-ruby-bottom-up-step-1.html

    martin
     
    Martin DeMello, Dec 14, 2008
    #5
  6. Rafael Rosa

    Rafael Rosa Guest

    Jen and Martin,

    Thanks to both of you, these links are very useful indeed. I'll dig into
    them as soon as finish a paper I'm working on. The compiler building is
    very very interesting, and it's seems to be quite accessible too. If
    everything goes as I expect I'll publish my learning notes somewhere,
    and I'll let you know.

    Thanks a lot,
    Rafael.
    --
    Posted via http://www.ruby-forum.com/.
     
    Rafael Rosa, Dec 14, 2008
    #6
  7. Rafael Rosa wrote:
    > Jen and Martin,
    >
    > Thanks to both of you, these links are very useful indeed. I'll dig into
    > them as soon as finish a paper I'm working on. The compiler building is
    > very very interesting, and it's seems to be quite accessible too. If
    > everything goes as I expect I'll publish my learning notes somewhere,
    > and I'll let you know.
    >
    > Thanks a lot,
    > Rafael.
    >

    Topher Cyil's book, "Practical Ruby Projects", has a chapter on parsing
    in Ruby.

    You may wish to consider implementing a simple interpreter before a
    compiler. This would let you see something happening sooner. The parsing
    part could be common to both. Some compilers for some languages rely
    heavily on an interpreter disguised as a run-time library.

    Have fun,
    Bill
     
    William Rutiser, Dec 14, 2008
    #7
  8. Rafael Rosa

    Ryan Davis Guest

    On Dec 14, 2008, at 12:47 , William Rutiser wrote:

    > You may wish to consider implementing a simple interpreter before a
    > compiler. This would let you see something happening sooner. The
    > parsing part could be common to both. Some compilers for some
    > languages rely heavily on an interpreter disguised as a run-time
    > library.


    agreed.

    and I'd also recommend sticking to wirth's book. It is very very
    terse, but a great book. Start with parsing, add an interpreter, and
    move to compiling as your final step.

    The ruby compiler link in this thread is interesting in that it starts
    from the bottom and works its way up. That might help or hinder
    depending on your learning style.

    Last thing, I'd stick to doing the simplest compiler you can for your
    first one, and not worry about a lot of the issues you brought up in
    your original email. Books like Hennessy & Patterson's Computer
    Architecture book and some of the newer texts on VM design will cover
    those edge cases very well.
     
    Ryan Davis, Dec 15, 2008
    #8
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Xah Lee
    Replies:
    13
    Views:
    490
    Brandon K
    Nov 3, 2005
  2. Paul K.
    Replies:
    2
    Views:
    306
  3. Paul K.
    Replies:
    0
    Views:
    277
    Paul K.
    Dec 8, 2006
  4. Paul K.
    Replies:
    0
    Views:
    235
    Paul K.
    Dec 8, 2006
  5. Martin M.
    Replies:
    5
    Views:
    311
    Michael J. Fromberger
    Sep 19, 2007
Loading...

Share This Page