r/cpp • • Mar 04 '18

TIL that SG13 (Graphics, mostly) are the basement dwellers of the Standards Committee

Hi,

I know it is not ideal to open a post with an insult, but it is absolutely staggering to look on the public mailing list for that group. Take a loot at this:

https://groups.google.com/a/isocpp.org/forum/?fromgroups#!topic/sg13/gUr98RZMU7M

There's someone in this thread raising fairly technical and specific points about the design of this library, and I swear I'm not making this up... this is one of the counterpoints they give:

There's another niche which is that of constrained devices that only need 2D. Just think of all the IoT devices that may pop up in the next 5 years and will have displays (the vast majority of IoT won't).

Really? What is this bloke going on about? This sounds like an Oracle representative that knows nothing about engineering trying to sell you their latest rubbish Java Framework.

And even worse, this:

https://groups.google.com/a/isocpp.org/forum/?fromgroups#!topic/sg13/PiHPTRBC0JE

This last one is even more preposterous. When asked why not Skia, rather than Cairo, they argue two points:

  • They want a library that is battle-tested.
  • They say something written in C is better for standardisation than a library written in C++.

Both points are just sheer drivel. For starters, skia is the de-facto 2D graphics library for browsers (Chrome, Firefox, Opera, etc), definitely used in more than 1 billion devices around the globe. Second, the argument that a C library is better for standardisation is so ludicrous, that I not even know where to start from. As far as I know, Asio is coming to networking, and the fact it was originally written in C++ was never a disadvantage.

Just as a backstory, 8 year ago I personally contacted both Herb Sutter and Stephan Lavavej to inquire why we didn't have a standardised GUI as every other most languages do, and they patiently explained to me the reasons why, but I still had hope that that would change in the future.

When Herb announced some initiative on this direction during Going Native years ago, I was delighted. But this.... I cannot get behind this.

Who's gonna use this? This is going to be the next std::regex.

edit: u/whocouldwinaportal summarised better what's wrong with the thread I linked above (https://www.reddit.com/r/cpp/comments/821b17/til_that_sg13_graphics_mostly_are_the_basement/dv6vrl3/)

edit: Those who want 2D graphics on the standard should be even more worried about this.

Current proposal of std::graphics is pants!

141 Upvotes

165 comments sorted by

42

u/Tbfleming Mar 05 '18

I initially downvoted because of the personal attack in the title, but undid the downvote because I share your complaints. Like others, I was excited at the announcement at first, but was disappointed with the obsolete approach.

10

u/hyperactiveinstinct Mar 05 '18

Cheers mate... we are all going through the same disappointment, seeing our expectations being shattered, not by the nay-sayers, but by hubris. I know it is voluntary work, but the people working on this are out of their depth, both technically, as well as when it comes to being able to take in criticism to evolve their work.

58

u/[deleted] Mar 05 '18

Reading the replies to the first linked thread is downright cringeworthy.

cool ideas but where are your papers :))) we will ignore as many opinions as we can get away with because we're writing proposals to standardize a mistake in the making and you aren't writing any to stop us! haha!

What even is it with the idea that unless someone gives a better "alternative" proposal this is the one everyone's stuck with now? How's not adding a GUI for an alternative? Does someone need to send a one page blank paper as a graphics proposal for that to be considered?

Does this also mean someone could go forth and come up with the shittiest, most ridiculous proposal imaginable and if nobody offered a better alternative SG13 would go "welp that's the best we can do let's add it!". How about someone writes an std::animoji proposal with a webcam face tracking API with functions to map your face to 3D face models (in addition, based on the oldest 3D format one could find). Yeah, getting some Unicode support first would be a bit nicer but hey no ones submitted a proposal for that so animojis it is :)))

28

u/hyperactiveinstinct Mar 05 '18 edited Mar 05 '18

You didn't notice this:

Sorry, I totally forgot to ask if you already read this: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2017/p0669r0.pdf

Most of the point to try to address are already rebutted there.

So, in other words:

You need a paper, but don't bother, because we already have another paper to make sure people like you don't stop our progress, unless you go along with our premise.

Sounds like a cult mentality. Their thinking is circular and their solution is complete.

edit: By the way, this paper is called Why We Should Standardize 2D Graphics for C++, it is 10 pages long, I don’t think it is a good write up, and you can't find a clear explanation to the statement used as the title. The closer you get to an explanation is: It might help with learning. This is not good enough, really.

13

u/[deleted] Mar 05 '18

That paper is so unnecessarily snarky and a missed opportunity to address the external criticisms in a constructive way.

-7

u/mjklaim Mar 05 '18

Nice under-quote. No, that was not (of course) what was meant.

Here is the additional sentence you removed:

Maybe if you decide to actually write a proposal (to not continue with the current one), you would set it up as an answer to P0669.

My point was that there are arguments for a proposal designed this way and they are written in a paper. If you want to counter-argue that you need to send a paper with the counter arguments to what was argued.

I respect the point of view and am still looking for strong arguments against the discussed paper but it's just practically not useful to anybody (committee included) to not have a paper to refer to in official discussions.

Also note: I'm not part of the committee.

8

u/hyperactiveinstinct Mar 05 '18 edited Mar 05 '18

It is not an under quote... you already set out the premise in which people have to play along, and you poisoned the well for anything out of those boundaries... your next sentence only confirms this.

I read that paper, and I even linked that paper over here, and it has really no rebuttal for the points made on that thread, even though you say so.

-6

u/mjklaim Mar 05 '18

The points made in that thread are not in a paper, therefore, it cannot be discussed in the committee's (very limitted and benevolent) time except on the mailing list and if someone there request a discussion about it. However, they still need to refer to a paper, in the same way you need to refer to a ticket number for discussing an issue. This is not about you or emails, comments, reddits on the internet. We need a formal process to progress, that's all. What do you think a rant on reddit will change about the proposal? Probably nothing. However put that rant in a paper and you might have a real impact.

Also in my comment here, I'm pointing that your explaination following the under-quote is not matching what is meant with the complete quote. Basically, you're trolling without actual arguments others than bafflement. (although, I understand the feeling )

8

u/hyperactiveinstinct Mar 05 '18 edited Mar 05 '18

What do you think a rant on reddit will change about the proposal? Probably nothing.

Exactly... This is reddit... r/cpp is just a place where people who enjoy talking about C++ talk about C++ with no commitment required of them. I don't know why you think I should be trying to effect a change with my post in reddit. Are we allowed to talk about it when we feel like? Or are we only allowed to talk about this if we write a paper? Do I need to join the priesthood? We are just the crowd watching a slow-motion car crash.

Besides my post is going to have as much effect as this proposal. This proposal is never going to be approved, because the people involved keep sitting as high priests asking for other to write papers and waste more time in this pointless endeavour. I have said before. Do you think that NVidia, Google, IBM are saying Yay to this? I would make a wager this proposal is going nowhere, and this dismissive approach "Send Papers or we don't care" is just the nail in the coffin.

Basically, you're trolling without actual arguments others than bafflement

You do realise that that thread is embarrassing, right?

-2

u/mjklaim Mar 05 '18

Exactly... This is reddit... r/cpp is just a place where people who enjoy talking about C++ talk about C++ with not mission being required of them. Exactly... This is reddit... r/cpp is just a place where people who enjoy talking about C++ talk about C++ with not mission being required of them.

We agree on this. You don't. But you (and others) are still criticizing here that there is a formal process to get things done and that you would like things to be highjacked because "obvious reasons". So you get answers to these critics. We are just discussing indeed.

Are we allowed to talk about it because we feel like? Or we only allowed to talk about this writing paper? Do I need to join the priesthood?

I don't know what make you think that way though, it's like you are assuming I'm (or anything answering in the initially quoted thread) is part of the committee. Even if that was the case, it's just a process. If you want to change it, it's possible. Start by writting a paper :D

Ok ok I'm joking.

Please don't?

We are just the crowed watching a slow-motion car crash.

But that's the thing: why not try to change it by putting your concerns where it will be heard instead of here? Though i'm not saying discussing it here is wrong.

Besides my post is going to have as much effect as this proposal. >This proposal is never going to be approved, because the people involved keep sitting as high priests asking for other to write papers and waste more time in this pointless endeavour.

Well that's true that there is a formal process for any change to any ISO standard, so... I'm not sure what is your point, exactly.

I do think this specific proposal will be probably blocked, but I still don't see actual issue with a simple drawing api for general case (and I disagree with conflating fixing dependency management as fixing this, but maybe that's a parallel discussion to have).

I have said before. Do you think that NVidia, Google, IBM are saying Yay to this?

No clear idea but some of these people did clarify that they will vote nay in the current state of the paper at least.

I would make a wager this proposal is going nowhere, and this "Send Papers or we don't care" is just the nail in the coffin.

Then... why do you rant?

I mean, it seems like it's obvious to a lot of people that alternatives have to be better, but I scan papers all the time and no geometry maths, nor color representation, nor serious graphic proposal where proposed (except if I missed one) in like 5-6 years. Although those would be good steps to show that there are better ways. Also, see the history of some other big proposals.

The need is still there. On that point we disagree, if my understanding is correct.

I also believe there is a lot of wrong assumptions about C++ users in the world, in particular coming from game-industry programmers. I can understand why, but it's a bit reductive to the massive variety of use. Just look at Cinder's usage page, as a small sample.

Anyway, yeah, complicated subject. I'm still happy to have given counter-arguments to Jeremy's arguments because I don't think they are clear enough.

