6 ms·
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
by cousin_it 9y ago
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)?
- mpweiher 9y ago4.) 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.
- cousin_it 9y agoRadical! 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?
- qznc 9y agoSpecify an interface. Alternatively, infer the interface and type check that in the composing module.
- mpweiher 9y agoNewspeak 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.
- jmh530 9y agoI 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.
- Too 9y agoSo sortof like the -I flag in c++ compilers?
- Koshkin 9y ago> 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.)
- majewsky 9y agoPlease 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.)
- Koshkin 9y agoNo, 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.
- qznc 9y agoI cannot imagine any fundamental improvements. Care to share your dream?
- Koshkin 9y ago> 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.)
- ajuc 9y agoThere 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.
- qznc 9y agoAnother 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)
- ndh2 9y agoWhy would my dream language have a makefile?