Google-apps
Hoofdmenu

Post a Comment On: C0DE517E

"Bonus round: languages, metaprogramming and terseness"

9 Comments -

1 – 9 of 9
Anonymous Anonymous said...

Concepts was rejected, but has returned.

See Concepts lite:
Concepts lite

It seems likely to be approved, possibly later this year as a C++14 TS.

June 16, 2014 at 5:33 PM

Blogger DEADC0DE said...

I know. The point is that modules and concepts where a thousand times more valuable than all the C++11 "improvements" added together.

Apart from a couple all C++11 features (auto, lambdas) are either dangerous (rvalues) or standardization of trivial stuff that everybody already had implemented (threads, alignment, smartpointers).

Modules and concepts, unlike threads and the other crap, can't be implemented by users and are very valuable, but were scraped.

It's sad.

June 16, 2014 at 5:48 PM

Anonymous Anonymous said...

I don't think many will disagree with you that C++ has serious flaws. If I could find a replacement for game development that ticket every box, I'd jump at it, but it hasn't happened.

I agree that better language support for hot-reloadable code would be very nice.

On the other hand, I disagree with your condemnation of metaprogramming in C++. It is verbose and unconstrained, but if you think of it as a pure functional compile time version of haskell(with ugly syntax), it isn't too hard to reason about what is going on.

And Concepts lite will soon fix the lack of constraints, and reduce verbosity.
Here is an example of concepts lite.

Unconstrained template:
template void swap(T& a, T& b);

Constrained template:
void swap(Swapable& a, Swapable& b);

June 16, 2014 at 5:55 PM

Blogger DEADC0DE said...

By "soon" you mean maybe at the end of the year (if they are on-time, which you can doubt) for the approved spec and years later for solid, wide-spread cross-platform implementation and many years later for people to actually trust they can use it in big production projects... So like, 2020 :)

Anyhow I'll add an example of what I'm talking about later.

BTW I'm ok with templates for containers (basically generics), even if they are a bad implementation of generic types, it's very useful and I have no problems accepting that.

June 16, 2014 at 6:42 PM

Anonymous Anonymous said...

"That's why most teams won't accept metaprogramming in general and will allow C++ templates only as generics, for collections. And will allow operator overloading only for numeric types and basic operations.
And don't like references if they are non-const (the argument is that a mutable reference parameter to a function can change the value of a variable and that change is not syntactically highlighted at the call-site, a better option would be to have an "out" annotation like C# or HLSL).
And don't like anything that adds complexity to the resolution rules of C++ calls, or exceptions, or the auto-generated operators of C++ classes, and should thus stay away also from R-value references."

I just have a feeling that the programmers you are talking about are stuck in 10 years ago, and like grumpy old men shoot at the new stuff. C is broken ( void*, function pointers, ... ), C++ 98 was broken, C++ 11 is much less broken, and C++ 14 will be even less so. It looks like you are looking at C++ and saying "look at how you can shoot yourself in the foot in such complex ways, that language is no good". You don't like references without const - and neither do I - and yet you also take a stab at that very feature that allows you to write functional code regardless of the resources allocated by the returned object namely R-value references.
It's not about how you can shoot yourself in the foot, it's about writing less code, because - and this is by far the most important reason why you should write less code - it will ensure greater code coverage while testing, thus improving the quality of your code immensely.

June 17, 2014 at 12:18 AM

Blogger jwatte_food said...

And yet, nobody is trying to put compile-time introspection (or even runtime ditto) into C++, leading to gobs of kludges and macros for re-implementing something the compiler already knows in any I/O code.

User-defined qualifiers (like const and volatile) would be nice, too, to make sure I could have the compiler check for thread or memory type errors for me.

June 17, 2014 at 8:50 AM

Anonymous Anonymous said...

jwatte_food: There are actually several proposal for compile time reflection in C++.

Though given the general slowness of the committee I don't expect to be writing any reflection code until C++17.

June 19, 2014 at 7:51 PM

Blogger Eamon Nerbonne said...

I think perhaps you're missing the forest for the trees.

Sure, specific instances of metaprogramming can go awry. Code generation gives you lots of rope to hang yourself.

Simultaneously, I don't think we'd be where we are without metaprogramming because it enables rapid experimentation with new constructs. Putting things *in* the language is a truly slow process; mistakes are usually made yet very hard to fix; and limitations can be hard to work around.

I think your examples of poor metaprogramming only underline how *important* it is because the alternative would be to make those mistakes in the language itself (a really bad idea), or to simply cease evolution. There's no third option; there's no magical solution to not make mistakes.

And in any case: I'll gladly accept 10 metaprogramming annoyances if I can get one Eigen or whatever. It's not a coincidence that even currently more popular languages lack C++'s diversity of data structures and libraries (e.g. Java in particular) - that's because many of these things simply can't be expressed practically without at least some metaprogramming.

I think it's in any case wrong to blame the concept of metaprogramming for C++'s warts. C++'s faults are largely unrelated to metaprogramming as a concept, and more to its huge syntax and peculiar way of expressing metaprogramming.

June 20, 2014 at 3:55 AM

Blogger Lucretia9 said...

I left C++ and C 10 years ago after burning out at a "games" company. I now use Ada for my programming. It's not 100% what I want, but it's closer than anything else at this time.

April 12, 2015 at 10:07 AM

You can use some HTML tags, such as <b>, <i>, <a>

Comment moderation has been enabled. All comments must be approved by the blog author.

You will be asked to sign in after submitting your comment.
Please prove you're not a robot