Live data from Hacker News

Help me sort out the meaning of “{}” as a constructor argument

scottmeyers.blogspot.com

141–150 of 181 posts

Re: Help me sort out the meaning of “{}” as a constructor argument

#141
post #137
post #135

Earlier quoted context omitted.

I'm not quite sure what you mean by 'goldilocks moment', but I think C++11 was it. Ever since then, the language has had a nice balance of high level abstractions at low level performance. (Theoretically it actually got faster due to move semantics)

The parent was asking the goldilocks question -- was there ever a point where C++ was not too complex like modern C++, e.g. this {} issue, but had enough features (contrast with C, which doesn't have enough features for many applications). I don't think there was such a moment. Apparently move constructors were a de-optimization in the case of std::vector. As far as I remember, it's related to iterator invalidation a…

On top of assembler being complicated, the CPUs contain another sort of compiler and optimizations, so it gets even harder to know what exactly happens.

I thought that moving is optional in a sense, and the compiler could decide to copy instead of move (?)

Re: Help me sort out the meaning of “{}” as a constructor argument

#142
post #16

Earlier quoted context omitted.

Any sense of where the C++ refugees are heading? Rust? Go?

"C with classes". (I'm not joking)

Using a subset of c++ in a c fashion seems much saner than raw c without objects and having to use macros so much.

Re: Help me sort out the meaning of “{}” as a constructor argument

#143
post #134

Earlier quoted context omitted.

Any sense of where the C++ refugees are heading? Rust? Go?

Honestly for me… C++. C++ but with restricted and consistent feature usage at every level of the stack. This means no stdlib, no stl, no boost. Writing your own pared-down standard library is actually not that hard if you make sure none of the calling code hits edge cases. 90% of boost just makes sure it's robust in the face of anything (classes that are movable but not assignable, initializer list constructors that…

Re: move semantics and unique_ptr in D, take a quick peek at std.typecons (unique, refCounted) and std.algorithm.mutation.move. I haven't used them, and they are library code (and so not as well specified as C++'s counterparts), but you might find them useful. There's been good progress on the @nogc front in the standard library, too, hoping to see continuing improvements there.

- http://dlang.org/phobos/std_typecons.html

- http://dlang.org/phobos/std_algorithm_mutation.html#.move

My personal worry with D is that the language changes a bit faster than, say, C++ or Rust. I don't know how whether the code I write today will still compile in five years. I wouldn't mind a feature freeze on the language design and the existing stdlib APIs.

Re: Help me sort out the meaning of “{}” as a constructor argument

#144
post #134

Earlier quoted context omitted.

Any sense of where the C++ refugees are heading? Rust? Go?

Honestly for me… C++. C++ but with restricted and consistent feature usage at every level of the stack. This means no stdlib, no stl, no boost. Writing your own pared-down standard library is actually not that hard if you make sure none of the calling code hits edge cases. 90% of boost just makes sure it's robust in the face of anything (classes that are movable but not assignable, initializer list constructors that…

No STL at all? That's the best part of C++!

OK, don't use iostreams, or stringstreams perhaps, and use boost very sparingly.

But not at all?

Re: Help me sort out the meaning of “{}” as a constructor argument

#145
Something to consider when judging C++ on the basis a Scott Meyer article is that he tends to find the dark corners.

He is an excellent writer and an excellent language lawyer but he has

> not written production software in over 20 years, and I have never written production software in C++. Nope, not ever.

https://news.ycombinator.com/item?id=9425083

Re: Help me sort out the meaning of “{}” as a constructor argument

#146

Earlier quoted context omitted.

> I've since moved on to languages that weren't full of problems like this I think you mean aren't full of those problems yet . :) There's a lot of nasty corners in C++ but almost all of them are because it effectively has 40 years of wild success. (I say 40 because C++ inherits C's baggage and success.) It's totally reasonable to pick a younger language with fewer warts. Become an expert in it! Be productive! Ship l…

Java is over two decades old and one of the most widely used languages in the world. It has absolutely stood the test of time. While it does has its pain points its nowhere near as terrible as C++ and (in my opinion) is improving with new versions, and honestly, I think its a joy to program in though that might not be a "cool" thing to say. Whereas C++ is a chore to program in. That's my opinion, maybe I'm just too u…

Checked exceptions is definitely cruft. Java is also has the advantage of trying to be less things than c++. It's not a systems language and it's hardly even a desktop applications language anymore. Java has the same niches as ruby and python more than c++.

Re: Help me sort out the meaning of “{}” as a constructor argument

#147

Earlier quoted context omitted.

> I've since moved on to languages that weren't full of problems like this I think you mean aren't full of those problems yet . :) There's a lot of nasty corners in C++ but almost all of them are because it effectively has 40 years of wild success. (I say 40 because C++ inherits C's baggage and success.) It's totally reasonable to pick a younger language with fewer warts. Become an expert in it! Be productive! Ship l…

> Then, one day, decades and several versions hence, you may find yourself now dealing with all of the warts that language has accrued over time. What languages are getting even close to being as bad as C++ in this respect though? Java, Python and JavaScript have been around for a while now for example and they seem more opinionated in a way that stops too many warts from appearing. C++ has undefined and compiler dep…

Javascript certainly has. Most people don't even seem to be writing javascript in javascript anymore.

Re: Help me sort out the meaning of “{}” as a constructor argument

#148

Earlier quoted context omitted.

I don't doubt at all that Scala is 'industrial grade tech' and is theoretically capable of supporting even banks. But it's not going to go mainstream because the alternatives are far more accessible. The examples you mentioned are relative small. You know what's big? Walmart. WellsFargo. Honeywell. Novartis. I don't think 'it will be a while' before Scala gets into those shops, I think it will be 'never' unless there…

> theoretically capable of supporting even banks https://scala.epfl.ch/ > The examples you mentioned are relative small. You know what's big? Walmart. WellsFargo. Honeywell. Novartis. https://www.lightbend.com/resources/case-studies-and-stories... https://www.lightbend.com/resources/case-studies-and-stories... https://medium.com/@kvnwbbr/transitioning-to-scala-d1818f25b...

Yeah - that's a lot of links for one point - Wallmart.ca.

Which is cool, and doesn't surprise me.

But I don't see the trend lines of Scala heading in the direction they need to be in such that it becomes and incumbent language.

I don't see it as having enough disruptive power to break into the Javascript/C/C++/Java or even C# club.

My own experience is with Scala is that there is just way, way to much 'change' for some added value.

I wish they could make some tweaks to Java to incorporate some elements of Functional programming and I would be happy.

And before you blow up, it's possible to mix both styles, obviously Scala itself is an example of that.

A specific example: a lot of FP comes along with how collections, lists, maps etc. are managed and used. Lodash/underscore provides a lot of that for JS and makes a lot of JS 'functional-like'. If Java had such libraries with the mechanisms to use them (first class functions - Lambda's are not quite that) - then Java would be a lot better. Anyhow - to get the 'good things' about FP I don't think you need an entirely new linguistic paradigm.

Re: Help me sort out the meaning of “{}” as a constructor argument

#149
post #134

Earlier quoted context omitted.

Honestly for me… C++. C++ but with restricted and consistent feature usage at every level of the stack. This means no stdlib, no stl, no boost. Writing your own pared-down standard library is actually not that hard if you make sure none of the calling code hits edge cases. 90% of boost just makes sure it's robust in the face of anything (classes that are movable but not assignable, initializer list constructors that…

No STL at all? That's the best part of C++! OK, don't use iostreams, or stringstreams perhaps, and use boost very sparingly. But not at all?

The STL is generally nice, I agree, and I really miss the separation of algorithms and containers in every other language.

Generally, however, I'm not really a fan the ‘generic programming’ paradigm the STL (and boost) are based around. In C++ it quickly leads to an explosion of complexity.

And as for the best part of C++, RAII and sparing use of templates. ;-)

Re: Help me sort out the meaning of “{}” as a constructor argument

#150
post #146

Earlier quoted context omitted.

Java is over two decades old and one of the most widely used languages in the world. It has absolutely stood the test of time. While it does has its pain points its nowhere near as terrible as C++ and (in my opinion) is improving with new versions, and honestly, I think its a joy to program in though that might not be a "cool" thing to say. Whereas C++ is a chore to program in. That's my opinion, maybe I'm just too u…

Checked exceptions is definitely cruft. Java is also has the advantage of trying to be less things than c++. It's not a systems language and it's hardly even a desktop applications language anymore. Java has the same niches as ruby and python more than c++.

I'm seeing a few people in this thread mention checked exceptions being cruft. I haven't heard this before and was wondering about the reasoning.

Why are checked exceptions cruft?

Post reply on HN