Live data from Hacker News

Apple's Module proposal to replace headers for C-based languages [pdf]

llvm.org

41–50 of 187 posts

Re: Apple's Module proposal to replace headers for C-based languages [pdf]

#41
post #9

Almost like the way D programming language handle it http://dlang.org/module.html

also looks like ada to me

with Ada.Strings.Unbounded;

but "withing" ada, you'd get the parent package(s). eg you'd get Ada.Strings and Ada.Strings.Unbounded but not Ada.Strings.Fixed

Re: Apple's Module proposal to replace headers for C-based languages [pdf]

#42
post #4

long overdue indeed, reminds me a lot of google go?

I found the Go module (aka package) system subtle to understand, but it seems to work well. The subtlety being that what you name when you write "import" is not a module, but a directory on the filesystem (under a known root). Actual module names that act as the namespace for a module's public identifiers do not have to be the same as (or derived from) the import path; that is just the convention. For example, importing "utils" could conceivably bring in bobsfunkystuff.SomeFunc with there being no such module as utils and hence utils.SomeFunc.

It's also my understanding that there are no "submodules" in Go. If you want what's in the import path "foo/bar", importing "foo" is unrelated. In fact, there might not be anything in "foo", making it an invalid import path, despite "foo/bar" being a valid one.

And then there's the stuff with being able to directly import code from github, code.google.com, etc, but that dovetails in to the same mechanism after downloading.

Re: Apple's Module proposal to replace headers for C-based languages [pdf]

#43
post #29

While LLVM authors probably know best, I don't understand some of his criticisms on the "Inherently Non-Scalable" slide. • M headers with N source files -> M x N build cost It's only MxN if there is no use of the "#ifndef _HEADER_H" workaround that he mentioned earlier. Wouldn't adding a preprocessor directive like "#include_once " solve this? Alternatively, these guards could be added to the headers themselves withou…

> Wouldn't adding a preprocessor directive like "#include_once " solve this?

Obj-C already has this: #import http://en.wikipedia.org/wiki/Objective-C#.23import

It’s just #include with built-in guards, but headers still have to be compiled once per compilation unit.

Re: Apple's Module proposal to replace headers for C-based languages [pdf]

#44
I thought one of the points of headers system was you could use the code without having to slog through all the source.

Thinking about my trips to /usr/include, those headers weren't that useful for coding with but you could get constants and function names at least.

Re: Apple's Module proposal to replace headers for C-based languages [pdf]

#45
post #15

"Apple's Module proposal..." Is Apple really who deserves credit here? Is there something I missed about Apple's management driving this, and not Gregor or the C++ standards committee?

Doug Gregor is an Apple employee. They also have a major investment in Clang and LLVM and drive most of its development.

Re: Apple's Module proposal to replace headers for C-based languages [pdf]

#46
Overall I like it. I like how they are treating both C and C++ as first-class citizens of this new feature (instead of, for example, inextricably tying its design to classes and namespaces). I like that they have a plausible migration story for how to interoperate with existing header files. And the overall design really looks like something that would fit into all of the C and C++ work that I do without getting in the way.

Sure it's non-standard and no one who cares about portability will use this (yet). But this is exactly the way that good ideas get refined and eventually standardized. You surely wouldn't want to standardize a module system that hadn't been already implemented and tested -- that would just leave you with surprises when theory meets reality.

C and C++ are here to stay -- we should be open to improvements in them.

They don't explicitly mention this, but I'm sure that they have no plans to remove existing #include functionality -- it is a near certainty that someone, somewhere depends on having the preprocessor state affect how an include file is processed. There are probably even cases where you can look at the design rationale for this choice and say "yep, that really is the best solution for what you are trying to do."

Re: Apple's Module proposal to replace headers for C-based languages [pdf]

#47
post #7
post #2

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 i…

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.

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 languages [pdf]

#48
post #24

It the risk of starting a fight, I really don't want this. I'm quite happy with headers and know how to effectively manage them without shooting myself. Granted there is some compiler overhead for importing large header files but I don't really notice it at all. Also, we already have an Apple/Next non-standard C extension (objective-C). I don't think we want anything else added without proper standardisation regardle…

> Also, we already have an Apple/Next non-standard C extension (objective-C). I don't think we want anything else added without proper standardisation regardless of the motivation. I'd rather they forked the language. This is confusing. Surely Objective-C, which adds a hell of a lot that C does not address and many syntax and runtime changes to support it, would fall under the definition of "fork of the language", ra…

Well Objective C was a preprocessor extension as this proposal is so it's one and the same. Both are extensions.

Yes we all know where vendors that do that got us:

   -moz-gradient:
   -ms-gradient:
   gradient:
   -webkit-gradient:
Oh and Microsoft with their C++ CLR extensions and middle finger to C99.

Re: Apple's Module proposal to replace headers for C-based languages [pdf]

#49
post #24

It the risk of starting a fight, I really don't want this. I'm quite happy with headers and know how to effectively manage them without shooting myself. Granted there is some compiler overhead for importing large header files but I don't really notice it at all. Also, we already have an Apple/Next non-standard C extension (objective-C). I don't think we want anything else added without proper standardisation regardle…

> Also, we already have an Apple/Next non-standard C extension (objective-C). I don't think we want anything else added without proper standardisation regardless of the motivation. I'd rather they forked the language. This is confusing. Surely Objective-C, which adds a hell of a lot that C does not address and many syntax and runtime changes to support it, would fall under the definition of "fork of the language", ra…

> Surely Objective-C, which adds a hell of a lot that C does not address and many syntax and runtime changes to support it, would fall under the definition of "fork of the language"

It's not even a fork, it's a different language source-compatible with C. It has its own semantics, its own syntax and its own runtime.

Post reply on HN