The Artima Developer Community
Sponsored Link

Weblogs Forum
Why? Language Archaeology ... and Metaprogramming

89 replies on 6 pages. Most recent reply: Sep 14, 2009 7:31 PM by Andy Dent

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 89 replies on 6 pages [ « | 1 ... 3 4 5 6 ]
John Wellbelove

Posts: 72
Nickname: garibaldi
Registered: Mar, 2008

Re: Why? Language Archaeology ... and Metaprogramming Posted: Jul 1, 2009 11:03 AM
Reply to this message Reply
Advertisement
> There is no performance hit *now* with today's hardware.
>
> Back when this decision was made, the performance hit was
> clearly determined to be unacceptable.

Are you saying that modern hardware ensures there is *no* performance hit in implementing it, or that it is small because of increased processor speeds.

When you are dealing with algorithms that have to execute in tens of micro-seconds, *small* is a relative term.

>For example, if int was a class, all the constants related to it could be members of the class.

Which constants are these?

Cameron Purdy

Posts: 186
Nickname: cpurdy
Registered: Dec, 2004

Re: Why? Language Archaeology ... and Metaprogramming Posted: Jul 1, 2009 12:13 PM
Reply to this message Reply
> Every syntactic and semantic error is in principle caught
> by Cfront, the C++ compiler front−e nd. I stress this
> because there has been a long history of confusion about
> what Cfront was/is. It has been called a preprocessor
> because it generates C, and for people in the C community
> (and elsewhere) that has been taken as proof that Cfront
> was a rather simple program – something like a macro
> preprocessor. People have thus ‘‘deduced’’ (wrongly) that a
> line−f or−l ine translation from C++ to C is possible

Please pardon my previous facetiousness, and note that I am not bothered that someone "[finds] such unfounded claims most annoying".

While it's true that cfront did syntactic and semantic evaluation, and (having written compilers I must admit that) neither of those is as simple as macro substitution, it is pure fallacy to claim that the code generation requirement itself was any more complicated than macro substitution. While it has been some time (15+ years?) since I have analyzed the generated code, I only recall one additional data structure being introduced (the virtual function table) and other than that everything was accomplished by name mangling.

Nonetheless, please do not take this as a knock on C++. Designing it to be as simple as macro-substitution is itself a sign of genius. That is completely separate from the argument as to the genius of the language itself, which I unfortunately cannot defend ;-).

Peace,

Cameron Purdy | Oracle Coherence
http://coherence.oracle.com/

Nemanja Trifunovic

Posts: 172
Nickname: ntrif
Registered: Jun, 2004

Re: Why? Language Archaeology ... and Metaprogramming Posted: Jul 1, 2009 1:15 PM
Reply to this message Reply
> While it's true that cfront did syntactic and semantic
> evaluation, and (having written compilers I must admit
> that) neither of those is as simple as macro substitution,
> it is pure fallacy to claim that the code generation
> requirement itself was any more complicated than macro
> substitution.

At least we came to a conclusion that Cfront was a little more than Find-Replace feature of a text editor.

>
> Nonetheless, please do not take this as a knock on C++.
> Designing it to be as simple as macro-substitution is
> itself a sign of genius. That is completely separate from
> the argument as to the genius of the language itself,
> which I unfortunately cannot defend ;-).
>

Here we go again with the macro substitution :)

Anyway, I don't care whether C++ is "genius" or not. It is a useful and successful language that is not going away any time soon. If you don't believe me, check out the Programming Languages Beacon: http://www.lextrait.com/vincent/implementations.html

Cameron Purdy

Posts: 186
Nickname: cpurdy
Registered: Dec, 2004

Re: Why? Language Archaeology ... and Metaprogramming Posted: Jul 1, 2009 5:52 PM
Reply to this message Reply
Nemanja,

Despite my opinions on the language, I still use C++ (over the past 18 months my team wrote close to 200kloc of C++ .. all cross-platform and multi-OS, including Windows, OSX, Linux and Solaris).

I understand the emotional bond that one forms with tools and programming languages; honestly, I find that it's hard not to form such a bond, considering how much we use and rely on these things and how intimately we must know them in order to make them work optimally for us. Far from being "fans" of languages and tools as if they were mere sporting teams, we are "intimate" with them and "attached" to them as if they were our favorite shoes, our favorite chair, or our favorite pillow to sleep on.

Nonetheless, it is valuable to view even our personal favorites with a healthy dose of skepticism. No one (Stroustrup for example) wants to hear that their baby is butt-ugly, or that their skills are out of date (or more correctly, out of vogue ;-). I'm not going to comment on the ugly baby syndrome, but at the rate of innovation that our industry promulgates, one's skills are almost immediately "legacy" and out-of-vogue by definition. Regardless, valuing one's self by a self-measure of one's in-vogueness is narcissistic at best; we should derive our measure of worth from the value that we deliver to others, not the value we deliver to ourselves.

And please, don't take my comments personally or too seriously .. my opinions are worth little if any more than what you've paid for them. ;-)

