News for hackers. Stuff that matters.
Re:Apple's Module proposal to replace headers for C-based la... by _djo_ on Monday November 26, 2012 @11:39AM (#4832656)
This looks promising, aside from being long overdue. Header files have always been one of the more annoying parts of C/C++/Obj-C development.

The important bit is that the proposal's ideas for making the transition easier are good and make it seem like this may get traction where similar efforts have failed before. That Doug Gregor and other LLVM/Clang/LLDB developers are already working on the Clang implementation is even better. At the very least we may see this in Objective-C.

Re:Apple's Module proposal to replace headers for C-based la... by Someone on Monday November 26, 2012 @11:56AM (#4832739)
I think it is promising and long overdue, too. It also is clear to me that this will win, because Apple pushes it into LLVM, and has a head start at it.

On the other hand: if someone would do the equivalent to their browser, people would call it fragmentation.

It will be interesting to see how gcc reacts to this. If this decreases compilation times significantly, I think they will have to follow suit.

Re:Apple's Module proposal to replace headers for C-based la... by msbarnett on Monday November 26, 2012 @01:09PM (#4833077)
> On the other hand: if someone would do the equivalent to their browser, people would call it fragmentation.

This happens all of the time in browsers. See: Dart, vendor prefixes, JavaScript, etc, etc.

This is also absolutely nothing new in compilers. GCC has had a bucket load of its own C extensions for years (decades), as have many other compilers from many vendors.

Vendor-specific extensions are par for course. In fact, they're a good thing! The first step in moving a standardized language forward is to have the vendors designing and adding non-standard extensions so that they can experiment with ways to "scratch the itch" they're feeling. Good extensions get taken up in committee, and if they can be made palatable to all involved, they get standardized. Bad extensions die on the table.

Having tried-and-tested features drive standardization allows hindsight and experience to strengthen resulting standards. We call the opposite, where the standards body invents a feature out of whole cloth with no example implementation having been tested in the real world, "Design by Committee". This strategy does not have a high reputation for quality and success.

Re:Apple's Module proposal to replace headers for C-based la... by aidenn0 on Monday November 26, 2012 @01:03PM (#4833047)
There is almost no way this won't decrease compilation times, particularly with non-aggressive optimizations. With optimizations off, the vast majority of compilation time in C++ is processing the standard header files over and over again.
Re:Apple's Module proposal to replace headers for C-based la... by micampe on Monday November 26, 2012 @12:53PM (#4832985)
> On the other hand: if someone would do the equivalent to their browser, people would call it fragmentation.

I haven’t seen many people calling Dart, Pepper, Native Client or the Chrome Web Store “fragmentation”.

Re:Apple's Module proposal to replace headers for C-based la... by Someone on Monday November 26, 2012 @01:55PM (#4833319)
With "the equivalent" I wasn't thinking about creating entirely new ecosystems; I was thinking of tweaking the existing ecosystem to favor one's own tool chain.

The moment somebody writes the first module, the world sees the first 'best compiled with clang' code. Once that code uses #import to improve compilation speed, that could become 'must be compiled with clang'. That, IMO, is similar to adding an extra tag to your browser's HTML dialect and then promoting its use.

I expect Apple is aware of the risk and wants to to prevent this (the fact that they plan a 100% compatible middle step is an indication of that), but the risk is there.

Also, people have argued that the effort spent on Native Client should be spent on improving JavaScript performance because of the fragmentation issue. Responding to another comment: people also have complained about the gcc-isms present in lots of open source libraries.

Re:Apple's Module proposal to replace headers for C-based la... by micampe on Monday November 26, 2012 @02:26PM (#4833480)
The ecosystem is the www, not Javascript and HTML, so those are all tweaking and extending the ecosystem.

The moment somebody writes the first Dart or NaCl based website or the first Pepper plugin, the world sees yet another (not the first) "must be viewed with Chrome".

Re:Apple's Module proposal to replace headers for C-based la... by munificent on Monday November 26, 2012 @02:46PM (#4833603)
Websites written in Dart work just fine in any standards-compliant modern browser. You just compile it to JS the same way you do CoffeeScript.

This makes sense because no widely deployed browser, not even Chrome, has the native Dart VM in it. You can download a build of Chromium with the Dart VM in it, but Chrome itself doesn't have it (though we hope it will when the time is right).

Check out api.dartlang.org. If the site works for you then your browser supports Dart just fine. :)

Re:Apple's Module proposal to replace headers for C-based la... by micampe on Monday November 26, 2012 @02:53PM (#4833648)
Right, I forgot about that, thanks.
Re:Apple's Module proposal to replace headers for C-based la... by gte910h on Monday November 26, 2012 @11:43AM (#4832685)
Objective-C is certainly important, but C++ and Objective C++ is where I think this is super important to see. I don't care which solution wins (yet, I might after more inspection/convincing), we just need A solution, and one that works for some older projects with little work.
Re:Apple's Module proposal to replace headers for C-based la... by tptacek on Monday November 26, 2012 @11:52AM (#4832720)
It's been awhile since I did large scale C++, but I remember precision with header file inclusion was a big deal in C++ projects, to the point where you'd mangle your class structure if it'd keep a cascade of header dependencies out of a set of source files. It looks like this module proposal would work at cross purposes to that effort.
Re:Apple's Module proposal to replace headers for C-based la... by gte910h on Monday November 26, 2012 @01:28PM (#4833162)
I don't see why this is at cross purposes. The point of this is to do the following transformation to the Big O numbers

M x N -> M + N

With M being numbers of included headers and N being the number of files including that header.

I think that would be solving that mangling of stuff not working at cross purposes.

The point is to make it so you go over each file once, rather than multiplicatively many as you do now.

Re:Apple's Module proposal to replace headers for C-based la... by tptacek on Monday November 26, 2012 @01:56PM (#4833326)
That's what the previous best practices (impl pointers and such) did with C++ before; the goal of some of those practices was to minimize the constant factors. I may be misreading how "modules" work, but they seem to accept that sprawling dependencies will get pulled in (if only once).
Re:Apple's Module proposal to replace headers for C-based la... by gte910h on Monday November 26, 2012 @02:47PM (#4833613)
This proposal supports "import std.stdio;" type syntax as well. That seems to greatly help fix the constant part of the equation as well.

(In the selection called "Selective Import"). We can't save the world from horrible coders, but selective import would drastically drop the constant costs.

Re:Apple's Module proposal to replace headers for C-based la... by Locke1689 on Monday November 26, 2012 @02:20PM (#4833451)
I think the submodule system will help address this issue. People will often import the entire standard library just for one small feature. If submodules are implemented correctly we can reduce that.

I'm a little wary at such a major change to C, though.