News for hackers. Stuff that matters.
Re:Killing the C++ Modules Technical Specification by cousin_it on Wednesday October 11, 2017 @09:34AM (#15449581)
Forget C++ for a moment. In your dream language, if one source file uses functionality from another, where should that fact be specified?

1) In the source file

2) In the makefile

3) In both

It seems to me that the only sane option is (1) with a project-wide or system-wide set of "roots". Why is anyone in favor of (2) or (3)?

Re:Killing the C++ Modules Technical Specification by mpweiher on Wednesday October 11, 2017 @09:44AM (#15449667)
4.) In the source file where the two are composed.

In general, modules should not import their dependencies, but have them provided to them by their common parent. See Newspeak's module system as an example.

Re:Killing the C++ Modules Technical Specification by cousin_it on Wednesday October 11, 2017 @09:54AM (#15449753)
Radical! But doesn't that mean the first module can't be typechecked in isolation? I see Newspeak is dynamically typed so maybe it's not a problem there, but what's the right solution for statically typed languages then?
Re:Killing the C++ Modules Technical Specification by mpweiher on Wednesday October 11, 2017 @12:01PM (#15450772)
Newspeak is intended to be statically typed, presumably optionally/gradually. I think the implementation is missing right now, though the syntax already allows type annotations.

As the other commenter wrote, the answer is that modules can never "import" concrete modules, only interfaces. And that means some extra effort, though having type-inference assist with the construction of that module should help. Definitely something that needs figuring out.

IMHO, explicit composition is something we really need to figure out in general, and it should solve the weird mix of linguistic and extra-linguistic mechanisms we have now.

Re:Killing the C++ Modules Technical Specification by qznc on Wednesday October 11, 2017 @10:07AM (#15449854)
Specify an interface.

Alternatively, infer the interface and type check that in the composing module.

Re:Killing the C++ Modules Technical Specification by jmh530 on Wednesday October 11, 2017 @09:50AM (#15449726)
I think D uses 3. You import a module in the source file, but if you need to include outside source files, then they would have to be listed when invoking the compiler. D also has a package system so that this isn't needed if you have sub-modules within a larger project.
Re:Killing the C++ Modules Technical Specification by Too on Wednesday October 11, 2017 @11:06AM (#15450351)
So sortof like the -I flag in c++ compilers?
Re:Killing the C++ Modules Technical Specification by pjmlp on Wednesday October 11, 2017 @05:50PM (#15453816)
Yes, but D also follows the convention of module names being mapped into the filesystem, or package name if it is a directory with a package.d file in it.
Re:Killing the C++ Modules Technical Specification by jmh530 on Tuesday October 17, 2017 @11:13AM (#15491589)
D also has the -I flag. Still needed for libraries in other folders.
Re:Killing the C++ Modules Technical Specification by ajuc on Wednesday October 11, 2017 @10:03AM (#15449824)
There are many kinds of dependencies. If X needs Y to compile I would expect the dependencies to be specified in the code.

If X needs one of (Y1, Y2, ...) to run - I could understand some kind of external configuration.

It's especially useful for frameworks and game engines. Kinda strange to edit sourcecode of tomcat or unreal engine to configure it to use particular regexp implementation.

Re:Killing the C++ Modules Technical Specification by qznc on Wednesday October 11, 2017 @10:21AM (#15449963)
Another aspect is when the linking happens.When building the application? When running the application (plugins)? You mention "to compile" and "to run", but that is an orthogonal design dimension.

So, currently we have four ways to resolve dependencies:

1. Specific at compile time (import in source file via compiler)

2. Unspecific at compile time (via build system)

3. Specific at run time (shared library via OS)

4. Unspecific at compile time (via plugin system)

Re:Killing the C++ Modules Technical Specification by Koshkin on Wednesday October 11, 2017 @10:01AM (#15449811)
> dream language... source file... makefile...

I am dreaming of a programming system that takes advantage of the modern developer workstations which are very powerful and thus can support more sophisticated design and build tools than a text editor and a make. (IDEs provide only an incremental improvement on top of these.)

Re:Killing the C++ Modules Technical Specification by majewsky on Wednesday October 11, 2017 @10:33AM (#15450055)
Please do design it. Whenever someone does "visual programming" or something like that, it usually fails for anything beyond toy examples.

The only counterexample that I can think of is LabVIEW, which is pretty successful with (or rather, despite) its visual editing. (Its main selling point is device compatibility, AFAIK.)

So if you have a design for a visual (or, more generally, "beyond-text") programming system in your head that's any good, please let it out. I'd like to see it. (And until then, I'm sticking to vim.)

Re:Killing the C++ Modules Technical Specification by Koshkin on Wednesday October 11, 2017 @11:13AM (#15450405)
No, I am not a huge believer in visual programming, either. Text is (still) a better medium for formal specifications, which is evident from the wide use of HDLs rather than visual tools in hardware design.

That said, nothing prevents anyone from having (admittedly rather vague) ideas about using a computer as something more than a glorified typewriter.

Re:Killing the C++ Modules Technical Specification by qznc on Wednesday October 11, 2017 @10:33AM (#15450057)
I cannot imagine any fundamental improvements. Care to share your dream?
Re:Killing the C++ Modules Technical Specification by Koshkin on Wednesday October 11, 2017 @10:53AM (#15450237)
> I cannot imagine

I know, it's hard - people could not imagine a car looking different from a horseless carriage back in the day...

(Speaking of the "dream", it is something along the lines of modern environments for Smalltalk. When you model a system, you do not necessarily want to be repeatedly going through the rigid edit/compile/debug cycle; the environment could in theory give you more "immediate" experience modeling the system you are trying to develop.)

Re:Killing the C++ Modules Technical Specification by qznc on Thursday October 12, 2017 @03:26AM (#15456266)
Ah, the Bret-Victor-dream. There are IDEs which provide this. For example, Eclipse can do hot code replace for Java. The Unreal Editor can also hot reload dlls. Many web frameworks come with auto-update functionality.
Re:Killing the C++ Modules Technical Specification by ndh2 on Wednesday October 11, 2017 @01:03PM (#15451264)
Why would my dream language have a makefile?