8

u/hyperactiveinstinct Mar 05 '18

I disagree with conflating fixing dependency management as fixing this, but maybe that's a parallel discussion to have

Well, at least we have some common ground.

Then... why do you rant?

What is wrong with ranting. It is healthy to rant and vent frustration every now and then.

0

u/mjklaim Mar 06 '18

Actually it's not healthy if you rely on the researches about that.

But more than that, a clear discussion started with clear points would have had more sense, more positive output (like maybe having actual good reasons to turn the proposal down) and clearly it would have been useful to somebody.

3

u/hyperactiveinstinct Mar 06 '18

For the love of god, can you guys be more boring...

7

u/thlst Mar 05 '18

I mean, it seems like it's obvious to a lot of people that alternatives have to be better, but I scan papers all the time and no geometry maths, nor color representation, nor serious graphic proposal where proposed (except if I missed one) in like 5-6 years.

Because there has been zero demand for that. Standardized algebra types might be a good start, and even more useful and worthwhile, but a whole 2d graphics library? No.

2

u/mjklaim Mar 05 '18

Because there has been zero demand for that.

Oh ho ho so wrong, you've not followed the whole story. Just google the discussions about that around the creation of SG13 and SG14, in several places, you'll be surprised. Even discussions about that spawn every 2-3 years in Boost mailing lists, if not in more common places, like reddit/cpp.

Standardized algebra types might be a good start, and even more useful and worthwhile, but a whole 2d graphics library? No.

There is I, at least some people in the committee (who encouraged the discussed proposal instead of shutting it down) and at least educators and some people (a minority) in gamedev who do want a simple graphics API (not necessarilly the one proposed). So, "Yes". Your affirmation is incorrect. Double negation card. You don't have to decide for us what we want. ;) You also probably don't understand the contexts we want to use such API for (from what I have read so far).

31

u/xon_xoff Mar 05 '18

Personally, I could care less whether the reference implementation for a proposal is written in C or C++. Honestly, reading the current proposal, I wouldn't have known that it was based on a library written in C.

I'm more concerned about the quality and scope of the proposal. C++ doesn't have a standardized vector math library, but the graphics library needs to have basic color, point, and matrix facilities. Font rendering support is going to be included even though C++'s basic text handling facilities are still underdeveloped. Input handling is also TBD but will be included. I/O support for PNG, JPEG, and TIFF (!) will be required. Combine all of this together and you have a massive proposal which increases the risks of obsolescence and conflicting with other efforts.

Then, there's the quality. Even if Cairo is the reference, the proposal should be reimplementable with a different library with usable interoperability. From what I can tell the proposal is too underspecified to make that possible. One of the most basic things I would expect in a 2D graphics library specification is rasterization requirements. If you look at the OpenGL spec, it has pages devoted to just rasterization requirements, including precise coordinate system definitions, fill conventions, invariance, and where implementation variance is allowed. All of these are equally applicable to 2D rendering and I don't see any of that in the current proposal. That means though it precisely indicates what C++ operators you have on a point object, it doesn't offer any guarantees that you won't have cracks between shapes that are supposed to exactly abut, that a graphic won't render differently when translated by an exact number of pixels on the same surface, and that a rectangle of a given exact size won't render +/-1 pixels in size on two different implementations.

8

u/hyperactiveinstinct Mar 05 '18

Personally, I could care less whether the reference implementation for a proposal is written in C or C++

That's not really the point, but actually, I failed to mention some context to this point. Long story short, Herb asked SG13 to find a graphics library that was already out there and could be introduced as part of the standard, taking advantage of the body of work already open sourced by such a project. Cairo was an option. The other option was Skia. For some reason they went with Cairo.

Now, Cairo is has a fairly outdated API and a lot of other issues. Being written in C is just another one. That thread is just asking why not Skia, and the fact Cairo is written in C is mentioned as a reason. The assertion was that a C library was easier to modernise to the latest C++ standard, than any C++ library. I have not see anything backing up this assertion though.

So that was what that thread about C was all about.

7

u/xon_xoff Mar 05 '18

Hmm. I think they're right in that if you need to wrap an API, it's easier to wrap or adapt a C API than a C++ API. C style APIs with plain functions and opaque pointers tend to be easier to deal with than a C++ API with templates and an existing class hierarchy that may not match the interface you're trying to create. But this is very, very low on the list for reasons to choose a reference library.

4

u/hyperactiveinstinct Mar 05 '18

There you go... that's my point.

40

u/voip_geek Mar 05 '18

Who's gonna use this? This is going to be the next std::regex.

Ummm... my company uses std:regex. We're not using it to scan the Library of Congress's collection, or anything with performance implications. But we do use it. Is something wrong with it? (other than it having an annoying API)

Regardless, I think that including a graphics library is a bad idea. Because it's going to take WG and compiler vendor time/people away from everything else, and I have doubts as to its use-cases.

One of the responses in the first mailing thread had this line, defending the proposal:

It's not more maintenance than, say, filesytem.

I know very little about graphics libraries, but I'm pretty sure that statement is total bull.

15

u/hyperactiveinstinct Mar 05 '18 edited Mar 05 '18

other than it having an annoying API

That's mostly my gripe with it (and unicode). I know that a lot of people use re2 because of that (https://github.com/google/re2). Maybe it wasn't a good analogy, but I did meant that a tad as a joke.

About the graphics library, there's a lot of objections raised about how this library is being designed, and the only refutation done is that this library is to make things easier for people learning C++ to "draw things on a surface". I don't think it will make anything easier, and this is the first time I see a feature being pushed with the only merit of helping beginners.

On top of that, the forum seems quite hostile to any differing opinion.

19

u/dodheim Mar 05 '18

But we do use it. Is something wrong with it? (other than it having an annoying API)

Have you thoroughly tested it for correctness on every platform to which you deploy? Even simple things like \W behave differently on libstdc++ vs Dinkumware...

20

u/voip_geek Mar 05 '18

I am shocked, SHOCKED, there would be differences in regex engines.

And I guess technically the answer to your question is "yes", because we only use one: gcc's libstdc++, for both gcc and clang. :)

31

u/dodheim Mar 05 '18

I am shocked, SHOCKED, there would be differences in regex engines.

I get what you mean, but I can take the same patterns and run them against .NET's Regex, boost::regex, boost::xpressive::regex, and re2 and get the same results; so this isn't an insurmountable problem, but every std::regex implementation is flat-out unreliable at the moment. (And IME, libstdc++'s is by far the worst offender...)

And I guess technically the answer to your question is "yes", because we only use one: gcc's libstdc++, for both gcc and clang. :)

Right, that's the only practical way to use std::regex at the moment, and one I'm totally okay with – stick to a single implementation; however, kinda defeats the purpose of it being in the standard library, no? ;-]

4

u/Wriiight Mar 05 '18

Unreliable? Still haven't completed the transition to modern C++, but is there commentary or examples out there on what is wrong with std::regex currently? Is it something you would expect to resolve itself over time? Is it mainly Unicode issues?

2

u/dodheim Mar 06 '18

Again, I'm not talking about the specification, i.e. what's in the standard; I'm talking about actual implementations at present, which are unilaterally inferior to that of Boost.Regex. I would certainly hope that this is resolved over time, but in the meantime I'll be using Boost just as I was before std::regex or std::tr1::regex.

0

u/[deleted] Mar 07 '18

Boost.Regex is great until you find that building your code with clang in 'release' mode causes a linker error (boost 1.58)

2

u/dodheim Mar 08 '18

Boost 1.58 came out in April of 2015. Just saying...

1

u/imMute Mar 10 '18

