C++ Creator Wants To Solve 35-Year-Old Generic Programming Issues With Concepts (cio.com)
C++ creator Bjarne Stroustrup is arguing that we can improve code by grounding generic programming in concepts -- what's required by a template's arguments. An anonymous reader quotes Paul Krill's report on a new paper by Stroustrup:
In concepts, Stroustrup sees the solution to the interface specification problem that has long dogged C++, the language he founded more than 35 years ago. "The way we write generic code today is simply too different from the way we write other code," Stroustrup says... Currently an ISO technical specification, concepts provide well-specified interfaces to templates without runtime overhead. Concepts, Stroustrup writes, are intended to complete C++'s support for generic programming as initially envisioned. "The purpose of concepts is to fundamentally simplify and improve design. This leads to fewer bugs and clearer -- often shorter -- code"...
Concepts, Stroustrup believes, will greatly ease engineers' ability to write efficient, reliable C++ code... The most obvious effect will be a massive improvement in the quality of error messages, but the most important long-term effect will be found in the flexibility and clarity of code, Stroustrup says. "In particular, having well-specified interfaces allows for simple, general and zero-overhead overloading of templates. That simplifies much generic code"
Concepts are already available in GNU C Compiler 6.2, and Stroustrup wants them to be included in C++ 20. "In my opinion, concepts should have been part of C++ 17, but the committee couldn't reach consensus on that."
Concepts, Stroustrup believes, will greatly ease engineers' ability to write efficient, reliable C++ code... The most obvious effect will be a massive improvement in the quality of error messages, but the most important long-term effect will be found in the flexibility and clarity of code, Stroustrup says. "In particular, having well-specified interfaces allows for simple, general and zero-overhead overloading of templates. That simplifies much generic code"
Concepts are already available in GNU C Compiler 6.2, and Stroustrup wants them to be included in C++ 20. "In my opinion, concepts should have been part of C++ 17, but the committee couldn't reach consensus on that."
We'll see.
Bjarne Stroustrup, Doug Lea, Knuth, etc... still make feel like a moron on a almost daily basis....
That's what C++ needs: More features! They had better introduce sidgils like in Perl so they can have room for more keywords.
Templates produce very bloated code. Most embedded programmers working in C++ use a very small subset of the language for a reason. But C++ has lots of other problems. It was nice when it saved you from having to hand-build vtables doing OOP in C. Now after the meta-programming fads have gotten into it the language seems all over the map.
The vagaries and complexities of C++ as it progresses in it's specification is reminiscent of efforts to get epicycles to explain motions of heavenly bodies. Geez, people are snide about Perl syntax. Now we have &ref, &&global_ref, [](args){my_lambda_code();}, copy constructors, move constructors, 'override' to fix virtual function breakage. This is just a mess of a language.
In a band? Use WheresTheGig for free.
I was just saying, "You know, C++ is too straightforward, and there are too few ways to get things done. It needs a few more keywords and paradigms to make it make it work."
What a freakin' mess.
should REALLY do something original here
c++ is due for deletion
When a "high" level language require half a dozen or so ways to implement a cast, it's time to go.
Remember when a programming language was truly object-oriented? I mean the object was what it
produced; not itself.. Look at any C++ code lately, you see what I mean. C++ programmers care
more about the screaming during the delivery than the baby.
And we're still waiting for a decent C++ strcpy() implementation! Not gonna happen...
Jeez...
CAP === 'beatify'
American jobs for Americans. Send all the H1-B indo-chimp street shitters back to the third world! God bless President Trump.
Bjarne Stroustrup, I appreciate your continuing to improve C++ and all that. But really, if "Concepts [...] are intended to complete C++'s support for generic programming as initially envisioned," maybe Concepts should have been included in the language definition in 1985 or thereabouts?
The heyday of C++ was a long time ago now. Practitioners of C++ will probably welcome this enhancement. However if this completes Stroustrup's original vision for the language, this is late, very late in the day. Maybe too late.
Another slow addition to an already slow language.
Just program in Java. Java already supports "concepts", this is just another way C steals from Java in order to make it relevant, and appear fast.
Java is the language of the future.
We will all be programming java, using java runtimes written in java, running on java runtimes written in java, because recursion [a concept!] makes things faster!
https://www-users.cs.york.ac.u...
"Well, one day, when I was sitting in my office, I thought of this little scheme, which would redress the balance a little. I thought 'I wonder what would happen, if there were a language so complicated, so difficult to learn, that nobody would ever be able to swamp the market with programmers? "
I reckon he's starting to go a bit ga-ga. What next, incantations? Almost as bad as Android's java-except-it-isn't with its motivations or whatever it calls signals & slots.
New features force . . . you!
Seriously, people, you may decide to forgo those features, but you may be "forced" to maintain code using those features that you need to figure out what that code does.
I heard Stroustrup used to post regularly in comp.lang.c++ and engage in huge protracted flame wars with newbies. I was a FORTRAN guy those days, and so I don't know first hand. Could not find such postings in the typical archives. Is it true, or just some stories bandied about him?
sed -e 's/Chuck Norris/Rajnikant/g' joke > fact
A bunch of hipsters using computers designed with C++, running a kernel written in C++, using graphics libraries written in C++, through keyboard drivers written in C++ that are sitting in a chair that was manufactured with mostly C and C++ code.... of course with internet mostly going through BSD/Linux systems both of which were written with mostly C++.
But we're glad to know their little C++ program that runs their code is so cool that they think they can get rid of C++.
Well, when I was thinking about programming languages a long time ago, I have come to a grudging respect for Windows, and backwards compatibility. Really good compilers, IDEs and debuggers will take many man years before production code can be made. In order to get that fancy stuff, you need a really big market to justify all that expensive development. That god scripting languages don't require such complicated tooling, and one has choices. I'm looking at you Javascript!
I want him to roll in the additions from Cilk++, Aspect-Oriented C++ and FeatureC++, the mobility and personalisation capabilities of Occam Pi, the networking extensions provided by rtnet and GridRPC, full encryption and error correction code facilities, everything in Boost, and a pointless subset of features from PL/1.
If you're going to do it all, might as well do it in style.
Seriously, though, Aspects would be nice.
It's a small world and it smells funny; I'd buy another if it wasn't for the money; Take back what I paid (SoM)
How about first fixing something much more basic, like modules?
I used to be a C/C++ dev, and wrote a lot of COM objects for the financial space back in the day. The ten different ways to cast something was becoming a pain to deal with. .NET/C# for my company in about 2001, liked what I saw and moved over to C# with a short stint in Java along the way, and I have NEVER looked back.
Writing LOB applications is all about delivering functionality for the end user. In C# I've designed the most, developed the most and maintained the most applications I've ever managed to do in my 30 year career in software development.
I was tasked to evaluate
Beautiful generics, LINQ, clean looking code, interoperability with legacy code, ultra-rich APIs and a rock-solid dev environment, ECMA-standardised are clear winners for me and C#.
A greybeard trying to breathe new life onto a now 30 year old language he put together doesn't surprise me, but C++ is never going to get the attention it once had. Sorry Bjarne, I saw it all before with Bertrand Meyer trying his darndest to keep Eiffel relevant. Same thing's happening with your baby, sorrry to say.
This is actually how the GNAA spawns new members. For years, a requirement for joining their group was to first post this spam on slashdot, and it may still be the case. They are a group of dual classed hacker/trolls. As with all the posts, you could be witnessing the birth of a new member, an old member being bored, or a nonmember who just wants to fuck over discussion if possible. In general, it will get modded all the way down, and often deleted. But anyway, this is what these posts have looked like for years.
The concept stuff seems all well and good, but I was a little horrified at
template<typename X> using Value_type<X> = X::value_type;
I'm sure there are good uses for this language feature, but in this case it just looks like he wants it to be angled brackets all the way down.
So, 2020 is the year C++ finally catches up to Ada wrt generics?
The key difference between this and interfaces in Java seems to be push vs pull, does a class explicitly declare that it is say sortable or do you just check if it has functions that match something that's sortable. If you look at the example he does on page 8 with Shape.draw() and Cowboy.draw() sure you could be more explicit in the template requirements or you could demand that the cowboy explicitly has to say he's "drawable". To me Stroustrup's idea sounds a bit too much like the story about the blind man and the elephant, if you only touch it in enough places you can be sure it's an elephant. The obviously problem is that once you have a birth defect or amputee with only three legs, it all fails.
For example I might like to define a class "SequenceNumber" that has functions like setInitialValue(), getNextValue() etc. but lacks typical characteristics of a number like being able to add and subtract them, but I can still sort sequence numbers. If it's explicit I only have to declare it sortable and implement the necessary functions. If it looks at the "concept" number it'll say nope, you're not a real number because we can't add two of you together.
This could be trivially avoided by having the possibility to supplement class definitions as implementing additional interfaces, like here's a library with the Circle shape header and I say it's a drawable even though it doesn't say so itself. It'll still have to actually fulfill the interface, but that way you're not bound by the ones supplied by the library. Since that's purely a synthetic check on whether your code should be able to call that code I don't see how that should be a problem.
Live today, because you never know what tomorrow brings
The real problem with C# is forced garbage collection. For your case, it may not matter, but in large memory needs I've seen GC run 30% of my CPU. Sure, you can find ways to pin memory - reuse it - but then you complain about "10 different ways to cast", which frankly is a stupid complaint compared to GC.
C# is fine for many. For performance cases where lots of memory use is required, to name just one, it's not a good choice.
"In my opinion, concepts should have been part of C++ 17, but the committee couldn't reach consensus on that."
No wonder C++ is a mess. Where's a benevolent dictator when you need one?
Concepts lets you check that the parameters of a template instantiation satisfy the template's requirements. However, it doesn't let you check that the *definition* of a template is valid whenever the parameters satisfy the template's requirements. So it's really only solving half of the problem.
Only the poorly educated say 'learnt' in the US (it's 'learned') here, but using a 't' for past tense is a legitimate British grammar construct. I've seen terms like this in respected British publications. More here.
I want people to not think they understand me when they don't more than I want them to understand me due to the odds involved, so I choose slightly harder to understand constructions. People generally come back with the notion that I am stupid, and that I think my statements are too brilliant for the average mind.
By no means. I think that if the average mind takes an honest stab at what I am trying to convey and asks for clarifications they can readily come to understand what I intend to get conveyed. Very few have gone that route, though.
But anyways the concepts expressed by those people aren't that out of reach and just require some dictionary lookups and Google searches that require reads of still other articles. By this approach the meaning of just about anything becomes substantially clearer.
Trump does tend to oversimplify so that his followers only think they understand. If the parent post meant to say that Trump is like a child who only thinks he understands, that is not the case, but the former is pretty true.
I wanted one I didn't get. I forget exactly which two I have, but besides the one in C there is one in C++ and one in Java. If I recall correctly I have the C and Java one. I think I bought the C one myself and added the C++ edition to my Amazon gift wishlist, but my Aunt thought she had a better idea to buy a newer edition. My wishlist now contains only things that it doesn't matter about editions.
Since C++11, I feel c++ has been on a roll with a lot of great new stuff (a lot ported from boost, of course).
But I think the syntax is not improving. I use C++17 extensively. My brother is starting to learn C++, coming from other languages. I don't think looking at my code is going to help him get started. For example, I use SFINAE, which could have been implemented in C++ with a clear syntax as opposed to using weird looking template/struct constructs.
Because everybody knows that QB64 is the most productive language to program in. There's a huge library of code that will compile in it and IBM samples included with DOS will compile with it. Compressed files with IBM DOS and the aforementioned samples are available on the net. https://www.bing.com/search?q=...
Please see this: http://www.medicaldaily.com/10...
You will notice there are 10 parts (organs) you don't need in your body that we don't need. But nature put it there so if has to reprogram people, it has the tools. C++ evolves and your own needs do not over ride the needs of others. Natural Language like English has lots of redundant words etc. Now if you specifically show how a feature has affected 2 or more application in your life, then it will prove either you did not understand the tool or took it for granted. Just deeply think and write. Robustness does not include absoluteness which with one single error will destroy the whole system. Head ache never kills you. but that is part of having head and the enviornment.
Seems everyone I run into these days who says "I'm a software engineer" has zero CS instinct
That's because software engineering has very little to do with computer science. A software engineer solves real-world problem with software.
How many cops do you run into these days that have more than the strict minimum knowledge of the law needed to do their job? Does that make them incompetent cops, or is it possible that maybe a different skill set is required?
If you want to stick to academia and horse around in labs that depend on grant money and alumni, knock yourself out, nobody is stopping you - there will always be a need for abstract thinkers. But out there in the real world, people must build things on time and on budget, and while we all wish that the best algorithms and the most elegant code is the way to achieve that, when push comes to shove, shipping the product is what pays the bills and if that means ugly code, then ugly code it is. Do you think the POS software on the cash register that allowed you to buy grocery this week is a masterpiece, or that the algorithm that decides when and how to to take over your car brakes is flawless? No, it's probably full of bugs and hard-coded passwords and antipatterns. But guess what, you still got that food in your fridge and you've made it alive on the freeway. Good. Enough.
lucm, indeed.
Just because you never encountered the variant "learnt" in your small world doesn't make it wrong, idiot.
Those who do not learn from commit history are doomed to regress it.
The concepts thing sounds interesting. But when will C++ run on Node.js and MongoDB? That's the real question.
Why not simply, get rid of curly braces, restrict C compatibility, and just rename it to Ada while you are at it...
Something like C# Type constraints on generics?
public class Vector where T: IComparable
https://msdn.microsoft.com/en-us/library/d5x73970.aspx?f=255&MSPPError=-2147217396
The problems appear when people with no technical background make the decision of which language to use for a particular project. They base their decision on what they heard from friends or on the latest buzzwords. For example Scala is now imposed on some projects simply because of the word going around that it is the latest and greatest thing.
Experienced developers have already agreed that C++ is great for writing libraries. Personally I use it because I can do everything I need with one language. Handling large data trees, SSE optimizations, OpenGL graphics, all in the same language, but these are all one-person projects.
Go to any large organization and look at a C++ code base developed over 20 years by a team of kept to a size of about 50 developers, when each developer spent an average of 2 years on the job. After a while you can identify what different developers tried to learn on the job.
By the way, I saw similar code bases, but developed in Java. They look just as bad as the C++ ones, and the managed environment which prevents crashes makes the bugs more difficult to find.
In my country we use "learnt" to specify the past tense of learn and "learned" (with emphasis on the -ed) to specify a person with high academic credentials.
What is supposed to be wrong with that statement? It is quite common to say thant one has learnt a programming language when one knows the grammar and the syntax of a language and is able to write code in it.
In Haskell both 'concepts' and 'virtual function interfaces' have the same name and syntax, 'type classes'. The only thing that differentiates between them is a pragma called SPECIALIZE which decides on which implementation to used. It is too bad, but not surprising, that C++ insists on forcing duality where it is not needed.
Avantgarde Hebrew science fiction
aah look. an 18 year old telling a 16 year old how to drive.
Look here kid. I've been on here since 98. the gnaa and the trolls are a part of the magic that is this site. we do want them here, and it's not spam. grammar nazis are spam. the gnaa adds spice.
and by the way, no, posts on this site don't get deleted. period. go back to reddit dipshit.
"Concepts are already available in GNU C Compiler 6.2," So, it is a standard :-)
... such that it would be amenable to have a simple, self-contained explanation. He avoided the more hairy subjects.
He did not go over the structure of the proton, or QCD and try to make those accessible.
And for the more accessible subjects other physicists have done a great job at explaining them as well. Landau and Kitaigorodsky come to mind.
I'm sorry but I don't see how adding more to a language will simplify things and make code better. Teach good programming practices. Teach COMMENTING! Teach by example. Don't teach programmers to be lazy and use the simplest tools but teach them to use the best tool for the job.
Standards
https://xkcd.com/927/
C++ is many things to many people, but efficient? I don't agree.
https://www.youtube.com/c/BrendaEM
actually, I take that back. I troll, but the race and sexuality issues are real, and putting up with this stuff, even if it's a long-running meme, just normalises something awful. I don't know if I want a deletion system, but I shouldn't have been so antagonistic, so sorry about that.
I'm an old man who's trying to do better in a world that's a lot more sensitive than it seemed when I was young, but, y'know, anonymity on the internet, it brings out the worst in us.
First, those 10 things aren't "organs", they're just features. Your fingers aren't organs either, even though you probably need them to function normally every day.
Secondly, the article is partly wrong. For #1, it even admits that the "third eyelid" is useful for ensuring tear drainage and sweeping debris away. #9 is flat-out wrong: the appendix, while not essential to life, is very useful when you have big problems with your GI system. It's basically like a first-stage bootloader for your gut bacteria. You may never even need it, but when you do, it's really useful. #10 isn't a misfeature, it's a by-product of the way we develop as embryos. Take away male nipples and you lose female ones too, which really do have an important function. Eliminating them without losing the female ones would probably require a significant re-engineering of the genetic code, which doesn't happen with an evolved system. #4 sounds like #9: calling something "useless" because we don't fully understand it yet. Maybe we really do make good use of the ability to detect pheromones (or then again, maybe it causes us to make terrible choices for dating/marriage partners). For #3, I've read some people claim that armpit and pubic hair does serve some important function WRT bacteria, I forget exactly what now. It may have some truth or may be bunk, I don't know, but as seen with #9 and our complete lack of understanding until very very recently the role of gut bacteria (such as with its effect on obesity), it does seem like our medical sciences have largely overlooked the roles of bacteria on human health over the years.
So back to C++, just because you don't see the need for a feature doesn't mean that it's actually useless. A good example here is the 'volatile' keyword. It's useless in most C++ programming, but absolutely essential if you're doing low-level hardware access on an embedded system.
The mark of someone looking for mastery is the humbleness to know that you don't know everything and seek wise people.
Arrogance and over-confidence leads to poorly designed software that changes frequently and pisses off the customers. We call that "Web Software".
I think he just reinvented Haskell's type classes. Good, they're a useful concept.
"Good. Enough."
Ah, the cry of the "programmer" who churns out barely functional junk. Let us know how you get on after your non-job is automated.
"Good enough" means fit for purpose. If you go beyond that you're not solving a business problem, you're feeding your OCD on the company's dime, like an office manager that puts barcodes on office chairs.
lucm, indeed.
I see nothing wrong with your OpenGL example. You basically used python to flush out requirements and determined that you needed a more robust language to get you to the next level. That's the "nail it then scale it" approach, which is pure engineering.
lucm, indeed.
Than to replace those 50 lines of template compile errors to something the poor sucker who has to try and understand someone else's template code can actually read, yet alone understand. I vote !Yay!
"The first thing to do when you find yourself in a hole is stop digging."
Only the poorly educated say 'learnt' in the US (it's 'learned') here, but using a 't' for past tense is a legitimate British grammar construct.
I don't know when I've seen such a glide from prescriptivism to descriptivism in a single (albeit compound) sentence before. Perhaps in Bryson's book on English. (As a professional crank, Bryson's good at freely mixing fact and opinion.)
In any case, DARE[1] shows some regional use of "learnt" in the US, and I dare say[2] that you'd have a difficult time demonstrating that every such use was by someone who is "poorly educated" by any reasonable standard.
Certainly use of the -t suffix has been declining on this continent for more than a century, though in English as a whole the trend is not so clear. And it's not just the past-tense inflection of verbs, as the rarity of "whilst" in this country shows.[3]
[1] The Dictionary of American Regional English, the unassuming name for a mammoth project to catalog regional differences in English usage in the US.
[2] Heh.
[3] Etymologically "whilst" is "whiles" + -t, where -t is still in effect a suffix indicating the past tense. But "whilst", a synonym for "while", is pretty much always used grammatically an adverb, even if etymologically it's the simple past tense of "to while" (as in "while away the time"). All this thanks to the eagerness with which English users move words among parts of speech.
than you shouldn't be using C.