
A Summary of the Metaclasses Proposal for C++ - PleaseHelpMe
http://www.fluentcpp.com/2017/08/04/metaclasses-cpp-summary/
======
mattbierner
I'm torn about this proposal. One one hand, I like that the feature
generalized something that you can (for the most part) already do in C++, and
I like the new expressiveness metaclasses would provide.

On the other hand, this is kind of insane. C++ is insane. And I'm still not
convinced this proposal is more than another bandaid over the fundamental
problems with the language. Why do our programming languages keep ending up as
terribly complicated and incomplete specifications of scheme or smalltalk?

I don't have a better proposal though and do admire the thought and effort
given to retrofitting C++ as a modern language

~~~
Koshkin
But C++ has always been a "modern a language". In the sense that there is
nothing "obsolete" about it. Yes, it is complicated, but so is math, for
example. Programming is complicated. Real world programming, that is. C++ is
"complicated" because it is designed to address real life problems. It was
designed based on a well-defined set of design criteria. Which are different
from those Java's and JavaScript's designs were based on. If you are to
question the sanity of C++, question those criteria.

------
stephen82
My first reaction to $class was the following: since we are talking about
metaclasses, why not use that name instead, that is "metaclass" in place of
"$class"?

~~~
stinos
Not sure what you mean exactly, but $class is just an example, you can also
have $interface $sometypeofstruct $unmutablevaluetype etc so prefixing that
all with 'meta' would be a mess

~~~
scott_s
In the proposal, '$class' is actually the proposed keyword for introducing a
metaclass; you won't continue to use '$' for all of the classes created from
that metaclass. stephen82 is suggesting that we use the keyword 'metaclass'
instead, which I probably prefer.

------
quickben
I don't see this making it into the standard.

1\. Interface = abstract class, already present.

2\. Reflection, rtti is sparsely used because c++ is primarily used for speed
and large teams.

3\. Reserved words prefixed by $, etc. Well, outside of a preprocessor
directives, that will be a first , if it ever happens.

By the look of the thing, the author wants c++ to be more like c#. But c++
isn't restricting on patterns, we create them. Unlike c# there is no language
defined way for dependency injection, interfaces etc. Well we can argue that,
but c++ is more flexible on pattern creation, and this proposal wants to put
two patterns inside the standard. I just don't see it happening.

~~~
kmill
1\. It's about abstracting what "classes" are, since the built-in "class"
metaclass is trying to be one-size-fits-all. Yes, an interface is an abstract
class, and if you could do things like make your own "interface" metaclass,
then you can "create more patterns," in your words.

2\. This is compile-time reflection, which is how a metaclass generates code,
so there shouldn't be much of a run-time speed consideration. I think the
comparison with C# isn't quite right; if anything, the author wants C++ to be
more like Lisp, Smalltalk, or even Python, which all have at least some
semblance of a meta-object protocol (and code-writing code, in the case of
Lisp).

~~~
quickben
1\. Classes itself can be improved, but at this point, will they date breaking
compatibility? Maybe from that perspective this will be given a shot.

2\. More code at compile time would work. Pythinizing may work. Lisp is quite
different.

~~~
moomin
Indeed. I think this is one of the best things about the proposal: it offers a
way out of the current hardcoded behaviours. At the moment we barely even
think about whether or not they're correct, because they're obviously too hard
to opt out of.

~~~
quickben
If anything, the proposal corners people into _more_ hardcoded behaviours.

~~~
moomin
Don't see why, you don't have to use the keywords given, and in the future
existing keywords could be deprecated.

------
D-Coder
If a metaclass is a way to make classes, can you have a meta-metaclass that
makes metaclasses? Meta-meta-metaclasses to make meta-metaclasses? (etc)

------
joshsyn
funny how D already solves all these issues.

------
flavio81
From the article:

> "Compile-time programming consists in defining a region in the codeline
> where the code is meant to be executed at compile time, with the evaluation
> of compile time data leading to a result. "

Wow, great. So in 2017, C++ is finally able to have a feature that Lisp had
since about 1966.

Yes, you can call this comment "smug", but my point is less smug and it's the
following:

C++ has been bloated _too much_. It used to be a nice OO language -perhaps not
as elegant as Objective C- but, as the times advanced, good-intentioned people
retrofitted more and more characteristics into C++, but the side efects of
these "retrofits" is a chaos that is ultimately leading to more criticism of
C++ and more people getting interested in alternatives like Julia and Rust.

Julia in particular has a very interesting OOP implementation that includes
multiple dispatch, and also has good support for metaprogramming.

Rust, as I see it, is a good alternative to C++, and should also work for
systems programming.