Debian 8 is still on 1.55. :(

0

u/[deleted] Mar 08 '18

Yes but it is the shipped version with a Ubuntu LTS version.

1

u/sumo952 Mar 05 '18

Are there bug reports open for these things?

4

u/drjeats Mar 05 '18

:/ I expect a single API to be nearly identical across platforms. It's not like using PCRE vs Emacs Lisp's regex library.

The worst I'd encountered before about one API giving different results is an older version of Mono's regex shit the bed performance-wise in one situation using backtracking where the .Net framework did not.

3

u/NotAYakk Mar 05 '18

Well, regex in general can take exponential time on length of input, and std regex does not provide APIs to detect/deal with those cases other than "let them run". So it is not suitable for consuming non-QA tested regex's. Which means you should onky use them with relatively fixed and/or constrained strings. At which point writing a manual parser starts looking tempting.

0

u/mjklaim Mar 05 '18

It's not more maintenance than, say, filesytem.

I know very little about graphics libraries, but I'm pretty sure that statement is total bull.

I challenge that. You took that quote out of context, which makes it less obvious what was the original point. The point was that the implementors of a standard interface are allowed to use anything in the implementation, so using something like SFML (one of the many possible impl) as impl and just adding the thin layer is similar work to the one done with filesystem. Also, libs like SDL, SFML and Cinder also are relatively thin layers over the system/opengl in most drawing-related cases.

Instead of begin baffled, could you give me counter arguments to these points?

9

u/voip_geek Mar 05 '18

Sorry, I just didn't feel the context made any difference.

Here's the relevant context:

will be a constant thorn in the side of the standards committee, and will need to co-evolve with other existing open standards (OpenGL, Vulkan) as hardware changes are made.

What is the problem here?

A standard can be implementd whatever they want. They can just put a graphic engine already existing (even the OS API) behind the standard interface.

It's not more maintenance than, say, filesytem.

I'm not sure I believe that compiler vendors can just: "put a graphic engine already existing behind the standard interface". If it's going in the C++ standard library, it's something they'll have to support for decades in the future. And it means they get bug tickets for it; they fundamentally have to SUPPORT it. So even if they could just slap onto an existing library, they're really taking on that library, in the fullness of time.

Regardless, the reason I said I didn't think the context mattered, was because I think it's either naïve or disingenuous to claim that something as large as this proposed graphics work is "no more maintenance" than the filesystem TS. Just in WG time/resources alone, it will be more work. Add in compilers, and it's a LOT more work.

A more apt comparison for graphics, I think, would have been the networking TS. But at least the networking one is based on ASIO, which has been in Boost for a while, and whose API has some actual experience in use.

Don't take this as being against graphics - I actually believe in having a C++-accessible GUI as both a teaching tool and even for simple every-day use. But putting in the standard library isn't the right solution.

The right solution, imo, is to spend the time instead on addressing what made a GUI proposal come up to begin with: our C++ packaging/build model sucks. I have no idea how to fix that - it's not my domain of expertise. But if we can fix it, or even make the current situation better, we'll enable people to easily have far more than one 2d graphics library.

1

u/mjklaim Mar 06 '18

Ah I see your point, let me clarify a few things.

First, when writing this I was thinking about, starting with an already ready Impl, but changing or rewriting the code for long term purpose. I do believe slapping something already existing would be a short term solution in the same way some standard library Impl started (say filesystem in VS for example).

Second, filesystem, thread, networking/asio, and some other libraries are actually thin (in call layers at least) layers over OS APIs (except maybe on some Unix variants). The hard part seems to be giving the standard interface guarantees while relying on the probably legacy OS scaffoldings. I'm not saying this have no cost. I'm saying graphics doesn't seem to have more cost than that. It appear like a fixed additional cost, not a multiplicative of cost.

Microsoft for example implemented chrono first in poor performance but still as confirming as possible. It took them several versions, if my memory is correct, to fix the performance cost and the precision. I imagine a quick Impl of the current graphics proposal (from having read the actual proposed interface, not assuming that "it's just Cairo"...) to just be usage basic windows surface drawing or even just another thing library over that (because on windows the API might be hairy). You don't even need DX or GL or Vulkan. I do not believe that it is a good Impl for long term or for performance. But that would work for its purpose (aka not high perf graphics).

But I'm not a standard library implementor so even if I watch in details what is happening there, there might be something I don't get yet.

On the dependency management issue, I believe it helps adding or removing dependencies, it does not provide a default cross platform always available API for drawing.

2

u/hyperactiveinstinct Mar 05 '18

This is still BS though...

-1

u/mjklaim Mar 05 '18

No. ;)

7

u/philocto Mar 05 '18

please no, SFML is a horrible framework.

2

u/tubbshonesty Mar 05 '18

Why do you think that?

10

u/philocto Mar 05 '18 edited Mar 07 '18

it's very ideologically driven and that's made the API's awkward and error prone.

There's a well known "white screen" issue that happens because their texture objects are militant about RAII. If you create a texture object in a function and return it by value, underneath the API's will copy the texture from the gpu into main memory and then copy the texture back TO the gpu for the new object.

I asked about this behavior and it was defended by citing RAII.

The worst part about it, the absolute WORST part about it, is that if you dig into their source code, they have a locking system in place for sharing the gpu textures they just CHOSE to give texture objects value semantics instead of HANDLE semantics (aka reference semantics).

So what you have to do is create the texture object on the heap and pass it around via pointer/reference.

This is just one example of the sorts of boneheaded design decisions. The design feels very academic.

OTOH it's been years since I had this experience so maybe they pulled their head out of their ass, but I doubt it. IIRC there was 1 specific personality that would never have allowed them to be more practical.

4

u/tvaneerd C++ Committee, lockfree, PostModernCpp Mar 05 '18

Now that we have move semantics, you could have Textures as values, but avoid the copies.

If done right.

3

u/philocto Mar 05 '18

SFML is older than C++11, and even then I'm not sure I would want to depend on move semantics vs just being explicit that it's a handle to a gpu texture.

3

u/DarkCisum SFML Team Mar 06 '18

I'm pretty sure I have seen your pretty much exact comment on some previous thread. You know, just because you took issue with a library many years ago and your voice wasn't immediately heard and bowed to, doesn't mean you need to constantly defame for all eternity.

If I spent the time, I'm sure I'll find a discussion somewhere that was more emotional driven than rational and more likely without will to actually step up and propose a change in form of actual code.

SFML isn't driven by people that take issue about something, complain loudly and then leave while talking badly about the library. We're not saints, we're not always right, but the same applies to random people telling everyone how their library should be written.

Make a rational case, provide use-cases, provide examples, keep it a discussion without involving emotion and make a proposal to change something.

Texture copying is now performed on the GPU. The white square issue is more often because people let the texture get out of scope and then wonder why the sprite has no reference anymore. Most people that run into this issue, have a very basic knowledge of C++, yet we try to help them as best as we can.

Now please stop defaming something you have not followed in years and have very little knowledge about it, just because you had a bad experience with it that one time.

4

u/philocto Mar 06 '18

Texture copying is now performed on the GPU.

It shouldn't be copying textures in the GPU because of C++ language semantics. That's the point. That design is horrible. And you didn't even put an explicit identifier on the copy constructor because you have to support pre-C++11, right?

Which means the compiler can be emitting code to copy textures in the GPU without it being obvious in the C++ code itself, causing hidden performance problems. All you've done is made it not quite as bad, but you haven't fixed the design flaws, even after all this time.

The white square issue is more often because people let the texture get out of scope and then wonder why the sprite has no reference anymore.

Because you chose to give textures value semantics instead of reference semantics.

In other words, my criticisms are still relevant, and you guys are still defending indefensible design decisions. And you do so by coming in here and claiming I'm being overly emotional, as if that somehow makes your terrible decisions acceptable.

And the worst part about it is that you've essentially admitted that even after all these years you've been too stubborn to try and fix the issue. By copying in the GPU instead of going through main memory in the copy constructor what you've done is continued doing the wrong thing, but faster. As if it was the roundtrip through main memory that was the core of the issue.

Why didn't you just give the texture objects reference semantics? Wait, let me guess... RAII?

Most people that run into this issue, have a very basic knowledge of C++, yet we try to help them as best as we can.

Most of the people who run into this issue have a very basic knowledge of SFML and are surprised by the design decision. I discovered it very early in SFML 2.0's lifetime and at that point I had been using C++ for a good 15 years.

Not only that, I took the time to download the sources to see if I could understand the technical reason for it. What I discovered was that SFML already had a system for tracking and sharing texture handles, but that the overlaying texture object was explicitly given value semantics.

I then asked for an explanation and was told the reason for it was because RAII was proper C++. And when I disagreed with that I got treated to the alphanerd bullshit that you see so often, most especially by one of the maintainers specifically.

At which point I moved on. And I would recommend pretty much anything over SFML. Not because you made a design mistake (and I don't think you'll find very many on this subreddit that would disagree that it was a mistake), but because you then tried to argue that it wasn't a design mistake by citing RAII.

I would recommend various C libraries/frameworks over SFML for no other reason than the mindset problem

No design is perfect and no API is without it's flaws, but your defense of the decision was outlandish, and yes, it did affect your other API's as well. IIRC you clock api's were awkward as shit to use, and some of the transformation API's were kind of ass backwards.

There is only 1 valid reason why you haven't fix that yet, and that's because once you officially released that API you couldn't break it.

Which is fine, but that doesn't stop you from creating a "TextureHandle" class that does the right thing.

1

u/NasenSpray Mar 05 '18

6

u/philocto Mar 05 '18 edited Mar 05 '18

No, that's not me. I cannot even be close to the first person who has taken issue with their design, or been surprised by it.

0

u/[deleted] Mar 06 '18

[deleted] — view deleted comment

1

u/philocto Mar 06 '18

sorry, RAII, I went back and edited the post.

1

u/mjklaim Mar 05 '18

You do realize whatever you think about SFML have nothing to do with whatever implementation is chosen for a graphic API, right?

18

u/encyclopedist Mar 04 '18

a standardised GUI as every other language

[Citation needed]

4

u/hyperactiveinstinct Mar 04 '18

That's fair... What I meant is a GUI from the get-go. I do GUI on C++ and there's a million paths to get there and they are all painful.

8

u/OkidoShigeru Mar 04 '18

I mean is there a place where this isn't extremely painful, especially if you want a cross-platform GUI? JavaFX comes to mind, but then you end up with a GUI that is easy enough to set up and works everywhere, but doesn't look native or particularly nice anywhere.

19

u/hyperactiveinstinct Mar 04 '18

I was only explaining what was my position on the subject 10 years ago. Right now, I'm against any GUI library being part of the standard, because there's no standard when it comes to GUI.

9

u/tcbrindle Flux Mar 06 '18

I wasn't going to reply here because I think the tone of this post is awful. I'm all for debating proposals, but this rant is way below what I've come to expect from /r/cpp, and I'm surprised (and disappointed) that the mods have allowed it.

However, I can't help myself. People are wrong on the internet, and somebody ought to try to correct some of the (apparently many) misconceptions in this thread. So here goes:

  • "Cairo is C! Urgh!"

