Intermediate to Elite: Making the jump

T

TTA

I'm an intermediate C++ programmer. My skills are good but they need
to be fine-tuned and my software methodologies in theory are good but
I need more practical experience . I am still in university pursuing
my bachelors in Comp Sci.

My old (and favorite) prof used to tell us the best way to learn a
language is to write a compiler. I know it's a big project, but the
guy did have a point. If you write a C++ compiler, you will have
awesome insight into the language.
The more and more I learn C++, the more I realize that greater
knowledge of what the compiler is trying to do must be obtained. This
will lead (IMO) to better programming.
All the books I can find on compilers usually too theoretical or the
opposite something like "Let's build a compiler". I am not interested
in a toolkit. Is there a good book or resource that tells me exactly
what's happening "behind the scenes"? I am interested in C++ solely.

The only thing that comes close to this is "Effective C++" by Meyers.
It's an excellent book but limits itself to 50 specific topics. Does
such a resource even exist or do I just need experience? I'd
appreciate some guidance.

Thanks
TTA
 
J

John Harrison

TTA said:
I'm an intermediate C++ programmer. My skills are good but they need
to be fine-tuned and my software methodologies in theory are good but
I need more practical experience . I am still in university pursuing
my bachelors in Comp Sci.

My old (and favorite) prof used to tell us the best way to learn a
language is to write a compiler. I know it's a big project, but the
guy did have a point. If you write a C++ compiler, you will have
awesome insight into the language.

Its good advice, but you don't have to write a C++ compiler, in fact that
seems a near impossible task for one programmer who by his own admission is
at intermediate level. Try a simpler language instead (maybe even one which
would be useful to you, rather than
The more and more I learn C++, the more I realize that greater
knowledge of what the compiler is trying to do must be obtained. This
will lead (IMO) to better programming.
Possibly.

All the books I can find on compilers usually too theoretical or the
opposite something like "Let's build a compiler". I am not interested
in a toolkit. Is there a good book or resource that tells me exactly
what's happening "behind the scenes"? I am interested in C++ solely.

Stanley Lippman's Inside the C++ Object Model. It's a bit dated but still
apparently useful, (I haven't read it, but it always seems to be recommended
when this sort of question comes up).
The only thing that comes close to this is "Effective C++" by Meyers.
It's an excellent book but limits itself to 50 specific topics. Does
such a resource even exist or do I just need experience? I'd
appreciate some guidance.

Well you could do worse than More Effective C++ by Scott Meyers, which is
quite a bit more advanced than the one you have read. I don't see what
either has specifically to do with writing a compiler however.

For a thorough treatment templates (including how compilers have to deal
with them) I would also recommend C++ Templates by Vandevoorde and Josuttis.
If nothing else this book will show you what an ambitious task you've set
yourself in writing a C++ compiler.

John
 
C

Claudio Puviani

TTA said:
I'm an intermediate C++ programmer. My skills are good but they need
to be fine-tuned and my software methodologies in theory are good but
I need more practical experience . I am still in university pursuing
my bachelors in Comp Sci.

My old (and favorite) prof used to tell us the best way to learn a
language is to write a compiler. I know it's a big project, but the
guy did have a point. If you write a C++ compiler, you will have
awesome insight into the language.
The more and more I learn C++, the more I realize that greater
knowledge of what the compiler is trying to do must be obtained. This
will lead (IMO) to better programming.
All the books I can find on compilers usually too theoretical or the
opposite something like "Let's build a compiler". I am not interested
in a toolkit. Is there a good book or resource that tells me exactly
what's happening "behind the scenes"? I am interested in C++ solely.

The only thing that comes close to this is "Effective C++" by Meyers.
It's an excellent book but limits itself to 50 specific topics. Does
such a resource even exist or do I just need experience? I'd
appreciate some guidance.

I'm assuming that you already have Stroustrup's "The C++ Programming Language":
http://search.barnesandnoble.com/textbooks/booksearch/isbnInquiry.asp?isbn=0201700735

The following books aren't all recent, but they should give you plenty to work
with:

"The C++ Standard" is the place to start:
http://search.barnesandnoble.com/booksearch/isbnInquiry.asp?isbn=0470846747. If
you're not implementing Standard C++, you're just implementing something else.

"The Annotated C++ Reference Manual" by Stroustrup and Ellis will give you
insights and rationales on the language that, to this day, you won't find
elsewhere:
http://search.barnesandnoble.com/textbooks/booksearch/isbnInquiry.asp?isbn=0201514591

Stroustrup's "The Design and Evolution of C++" will give you still more insights
into why things are as they are:
http://search.barnesandnoble.com/textbooks/booksearch/isbnInquiry.asp?isbn=0201543303

Lippman's "Inside the C++ Object Model" will give you some ideas of how to
implement various aspects of the language:
http://search.barnesandnoble.com/textbooks/booksearch/isbnInquiry.asp?isbn=0201834545

For compiler texts, if you're not making the bridge between theory and practice
from the canons like the Aho and Ullman books, you can dive into practical
compiler writing with these books:

"Compiler Design in C" by Allen Holub:
http://search.barnesandnoble.com/textbooks/booksearch/isbnInquiry.asp?isbn=0131550454

"A Retargetable C Compiler: Design and Implementation" by the Hans*n bunch:
http://search.barnesandnoble.com/textbooks/booksearch/isbnInquiry.asp?isbn=0805316701

The advantage of the latter is that the compiler described is available and
supported at http://www.cs.princeton.edu/software/lcc/.

Both of these implement C compilers, but the goal is to allow you to see how the
theory is applied (if all you wanted was to see an existing C++ compiler, you'd
just download the G++ or OpenWatcom source). You should be able to extrapolate
that into what's needed to write a C++ compiler, especially since a subset of the
language is already represented.

And just in passing, you might want to use the term "advanced" instead of
"elite". Aside from the term having pompous connotations (I'm sure that's not how
you meant it), it's now also sullied by the teeny-bopper-wannabe-hacker use of
"leet". There are few programmers in the world who could call themselves "elite"
without drawing gales of laughter from everyone in the vicinity. :)

