Re: My Most Important C++ Aha! Moments...Ever
Posted: Oct 2, 2006 9:36 AM
> > > My best Aha! moment wasn't directly related to C++
> > > although it uses it. I realised that programming
> > doesn't
> > > need functions, execution points or any execution
> > control
> > > statements at all. [...] It's
> > a
> > > a 30 year old idea that will probably take another 30
> > > years to come to fruition by the looks of things.
> > This sounds interesting, could you elaborate on it, or
> > give any pointers to where to learn about this idea?
> I'm talking about specifying instructions on data and not
> the machine. It can come in any form. Right now, only
> data flow "languages" come close, but not completely. I
> took it for granted. I didn't understand the power that
> this gives.
> I don't know where I could give you a link because there's
> nothing out there that fully exploits this power. I'm
> working on a tool for this though.
> The simplest way I could describe this is by comparison.
> When we add two numbers, we take for granted that we're
> e asking the computer to do it.
> a = b+c;
> is actually
> a = CPU->Add(b,c);
Well, not really from a functional programming view of things, i.e. "a = b+c" _declares_ that a is the sum of b and c; no instruction about how to do that, or in which order (compared to other things) is given. However, that distinction may not be important in this context.
That's also something like a 30 year old idea.
Indeed, declarative programming (such as functional programming) is recognised as a powerful way of doing things, but like other "paradigms", there may be areas where it may be hard to write something in a purely declarative style.
However, recent developments of HTML (XHTML 2.0) aims to take care of 90% or so of what we now use scripting for (validation, calculations, etc.) using declarative constructs.
It seems you're talking about something quite different, though.
> I don't like that. I'd rather specify that b and c should
> be added and sent to a.
> I found the majority of people think that the two Add
> statements above are the same. They're not even
> equivalent, but that's irrelevant. One is machine
> specific (low level), the other is not.
Regarding the last paragraph: The same can be said for the distinction between imperative and declarative programming: a=b+c is a statement about the relationship between a, b and c, but it _can_ also be viewed as the instruction: "Add b and c, and assign the result to a".
> This seemingly
> small detail in the previous sentence can open up a whole
> new area in the computing industry. Understanding this
> was my AHA! moment.
I see. Hm, you say the variables are _streams_... I still have a little difficulty understanding what is meant by the pseudo-code you gave. How is it different from the FP-interpretation of a=b+c?