Using C++ #128
Replies: 19 comments 4 replies
-
I am unrelated to X11 development (yet). |
Beta Was this translation helpful? Give feedback.
-
I am also unrelated to X11 development yet, but "some" c++ would be great, as long as the ABI remains in pure C, and there is a decent tooling to prevent contributors from going rampage with C++ magic. I am not sure whether such tooling exists, but something clang-tidy-related might be an option.
I suggest enabling C++ features one-by-one, instead of "enabling C++". For a start, I would enable just one (single) feature: RAII.
it is super easy to forget being able to use |
Beta Was this translation helpful? Give feedback.
-
But what's wrong with attribute((cleanup(...)))? It's implemented in c compilers for ages. |
Beta Was this translation helpful? Give feedback.
-
related to simplifying memory allocation/freeing: X11Libre/xserver#226
It's a dangerous can of worms to open. It can sometimes be convenient, but it also tends to make the code harder to reason about, since you now need the context of the current function plus all of the constructors and destructors that may exist and get silently called. |
Beta Was this translation helpful? Give feedback.
-
@shamefulCake1, thanks for the specifics. Well, to achieve that instead of C++ I would switch to some newer language maintaining source level compatibility with C. Eg. @ziglang. It can both compile C code and import its' source into own code. But maybe that's another topic. |
Beta Was this translation helpful? Give feedback.
-
I like zig, but it's nowhere near mature enough for a project like this |
Beta Was this translation helpful? Give feedback.
-
C++ requires in code optimizations as opposed to C which uses compile time optimizations. While C++ can produce cleaner code in some instances, the ability to control the compiler for optimizations is more valuable. |
Beta Was this translation helpful? Give feedback.
-
I do not disagree a slightest bit, it is a dangerous tool. But, as has already been mentioned, the Anyway, I am not qualified to express more of an opinion. |
Beta Was this translation helpful? Give feedback.
-
The main problem of C++ is that you really need to be authoritarian and have full control over the project to not allow C++ mess. You can write C-like code in C++ and keep it sane but once you have people bothering you with std, virtual functions and templates it's over, the project is finished, it's done. Good luck debugging that mess and have fun spending time rejecting all those donkeys. You might as well propose rewrite to Rust. Limiting standard to C++11 does not help in this case, this is the lesson I had to learn the hard way. |
Beta Was this translation helpful? Give feedback.
-
@powerboat9 Thank you for reporting the issue. Due to the broad nature we will move it to the X11Libre · Discussions · GitHub section so that it can be fleshed out further. |
Beta Was this translation helpful? Give feedback.
-
I meant to never again log into github, but I had to just for this. |
Beta Was this translation helpful? Give feedback.
-
|
Beta Was this translation helpful? Give feedback.
-
Hah, it's a nice satire. :) |
Beta Was this translation helpful? Give feedback.
-
Reminds me of a similar satire I read somewhere about how K&R wrote Unix and C as a joke.... the punchline was a 200 or so character line of "code" that seriously looked like something a modem would have chucked out with line noise and mismatched baud rate, with the tagline: "We didn't stop until we got this to compile". |
Beta Was this translation helpful? Give feedback.
-
@sjm-cc Unix Haters Handbook? |
Beta Was this translation helpful? Give feedback.
-
Nope, but thank you for that! I have a copy now.... and it made me go looking. You can find what I was remembering by searching for "Unix is a hoax" CREATORS ADMIT UNIX, C HOAX "We stopped when we got a clean compile on the following syntax: Here's one copy: https://www.cs.cmu.edu/~jbruce/humor/unix_hoax.html |
Beta Was this translation helpful? Give feedback.
-
Rust? Edit- Looks like Rust already has a thread |
Beta Was this translation helpful? Give feedback.
-
It's not worth the headache. |
Beta Was this translation helpful? Give feedback.
-
I think the following statement of @metux at [[xlibre] Re: Can a C++ programmer contribute to xlibre? - xlibre - FreeLists] make it very clear: There will be no C++ code in XLibre in the foreseeable future. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Describe the cleanup
Using some C++11 internally
It should be done because
Applying some C++ might cut down on boilerplate
What are the alternatives?
Not using C++
Additional context
I'm not quite sure what this would look like yet -- this is intended as more of a RFC to check if the answer is "absolutely not" before I try to put together a proof of concept.
Extra fields
Beta Was this translation helpful? Give feedback.
All reactions