Claudio Puviani
 
D

Dave Townsend

I agree, building a compiler is a multi-man year project, there are
surely more efficient ways to improve your C++ programming and software
skills. Besides, the code I've seen in some compilers has been pretty
awful!

I'd recommend some of the Addison Wesley books in the same series,
Herb Sutter's books on Exceptional C++, Modern C++ Design - although
I could never get the examples to even compile on VC++, there are some
interesting ideas in there. There's another one, Applied C++, I didn't
think
it was up to the same level as the others, but if you want to see how things
are done in the real world, they have a some good coverage. Not language
specific but very useful in OOP, is Object Design Heuristics, lots of C++
snippets. Of course if you really want to make it as a C++ "elite", gotta
know Design Patterns by Gamma Et all.

Good luck.

dave
 
J

Jeff Schwab

TTA said:
I'm an intermediate C++ programmer. My skills are good but they need
to be fine-tuned and my software methodologies in theory are good but
I need more practical experience . I am still in university pursuing
my bachelors in Comp Sci.

My old (and favorite) prof used to tell us the best way to learn a
language is to write a compiler. I know it's a big project, but the
guy did have a point. If you write a C++ compiler, you will have
awesome insight into the language.
The more and more I learn C++, the more I realize that greater
knowledge of what the compiler is trying to do must be obtained. This
will lead (IMO) to better programming.
All the books I can find on compilers usually too theoretical or the
opposite something like "Let's build a compiler". I am not interested
in a toolkit. Is there a good book or resource that tells me exactly
what's happening "behind the scenes"? I am interested in C++ solely.

The only thing that comes close to this is "Effective C++" by Meyers.
It's an excellent book but limits itself to 50 specific topics. Does
such a resource even exist or do I just need experience? I'd
appreciate some guidance.

This seems somewhat like trying to become a better driver by building a
car. I'm not convinced it will work, and the time investment will be
enormous, especially if you're not interested in starting from a kit.
 