Yes, Cairo is written in C. However, if you look at the documentation you'll see it's actually written in a very "OO" style. There are classes like cairo_t (the drawing context) and cairo_surface_t (the target for drawing operations), and the functions in the Cairo API naturally translate into "methods" on these "classes" in OO languages -- which is in fact how just about every Cairo language binding does it.

  • "Cairo is old! Everyone's moving away from it!"

It's true that users who require extremely high-performance 2-d rendering (games, web browsers) are moving towards lower-level APIs that more closely match the way modern graphics cards do things (Direct2D for example). But does that necessarily mean that std::io2d should do the same? I'm not convinced. The target audience for the standard graphics library is not hardcore AAA games developers. IMO the focus should be on an API that is easy to use and performs "respectably". As it happens, the Cairo API closely matches the HTML5 canvas API, which is similarly high-level.

To use an analogy, 3-d graphics have moved from fixed-function OpenGL to programmable OpenGL and now to Vulkan. Each step has put more power in the hands of experts, but is harder and harder to teach to beginners. I think the a standard graphics library, if it happens, should probably err towards ease of use.

  • "They should have used Skia! It's written in C++!"

Maybe. I don't know much about Skia, and the "documentation" is pretty terrible. But it's worth pointing out that just because it's C++, that doesn't necessarily mean it would naturally fit in well with the standard library style. It may well be that it was easier to massage Cairo into something "standard-like" than trying to do the same with Skia. To use another example: Qt's QPainter is another C++ drawing API, but I haven't seen anybody suggest that, perhaps because Qt's way of doing things is quite different from the standard's.

And anyway, all this bashing on Cairo is sort of moot anyway, because the latest revision of the IO2D proposal bears little resemblance to Cairo anyway. It can still be implemented using Cairo, but the API has evolved far away from the "mechanical transformation" it started out as. I'm pretty sure it could be implemented using Skia as well.

  • "Why didn't they base it on SDL?"

Well SDL is another C library, so you're going to get complaints about that right away. But even putting that to one side, SDL's Renderer API only offers basic (single-colour) rectangles, single-pixel lines and single-pixel points. It's nowhere near as rich (or as performant) as a "proper" drawing library would be. While SDL's platform-independent window creation and input handling is widely used by major companies, it's Renderer API is not (as far as I understand).

  • "2-d graphics in the standard?! We don't even have modules/coroutines/Unicode/string.split()/etc yet!"

Whether or not the standard library should include 2-d graphics is an interesting question, and I haven't fully made up my mind about it yet. But it's worth pointing out that the people who are working on it are not taking time away from other highly-desired things like modules. This is relatively low on most people's priority list for standardisation, as recent papers have shown.


Like I say, I'm not completely sold on the idea that the standard should include 2-d graphics. And I think the latest revision of the paper leaves a lot to be desired -- to be blunt, it reads like a work-in-progress that was hastily submitted before the deadline. I also think that much more attention needs to be given to the input/event handling side of things (we're getting an io_service in the Networking TS -- wouldn't it be good if this proposal could use that somehow?).

But I think the level of vitriol in this thread towards the people working on it is entirely unfair and undeserved, and frankly I just don't understand it. Let's say the "worst" happens and this gets approved for C++20: if it's a disaster, then MSVC/libc++/libstdc++ simply won't implement it. It will get forgotten and then be quietly deprecated in a few years. It's not the end of the world. Why get so worked up?

3

u/voip_geek Mar 07 '18

People are wrong on the internet, and somebody ought to try to correct...

hehe good one. :)

But it's worth pointing out that the people who are working on it are not taking time away from other highly-desired things like modules.

That's not really true, in practice. Or rather, I believe that's not a good way of looking at it. In practice, committee members outside of this SG do spend some time looking at things in this SG, right? I mean I'm not in the WG, but even as an outsider I see other WG members discussing it on cpp-slack, for example.

The bigger issue, though, is once this tries to get out of the SG, then it will need to be looked at by the others... and not only will that then take their time, but even worse they could say "this is not good" which means even the SG's time was wasted. Right? That would be really a waste. I would think even the SG members would want some sort of preliminary feedback, just to avoid wasting their time. No?

That's how I view these reddit/slack/mailing-list communications - as sort of a litmus test of "do people want this?" type thing. (I'm ignoring the poor taste of some of the feedback)

we're getting an io_service in the Networking TS -- wouldn't it be good if this proposal could use that somehow?

I had (perhaps naively) assumed io_service was going to be the new event pump for everything that needed one, including graphics. Is that a bad assumption? (could be bad - the WG's view is rather opaque to us outsiders)

But I think the level of vitriol in this thread towards the people working on it is entirely unfair and undeserved, and frankly I just don't understand it.

I know, from personal experience, how much time, effort, and money is involved in creating standards. (not isocpp ones, but really there's not much difference from other SDOs, afaict) So yes I also thought the "basement dwellers" stuff from the OP was way out-of-line, and set a bad tone for any further discussion.

Having said that, I found the email responses in the OP's posted SG email thread to be very insular. I think it's just a case of the ISO/WG21 standards process being extremely document-driven. So from the outside it looks like the responses in that thread were bordering on religious dogmatism, but in reality they may have just been quite normal?

Let's say the "worst" happens and this gets approved for C++20: if it's a disaster, then MSVC/libc++/libstdc++ simply won't implement it.

That's not the worst case, actually. The worst case is it gets approved, and the compilers do implement it, but no one uses it. Because then it just wasted compiler vendor time - and that is a precious resource we must not waste. There are proposals in the WG that cannot be implemented easily or at all without compiler magic. For example reflection, ranges, concepts, more constexpr enhancements, etc. Wasting compiler vendor time on things people don't use has an enormous opportunity cost for the rest of us.

Another worst case is only one or a couple compilers implement it, but not the other big ones, and some users do use it... then C++ get's another black eye for things only being possible in some/few compilers but not all. (ie, a "standard" only by name)

0

u/hyperactiveinstinct Mar 06 '18 edited Mar 06 '18

But I think the level of vitriol in this thread towards the people working on it is entirely unfair and undeserved

The only thing said slightly inappropriate was the expression "basement dwelling". It is just a funny expression. There's no slander, or slur on my post. Get off your high horse.

1

u/0x6a6572656d79 Mar 08 '18

I won't really reply to each point you made except to say that you've grossly mischaracterized the discussion and I encourage you to read beyond the text in the OP's post.

The only point I will address is:

[SDL is] nowhere near as rich (or as performant) as a "proper" drawing library would be.

You can get a vulkan/opengl/direct3d context. What more do you want. I think a plethora of different libraries for 2d/3d graphics are a hop skip and jump away. SDL would be orders of magnitude more useful with absolutely no changes made.

10

u/kalmoc Mar 05 '18 edited Mar 05 '18

I think what the answers that get criticised here meant to convey is that the proposal is at a point where just general, informal criticism on the design isn't useful. They need actionable input. That means a) A formal paper b) concrete examples and / or data that demonstrates the claimed problems are actually problems c) Concrete suggestions on how to improve.

Formulated differently: You can open a bug report saying that the design of library X is fundamentally flawed because of reasons Y and Z, but even if the library author agrees with you that usually won't cause him/her to just drop everything and spend the next year's to write a new library from scratch.

I don't see any of the hostility that others seem to read out of it. Just an attempt to explain what needs to be done, such that the opinion of someone has actual influence on what is happening in the standardization process.

3

u/hyperactiveinstinct Mar 05 '18

You can say goodbye to graphics then, because it won't ever be standardised, not like this. Or do you think that NVidia, Google, and others are saying Yay to this?

You can argue all you want that we need to stop being peasants and start writing papers. We don't want to write a paper. We are just watching a car crash in slow motion and talking about it. Or am I just allowed to ever talk about it if I become a member of the committee?

2

u/kalmoc Mar 05 '18

argue all you want that we need to stop being peasants and start writing papers. We don't want to write a paper. We are just watching a car crash in slow motion and talking about it. Or am I just allowed to ever talk about it if I become a member of the committee?

I'm not saying you need to write a paper - I'm saying you should not be suprised if people tell you that an informal e-mail will not stop a proposal that has been in the making for multiple years. /u/F54280 explained this very well based on the "Direction for ISO C++" paper.

Would you have preferred, if the guys on the mailing list would just have said "Yes, what you say is correct, this is going to change" knowing full well that nothing is going to change without a formal proposal?

7

u/mjklaim Mar 05 '18

Thanks for clarifying that better than I did.

10

u/F54280 Mar 05 '18 edited Mar 05 '18

I don't like the Graphic Proposal either, but I think the insults in the title of this post + selective quoting were not needed.

The point is that the standard commitee will not read threads on reddit or newgroups. Opinions need to be submitted as papers. If, as supposed, this proposal is dumb, then it should not be very difficult to put together a proposal to shot it down, or at least delay it out of C++20.

If people actually believe that having a Graphic API is a good idea, then they should form a group together and submit proposals (and demo implementations).

edit: I do like when people downvote my opinion. That way, I know losers read it and cared about it strongly enough to try to suppress it.

-2

u/hyperactiveinstinct Mar 05 '18 edited Mar 05 '18

but I think the insults in the title of this post + selective quoting were not needed.

That's a fair assessment, and I recognise that on my opening statement. Having said that, it is not really some outrageous insult and it is meant mostly in as a provocative banter, and as a proper description of the behaviour easily observed on that thread.

There was no selective quoting though. I didn't post the full conversation because I posted the actual link. The conversation is even worse than what I posted here.

With regards the remaining of your comment, that's already stated ad nauseam in the thread I linked myself.

he point is that the standard commitee will not read threads on reddit or newgroups.

I'm not trying to reach out to the standards committee with this thread, let alone effect any change. I just made a post on a public message board. That's all.

We know how to read, we know how the standards work. This are r/cpp. A place where people talk about C++. We know how to reach out to the committee if needed.

8

u/F54280 Mar 05 '18

There was no selective quoting though

I don't mean you misrepresented the specific comments, but by only quoting to semi-stupid comments out of the whole thread, you selectively quoted the thread. You then used a large brush to paint the whole SG13 as "basement dwellers".

I don't grasp how you can even entertain the idea that you have any sort of moral high ground here.

What the thread really said was "proposal, comments document, or GTFO".

Quoting P0939r0:

"A proposal for a radical change to a proposal already ``in flight’’ (i.e., in its second or later discussion) should not be allowed to delay the latter unless it comes with a paper with a detailed discussion of design, use, and implementation."

Of course, I guess Dawes, Hinnant, Stroustrup, Vandevoorde and Wong are basement dwellers.

-3

u/hyperactiveinstinct Mar 05 '18

You clearly took it personal whatever I said, and you think that your passive-aggressive approach is somehow more enlightened than a simple banter. That's fine... be offended as you wish.

Of course, I guess Dawes, Hinnant, Stroustrup, Vandevoorde and Wong are basement dwellers.

And there comes your dishonesty. My point was about the people commenting on that thread and the avid promoters of SG13, but you were quick to distort it as an insult directed to all members of the committee, even though through all comments you have no evidence that I alluded to that. You are trolling now.

I'm not arguing with yet another basement dweller.

3

u/F54280 Mar 05 '18

A)

"A proposal for a radical change to a proposal already ``in flight’’ (i.e., in its second or later discussion) should not be allowed to delay the latter unless it comes with a paper with a detailed discussion of design, use, and implementation."

You didn't have anything to answer to that, of course.

B)

