6 ms·
A Proposal to Add 2D Graphics Rendering and Display to C++ [pdf]
- jbb555 13y agoC++ needs something. It's a bit embarrassing when someone used to the standard library from most other languages asks "How do I draw this picture of a cat" or "how do I print 'Hello World!' in red in a welcoming font" and you have to say, erm, well.. there is nothing in c++ for that. Maybe you can find a platform dependent library that will work for you. It doesn't need a library to do everything, but something that lets you draw and write text to a window seems like something that should be available on every platform that can support it.
- ahomescu1 13y ago"Most other languages" seems like an exaggeration. I don't think you can do any of the things you list easily in Python, PHP (you wouldn't even want to in PHP), JavaScript or Haskell.
- hendzen 13y agoPython includes Tkinter for GUI programming. That said, Tkinter is pretty crappy compared to PyQt.
- Daishiman 13y agoThe number of users of Tkinter in Python is so low that I would seriously question its utility in the standard library. IDLE is the only piece of software that I know of that targets it, and it's quite underwhelming.
- shurcooL 13y agoIt is available in the form of cross platform libraries like GLFW.
- angersock 13y agoIt's not quite the Java 2D API, but damned it's close. Why not just knock off a good API, like that for <canvas>?
- adamnemecek 13y agoAFAIK, Cairo is said to be the bee's knees. As in, I've heard multiple people refer to it as a yardstick of good library design.
- TheZenPsycho 13y agoIt's covered in the linked document. To paraphrase: 1. It includes some extraneous things such as some CSS stuff. 2. There is some evidence that some of the canvas api may be covered by patents.
- robin_reala 13y agoRegarding (1), the mention of CSS refers specifically to SVG, not canvas.
- TheZenPsycho 13y agotrue, but canvas does have some css things in it, such as, specifically, it uses the Color css submodule.
- robin_reala 13y agoOh yeah, good point.
- fyolnish 13y agoCairo & <canvas>'s drawing models are rather similar iirc.
- ygra 13y agoAs are pretty much all immediate-mode 2D graphics APIs, except maybe OpenGL (when used as such).
- rwbt 13y agoI'm not sure about Cairo, but IMHO AGG is probably one of the best C++ libraries out there. Great use of C++ capabilities like templates. Too bad, development isn't active anymore. AGG - http://antigrain.com http://antigrain.com
- adamnemecek 13y agoOh shit, apparently the guy behind AGG, Maxim Shemanarev, died 2 months ago. http://beta.slashdot.org/submission/3154635/rip-maxim-shemanarev http://beta.slashdot.org/submission/3154635/rip-maxim-sheman...
- shurcooL 13y agoOh man, that is so unfortunate.
- ezolotko 13y agoVery sad.
- yeureka 13y agoWhat a sad loss... AGG is amazing and I always thought Maxim was a little bit of a genius.
- sigmaml 13y agoI came across AGG very recently. Yes, several parts of the code are designed and implemented very well. Unfortunate that Maxim died.
- Someone 13y agoEarlier discussion: https://news.ycombinator.com/item?id=7012329 https://news.ycombinator.com/item?id=7012329
- copx 13y agoIn the past the argument against putting things like this in the standard library was always that it is non-portable. C and C++ are meant to run on systems which do not even have a monitor, much less a GPU (think embedded). The logic was that standard library functions should work on all systems. That is also the reason why the "file system" API of ISO C/C++ is so severely limited. It is designed for the lowest common denominator. There are no functions for handling directories because of the assumption that some platforms do not even have directories. In fact the file system API does not even assume a hard disk but can be implemented by returning handles to RAM. Now that this principle seems to be abandoned why not go all the way and give us a full GUI toolkit? That would be so much more versatile than just a 2D drawing API. I do not see much use for this except maybe making ISO C++ tutorials more exciting because your programs can show something else than console output. And I mean Cairo is not a simple framebuffer, it is quite complex so why not make another step and give us a full GUI? I read that the C++ guys want a standard library comparable to those of modern languages like Java, C#, Python etc. and they all come with GUI support. Oh, and before they even think about adding graphics they should beef up the file system API. That is an actual issue. Right now every piece of crossplatform C/C++ includes a wrapper around platform specific APIs just to handle something as basic as getting a list of all files in a directory. They want to give us vector graphics rendering before that?
- pjmlp 13y agoIf you check the working groups there are lots of APIs being worked on, including file system ones. http://isocpp.org/std/the-committee http://isocpp.org/std/the-committee - SG1, Concurrency - SG2, Modules - SG3, File System - SG4, Networking - SG5, Transactional Memory - SG6, Numerics - SG7, Reflection - SG8, Concepts - SG9, Ranges - SG10, Feature Test - SG11, Databases - SG12, Undefined and Unspecified Behavior - SG13, Graphics Any modern language should have a "batteries included" set of libraries, even when targeted for systems programming.
- the_mitsuhiko 13y ago> Any modern language should have a "batteries included" set of libraries, even when targeted for systems programming. I would argue the inverse: modern languages should have a lean standard library but a strong package ecosystem.
- midas007 13y agoThird-party libraries are third-party for a reason. Adding every conceivable library as standard doesn't make sense, unless you're Java, in which case no one cares how much crap you bring along.
- zurn 13y agoOther platforms doing this include Python, Erlang, Perl, and C#. "Batteries included" works very well in many cases. Having a single de-facto dominant implementation helps.
- Daishiman 13y agoNone of those languages are meant for systems programming.
- pjmlp 13y agoSo what?! Every language should have a proper set of "batteries included" in the standard library. One is not forced to use every single feature on every program.
- Daishiman 13y agoYou're making the situation far simpler than it is. Extra batteries imply a greater codebase that has to be maintained, must support all modern architectures and compilers, and must evolve in a graceful way while maintaining backwards compatibility. In general, backwards compatibility is a pain in the neck and results in libraries not evolving once they reach the standard library. Python has tons of examples: urllib, urllib2 (both of them superceded by Requests, an external library that manages to incorporate a sane API), multiple subprocessing libraries, several refactorings of the OS exception hierarchy, etc. Oh, and nobody actually uses the included GUI library for anything except the smallest of trivial examples. This is something that can be tolerable in some high-level languages where performance is not a concern, but systems programming languages should tend to more conservative defaults and things that can be used in production to a certain degree of satisfaction. Nobody is going to be happy with the default GUI lib in at least one of the many platforms; the existence of dozens of UI toolkits with different idioms, different looks, and different levels of integration are proof of that. And contrary to some more basic use cases, UI libraries tend to be, by necessity, absolutely enormous. If the end result is going to be another poorly-designed library like many of the STLs modules, I'd much rather developers use the proper UI toolkit for the situation.
- JasuM 13y agoCairo is dual-licensed under the LGPL and MPL. Both of these are restrictive enough to make them incompatible with, eg., App Store terms. Yet the proposal does not seem to even mention the license (or maybe I just missed it). The standards committee is conserned about portability, at least on a technical level. I wonder what their take is on portability issues caused by license terms.
- pmelendez 13y agoThey wouldn't be using the library code. They would just specify what have to be implemented based on the library. They have been doing this with all the libraries that they include in the standard (such as part of boost) and most of the time the resulted specification is way simpler and limited than the original inspiration. Also this is a design for implementation, once done each implementer have to decide how to make it real.
- JasuM 13y agoBoost has a very liberal license, unlike Cairo. C++ libraries, at least the GNU C++ library, have directly based some of their implementations on Boost. This might lead to C++ library vendors not implementing the standard and requiring using a third party library, perhaps later integrating them into their own libraries. Thinking about it, it is not probably a bad thing, it will just take longer than with other parts of the standard. Of course, this is just pure speculation and things might turn out very differently.
- pmelendez 13y agoYou have a point if implementers choose to use cairo code instead of re-implementer it, but in the other case they don't need to follow any license at all since licenses are valid just for code, unless they have patents on it (which I don't think is the case in libcairo)
- rcfox 13y agoThe motivation reads exactly like the xkcd comic on standards. http://xkcd.com/927/ http://xkcd.com/927/ The rest of the document reads like someone just discovered the Cairo library and wouldn't it be cool if we jammed this into our already overly-bloated standards document? There is no all-purpose graphics library. What's good for games isn't necessarily good for rendering PDFs and vice versa.
- adamnemecek 13y agoThat comic is starting to be used in situation where it's pretty irrelevant, such as here. How many cross-platform 2D graphics libraries are there? Also, the purpose is pretty obvious if you look at the use cases of Cairo and it's obviously not meant for (serious) game making, but there already is an open standard for that.
- rcfox 13y agoI'd say it's very relevant. The "Motivation and Scope" section bemoans the over-abundance of library choices and then declares that there should be one standard library for all developers to use. That's literally the situation in the comic. > How many cross-platform 2D graphics libraries are there? The document itself points out 4 cross-platform libraries. A simple Google search for "cross-platform 2d library" yields at least a dozen more. > Also, the purpose is pretty obvious if you look at the use cases of Cairo and it's obviously not meant for (serious) game making ... They explicitly state that they want to serve rendering of any type, including games.
- adamnemecek 13y ago>> That's literally the situation in the comic. No, the comic describes a situation with 15 competing standards. This is the first standard of it's kind. >> The document itself points out 4 cross-platform libraries. The document points out Qt, Cairo, GTK+, or SDL. Let's not count Cairo since this is basically Cairo. Qt is not GPU accelerated (nor is it a graphics library, Qt's graphics library is called Albert I believe) and GTK+ is not really a graphics library either and AFAIK, it itself relies on Cairo. So the only contender is maybe SDL (idk I don't know much about it, but it appears to be higher in the stack). And yeah, Google search does yield a lot of results. Similarly, if you Google for 'programming language', you will also get a lot of results. That does not mean that all of them are interchangeable or that all of them can be used for general purpose computing. If you are going to build a serious project, you will probably choose a platform with some support (such as a standard implemented by several vendors) behind it. The only real contender that comes to mind is Skia (of the Chrome and Android fames). >> They explicitly state that they want to serve rendering of any type, including games. They're talking about 2D games.
- pmelendez 13y agoI know it is irrelevant but still is interesting that one of the authors is Herb Sutter from Microsoft and that he chooses to propose an open source library from C instead of something coming from Microsoft.