Peace,

Cameron Purdy | Oracle Coherence
<a href="http://coherence.oracle.com/">http://coherence.oracle.com/</a>

Nemanja Trifunovic

Posts: 172
Nickname: ntrif
Registered: Jun, 2004

Re: Why? Language Archaeology ... and Metaprogramming Posted: Jul 2, 2009 10:04 AM
Reply to this message Reply
Hey, peace :)

Please note that I am responding to your opinions only because I value them; for instance, I am ignoring the "M$ hate" comments.

In short, I agree C++ is "ugly" but there are so many good arguments to prove it (syntax, default behaviors, long compilation times, compiler error messages, ...) that it genuinly bothers me to see arguments like "it is a little more than a macro preprocessor" from people who know better than that.

I have a similar sentiment when reading Walter Bright's promotions of D. Tell me about your module system, faster compilation time and better syntax (if it is better) and I'll listen. Don't tell me about "huge productivity improvements" that come with a garbage collector because you are only losing credibility in my eyes - I've worked with GC languages long enough to know it is simply not true.

Cameron Purdy

Posts: 186
Nickname: cpurdy
Registered: Dec, 2004

Re: Why? Language Archaeology ... and Metaprogramming Posted: Jul 2, 2009 11:15 AM
Reply to this message Reply
> Don't tell me about "huge productivity improvements" that
> come with a garbage collector because you are only losing
> credibility in my eyes - I've worked with GC languages long
> enough to know it is simply not true.

It ultimately does depend on the application. I think in general there are very few things that I would drop down to assembly for now, and relatively few things I would drop down to C/C++ for, and (hopefully in a few years) relatively few things that I would drop down to Java for ;-)

The unanswered question is what comes next, and despite some cute things in it (and the overwhelming support for it on this particular site ;-), I don't believe it's going to be Scala. At any rate, the future is what we make of it, right?

Peace,

Cameron Purdy | Oracle Coherence
http://coherence.oracle.com/

Rebol Tutorial

Posts: 2
Nickname: rebol
Registered: Jul, 2009

Re: Why? Language Archaeology ... and Metaprogramming Posted: Jul 5, 2009 6:22 AM
Reply to this message Reply
Rebol is the best for Metaprogramming in my opinion as it is so accessible even for programmers

http://www.dzone.com/links/ground_breaking_languages.html

Rebol: A multi-paradigm (symbolic, functional, OO) messaging language; designed for the semantic exchange of information between people and machines. Draws some concepts and features from other languages: Duality of code and data (Lisp), complete extensibility (Forth), raw usability and light syntax in a functional language (Logo). It is a meta-language like Forth, but with full reflective capabilities (it is a meta-circular language). Supports 40+ datatypes, including things like email, url, money, pair, and more. These are not classes or objects, they are native types recognized directly by their lexical form. In support of the messaging concept, REBOL contains a function called parse which you can use to build dialects (embedded languages). Parse, itself, uses a BNF-like dialect to specify grammars and you can use any of REBOL's datatypes as tokens to be recognized. The concept of pseudo-types, different than inheritance, is unique as well (AFAIK).

david david

Posts: 16
Nickname: david21001
Registered: Mar, 2007

monday morning quarterbacking... Posted: Jul 6, 2009 10:18 AM
Reply to this message Reply
why nit-pick the language to death, go roll your own if you don't like it? i don't understand all your pent up frustration ... either deal with it or use another language.

George Sakkis

Posts: 14
Nickname: gsakkis
Registered: Jun, 2007

Re: monday morning quarterbacking... Posted: Jul 11, 2009 10:32 AM
Reply to this message Reply
> why nit-pick the language to death, go roll your own if
> you don't like it? i don't understand all your pent up
> frustration ... either deal with it or use another
> language.

why defend the language to death, go open a fan club if you like it? i don't understand all your rabid fanboyism ... either deal with it or change profession/hobby.

John Zabroski

Posts: 272
Nickname: zbo
Registered: Jan, 2007

Re: Why? Language Archaeology ... and Metaprogramming Posted: Jul 12, 2009 10:58 AM
Reply to this message Reply
Great article, Bruce. Just great.

One question...

Have you ever read Ian Joyner's book Objects Unencapsulated: A Critique of C++ or his short essay C++??: A Critique of C++ (http://burks.bton.ac.uk/burks/pcinfo/progdocs/cppcrit/) that lead to the book deal? At the end of his essay, he includes a personal bio that says, "During 1996, he read up about Java, and realised most of the things Java left out were things that were criticised in the 2nd edition of the critique."

Darko Latkovic

Posts: 9
Nickname: darko
Registered: Jul, 2009

Re: monday morning quarterbacking... Posted: Jul 15, 2009 6:38 AM
Reply to this message Reply
Well, it seems more serious than Monday morning quarterbacking:

> I am working on a 120,000 lines of code C++ project as we speak.

> I would give credit to anyone who creates a programming language that
> does not torture me for no reason other than the shortsightedness of its creator.