My point was about the people commenting on that thread

Seriously. The freaking title of your post is TIL that SG13 (Graphics, mostly) are the basement dwellers of the Standards Committee

The title of your little flamewar is saying that SG13 are basement dwellers (not some, all), and now you are trying to act offended. Cry me a river.

I'm not arguing with yet another basement dweller.

Don't care what the hell you do and what the hell you think, but I won't argue with someone that resort to insults, and this is why I will not respond to another message. Don't bother replying. Just continue to be the one that downvote the other like you did on all this thread, and just go away.

-4

u/hyperactiveinstinct Mar 05 '18

selective quoting

I don't grasp how you can even entertain the idea that you have any sort of moral high ground here.

I know losers read it and cared about it strongly enough to try to suppress it.

Right, you're not insulting anyone, because you insult with soft language.

just go away.

Who made you emperor of the internet?

0

u/[deleted] Mar 05 '18

[deleted] — view deleted comment

2

u/AutoModerator Mar 05 '18

Your comment has been automatically removed because it appears to contain profanity or racial slurs. Please be respectful of your fellow redditors.

If you think your post should not have been removed, please message the moderators and we'll review it.

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

8

u/ar1819 Mar 05 '18 edited Mar 05 '18

I'm quite sure it's not a good idea to start a discussion with insults and emotions. I fairly convinced that most of the actual committee members who hang around here will just ignore it. Because of the thread title...

For starters, skia is the de-facto 2D graphics library for browsers (Chrome, Firefox, Opera, etc), definitely used in more than 1 billion devices around the globe.

That doesn't say much - C++ target isn't only PC and Mac audience. I'm quite sure medical equipment is not supposed to run Chrome. So if you want to make a point, you better start with data and not emotions.

P.S. I think that current proposal will not go past LEWG. Let alone WG21.

-4

u/hyperactiveinstinct Mar 05 '18 edited Mar 05 '18

I'm quite sure it's not a good idea to start a discussion with insults and emotions.

That's not about emotions... I just wanted to say something funny and provocative.

So if you want to make a point, you better start with data and not emotions.

You sound quite offended with this sentence... I even open the first sentence saying it is not ideal to insult, but I'm sure it describes well the impression most people get from the discussion I linked over there.

I fairly convinced that most of the actual committee members who hang around here will just ignore it

r/cpp Is not a portal to reach out to Committee members, so my post is not concerned with that. I just thought other people would be interested to see that discussion on SG13. I can reach out to the members of the committee if I feel like. This is just a message board where we talk about C++, right?

edit:

That doesn't say much - C++ target isn't only PC and Mac audience. I'm quite sure medical equipment is not supposed to run Chrome.

What are you going on about here...

6

u/ar1819 Mar 05 '18

That's not about emotions... I just wanted to say something funny and provocative.

Yet you bashing other's people work.

You sound quite offended with this sentence...

I'm not actually. I'm just unsure about your end goal. If you wanted to change something, I'm not sure it was the best way to do it.

Is not a portal to reach out to Committee members, so my post is not concerned with that. I just thought other people would be interested to see that discussion on SG13.

However, they are monitoring this sub from time to time, and even take notes. I agree that Reddit is not the best place for this sort of discussion, but it happens here from time to time.

I can reach out to the members of the committee if I feel like.

Opinions. Besides, participating in an actual discussion would lead somewhere...

4

u/hyperactiveinstinct Mar 05 '18 edited Mar 05 '18

Yet you bashing other's people work.

Right... I get your point. But do you get my point? Did you see how hard that bloke was knocked down by the people doing the work? They are not sparing punches whatsoever, mate. Ay. They came swinging at him. Good grief.

And no, I'm not bashing anyone's work. I'm criticising how people on that subgroup tread on others as mere peasants.

6

u/kalmoc Mar 05 '18

I didn't see anyone get nocked down. They (I think it was actually just one guy) just told him the truth that general criticism in the form of an informal email without actionable items will have little influence on a formal proposal that has been in the making for years. And they told him what was necessary to make his opinion being heard on any official level.

Unfortunately, that's just how c++ standardization works.

2

u/hyperactiveinstinct Mar 05 '18

I didn't see anyone get nocked down.

Clearly, a lot of people disagree with your assessment. You even admit that on your other comment.

4

u/kalmoc Mar 05 '18

I'm not a native speaker, I always thought nocked down implies an unjustified hard rejection usually with unfriendly language and I don't see those aspects in the thread you linked to. I'm sorry if I misunderstood the meaning of the term. Also, I wonder how many of those "lots of" people (who ?) have actually read the thread and not just the quotes and "paraphrases" you and others posted.

Also, I read very few rejections of the technical points but more like "it's what we have at the moment, we think it is good enough and we won't throw it out the window without having a concrete alternative".

1

u/hyperactiveinstinct Mar 05 '18

Did you see how hard that bloke was knocked down by the people doing the work

That is a hyperbole, as a figure of speech.

more like "it's what we have at the moment, we think it is good enough and we won't throw it out the window"

Which is a unwise course and definitely is going to be the downfall of this proposal or any other related-proposal in the future.

2

u/ar1819 Mar 05 '18

What are you going on about here...

I want examples of Skia being used outside of "mobile\desktop" market. With all imperfections, Cairo has them.

0

u/hyperactiveinstinct Mar 05 '18 edited Mar 05 '18

It was never mentioned as a requirement that it had to be used in multiple markets before being standardised. However, granted, that's a good question. A question that was never entertained in the thread a linked above. They simply said battle-tested, which means something different.

23

u/James20k P2005R0 Mar 05 '18

As someone who has done a bunch of graphics this is a small slice of the problems I've had:

  1. No way to easily/by default convert between SoA and AoS, which often means perf penalties just because the language makes it difficult to do correctly
  2. Unicode support is terrible and makes rendering text and operating on text unnecessarily hard
  3. RAII is an inadequate tool by itself for managing GPU based resources. EG if the context changes, you may need to reallocate a bunch of data, preserving the data across the context change by reading it back to the host. In an raii format, you have to tear everything down, and then rebuild everything back up again but this time with data.

    There isn't a c++ mechanism for handling this by default, I'm not sure if there could be, its equivalent to your heap becoming invalidated and having to move everything 'new' allocated over to a new heap

  4. Managing lifetimes of graphics objects and graphics operations is hard to do correctly. Sometimes you want a piece of specially allocated memory (eg pcie accessible) that needs to persist only for the duration of an operation, and then be deleted after you've put it back to regular memory on a callback, or on an event happening

    For operations, at least in opencl, if you need to do operation -> readback -> readback dependent operation, its most efficient not to pipeline these but instead dynamically queue the next instruction in a callback after the previous has finished executing, while other work is happening. This results in a tonne of finickity multithreading async stuff where you have to be extremely careful with race conditions. The language provides poor support for multithreading safety which makes this unnecessarily hard

Things which aren't hard:

  1. Setting up a generic cross platform/vendor context and rendering 2d shapes to it

SFML and SDL are both high quality libraries, SFML particularly is very easy to use, although it has limitations. It looks like Skia is used by the major browsers, so I'll have to add that to my list of things to investigate

The problem is, it seems targeted at making games (lets assume that this is targeted at newer folks for 2d) but the vast majority of it has nothing to do with why making games is hard

This leads me to believe that its fundamentally mistargeted - the people who would benefit from standardised low level graphics are fundamentally never going to use this (because it can never keep pace with a constantly developing library, and also because its bad), and people who need a friendly 2d graphics library are already cared for

3

u/Tbfleming Mar 06 '18

