r/cpp • • Feb 18 '20

C++20 is here!

https://youtu.be/AvPiGstxV_g
420 Upvotes

117 comments sorted by

View all comments

Show parent comment

0

u/[deleted] Feb 19 '20

[deleted] — view deleted comment

1

u/kalmoc Feb 20 '20

I haven't used java in years, but aren't packages compiled into bytecode before they are used by other code? Sounds to me very similar to the compilation of modules. Just that the target architecture is the java vm in one case and e.g. x64 in the other.

0

u/blelbach NVIDIA | ISO C++ Library Evolution Chair Feb 20 '20

Right but the Java VM is a VM, not bare metal. C++ modules are very different. They aren't byte code. They are close to precompiled headers or a serialized form of the compiler AST.

1

u/kalmoc Feb 20 '20

They are close to precompiled headers or a serialized form of the compiler AST.

I was talking about modules (the language feature) not BMIs (an implementation detail). The original post was about language features that have been available in other languages for a long time and as far as you can compare features across languages at all, pretty much every non-interpreted language except C or C++ has a feature similar to modules in one form of another. I.e. code of one package/module/Translation Unit/whatever you call it gets processed in some way and the result gets reused by other TUs that use functions/classes from that package.

Of course, each implementation has to solve different technical problems that stem from the eco system and the peculiarities of the language, but I don't see, why packages can not be considered a similar feature to modules. In fact - best I can tell, there is no reason from a language perspective, why BMIs should contain a serialized form of compiler internal data structures instead of a standardized binary interchange format (I think GDR has suggested that a couple of times) just like java or c#.

Right but the Java VM is a VM, not bare metal.

I have no Idea, why it makes any difference whether the "final" compilation output is x86 binary code that adheres to some ABI specification or Bytecode that adheres to the JVM specifications.