J

Joe Cipale

John said:
Well you could do worse than More Effective C++ by Scott Meyers, which is
quite a bit more advanced than the one you have read. I don't see what
either has specifically to do with writing a compiler however.

True... anything by shildt immediately comes to mind. Stroustrup is also
a good reference.

Joe
--
#----------------------------------------------------------#
# "Don't fear the penguin!" #
#----------------------------------------------------------#
# Registered Linux user: #309247 http://counter.li.org #
#----------------------------------------------------------#
 
T

TTA

Jeff Schwab said:
This seems somewhat like trying to become a better driver by building a
car. I'm not convinced it will work, and the time investment will be
enormous, especially if you're not interested in starting from a kit.

Thank you all for the great response. A couple of you pointed out that
this is not a "one-man" project. If the project becomes serious, then
I will definitely have a team. But the whole point is to hone *my*
skills. I've participated in many group programming assignments
throughout college and while I realize that a group is pretty much
required to produce anything non-trivial (some might disagree), I will
see how far I can go.
The analogy of becoming a better driver while building a car to
building a compiler to learn the language does not hold very well.
You're writing a compiler FOR the language IN the language. I'm
confused...how does that not teach you better C++? You may still need
to learn some software methodologies for different types of projects,
but you'd know the language inside-out. But I do understand your
point.
 
J

Jerry Coffin

(e-mail address removed) (TTA) wrote in message
[ ... ]
The analogy of becoming a better driver while building a car to
building a compiler to learn the language does not hold very well.
You're writing a compiler FOR the language IN the language. I'm
confused...how does that not teach you better C++?

Almost any major project (and a C++ compiler certainly qualifies) will
be educational, but learning C++ by writing a C++ compiler is a bit
like trying to read books under a microscope -- you miss the forest
for the trees.
You may still need to learn some software methodologies for different
types of projects, but you'd know the language inside-out. But I do
understand your point.

The relationship is not nearly as close as you seem to think -- I've
written compilers (and interpreters) for languages without ever
knowing those languages particularly well. I've also learned some
languages quite well without ever writing a compiler for them.

At least in my experience, your first two translators are more or less
throwaways. In the first, you're so caught up in learning the basics:
parsing, code-generation, etc., that those are really about all you
can learn at that stage. Intentionally or not, the second is largely
a rewrite of the first, using techniques you learned too late in the
first to apply them where you wanted to, and so on -- even when
they're really inappropriate to the project at hand.

The third translator is the first one in which you can start to step
back and look at things more systematically. Chances are that by
then, however, you'll have started to look at most languages as
variations on a couple of themes, and instead of really wanting to
know every detail of a particular language, you start to wish they
(the languages) were more consistent and had fewer of those ugly
details to deal with.

That usually leads to designing and implementing a few languages of
your own. Chances are they'll have some improvements over their
direct predecessors, but also that they'll never be used by anybody
but you and perhaps a few of your close friends.

After that, if you're a programmer who designed a few languages,
you'll do other programming, and occassionally when you look at a
language spec, you'll cringe and think "I'm sure glad I don't have to
write a compiler for that!".

OTOH, if you're really a language designer who happens to porgram,
you'll apparently continue trying to invent a better programming
language. If you're good (and a bit lucky) you might become the next
Dennis Ritchie, Bjarne Stroustrup, Niklaus Wirth, etc. (I can only
speak about this from observation though -- I'm clearly in the
category of a programmer who's designed a few languages).

Of course, there are other choices at each stage: just for example,
there are a few people who really do just write compilers and never
seem to have designed their own languages. For a long time, Walter
Bright seemed to be in that category, but now he's designed a language
of his own too (and it's better than most, I might add).

In the end, I'd say this: a particular language is nothing more than a
particular notation for expressing solutions to problems. Learning a
particular language in exceptional detail only helps you (possibly) do
a (slightly) better job of expressing the solution -- the real task is
in programming is the solution itself. Problem solving transcends
language.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top