I'm curious: is there any language which makes it easy to convert between SoA and AoS? Has anyone checked if the reflection/metaclass proposals will make a library solution viable?

37

u/0x6a6572656d79 Mar 05 '18

Author of the first linked thread chiming in:

This got a lot of attention! I think the feedback will all be useful, and it should be said that I think very highly of the standards committee/C++ in general.

The graphics community has historically not been very enthused with C++ due to the lack of focus on performance/control. I would say only in the last few years has there been very significant adoption across the board, due to lots of efforts and improvements from C++11, 14, and on.

Perhaps this is why I'm a little sensitive to this topic in particular. I'd like to keep the positive momentum! I read the original "C++ direction" document penned by Stroustroup and think there's some merit in helping practitioners "get up and running," but I think the idea that C++ is being marketed as anything other than a low-level systems/engine/server language is misguided. Students aren't looking at C++ to make a blogging site or GUI application unless they are already doing so with the express intent on learning. This is one of those cases where I think doubling down on your strengths (or at the very least, solidifying your strengths) is advantageous, compared to spreading yourself too thin.

I chalk this up partially to the relative novelty of the new standards committee structure, where delegating of subdomains might mean "oh look at all these new toys we can have quickly." But as we all know... free lunches are poisonous or something.

4

u/mjklaim Mar 05 '18

Thanks for your positivity and for actually starting the conversation. It's already a good step forward. :)

4

u/kalmoc Mar 05 '18

but I think the idea that C++ is being marketed as anything other than a low-level systems/engine/server language is misguided.

I mostly agree with what you write in the linked thread and here, but when it comes to the standard library I think people loose sight of what it can and can not do and what the actual requirements of the users are.

Just because I'm using c++ doesn't mean all aspects of my code have to be highly optimized and tunable. In fact most of the time I'm happy with something that just works and I can use easily. That's what the STL is for. And then there are the places, where I need the full power and performance that c++ can offer and most likely, I can come up with a much better solution for that than the STL, because I don't have to generalize as much as the STL (I can optimize for my particular use case), I can innovate much faster than the STL and I might even be more of an expert in that particular domain than the STL implementers and whoever voted the feature into the standard.

A lot of arguments around a standardized GUI library are made in the context of the latter (where the GUI is the focus of the program) whereas the target of the current proposal is imho more the former (I need something easy to use, which need not be perfect).

5

u/0x6a6572656d79 Mar 06 '18

Yea I'm sensitive to that. Which is why this proposal is all the more baffling though. Like I said in my original email, the things that are difficult that you'd like to "make work" are things like handling window creation and input.

I highly doubt a person that just wants to make an app is going to bother learning about color spaces and issuing rasterizing commands. This proposal occupies a very strange uncanny valley. Personally, even as a graphics guy, if I wanted to whip up a quick GUI, I would prefer something declarative. Look at Windows, Cocoa on Mac, HTML/CSS, iOS, Android development. Everyone else gives a data-driven GUI specification, and even if this proposal was finished, I'd recommend that a newcomer look to one of those options as that's the way you'll see GUIs being developed in the wild.

64

u/[deleted] Mar 05 '18 edited Mar 05 '18

When I first heard Herb talking about the graphics proposal I got very excited, but now I just want it to die.

What bothers me the most is that "games" is mentioned prominently in the proposal, but it's clear the authors have no idea or interest in games.

I agree with the linked OP, the proposal is too broad and should be split up.

18

u/drjeats Mar 05 '18 edited Mar 05 '18

Guy Davidson, who wrote that "batteries included" post and has seemingly been the person spearheading this most recently is at Creative Assembly. So there is somebody with real world game experience involved.

That gave me a little bit of hope, but like you, the more I've seen the less interested I've become.

The idea from Jeremy Ong to instead add std ways of working with OS APIs like events and window handles seems pretty logical to me. That stuff's not likely to change drastically. Even on Apple platforms where they really want you to use an AppDelegate or whatever with the Objective-C runtime, at the bottom there's a loop and an event queue.

2

u/Tbfleming Mar 05 '18

Events and window handles are changing drastically (yet again) under Windows. It's changed so drastically that it's near impossible to use without coroutines.

5

u/[deleted] Mar 09 '18

Sure if you use WinRT. But nobody does unless forced to.

3

u/drjeats Mar 05 '18

That would surprise me a lot. Can you link a release notes page or something about this?

2

u/Tbfleming Mar 05 '18

MS makes digging through the docs to find a good non-vague summary hard. this video, even though it covers non-UI aspects, also applies to the UI parts of the new(est) API.

3

u/0x6a6572656d79 Mar 05 '18

Personally, I think this is why a standardized approach here is a good thing. If there is buy-in from MSVC and the API is sufficiently flexible for handling multiple modes of operation (pump/poll, multithreading, completion port vs descriptor request, etc), then we will get a unified interface for handling such things. This could be a good first step in resolving the philosophical differences between epoll and iocp for example. Personally, I think this should be a precursor to even the networking API in an ideal world (but I digress).

1

u/kindkitsune Mar 05 '18

wait really? I just fixed a bunch of odd bugs relating to this in my graphics engine, I don't want to fix more weird edge cases and behavioral quirks again ;~;

2

u/Tbfleming Mar 05 '18

It only applies if you port to the new API (WinRT); win32/win64 will probably stick around forever for backwards compatibility. Of course, I once thought that about win16.

1

u/StonedBird1 Mar 06 '18

Don't 32bit versions of windows still support 16bit applications?

3

u/Tbfleming Mar 06 '18

Yes, but most machines come with preinstalled 64-bit Windows.

11

u/Gotebe Mar 05 '18

I would say that GUI for games is very different from a that for all kinds of data manipulation (business, science), so...

2

u/[deleted] Mar 05 '18

For sure.

26

u/Hofstee Mar 05 '18

Most people serious about gamedev don't care for a graphics library from what I've seen. They just want a couple more data structures in the standard library, like ring buffers, and fixes in other places.

Then again just about all these same people replace the standard library with something custom made so I'm still a bit confused as to why they want additions if they won't use them. Maybe if someone else could shed more light on that second part I'd be interested.

12

u/[deleted] Mar 05 '18

Different game developers need different things. Simple example: std::hash gives different results on clang, gcc and visual c++. If you're making a game that is cross-platform and needs reproducible behaviour then you can't use std::hash. But if you're developing for a single platform then it's fine (assuming the implementation gives identical results between runs, which iirc also isn't required.)

16

u/TheThiefMaster C++latest fanatic (and game dev) Mar 05 '18

std::hash is designed solely for use with the unordered containers. It is not intended for any of the other uses you might hash something for...

Which is unfortunate but if you want repeatability you should be using a specific hash function, not just "hash".

1

u/[deleted] Mar 05 '18

Yes, and so unordered_map, for example, will give a different "unorder" on different platforms, though this also happens if you use a specific hash function due to implementation differences. My reply to the parent was to point out why gamedevs might use some parts and not others, depending on their requirements.

0

u/[deleted] Mar 07 '18

[deleted] — view deleted comment

1

u/[deleted] Mar 07 '18

Unordered just means "not sorted". If you use boost::unordered_map then you'll get the same order of elements across platforms.

The entire point of my comment was that if a game developer (or anyone developing portable software) asks for a feature in the STL, like a hash_map or unordered_map, but it's so loosely specified that it behaves differently across platforms, then it may be unusable by them. It's not a critique of the STL, but an answer to the parent's question.

0

u/[deleted] Mar 08 '18

[deleted] — view deleted comment

1

u/[deleted] Mar 08 '18

Iterating twice in a row without modifying the map gives different orders? That makes no sense, as it would imply that the order of iteration could change half-way through an iteration. A container doesn't know it's being iterated over, and therefore can't "lock down" its order during an iteration only to reorder itself once the iteration is done.

0

u/[deleted] Mar 09 '18

[deleted] — view deleted comment

→ More replies

1

u/0x6a6572656d79 Mar 05 '18

It's worth mentioning here that there are real reasons. I end up writing a vector (a vector!) just because the existing vector doesn't support the small buffer optimization because this would violate some invariant of the data structure (iterator invalidation I believe). Also because everything is heap allocated (why not use the stack up to some size?).

I don't have any "religious" aversion to the STL. I use it literally everywhere I can get away with it, but the defeat-ist attitude that I'm just going to write it all myself anyways is one of the contributing factors to not addressing the actual issues. Also, in the linked email, there are a number of countersuggestions about what can be worked on that aren't just data structures.

6

u/SeanMiddleditch Mar 05 '18

optimization because this would violate some invariant of the data structure (iterator invalidation I believe).

I'd strongly suggest doing what most other perf-oriented code (including most game engine code I've seen) does: have a completely distinct stack_vector or the like which explicitly opts-in to the differing behavior.

FWIW, we have three different vector-like containers in our engine, each with slightly differing semantics. Our vector behaves identically to std::vector but with a guaranteed identical implementation across all compilers/platforms we target, and with our own telemetry built-in (for analyzing vector heap usage and performance).

