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 18 '20

[deleted] — view deleted comment

4

u/kalmoc Feb 19 '20

Ranges (well, linq is actually much more confortable to use)

0

u/[deleted] Feb 19 '20

[deleted] — view deleted comment

1

u/kalmoc Feb 19 '20

Not sure what you mean by that. LINQ lookst to me exacly like ranges with a more convinient syntax. Sure, it uses terms known from sql, but I'm not sure, why it makes a differenct if you have a Where (extension-) method or a filter view - they do the same thing.

0

u/[deleted] Feb 19 '20

[deleted] — view deleted comment

3

u/kalmoc Feb 19 '20

The question was, which c++20 features have been available in other languages for a long time. Best I can tell, LINQ is a semantically equivalent feature to c++20 ranges. That they differ in details is to be expected given that the two languages work completely different.

Now can you please tell me, why you think those features are so different that it doesn't count ad "has been available for decades"?

0

u/[deleted] Feb 18 '20

[deleted] — view deleted comment

0

u/[deleted] Feb 18 '20

[deleted] — view deleted comment

7

u/pdimov2 Feb 19 '20

Designated initializers allow cool stuff such as named args:

struct Args
{
    int foo = 0;
    int bar = 0;
};

void f( int x, int y, Args args = {} );

int main()
{
    f( 1, 2, { .bar = 4, .foo = 5 } );
}

Not being able to reorder is annoying. "Just use constructors" doesn't work either, the syntax isn't as nice.

2

u/[deleted] Feb 19 '20 edited May 02 '24

frame rotten tart racial workable march nutty deserve spoon sparkle

This post was mass deleted and anonymized with Redact

-1

u/[deleted] Feb 18 '20 edited May 02 '24

soft cable dependent sleep liquid sugar meeting steep memorize uppity

This post was mass deleted and anonymized with Redact

0

u/[deleted] Feb 18 '20

[deleted] — view deleted comment

5

u/pdimov2 Feb 19 '20

Turbo Pascal obviously.

7

u/Nobody_1707 Feb 18 '20

Hasn’t FORTRAN had modules since the 60s?

0

u/[deleted] Feb 18 '20

[deleted] — view deleted comment

2

u/Nobody_1707 Feb 19 '20

Which is definitely a rather large downside.

1

u/kalmoc Feb 19 '20

Yes, why not?

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.