Live data from Hacker News

Android NDK: GCC is now deprecated, everyone should be switching to Clang

android.googlesource.com

171–180 of 259 posts

Re: Android NDK: GCC is now deprecated, everyone should be switching to Clang

#171

I'm not sure if this will stoke a flamewar, because I've never seen a discussion here on this (might just be hanging around different articles). Is there any technical reason to prefer clang over gcc other than ideological reasons? I get the modular nature of llvm is useful, but is the android NDK using this feature? Quick google search shows clang lagging gcc in all but one test[0] at least on Intel Broadwell. Again…

In addition to what other people have said, Clang and LLVM are improving at a much faster rate than GCC.

So while they may still be lagging in some areas, I'm confident they'll get ahead of GCC in those areas long before GCC catches up in the areas where it's behind.

Re: Android NDK: GCC is now deprecated, everyone should be switching to Clang

#172

Earlier quoted context omitted.

With printf, you do have to look at the docs to see what the string conversion function is. With iostream, you still have to look at the docs to see if the ostream operator is implemented for the class, it's certainly not universal.

> look at the docs to see if the ostream operator is implemented for the class Or give it a go and see if the ide/compiler complains.

It has been so long that that bit of information had dropped out of my brain. I went to verify, and -obviously- there is no auto-conversion for instances of a non-trivial class.

Thanks for reminding me of this. Kudos!

Re: Android NDK: GCC is now deprecated, everyone should be switching to Clang

#173
post #130

Earlier quoted context omitted.

> How is iostream any better than *printf? Type checking.

You already have to do odd casting to get around compiler warnings when passing invalid types to a format—I don't buy this anymore.

> I don't buy this anymore.

You should: https://news.ycombinator.com/item?id=10775022

Re: Android NDK: GCC is now deprecated, everyone should be switching to Clang

#174
post #24

When we tried using clang for Android compiling C++ code half a year ago it caused problems, which disappeared when we switched to GCC. > If you have problems with Clang, please file bugs! Filing compiler bugs is really hard with a closed source project.

I can't see why that should be the case. If the bug is reproducible, then can't you create a reduced test case that shows the bug?

Re: Android NDK: GCC is now deprecated, everyone should be switching to Clang

#175
post #12

Earlier quoted context omitted.

As someone messing with LLVM a lot.. basically LLVM is where a ton of development effort is going. GCC is a dead end it seems like. LLVM is designed to be extended where as GCC.. well, usually doesn't really seem to have been designed.

It, sadly, goes deeper than that, past architecture to philosophy. LLVM is designed to be modularized and embedded in other binaries and toolchains, which makes it easier to build extensions and tooling around it. In addition to having a mountain of legacy code, gcc's project steering is philosophically opposed to allowing non-free (as in GPL) plugins [ https://lwn.net/Articles/582242/ ]. Because of this, developers…

> gcc's project steering is philosophically opposed to allowing non-free (as in GPL) plugins

