Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.glorb.com!news-out.readnews.com!news-xxxfer.readnews.com!news.misty.com!news.iecc.com!nerds-end From: Hans-Peter Diettrich Newsgroups: comp.compilers Subject: Re: Good practical language and OS agnostic text? Date: Thu, 19 Apr 2012 13:53:30 +0200 Organization: Compilers Central Lines: 51 Sender: news@iecc.com Approved: comp.compilers@iecc.com Message-ID: <12-04-033@comp.compilers> References: <12-04-019@comp.compilers> <12-04-023@comp.compilers> NNTP-Posting-Host: news.iecc.com X-Trace: leila.iecc.com 1334891602 82183 64.57.183.58 (20 Apr 2012 03:13:22 GMT) X-Complaints-To: abuse@iecc.com NNTP-Posting-Date: Fri, 20 Apr 2012 03:13:22 +0000 (UTC) Keywords: books, parse Posted-Date: 19 Apr 2012 23:13:22 EDT X-submission-address: compilers@iecc.com X-moderator-address: compilers-request@iecc.com X-FAQ-and-archives: http://compilers.iecc.com Xref: csiph.com comp.compilers:576 Alain Ketterlin schrieb: > compilers@is-not-my.name writes: > >> Guys, I'm having a bear of a time finding a good practical language >> and OS agnostic text on writing a compiler. I'm weak in math and not >> interested in the theoretical details. I want to understand the hows >> and whys of compiler writing. [...] > > First, don't expect to understand much of compilation without at least > some background in discrete maths (some basic language theory, but > also graph theory if you go down later stages), and of course > algorithmics and programming. I dare to disagree. For writing an parser it's sufficient to understand a formal language definition (BNF...), from which a LL(1) parser can be even hand-coded. When tools are used to create a compiler skeleton (lex/yacc, Coco/R, Antlr...), the related math is encapsulated in these tools, no need that their users bother with it. IMO the OP will be comfortable with Wirth's books, languages and compilers, which are understandable even without a big theoretical background. Even if Wirth is concerned with *teaching* compiler principles, his languages and compilers are not the toys as many people believe. E.g. Oberon implements a complete OS, with the compiler being an integrated part of the entire system. From there it's only a small step to understanding and implementing e.g. JIT compilers, which require an different approach from stand-alone compilers. > Second, don't think compilation is all about language theory. For > instance, control-flow analysis is heavy on graph traversals, code > generation may use subtle algorithmics (e.g., dynamic programming), etc. > And optimization techniques may use whatever will provide a suitable > model (some loop optimizations make heavy use of linear algebra). > > Of course, if you're interested in compilers you'll become interested > into all the theories/topics they use. And I think it's a very nice way > to learn a lot about computer science. Again I suggest the OP to dig into the various (optional) parts of an compiler later, when he discoverd a *practical* need/motivation for code flow analysis, register allocation etc. Many people (like me ;-) are much more open to the theory, when they have practical examples for their application *before*. Life is too short for writing an full-blown heavily-optimizing production compiler from scratch, including its whole RTL. A beginner IMO is better off with a small language and compiler, where he can study the related problems, and can find out the areas of his personal interest. DoDi