Live data from Hacker News

GCC starts move towards implementation in C++

article.gmane.org

1–10 of 37 posts

Re: GCC starts move towards implementation in C++

#2
I find this statement particularly interesting:

For example, I think constructors and destructors are pretty easy and hard to misuse.

Now, I am aware that the competence of the average GCC committer probably exceeds that of the average programmer, but still, constructors and destructors are easy to misuse: throwing an exception in the constructor comes to mind, in which case the destructor isn't called. Anything about C++ can be probably misused in the hands of the inexperienced.

Other than that, I think this is a good move, and it'll be interesting to see how this develops. There probably are a lot of (heavy) opinions on this inside the GCC community, and it it'll be interesting to see which directions they choose to go.

Re: GCC starts move towards implementation in C++

#3

I find this statement particularly interesting: For example, I think constructors and destructors are pretty easy and hard to misuse. Now, I am aware that the competence of the average GCC committer probably exceeds that of the average programmer, but still, constructors and destructors are easy to misuse: throwing an exception in the constructor comes to mind, in which case the destructor isn't called. Anything abou…

throwing an exception in the constructor comes to mind

I don't know C++ and thus don't know all the different ways to break constructors and destructors, but this particular way will be banned-- exceptions are off-limits.

I kind of think that the worst part of all of this will not be the C++ code that is added to gcc, but the massive bikeshedding that looks to be inevitable at the start.

Re: GCC starts move towards implementation in C++

#4
post #3

I find this statement particularly interesting: For example, I think constructors and destructors are pretty easy and hard to misuse. Now, I am aware that the competence of the average GCC committer probably exceeds that of the average programmer, but still, constructors and destructors are easy to misuse: throwing an exception in the constructor comes to mind, in which case the destructor isn't called. Anything abou…

throwing an exception in the constructor comes to mind I don't know C++ and thus don't know all the different ways to break constructors and destructors, but this particular way will be banned-- exceptions are off-limits. I kind of think that the worst part of all of this will not be the C++ code that is added to gcc, but the massive bikeshedding that looks to be inevitable at the start.

Yes, that would indeed be the case if they compiled with -fno-exceptions, which they just might do indeed, - otherwise, you can still cause exceptions to be thrown without using them yourself (for example, if you're out of memory, 'new Foo ()' causes a std::bad_alloc () exception to be thrown).

And yes, I feel for the people in the GCC community that have to lead the team through this process of coming up with an acceptable policy most people agree with. I'm pretty sure it will be a challenging task with lots of egos colliding.

Re: GCC starts move towards implementation in C++

#5
AFAIK gcc is not the best designed program in the world (I just compiled it once, and to me it seemed to be a huge bunch of patches over patches).

At the same time I know C++ enough to consider it extremely error-prone, expecially if not managed correctly!

Put together the two things and ...maybe it's time to have a look to some other compiler. What about TCC? :P

Re: GCC starts move towards implementation in C++

#6
Yes, they just allowed it. They're not going to rewrite gcc in C++.

But still, why, oh why?

Eventhough C++ allows, in some cases, the possibility to use easier syntax for certain constructs, it's not particularly more expressive language than C. I don't know gcc codebase but if they decided to actually reimplement something in C++, it would take a lot of time just to make it comparable to the current C implementation.

While something like a Haskell/OCaml implementation would probably be too cutting-edge, considering the conservative inertia of such a big project, I wonder why they didn't consider some high-level language better suited for compiler writing.

For a project like gcc, even designing a domain specific compiler-writing-language wouldn't be too far fetched given the limited problem domain and the big yields that a finely targeted language might give.

Re: GCC starts move towards implementation in C++

#8
post #5

AFAIK gcc is not the best designed program in the world (I just compiled it once, and to me it seemed to be a huge bunch of patches over patches). At the same time I know C++ enough to consider it extremely error-prone, expecially if not managed correctly! Put together the two things and ...maybe it's time to have a look to some other compiler. What about TCC? :P

...or LLVM :-P

http://en.wikipedia.org/wiki/Low_Level_Virtual_Machine

"The Low Level Virtual Machine (LLVM) is a compiler infrastructure, written in C++, which is designed for compile-time, link-time, run-time, and "idle-time" optimization of programs written in arbitrary programming languages. "

Re: GCC starts move towards implementation in C++

#9
This could be really great for GCC if they pick the right subset.

For instance, I could imagine that a GCC that takes advantage of namespaces, overloaded functions, and template functions (notably: not classes, exceptions, or implicit type coersion) to be quite a lot easier to understand than today's deeply preprocessor-dependent GCC.

It's easy to assume that C++ implies OO, but you really don't need to go that way, and you might not want to if you're starting with a project as old and hardened as GCC.

Re: GCC starts move towards implementation in C++

#10
post #6

Yes, they just allowed it. They're not going to rewrite gcc in C++. But still, why, oh why? Eventhough C++ allows, in some cases, the possibility to use easier syntax for certain constructs, it's not particularly more expressive language than C. I don't know gcc codebase but if they decided to actually reimplement something in C++, it would take a lot of time just to make it comparable to the current C implementation…

Every time I start a project in C, I end up switching to c-style C++ when I realize that I'd really like a standard library of type-safe containers.
Post reply on HN