I think that's the right philosophy. Why shouldn't you be contributing your plugin if you derive value from it, so that other people can derive value from it just as you did with GCC (if you distribute it that is - if you wrote it inhouse for internal use, then it doesn't matter at all!).

It's not like the code generated by GCC is licensed virally.

It's a shame that GCC's code is hard to modify, and difficult to extend. LLVM's permissive license means that contributions don't flow back unless it's favourable to the entity contributing it (such as good PR). I imagine that if somebody/some company wrote an excellent, non-obvious, non-trivial toolchain using LLVM, derive profit from it, they will not _want_ to contribute it back.

Re: Android NDK: GCC is now deprecated, everyone should be switching to Clang

#176
post #91

Earlier quoted context omitted.

Do you have an actual response? How is iostream any better than *printf? At least you can read the format of the former without needing to google un-googleable operators.

> How is iostream any better than [ ]printf? What consistent mechanism do you use to printf an instance of an arbitrary user-defined type? With ostream, you implement ostream& operator and you're done. with printf, you have to have a convention and remember to stick to it. (Do I call .toString(), .stringize(), .getString()... ??) For one-off things, printf is great . You take it from me when you pry it from my goddam…

noob question - what is the use case for a program that operates on arbitrary user defined types? Dynamic typing sounds lazy and slow in my head, might as well use python at this point

Re: Android NDK: GCC is now deprecated, everyone should be switching to Clang

#177

I'm not sure if this will stoke a flamewar, because I've never seen a discussion here on this (might just be hanging around different articles). Is there any technical reason to prefer clang over gcc other than ideological reasons? I get the modular nature of llvm is useful, but is the android NDK using this feature? Quick google search shows clang lagging gcc in all but one test[0] at least on Intel Broadwell. Again…

For development, having full access to the AST at will is a definite good reason. Having such allows you to analyze your code as you're writing it in much more intimate ways, allowing for better refactoring tools, better error analysis, better variable completion, etc. Additionally, because of the modular format of clang, pretty much every build is a cross compiler. You don't need to rebuild clang to get support for arm and x86, for example. There's even targets for GPUs, so you can use the same toolset top to bottom much more effectively.

Re: Android NDK: GCC is now deprecated, everyone should be switching to Clang

#178
post #175

Earlier quoted context omitted.

It, sadly, goes deeper than that, past architecture to philosophy. LLVM is designed to be modularized and embedded in other binaries and toolchains, which makes it easier to build extensions and tooling around it. In addition to having a mountain of legacy code, gcc's project steering is philosophically opposed to allowing non-free (as in GPL) plugins [ https://lwn.net/Articles/582242/ ]. Because of this, developers…

> gcc's project steering is philosophically opposed to allowing non-free (as in GPL) plugins I think that's the right philosophy. Why shouldn't you be contributing your plugin if you derive value from it, so that other people can derive value from it just as you did with GCC (if you distribute it that is - if you wrote it inhouse for internal use, then it doesn't matter at all!). It's not like the code generated by G…

The philosophy went farther than, "We want GCC plugins to be free." It went to, "We want GCC plugins to be basically impossible, because otherwise the risk of non-free plugins is too high."

So, the FSF sacrificed technical needs in order to serve philosophical goals.

Re: Android NDK: GCC is now deprecated, everyone should be switching to Clang

#179
post #85

Earlier quoted context omitted.

We used to call that "public domain software" and it was big in the 80s from what I recall (I was a kid then). You'd release something to the public domain and people can do with it whatever they wished. Then GNU came around and ate everyone's lunch, for better or worse. I suspect for better. Maybe GNU is just a stop-gap movement to get everyone on board the FOSS train, who knows. BSD licensing hasn't caused any apoc…

It was Microsoft that came and ate public domain software's lunch, not GNU. GNU and the GPL were not needed until aggressive copyright enforcers such as Microsoft came on the scene. Bill Gates wrote a famous rant calling anyone that shares code a thief, essentially. The GPL was a reaction to that attitude and has saved the culture of sharing code. If most people defaulted to sharing code like was done pre-Microsoft t…

> Bill Gates wrote a famous rant calling anyone that shares code a thief, essentially. The GPL was a reaction to that attitude and has saved the culture of sharing code.

Didn't Gates' letter come out ten or more years before the first version of the GPL.

Re: Android NDK: GCC is now deprecated, everyone should be switching to Clang

#180
post #24

When we tried using clang for Android compiling C++ code half a year ago it caused problems, which disappeared when we switched to GCC. > If you have problems with Clang, please file bugs! Filing compiler bugs is really hard with a closed source project.

I can't see why that should be the case. If the bug is reproducible, then can't you create a reduced test case that shows the bug?

Depends on the bug, it could be that it's only triggered as a result of the compiler getting in a certain state by processing a bunch of code leading up to the problem area.
Post reply on HN