Live data from Hacker News

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

scottmeyers.blogspot.com

41–50 of 181 posts

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

#41

C++ FAQs are full of massively complex conundrums like this for problems you just don't get in other languages. I used to love learning all these highly specific C++ rules and playing language lawyer when I didn't know any better and thought it was a good use of learning time to become an expert. I've since moved on to languages that weren't full of problems like this that let you just get on with what you're meant t…

> 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…

Not all languages age the same way. That's the reason I enjoy writing Lisp code even if I am not paid for it. There are some warts, but it aged well.

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

#42
post #16

Earlier quoted context omitted.

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

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

The most reasonable choice, restricting yourself to a subset. I knew C++ lost it when people started writing library code resembling monads.

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

#43
post #39

C++ FAQs are full of massively complex conundrums like this for problems you just don't get in other languages. I used to love learning all these highly specific C++ rules and playing language lawyer when I didn't know any better and thought it was a good use of learning time to become an expert. I've since moved on to languages that weren't full of problems like this that let you just get on with what you're meant t…

There is nothing to "figure out". You are putting up a false narrative that this is at all a big problem in C++. You'll have to do more work than that if you want anyone to seriously believe such an outlandish claim. The only reason such syntax bugs become popular is because because C++ has a sizable chunk of the complexity-loving developer populace who are attracted to such things. The vast majority of C++ developer…

Obviously this is very hard to quantify but for me the cognitive overload of being a good C++ is massively higher than for languages like Java, Python or JavaScript. C++ to me clearly has significantly more undefined behaviour, compiler specific behaviour and other quirks along with less safety nets (e.g. garbage collection, null pointer checks).

Do you really find JavaScript, Ruby, Java and Ruby harder to master than C++?

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

#44
post #36

It seems to me C/C++ has always had problems. K&R C had weird stuff like char pointers used to point to anything. And modern C++ has odd complexities like what Scott's article illustrates. Was there ever a Goldilocks moment when C was just right ?

C was already bad when it was born, comparing with what Burroughs was doing in Burroughs B5000 in 1961, nowadays sold by Unisys ClearPath MCP. Or other similar languages on those days, like Concurrent Pascal on Solo OS (1975). When I learned C in 1993, it seemed quite poor compared to my Turbo Pascal 6.0 type safety and respective language features.

The main advantage of C was that it allowed you to type stuff super fast comparing with Pascal ( {} instead of Begin .. End etc.) and had some very handy shortcuts for often used operations like ()?:, ++, --, += etc. Less verbose language, less need to type syntactic structures. You could basically keep the flow of what is in your mind with the progress on your keyboard and forget about typing it; you were simply assembling stuff in your mind and at a rapid face making it happen on a computer. Something similar you can now probably experience with Go, sometimes Scala.

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

#45
post #44
post #36

Earlier quoted context omitted.

C was already bad when it was born, comparing with what Burroughs was doing in Burroughs B5000 in 1961, nowadays sold by Unisys ClearPath MCP. Or other similar languages on those days, like Concurrent Pascal on Solo OS (1975). When I learned C in 1993, it seemed quite poor compared to my Turbo Pascal 6.0 type safety and respective language features.

The main advantage of C was that it allowed you to type stuff super fast comparing with Pascal ( {} instead of Begin .. End etc.) and had some very handy shortcuts for often used operations like ()?:, ++, --, += etc. Less verbose language, less need to type syntactic structures. You could basically keep the flow of what is in your mind with the progress on your keyboard and forget about typing it; you were simply ass…

Typing fast usually doesn't lead to working programs that solve what is actually the customer's problem.

Software engineering isn't about "keeping the flow", rather about achieving the quality, deliverables and desired outcomes required by the users of the software.

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

#46

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…

C# maybe? The amount of features in it is very rapidly nearing those of C++.

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

#47
post #39

Earlier quoted context omitted.

There is nothing to "figure out". You are putting up a false narrative that this is at all a big problem in C++. You'll have to do more work than that if you want anyone to seriously believe such an outlandish claim. The only reason such syntax bugs become popular is because because C++ has a sizable chunk of the complexity-loving developer populace who are attracted to such things. The vast majority of C++ developer…

Obviously this is very hard to quantify but for me the cognitive overload of being a good C++ is massively higher than for languages like Java, Python or JavaScript. C++ to me clearly has significantly more undefined behaviour, compiler specific behaviour and other quirks along with less safety nets (e.g. garbage collection, null pointer checks). Do you really find JavaScript, Ruby, Java and Ruby harder to master tha…

The blog post was about a possible bug in the syntax/standard itself. I pointed out that all languages have weird edge cases and buggy syntax.

If you want to discuss programming languages in general then that is a totally separate discussion. C++ is not in the same class of languages as JS or Ruby, so why would you use them interchangeably? C++ is meant for low level system programming, when performance or size are constraints on the problem you're trying to solve. The problem domain itself entails a certain amount of care.

Also, JS and Ruby are indeed just as hard to master as C++. Heck even Bash is hard to master. Case in point.

http://codegolf.stackexchange.com/questions/tagged/code-golf

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

#48
post #31
post #8

Earlier quoted context omitted.

C++ is hard. If one sticks to a strict subset it is a nice language. The problem is the code one didn't write. Even the STL is ugly to use. They are trying to fix the language by adding features but it's like Javascript, the old ugly ones are still part of the spec.

The problem is that even if all team members across the company agree on the subset, it might change its meaning depending on which language version (ANSI) and compiler vendor/version is being used.

And it might change meaning without changing language versions. Example proposals include N3922 and P0136R1.

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

#49

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…

Most languages have Undefined and Implementation specific behavior. Few languages have so carefully specified their undefined behavior as C++ though.

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

#50
post #40
post #29

Earlier quoted context omitted.

Same here, I will look at Scala Native, like Scala, but instead of JVM as the target platform, its using LLVM

You'll go from bad to worse; Scala is to Java what C++ is to C; barely anyone understands all constructs in either language. You either know everything or nothing (i.e. you can't understand somebody else's code unless you enforce rules or know the complete language in detail).

I'd say this is blatant non-sense usually coming from people who lack any kind of experience in C++, Scala or both.
Post reply on HN