IWETHEY v. 0.3.0 | TODO
1,095 registered users | 0 active users | 0 LpH | Statistics
Login | Create New User
IWETHEY Banner

Welcome to IWETHEY!

New Compiler courses need updating?

I'm teaching a compiler/interpreter class this term and I didn't much like the way the material was presented in the book.

That is, the text makes a couple of assumptions I don't agree with:
- All compilers are built from scratch (The book uses C++)
- That anyone needs to make a compiler/interpreter for standard programming languages these days.

My take on this is:
- There are now higher level tools that teach more of the concepts (grammar, parsing, lexical analysis) without having to grovel through lower-level code
- these days it's more useful to monkey up a text processor (which is all a compiler is, really) for a domain-specific problem

So I introduced my students to lex/flex and yacc/bison at the start. Now we're looking at the Eli compiler toolkit. So far they seem to like the idea of viewing the process from a higher level, concentrating on analysis and design.

Any thoughts from the crew here on this?
Tom Sinclair

"This is a lovely party," said the Bursar to a chair, "I wish I was here."
-- The Bursar is a man under a *lot* of stress
(Terry Pratchett, Lords and Ladies)
New Your right about the second
Your right about the second, but the first is more arguable.

Not because they will ever actually build a compiler from scratch in the real world. But because they won't understand them if they don't show them what is under the hood at some point. Nothing but theoretical design with no grounding in reality is one of the big problems with a lot of education.

Jay
New Not sure I agree.
It helps to know how the underneath works so you can program the tools that do a lot of the work for you. One of the standard books, 'Crafting a Compiler in C' takes you through the bits and pieces of writing a classic compiler, but it also teaches you how to use tools like lex and yacc once you know how they do it.