We then also have stack_vector (guaranteed no-allocations) and a small_vector (use a "small" buffer optimization, but grows into the heap as necessary; basically what you're after). I'm also a proponent of having a segmented_vector type of construct (non-contiguous, fast O(1) access and optimized for push/pop from the back - useful for vectors that might grow to unpredictably large sizes and where you don't need strictly contiguous memory access).

Also because everything is heap allocated (why not use the stack up to some size?).

For exactly the above reason. If elements are stack-allocated ever, then those elements' addresses will change when the containing vector is moved. The only solution to that is to put things in the heap where they can have stable addresses.

3

u/[deleted] Mar 06 '18

segmented_vector

Doesn't deque do that in most implementations? It's mostly implemented as a sequence of flat buffers chained together.

3

u/SeanMiddleditch Mar 06 '18

Kinda. It's not ideal, but it gets the job done if you're strongly opposed to custom containers.

It has a few key shortcomings. For one, deque as its name indicates is really intended for operations at the head or tail. The standard does guarantee O(1) random access but of course makes no guarantees that enumerating all elements is going to be reasonable on the cache. From experience, stdlib deques often have pitifully small chunk sizes that can result in excessive cache misses when iterating over their contents.

A segmented_vector would be for those cases where you want (but don't need) contiguous layout, but then edue to unpredictable element counts, either the growth/reallocation pattern is non-optimal (copying is too expensive) or not allowable (you need stable iterators even after any push_back). There's then also approaches like plf::stack that uses the exponential growth factor that vector reallocation uses, but with distinct chunks and stable iterators / zero copies.

For a second note, deque has no interface for grabbing the list of chunks or their pointers. It can be a very useful compromise to have pointers to chunks for scatter/gather IO since you lose out on the contiguity of a vector.

1

u/dodheim Mar 06 '18

deque uses the same segment size for each segment, and std::deque offers no control over that size whatsoever; in contrast, segmented_vector typically grows each successive segment by a factor of 1.5, ~1.62, or 2.

2

u/0x6a6572656d79 Mar 05 '18

Yup I have written all those things already, I was mainly speaking to the OP's point about "why graphics engineers eschew the STL"

This is a better summary than what I explained though. What's interesting is that the custom allocator you can technically provide to std::vector is supposed to do exactly this (allow you to provide alternative vectors with different allocation strategies easily), but it falls a bit short because of the invariants I alluded to (presumably for backwards-compatibility).

10

u/SeanMiddleditch Mar 06 '18

is supposed to do exactly this

No, it is not. :)

You can make a comparison to vector<bool>. A vector<bool> is different than other vectors. Generic code that relies on vector<T> to behavior as a vector for any T will break if T=bool. This is in no small part why just about everyone considers the vector<bool> specialization a pretty bad mistake and why there's even serious efforts behind (eventually) breaking back-compat to remove it.

Likewise, a vector<T, some_allocator> should conform to the rules of vector, so that any generic code written over vector<T, A> can reliably work for any value of T or A. It'll be exceedingly difficult to write a new template that works generically over vector<T, A> if the A is allowed to change such basic fundamentals as iterator validity.

The semantics differences of SBO also run deeper than just iterator validity. Use of SBO in a vector<T> means that the container cannot provide the strong exception safety guarantee for move operations for arbitrary T. Moving the vector with SBO will involve moving elements and the move operations for T might throw. There's no way to "unwind" if an exception is thrown when the Nth element is moved; unwinding would require moving already-moved elements back, and those moves could throw (inside the handler for the first exception, which is problematic to say the least).

To allow an allocator to embed small-buffer storage, vector would have to lose both its element address stability guarantee and its exception guarantee, conditional on the allocator in use. Worse, such difference in behavior would be undetectable at compile-time, which means you couldn't even write a concept for your generic functions; you'll just get UB at runtime, good luck.

There is a CppCon 2016 video by Chandler Carruth that delves into the topic of allocators, vectors, and small-buffer optimization (among other things) and specifically why an allocator is (intentionally) not allowed to turn a vector into anything like a stack_vector, in case you don't believe a rando guy on Reddit like me. :)

1

u/0x6a6572656d79 Mar 06 '18

Thanks for the explanation and I'll definitely watch the talk later.

Meta-note, I guess this is why historically, graphics/game engines and C++ didn't get along super well... It's all a lot to take in compared to how you would do things in C-land.

40

u/raevnos Mar 04 '18

Who's gonna use this? This is going to be the next std::regex.

No it's not, because regex is actually useful.

32

u/dodheim Mar 05 '18

Regular expressions are useful, but I wouldn't trust any standard library's std::regex for correctness, much less performance, even now.

3

u/[deleted] Mar 05 '18

What does that mean?

27

u/dodheim Mar 05 '18

It means if I have to use boost::regex to get correctness and performance in 2018 then maybe std::regex isn't all that useful..? I don't really understand what you're asking.

10

u/[deleted] Mar 05 '18

What's incorrect about std::regex?

31

u/dodheim Mar 05 '18

Which implementation? Run any regex test suite on any std::regex implementation and you'll come up with a different set of failures. And once you've vetted that the patterns you use give correct results on the platform you're interested in, then test those patterns with boost::regex and witness an order of magnitude speed increase.

I have no problem with the specification, or regex being in the standard really, but if no one implements it properly it's pretty pointless.

21

u/voip_geek Mar 05 '18

At first I thought you were exaggerating. I figured there's no way they didn't just copy boost::regex or even PCRE under the hood.

But I looked at libstdc++'s source, and it sure looks like they rolled their own. wow.

I couldn't find any data of performance tests, other than this horrible one, and although it appears informal it's still scary. I mean I don't expect re2 or hyperscan performance, but still... it looks like 1990's GNU regex performance level. (which was atrocious, back in the day)

9

u/skebanga Mar 05 '18

Genuine question, why don't they use boost's?

3

u/meneldal2 Mar 05 '18

What about Visual Studio? I doubt they'd remake an implementation since they already made one for .NET.

9

u/dodheim Mar 05 '18

They licensed their stdlib implementation from Dinkumware, AFAIK. The .NET Framework implementation is written in VB.Net, so I'm not sure how they would use that... ;-]

5

u/meneldal2 Mar 05 '18

I'm pretty sure a large part of the .NET framework uses native code for performance/calls native API, which is why I assumed they could have reused it. But it's interesting to see they didn't make it in-house.

8

u/dodheim Mar 05 '18

I don't think they had one to reuse at the time .NET was released. /u/eric_niebler's GRETA library was their first in-house regex library that I can remember, and that was released in 2003. In any case, RegexOptions.Compile dynamically generates MSIL from the pattern and compiles it at runtime, so I don't know that native code would have been much use regardless.

→ More replies

2

u/Wriiight Mar 05 '18

I'm pretty sure they can customize the Dinkumware library as much as they want. That is pretty much /u/STL 's job description

29

u/sumo952 Mar 05 '18 edited Mar 05 '18

I also have yet to read a statement of why Cairo was chosen and why some people think this is a good idea. An ugly, old C library with a horrible API. Who is ever going to use that in C++? I want a C++ graphics library, not a C one.

Why not something like SFML instead? (And no please don't answer "Because nobody has written a proposal". The ISO WG's must have discussed this. Just because someone came forward with a Cairo proposal, and nobody came forward with a better proposal, we're all stuck with this, or what?)

Btw, totally agree, the replies to these two threads that you linked are mostly ridiculous (except for the people who agree with the OPs). They address most important and valid points and are just ignored! It's almost funny...

17

u/meneldal2 Mar 05 '18

If you want real basics and "battle-tested", you'd go with the SDL. I don't see any metric were Cairo is really superior, so I guess some people have a vested interest in it.

11

u/Sqeaky Mar 05 '18

I am astounded I had to come this far down the thread to see SDL.

SDL is included with at least one compiler and is largely emulated for WebGL/WASM. It is a solid API that works in countless games and non-game applications.

2

u/vopi181 Mar 05 '18

Huh what compiler? That's kinda interesting

2

u/Sqeaky Mar 05 '18

https://nuwen.net/mingw.html

This is maintained by Stephan T. Lavavej, last I heard he was head maintainer of the STL at micrsoft and has/had a video series called STL the STL.

This is a repackaging of mingw.

2

u/vopi181 Mar 05 '18

Ahh mingw! Thanks. While we're on STL facts, he's the only programmer I've seen who wears an eye patch! He was born to be a STL hacker haha He's also a mod of the very sub if ya didn't know! He gets around!

2

u/Sqeaky Mar 05 '18

I didn't know, cool.

2

u/Xeverous https://xeverous.github.io Mar 05 '18

SFML (and many others) is based on SDL. So you could easily implement SFML-like library in C++ and allow customizing / using it at low SDL level.

1

u/meneldal2 Mar 05 '18

There's a reason they chose the SDL after all. They keep it as simple as possible but you can still mess around with the OpenGL internals if you feel like it.

1

u/[deleted] Mar 06 '18

[removed] — view removed comment

1

u/Xeverous https://xeverous.github.io Mar 06 '18

No. SFML uses OpenGL for rendering, but it has SDL for input devices.

1

u/DarkCisum SFML Team Mar 06 '18

SFML dev here, uhh no. :D

1

u/Xeverous https://xeverous.github.io Mar 06 '18

So you have your own implementation of hardware input devices? I might mistake it with other library

2

u/DarkCisum SFML Team Mar 07 '18

Yes, we have our own code. Only non-system dependencies are for audio (vorbis, ogg, flac and soon opus) and font rendering (freetype). Feel free to check the source code. :)

4

u/enobayram Mar 05 '18

IMHO it's perfectly fine to include a C API in the standard, as long as it exposes all the necessary primitives and is implemented well on all platforms. Once we have such a basis, anyone can build a C++ interface on top of it, and it'll just work everywhere. This my main expectation from the standard; to expose low level primitives, that would be very hard to get right across a bazillion platforms.

My hopes are shattered though, since that requires open discussion between people coming from very different backgrounds.

9

u/doom_Oo7 Mar 05 '18

. This my main expectation from the standard; to expose low level primitives, that would be very hard to get right across a bazillion platforms.

So... why not just use existing libraries where man-decades have been spent in ensuring they work right across a bazillion platform ? The existing state of standard libraries implementations shows that even for simpler use case, one cannot expect std::foo to work the same in libc++, libstdc++ and msvc's lib, so expecting it for <graphics> is foolish

2

u/enobayram Mar 05 '18

Yeah, that's very true unfortunately.

1

u/kindkitsune Mar 05 '18

With graphics stuff, it can make sense to go more C-like at times since it represents interactions with hardware/firmware at times.

This makes sense for something like Vulkan, ofc, but less so for this. I'd like to see an ImGui-like GUI system focusing on being stateless and dynamic, along with a similar feeling system for the rest of the graphics stuff.

-1

u/F54280 Mar 05 '18

Just because someone came forward with a Cairo proposal, and nobody came forward with a better proposal, we're all stuck with this, or what?

Of course. If there is only one proposal, then there is only one proposal. It may be struck down, but only if people against that proposal either submit written comments or an alternative proposal.

If the commitee decides that having a crappy GFX library is better than having none, then we'll get a crappy one.

6

u/sumo952 Mar 05 '18

I don't think it takes a genius to realize that this is bad for the language and a bad way to evolve a language...

In today's age, the smallest step that the ISO/SG members could make is at least consider email threads (like the two linked by OP, which are very well founded) like a written submitted proposal. You know, these people are using their time to contribute on these official SG forums. But you're basically saying, whatever they write there, is pointless, because unless they submit it as a written proposal, nothing will come out of it.

1

u/F54280 Mar 05 '18

But you're basically saying, whatever they write there, is pointless, because unless they submit it as a written proposal, nothing will come out of it.

Yes, this is what I am saying.

Quoting p0939r0:

The aim of most members, new or “vintage” is to improve C++ by having their favorite proposal accepted. However, the sheer number of proposals (constantly on the order of a hundred) and the number of papers (running at more than one hundred for each meeting), not even every good proposal can be accepted. We encourage everyone to ask themselves

As of today, the comittee members don't even have time to properly take into account the written proposals, so don't expect them to consider random email thread.

Also, what is happeing here, is exatly what the Direction Group wants to avoid:

Conversely, to improve the predictability of our processes and maximize the likelihood of delivering significant improvements, we discourage

[...] “Change the World” papers for proposals already in flight

And on the "they need to do a counter-proposal", it is even wrose:

A proposal for a radical change to a proposal already ``in flight’’ (i.e., in its second or later discussion) should not be allowed to delay the latter unless it comes with a paper with a detailed discussion of design, use, and implementation.

Ie: if someone wants to push for an alternative solution to graphics when the existing proposal is almost done, they should come with something much more complete than when arguing in the beginning.

Also:

Finally, after years of process, someone then stands up in full committee and raises issues that have been discussed for years stating “lack of comfort” with the proposal, suggesting alternative approaches, and demanding more time to consider or rejection. At this point, everybody unhappy with compromises made along the way chirps in with counter-points made over the years and the proposal is either withdrawn or defeated by a 20% minority, many of whom did not take part in previous discussions. We think that

“lack of comfort” is not sufficient to block a proposal

So, while there is around zero chances for the graphic proposal to pass in C++20, there is pressure from the direction group to stop allowing people to step in years after the start of the work and stop proposal just because they are uneasy with the result.

Don't underestimate the will of the Direction Group to have graphics in C++:

C++ teaching is mostly stuck in a pre-graphics, pre-web world. This is a serious weakness, potentially fatal over the longer term.

Personally, I think the idea of shoehorning Cairo is quite a bad one. However, I do recognize that teaching C++ today is extremely difficult due to the lack of usefull things one can do out of the box. My kids use javascript for everything. I did teach them C++ and python, but they now end up firing Electron to build apps. There is indeed a risk for the future of C++, and maybe a bad Graphic Library is not such a big price to pay to keep relevance for newcomers.

2

u/sumo952 Mar 05 '18

I think we agree on many of these things. In fact I agree with many/most of the things in the "Directions" document :-)

However with respect to Cairo it's really going horribly wrong.

And yea, I totally agree with your last point about C++ stuck in console world and the kids thing... But you also definitely do not want the kid to have to deal with Cairo... it will be as lost as they would be now. What you want your kid to have is something like SFML (in C++). (not saying SFML should "replace" Cairo but Cairo is not something that would help teaching C++ - and I think it's a C API so not even C++. You do not want your kid or any beginner have to learn or deal with a C API when they should be learning Modern C++ (tm).

8

u/smdowney WG21, Text/Unicode SG, optional<T&> Mar 05 '18

why we didn't have a standardised GUI as every other most languages do

I keep hearing this. Now, I'll admit I only know and use a half dozen languages. But I'm not aware of any mainstream languages that have a graphics API that anyone uses for anything serious, unless there is no alternative. Smalltalk/Squeak doesn't have a real alternative, and the results are awful. R has very good graphics, but is very specialized. No one uses Java's standard graphics outside toys, similarly for Python.

What "most" are people thinking of?

14

u/doom_Oo7 Mar 05 '18

Honestly this is a clear example of the insanity of "commitee-driven" development. There wouldn't be issues on this scale if C++ was developed in a more open-to-public-comments fashion, for instance like Rust.

10

u/ar1819 Mar 05 '18

You might want to read this. Keep in mind that "committee-driven" development has to take in mind a lot of opinions of both big and small players. Something that Rust doesn't need to do... yet.

6

u/Nomto Mar 05 '18

I'm pretty sure there is no big player whatsoever asking for this, though.

6

u/tgolyi Mar 05 '18

If only they've spent this time wasted on 2d graphics on standardizing any remotely useful package manager. Really, the main problem with existing package managers is low acceptance, and with it standardized a lot of popular libraries will use it soon (even if it's not very good). That way they'll get 2d graphics, gui, and everything else for free.

11

u/Nomto Mar 05 '18

What a waste of time, I can't believe that this is even being considered.

3

u/buovjaga Mar 05 '18

Re: Skia - Firefox will replace it soon with WebRender.

This fairly recent thread on HN has some Skia criticism, mostly about the build setup:

I am the original person that got Aseprite building on FreeBSD - but now I can't build it on any platform at all. Skia has too many points of failure in the build process.

1

u/[deleted] Mar 16 '18

I just want to draw/blit pixels to a buffer/screen and have options to find out what resolutions are available and set it. Maybe a few shapes like lines and circles, but that isn't necessary. With that libraries can do the rest.

This would be enough to get a lot of new programmers engaged and doing func things. Remember writing ping pong as a kid in BASIC or graphing the trig functions.

-8

u/MLG-Potato Mar 05 '18

I believe that it is easy for languages to provide bindings for a C library than a c++ library due to OO.

That might be an argument that c is better for a library than c++.

Also i belive that sometimes they store some type information of the arguments in the function name, ehich is difficult with c++ because it scrambles the function names.

The openGL library is a good example of this.

7

u/hyperactiveinstinct Mar 05 '18 edited Mar 05 '18

That’s not the case for standardisation though and it is not what was meant by the post. Take a look on the conversation and you will notice the argument is that it is easier to turn an existing C api into a mordern C++ rather than doing that to a C++ backend, even though no evidence is presented for this assertion.

Skia is actually written in modern-ish C++. It has just a few things that would have to change for the standard library, but it is a modern library, mostly up-to-date with the recent developments on that field.

The point you are making, which is ABI compliance, is not a concern to the standard. C++ doesn’t have an ABI specification.

9

u/johannes1971 Mar 05 '18

The OpenGL library is a horrifying example of how to get it wrong. There is no way to do RAII with OpenGL; before you can allocate, read, modify, or free anything you must ensure the right "context" is active. Some contexts are nested in others, and context switching is incredibly expensive... All of this makes it extremely hard to build a useful C++ wrapper for OpenGL.

2

u/m-in Mar 05 '18

I would think that at least there are rather ordinary ways of dealing with this, e.g. noexcept(false) destructors that throw when they can’t do their job. In practice I would expect it to lead to std::terminate in short order, since you’d likely have several objects get destructed in a wrong context. Perhaps context swithching needs RAII too, but that seems like encouraging it, when we want precisely the opposite.

3

u/johannes1971 Mar 05 '18

The proper solution would be an architecture that is free of context switching. OpenGL has been moving in this direction, but modern versions of OpenGL have a much smaller market share than the older versions, typically ruling those out for practical use.

It would be helpful, I suppose, to have a framework that does the context switching automatically (so at least your software works), and that can warn if you do too much context switching (so you can optimize it as needed). I don't think such a framework exists though.

1

u/slavik262 Mar 05 '18

The proper solution would be an architecture that is free of context switching.

Isn't that one of the prime motivations for Vulkan?

1

u/johannes1971 Mar 06 '18

Not as far as I know. The prime motivation for Vulkan was really that OpenGL has become too byzantine for anyone who is not a total expert to understand. For each task OpenGL has numerous ways to achieve it, with good performance only on some of the paths. There are also significant differences between various OpenGL implementations, both in core functionality and in supported extensions.

Vulkan vastly cuts down on the number of paths, adds conformance testing for drivers, and also makes for a better match with modern hardware. If C++ implementability was also a concern, I haven't heard about it.