Looks like someone got trapped in a C++ dungeon - and it's all Bjarne's fault.
Let's hope for a happy end (maybe it turns out the door was never actually locked).

Bruce Eckel

Posts: 868
Nickname: beckel
Registered: Jun, 2003

Re: monday morning quarterbacking... Posted: Jul 15, 2009 2:01 PM
Reply to this message Reply
> Well, it seems more serious than Monday morning
> quarterbacking:
>
> > I am working on a 120,000 lines of code C++ project as
> we speak.
>
> > I would give credit to anyone who creates a programming
> language that
> > does not torture me for no reason other than the
> shortsightedness of its creator.
>
> Looks like someone got trapped in a C++ dungeon - and it's
> all Bjarne's fault.
> Let's hope for a happy end (maybe it turns out the door
> was never actually locked).

What I tried very hard to do in "Thinking in C++" is to explain all the reasons that these decisions were made, and why they were the right decisions at the time. The problem is that C++ was designed to (1) retain most of the efficiency of C (2) Provide an easy transition path from C to a more powerful language.

It did these things, and in the meantime much of the environment has changed which has made some of those decisions no longer appropriate. In particular, more powerful processors and cheaper memory mean that something like Objective C can work on an iPhone. But in the process, the programming world got moved to objects, which enabled languages like Java, Ruby and Python to gain traction and move everyone forward.

So if you're stuck in what was once the next great thing and is now a dungeon you can respond in two ways: (1) curse the darkness and Bjarne and claim that it was all short sighted or (2) understand the language and the reasons for the decisions. I think (2) will make your life easier because you'll realize that, given the constraints, those were by and large the right decisions. Also, I found it easier to understand the nooks and crannies when I had a story to go along with it.

Of course, the other solution, if you have that option, is to change projects or jobs so that you can work with tools that are more suited to your temperament. Myself, I only write small pieces of C++ anymore, when required for efficiency reasons, and then call it from (ideally) Python using ctypes -- and that only rarely, because most of the time performance isn't an issue.

Darko Latkovic

Posts: 9
Nickname: darko
Registered: Jul, 2009

Re: monday morning quarterbacking... Posted: Jul 15, 2009 3:24 PM
Reply to this message Reply
Bruce, thanks for extending my point (I just tried to be short and "sweet").
And I think you made very fair and balanced comparisons with C++ in Thinking in Java.
BTW, there is a little issue regarding some code in the book - maybe you could take a look:

http://www.artima.com/forums/flat.jsp?forum=1&thread=240780

I didn't see it discussed/explained anywhere else.

Mathias Ziehmayer

Posts: 1
Nickname: bohemund
Registered: Jul, 2009

Re: monday morning quarterbacking... Posted: Jul 21, 2009 6:49 PM
Reply to this message Reply
Hello Bruce,

> What I tried very hard to do in "Thinking in C++" is to
> explain all the reasons that these decisions were made,
> and why they were the right decisions at the time. The
> problem is that C++ was designed to (1) retain most of the
> efficiency of C (2) Provide an easy transition path from C
> to a more powerful language.

Thanks for the article, I found it very interesting. But I think I have to disagree with you a bit. While C++'s perceived shortcomings sure have a lot to do with C++, at least initially, trying to be a true superset of C (which it is not and also is not in practice - try compiling a 'real life' C program with a C++ compiler (will almost never work)), I think a lot of what programmers dislike (now) about C++ has very little to do with trying to keep the C legacy.

C is simple. C++ is not, and the added OO-things were over-the-top from the beginning. You said, in your Europyhton keynote, something like that Java's forced catch-every-exception was something with no precedent, that maybe seemed like a good idea, but in reality was a a pain. I totally agree. But C++ is very similar in many ways:

Who really knows the difference between public, private and protected inheritance (not making a method public, protected or private, but as a modifier for inheriting from a class)? Friend functions? Operator overloading can be made useful, but maybe not when you allow every single operator in a language to be overloaded. What really happens when you overload the address-of operator? Or allowing every possible combination of const pointers / references to const or not const things? You start worrying about L & R-values and so on. It was always overcomplicated.

But anyways, thanks for your perspective.

Greetings,
Mathias

Andy Dent

Posts: 165
Nickname: andydent
Registered: Nov, 2005

Re: Why? Language Archaeology ... and Metaprogramming Posted: Sep 14, 2009 7:31 PM
Reply to this message Reply
> ObjectiveC doesn't have this
> stupid "constrain of 100% C compatibility", and it's much,
> MUCH more elegant, clean and useful language.

Huh?

Objective-C *is* 100% C with some object stuff added on top, including lacking the non-OO improvements of C++ over C.

Please be explicit - how does Objective-C lack backward-compatibility with C - what C code can you not compile with Objective-C?

Flat View: This topic has 89 replies on 6 pages [ « | 3  4  5  6 ]
Topic: First Steps in Flex: 6 Screencasts Available Previous Topic   Next Topic Topic: A Generic Ostream Iterator


Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2014 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use - Advertise with Us