Wade.
"Don't give up!"
New Have you seen Joel's article on this?
[link|http://www.joelonsoftware.com/articles/fog0000000319.html|Joel on Software]:
I think that some of the biggest mistakes people make even at the highest architectural levels come from having a weak or broken understanding of a few simple things at the very lowest levels.

[snip very long, very low-level explanation of why this is true]

This is why my view of teaching is that first year CS students need to start at the basics, using C and building their way up from the CPU. I am actually physically disgusted that so many computer science programs think that Java is a good introductory language, because it's "easy" and you don't get confused with all that boring string/malloc stuff but you can learn cool OOP stuff which will make your big programs ever so modular. This is a pedagogical disaster waiting to happen. Generations of graduates are descending on us and creating Shlemiel The Painter algorithms right and left and they don't even realize it, since they fundamentally have no idea that strings are, at a very deep level, difficult, even if you can't quite see that in your perl script. If you want to teach somebody something well, you have to start at the very lowest level. It's like Karate Kid. Wax On, Wax Off. Wax On, Wax Off. Do that for three weeks. Then Knocking The Other Kid's Head off is easy.
===

Kip Hawley is still an idiot.

===

Purveyor of Doc Hope's [link|http://DocHope.com|fresh-baked dog biscuits and pet treats].
[link|http://DocHope.com|http://DocHope.com]
New OT void removeSpaces(char *s)
I use this as my interview question, and I have seen scores of various ways to do it wrong.

Recently, however, I've got a spectacular recovery from a gentleman I was talking to.

He initially wrote something along the lines of

\nvoid removeSpaces(char *s)\n{\n    for (;*s != 0; s++) {\n        if (isspace(*s))\n           *s = *(++s);\n    }\n}\n


So, I wrote two strings "a<space><space>b" and "a<space>".

And then he goes, "Ahh, I should make it recursive!"

In the end, he's got something along the lines of
\nvoid removeSpaces(char *s)\n{\n    for (;*s != 0; s++) {\n        if (isspace(*s)){\n          *s = *(++s);\n          removeSpaces(s);\n          return;\n        }\n    }\n}\n



I think that's amazing. If the compiler supports tail recursion, it will even be cheap and safe WRT stack overflow, I think.

------

179. I will not outsource core functions.
--
[link|http://omega.med.yale.edu/~pcy5/misc/overlord2.htm|.]

New I hadn't actually.
But I understand his point of view. Even agree with it in a lot of ways.

Wade.
"Don't give up!"
New make sure those dev bastard wannabe's
understand hardware, creating a compiler or programming in assembler helps that. When they get to the higher levels it might help them to understand you cant make pigs fly by slapping an object class around them and shooting them out of a cannon.
thanx,
bill
Any opinions expressed by me are mine alone, posted from my home computer, on my own time as a free american and do not reflect the opinions of any person or company that I have had professional relations with in the past 50 years. meep
New Assembler is a pre-req for the class
Tom Sinclair

"This is a lovely party," said the Bursar to a chair, "I wish I was here."
-- The Bursar is a man under a *lot* of stress
(Terry Pratchett, Lords and Ladies)
New Parsers
There are two kinds of parsers - the kind that support an executable language and rigidly enforce their syntax - and the kind that try to figure out what people mean and are somewhat forgiving.

You absolutely must teach recurisve decent parsing to deal with the second (and I'll argue more common) scenario.

Consider html, syntax coloring editors, and a whole bunch of other domains I don't have time to list.

The standard parsers build by lex/yacc/bison/smacc, all bail at the first error. In practice, this is seldom good enough. You want to recover from errors and keep going, at least to save the developer some time down the road.

So I take a dim view of compiler compilers. The really good ones are written by hand.




[link|http://www.blackbagops.net|Black Bag Operations Log]

[link|http://www.objectiveclips.com|Artificial Intelligence]

[link|http://www.badpage.info/seaside/html|Scrutinizer]
New Here's why I went this way
While I was preparing for the class, I read a paper titled "Design and Implementation of a Modern Compiler Course" where the abstract read:

Current literature states that the undergraduate curriculum can no longer afford the luxury of a traditional compiler course. Nevertheless, there is an increasing need for an understanding of how to design and implement domain-specific languages. This paper presents a modern course in compiler construction, designed to provide a student with the capability of quickly constructing robust processors for a variety of language-related applications.

The authors went on to describe their experiences presenting a compiler course from a more abstract standpoint, letting their students focus more on analysis and design than on churning out low-level code. They used the [link|http://eli-project.sourceforge.net/|Eli compiler toolkit] as their tool of choice.

I looked at Eli and decided it was a bit much to just throw at my student without some preparation. So the first half of the class used flex and bison and we discussed such elements as regular expressions, lexers, context-free grammars and parse trees. Once they were comfortable with flex and bison, I added [link|http://memphis.compilertools.net/index.html|Memphis] to build the tree-walking code.

Now that they have a handle on the theory as well as the practice, we're exploring Eli. It's a pretty nifty set of tools, with a lot of cool features. The home page has a lot of documentation and several tutorials that are quite well-written.

Anyway, I did this because our programming curriculum (unlike that of a traditional CS program) is heavy on practice and only offers enough theory to move the practice forward. Since the compiler class is a senior project class I felt that my students could benefit from a more abstract approach.
Tom Sinclair

"This is a lovely party," said the Bursar to a chair, "I wish I was here."
-- The Bursar is a man under a *lot* of stress
(Terry Pratchett, Lords and Ladies)
     Compiler courses need updating? - (tjsinclair) - (9)
         Your right about the second - (JayMehaffey)
         Not sure I agree. - (static) - (3)
             Have you seen Joel's article on this? - (drewk) - (2)
                 OT void removeSpaces(char *s) - (Arkadiy)
                 I hadn't actually. - (static)
         make sure those dev bastard wannabe's - (boxley) - (1)
             Assembler is a pre-req for the class -NT - (tjsinclair)
         Parsers - (tuberculosis)
         Here's why I went this way - (tjsinclair)

Menage a dodecahedron?
51 ms