Live data from Hacker News

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

scottmeyers.blogspot.com

111–120 of 181 posts

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

#111
post #44

Earlier quoted context omitted.

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…

> The main advantage of C was that it allowed you to type stuff super fast comparing with Pascal ( {} instead of Begin .. End etc.) Speaking as a developer who works mostly in C and C++, that's a pretty crappy advantage. Based on the answers here[1], it seems like the real benefits were a more permissive type system, better library, separate compilation units, and better ways to directly access hardware. https://www.…

All the advantages of C over Pascal, usually disregard the extensions that almost all Pascal implementations had.

All the points you mention from Quora were covered by Object Pascal, Turbo Pascal, Quick Pascal, TMT Pascal, Think Pascal, VMS Pascal, HP Pascal,....

Yes there were lots of dialects, but writing C code back in the day each C compiler outside UNIX had their own view of what compiling K&R C was all about, C wasn't any better in portability across compiler vendors and OSes.

If it wasn't for UNIX's adoption, C would have been just yet another systems programming language.

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

#112
post #44

Earlier quoted context omitted.

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…

> The main advantage of C was that it allowed you to type stuff super fast comparing with Pascal ( {} instead of Begin .. End etc.) Speaking as a developer who works mostly in C and C++, that's a pretty crappy advantage. Based on the answers here[1], it seems like the real benefits were a more permissive type system, better library, separate compilation units, and better ways to directly access hardware. https://www.…

This was my personal experience, where learning C allowed me to make a 3D engine with Gouraud shading in a few days, where the same in Pascal would have taken a lot longer, mainly because of necessary syntactic sugar. C just allowed to go super fast and didn't restrict experimenting as much as Pascal did (which is still a pretty permissive language), and even adding inline assembly code to render fast felt natural, unlike in Turbo Pascal. And this speed carried over to competitions.

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

#113

Earlier quoted context omitted.

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

Most of them moved to Java twenty years ago. People who are still programming in C++ today do so either because they like it or because they have no choice.

Many of the bigger, well paying companies like FB, GOOG, LNKD, etc. have C++ backends

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

#114
post #109

Earlier quoted context omitted.

"I need to write code to get things done. " Yes. But their cultures are a little different. C++ I think is 1/2 academic, 1/2 Engineering - with a lot of voices, and a lot of anachronistic 'grey beards' arguing over stuff. Even for Java, James Gosling said 'Sun less less a company than it is a debating society'. Scala is almost purely academic - but driven by a single person / small team. Scala was not designed to sol…

Scala is increasingly used in projects that underpin allot of todays infrastructure, for example Kafka, Spark, Akka and Finagle.

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 is a change to how Scala is presented. As of 2016, it's still a little academic and cliquish.

Though I predict some things will change and it might gain popularity.

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

#115

Earlier quoted context omitted.

I've just looked at this line in darcs documentation: (Patchy p, (~) ((* -> *) -> *) (ApplyState p) Tree) => Patchy (PatchInfoAnd rt p)

The C++ usage (T x{{}}) is problematic because its interpretation is so obscure as to flirt with ambiguity and lead to program-breaking changes in compilers as their semantic analyzers improved. The Haskell line you cite isn't ambiguous at all.

Ambiguity, yes it has none.

About obscurity, how many GHC extensions were required to make it accept this code? (Is GADT enough?) And by the way, this is in the interface, while the C++ example is in the implementation.

Besides, that's Haskell code that happens in practice. This is one I've just looked at, if I did some research I would certainly come up with more egregious code (maybe even mine). This one probably isn't even problematic (it's hard to say from the interface), but in general, mixing those extensions does lead to some very interesting problems from time to time.

Haskell has the same excessive complexity problem that C++ suffers. I do think this is the right thing to do right now. But I can't imagine it not looking as dated in 4 decades as C++ is now.

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

#116
post #99
post #80

Earlier quoted context omitted.

Interesting post. Small comment: the C++11 standard has about 1300 pages, not 5500, thank goodness.

I misremembered... So I just went and look this up the C++14 standard, or at least the nNvember draft is 1368 pages and the Ruby ISO standard is 313. I was off by a fair amount. But this made my point more extreme. C++ has mauch smaller feature list than Ruby and the spec is more 4x the size C++ is much more specific and precise. Ruby and many other languages will use the behavior of some de-facto implementation as t…

Is C++ really better specified? Some languages use "the implementation is the spec" and that's bad, sure (though I'd argue it's less bad than "programs that worked on previous versions of the compiler will contain memory safety vulnerabilities on newer versions of the compiler", which is the end result of C++'s approach to undefined behaviour). But compare to e.g. Java, which has a (shorter!) spec with multiple implementations, including a well-specified memory model in the presence of threads (which weren't even specified at all by C++ until recently), and more importantly actually defines behaviour rather than specifying very carefully the wide range of conditions in which the compiler is permitted to arbitrarily break your code.

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

#117
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).

Not my experience at all. There are a lot of dense one-liners in Scala but they tend to be the result of combining several orthogonal features in one place; the set of fundamental constructs is quite small and you can learn them pretty quickly, at which point as long as you're willing to keep calm, take your time, and read the one-liner like it's the five or ten lines it would be in other languages, you'll be fine.

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

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

I really find Python harder to master than C++: in C++ you sometimes have to grapple with syntax and development tools, but after it's resolved, your program works predictably, just don't forget to enable debug symbols and core dumps in release builds. Resources are allocated and freed deterministically, the memory requirements are often obvious from code down to some additive, not multiplicative, constant.

Granted, I mostly work on embedded image processing systems, but would use C++ in any context where long-running processes and/or low latencies are required.

On a more subjective note, I'm waiting for .NET Core to mature a bit, since C# seems to have a balanced selection of features from managed and native worlds, plus a very pleasant syntax and tool support.

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

#119

Earlier quoted context omitted.

Most of them moved to Java twenty years ago. People who are still programming in C++ today do so either because they like it or because they have no choice.

Many of the bigger, well paying companies like FB, GOOG, LNKD, etc. have C++ backends

Those worshipped companies at Silicon Valley are a tiny spot in the ocean of companies that most of us, common developers, get to work on.

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

#120
post #112

Earlier quoted context omitted.

> The main advantage of C was that it allowed you to type stuff super fast comparing with Pascal ( {} instead of Begin .. End etc.) Speaking as a developer who works mostly in C and C++, that's a pretty crappy advantage. Based on the answers here[1], it seems like the real benefits were a more permissive type system, better library, separate compilation units, and better ways to directly access hardware. https://www.…

This was my personal experience, where learning C allowed me to make a 3D engine with Gouraud shading in a few days, where the same in Pascal would have taken a lot longer, mainly because of necessary syntactic sugar. C just allowed to go super fast and didn't restrict experimenting as much as Pascal did (which is still a pretty permissive language), and even adding inline assembly code to render fast felt natural, u…

> inline assembly code to render fast felt natural, unlike in Turbo Pascal.

Turbo C:

    asm {
     ....
    }
Turbo Pascal:

    asm
     ...
    end;
What was unnatural about it?
Post reply on HN