Live data from Hacker News

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

scottmeyers.blogspot.com

121–130 of 181 posts

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

#121
post #120
post #112

Earlier quoted context omitted.

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?

You could do some tricks with GCC like not specifying arguments in your MOV instructions and let GCC use the optimal registers it calculates during compiling. Practical consequence was that instead of doing some default MOV AX, [something] then MOV BX, [something], then e.g. MUL BX, you could have avoided the first two operations as GCC would chain them together properly without the need to fill in values; so by inlining such code you'd get very very close to hand-written assembly language without additional overhead, speeding up your 3D engine significantly.

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

#122

Earlier quoted context omitted.

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

Ah, but most of the complexity in that line is an artifact of how Haddock (egregiously badly) generates documentation. The line in the source code is

    instance (Patchy p, ApplyState p ~ Tree) => Patchy (PatchInfoAnd rt p)
I don't personally like typeclassitis, but this is actually easy to interpret:

"If 'p' is a patch-like thing, and its ApplyState is a Tree, then 'PatchInfoAnd rt p' is a patch-like thing"

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

#123
post #109

Earlier quoted context omitted.

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…

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

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

#124
post #85

Earlier quoted context omitted.

Exactly, the "custom syntax" is the problem. The problem is that Scala seems to attract the same type of thinking as C++, where there is a culture that rewards obscure, bizarre syntax. I mean, why is it an exclamation mark to send messages to actors in Akka? I need to write code to get things done. I want to spend minimal time figuring out bizarre operator-overloaded library syntax.

Fun like this: http://www.flotsam.nl/dispatch-periodic-table.html When I was a teenager, it was fun to do that in C++ until I realized everybody thought it was fun but their version of fun wasn't compatible with my version of fun.

If all you found was an old API from half a decade ago that doesn't even exist anymore, than I think that's a pretty good case for Scala.

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

#125
post #52

Earlier quoted context omitted.

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

OK. Enjoy your ignorance then.

I'm not the one being ignorant. See your other comment where you have been flat-out misinformed.

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

#126

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…

> Java is over two decades old and one of the most widely used languages in the world. Half the age of C++ (and it's ancestor C which is it largely compatible with). > It has absolutely stood the test of time. Sure, it's held up really well. It takes advantage of the fact that baking in GC, memory safety, and platform independence sweeps a lot of C++'s nastiness under the rug. Of course, those choices are also what g…

It's URL::equals that hits the network, not URI::equals; the latter is a lot more sane. And even URL::equals often won't hit the network, because Java caches DNS lookups forever.

I realise that i am not exactly disproving your point about cruft here.

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

#127
post #92
post #11

Earlier quoted context omitted.

I'm loving the fact fact that languages seem to be moving towards some of the better parts of FP and away from some of the worse parts of OOP. I'm not particularly fond of fully FP languages but they have some really nice ideas that I've been enjoying using.

I agree. And for myself at least, I could also say: I'm not particularly fond of fully OOP languages, but they have some nice ideas that I've been enjoying using. If a thing I want to make is a stateless process, modeling it as a function seems nicest. If that function can be truly a function (i.e. pure), that's best. If it can be semi-pure, in the sense that its only access to mutation is via its arguments (e.g. it…

FP and OO are completely orthogonal in my eyes. I can utilise immutable data with referential transparency just as well with Objects as I can with Modules + Structs, but only the latter is called "FP".

I think because Java and C++ championed a very impure OO, based around C-like imperative semantics, people regard huge bundles of mutable state as canonical OO. To me that's not the big idea, the big idea is Objects vs Modules + Structs.

But I think I'm on the fringe here.

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

#128
post #119

Earlier quoted context omitted.

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.

They do hire a lot of C++ programmers to work on cool projects tough. They also pay well.

Also banks.

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

#129
post #126

Earlier quoted context omitted.

> Java is over two decades old and one of the most widely used languages in the world. Half the age of C++ (and it's ancestor C which is it largely compatible with). > It has absolutely stood the test of time. Sure, it's held up really well. It takes advantage of the fact that baking in GC, memory safety, and platform independence sweeps a lot of C++'s nastiness under the rug. Of course, those choices are also what g…

It's URL::equals that hits the network, not URI::equals; the latter is a lot more sane. And even URL::equals often won't hit the network, because Java caches DNS lookups forever. I realise that i am not exactly disproving your point about cruft here.

Ha, I couldn't remember if it was URI or URL and I was too lazy to look. :-/

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

#130
post #47

Earlier quoted context omitted.

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

I agree with most of your post. The domain of C++ and JS are widely apart. Comparing C++ and JS is hardly justified, IMHO. However if we were to compare them: > Also, JS and Ruby are indeed just as hard to master as C++. I have to call Bull on this part, with apologies for the tone (but I don't know any better way to put it). How on earth you can claim JS is harder than C++? C++ is doubtlessly a much more complicated…

>How on earth you can claim JS is harder than C++?

Because I didn't? Please re-read. I said any language is just as hard to master since the earlier context was obscure dark corners of C++ syntax (Which was the general topic of the article. The vast majority of C++ programmers would never have run into that syntax bug). JS has obscure syntax and my argument is that you need to expend equal effort to master it.

Post reply on HN