News for hackers. Stuff that matters.
Re:Help me sort out the meaning of “{}” as a constructor arg... by DoofusOfDeath on Tuesday November 22, 2016 @12:04PM (#13015475)
I've been programming professionally for over 20 years, most of it in C++. I really like developing fast code, and C++ used to be my favorite tool for the job.

But the language complexity gets more insane with every revision. It's now at the point where Scott Freakin' Meyers can't figure out the interpretation of a short little chunk of code.

I'm now actively looking for gigs in which I can develop high-performance code in a language _other than_ C++, just because it's such a minefield.

I don't follow the discussions of the standards committee carefully, but it seems like they must place almost no premium on keeping the language (and its programs) understandable by non-language-lawyers.

Re:Help me sort out the meaning of “{}” as a constructor arg... by pjmlp on Tuesday November 22, 2016 @12:48PM (#13015844)
> I'm now actively looking for gigs in which I can develop high-performance code in a language _other than_ C++, just because it's such a minefield.

C++ was my next loved language after Turbo Pascal and I still like it.

Nowadays I use mostly JVM and .NET languages and after reading Meyers's latest book, and still following the standardization process, I have to agree with you.

On private projects I can control what gets used, but at company wide level, it is almost impossible to do so.

So one ends up with a gigantic C++ code base, many times just C with C++ compiler, with different meanings depending which ANSI version, compiler extensions and version are being used.

Considering most common companies don't follow code reviews or use static analysis tools, this just leads to quite some buggy code.

Re:Help me sort out the meaning of “{}” as a constructor arg... by walkingolof on Tuesday November 22, 2016 @12:35PM (#13015719)
Same here, I will look at Scala Native, like Scala, but instead of JVM as the target platform, its using LLVM
Re:Help me sort out the meaning of “{}” as a constructor arg... by bitL on Tuesday November 22, 2016 @01:07PM (#13016020)
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).
Re:Help me sort out the meaning of “{}” as a constructor arg... by edblarney on Tuesday November 22, 2016 @01:50PM (#13016413)
I think this comment is fair, but could be misinterpreted.

Scala allows you to do the same thing in many different ways, and with operator overloading ... the approach you chose to coding defines almost a 'custom syntax' for a project.

Which makes it very hard to read sometimes - you have to infer the 'style' before you can get too far.

To be fair - that's a different kind of 'inconvenience' than C++ from C - but the comparison is pragmatically valid.

Re:Help me sort out the meaning of “{}” as a constructor arg... by astral303 on Tuesday November 22, 2016 @03:03PM (#13017139)
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.

Re:Help me sort out the meaning of “{}” as a constructor arg... by edblarney on Tuesday November 22, 2016 @03:34PM (#13017413)
"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 solve an Engineering problem, thus it seems a little 'intellectually masturbatory' (pardon the term).

Scala is way to hard to learn - partly because it's a 'new paradigm' but partly for the reasons aforementioned. So it's only going to make it's way into production for specific entities.

Scala may have a 'big future' if tutorials, training and approaches settle down on commonly accepted standards and practices.

Re:Help me sort out the meaning of “{}” as a constructor arg... by walkingolof on Tuesday November 22, 2016 @04:24PM (#13017802)
Scala is increasingly used in projects that underpin allot of todays infrastructure, for example Kafka, Spark, Akka and Finagle.
Re:Help me sort out the meaning of “{}” as a constructor arg... by edblarney on Tuesday November 22, 2016 @04:46PM (#13017956)
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 arg... by premium-concern on Tuesday November 22, 2016 @06:07PM (#13018487)
> 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 arg... by edblarney on Tuesday November 22, 2016 @11:51PM (#13020137)
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 arg... by bitL on Tuesday November 22, 2016 @03:21PM (#13017309)
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.

Re:Help me sort out the meaning of “{}” as a constructor arg... by premium-concern on Tuesday November 22, 2016 @06:12PM (#13018513)
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 arg... by bitL on Tuesday November 22, 2016 @08:31PM (#13019213)
That's irrelevant. Scala simply allows your coworker to go "off the rails", employing their creativity even to language constructs, and you either spend time to learn their way of thinking, set firm rules about what is allowed, or you are simply out of luck, like often with C++.
Re:Help me sort out the meaning of “{}” as a constructor arg... by walkingolof on Tuesday November 22, 2016 @02:38PM (#13016867)
Even if C++ have been the way I've earned money the past +20 years, I've programmed quite allot of Scala in my spare time. If find the language beautiful in its compact, expressive syntax, I also like the standard lib and the vibrant community. Being able to mix OO and functional programming, is also something I enjoy very much.

So being able to use this language as a system language, I very much look forward to.

But your mileage may vary.

Re:Help me sort out the meaning of “{}” as a constructor arg... by bitL on Tuesday November 22, 2016 @02:47PM (#13016965)
Sure, I use and like both of them. C++ for 3D graphics, Scala for Big Data. Yet I have seen so many things go wrong in both of them so my perspective is a bit different. Imagine if somebody redefines basic operators to mean something different, starts throwing int as exception in C++ or use templates with template parameters with number parameters and you have to figure out what exactly does this thing do? Or in Scala if somebody feels super clever and redefines half of the language by preparing some half-baked barely functioning DSL unable to compile a slightly different code than expected and you have to use it? It's the price you pay in both C++ and Scala for expressibility.
Re:Help me sort out the meaning of “{}” as a constructor arg... by jjnoakes on Wednesday November 23, 2016 @11:45AM (#13023796)
How is that different from using a C function called add_two_ints which deletes the root file system and returns 42?

I don't think it is possible to create a language that can prevent dumb code from being written.

Re:Help me sort out the meaning of “{}” as a constructor arg... by bitL on Wednesday November 23, 2016 @02:01PM (#13024878)
It's not about dumb code. Actually both C++ and Scala can allow you unbelievably clever code which is also super difficult to understand by somebody uninvolved. Remember how some Haskell guys were complaining they aren't able to understand the code they wrote at the top of their game anymore?
Re:Help me sort out the meaning of “{}” as a constructor arg... by jjnoakes on Thursday November 24, 2016 @12:02AM (#13028251)
Being too clever or too terse is possible in any language though. It is an education and experience problem, not a language problem.

Some languages may be slightly worse than others, but the root cause (and solution) is the same across the board.

Re:Help me sort out the meaning of “{}” as a constructor arg... by paulddraper on Tuesday November 22, 2016 @03:51PM (#13017542)
That comparison is unfair.

For starters, there's not the syntactic ambiguity (or at least human uncertainty) found so often in C++.

There may be language complexity, e.g. how visibility interoperates can be difficult in weird cases. But I can at least parse it.

Re:Help me sort out the meaning of “{}” as a constructor arg... by lmm on Tuesday November 22, 2016 @04:57PM (#13018036)
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 arg... by premium-concern on Tuesday November 22, 2016 @01:40PM (#13016338)
I'd say this is blatant non-sense usually coming from people who lack any kind of experience in C++, Scala or both.
Re:Help me sort out the meaning of “{}” as a constructor arg... by bitL on Tuesday November 22, 2016 @01:45PM (#13016382)
OK. Enjoy your ignorance then.
Re:Help me sort out the meaning of “{}” as a constructor arg... by premium-concern on Tuesday November 22, 2016 @06:17PM (#13018549)
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 arg... by johan_larson on Tuesday November 22, 2016 @12:05PM (#13015492)
Any sense of where the C++ refugees are heading?

Rust? Go?

Re:Help me sort out the meaning of “{}” as a constructor arg... by agersant on Wednesday November 23, 2016 @03:15AM (#13021020)
I'm a game developer using C++ every day at work. It's the standard in our industry (at least for AAA games) and probably will be for at least another decade.

I used to choose C for pet projects (when I cared about performance) but I've been learning Rust for ~3 months now. I think I'll replace my usage of C by Rust from here on as much as I can.

I also had a brief affair writing Go but it didn't resonate nearly as well with my background as Rust does.

Re:Help me sort out the meaning of “{}” as a constructor arg... by bnastic on Tuesday November 22, 2016 @12:10PM (#13015531)
"C with classes". (I'm not joking)
Re:Help me sort out the meaning of “{}” as a constructor arg... by isaacremuant on Tuesday November 22, 2016 @10:21PM (#13019702)
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 arg... by Roboprog on Tuesday November 22, 2016 @12:17PM (#13015586)
And yet, I'm laughing. As you know, that was what we called the C preprocessor thing back in the mid 80s (as discussed in Uni - I never used it until about 1990)
Re:Help me sort out the meaning of “{}” as a constructor arg... by bitL on Tuesday November 22, 2016 @01:09PM (#13016045)
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 arg... by johan_larson on Tuesday November 22, 2016 @03:02PM (#13017134)
"When your template system turns out to be Turing-complete, you may have gone too far."
Re:Help me sort out the meaning of “{}” as a constructor arg... by pjmlp on Tuesday November 22, 2016 @12:53PM (#13015902)
I went to Java/.NET lands and respective languages.

Since 2006, I only had one project where using C++ really mattered. A mix of Assembly and C++ was used for image codecs, which were just 5% of the whole application done in WPF.

On personal projects, I went back to it for portable code across Android and Windows Store, but now with Xamarin being part of Microsoft, I am using it for newer projects.

Re:Help me sort out the meaning of “{}” as a constructor arg... by petters on Tuesday November 22, 2016 @12:24PM (#13015629)
Go is nice, but not a substitute for C++. https://github.com/nieksand/sortgenerics/blob/master/README....
Re:Help me sort out the meaning of “{}” as a constructor arg... by rb808 on Tuesday November 22, 2016 @02:19PM (#13016689)
Java/C#, though the complexity is now matching C++, especially with all the new fashionable functional "features" most large code bases are a huge mishmash of styles and complexity that is making me wish for sensible C++ developers again.
Re:Help me sort out the meaning of “{}” as a constructor arg... by johan_larson on Wednesday November 23, 2016 @07:51AM (#13022240)
The problem with Java isn't so much the language. It's the ecosystem and the community. The ecosystem is very rich, so there are many ways of doing pretty much anything, which means it's easy to get lost in the complexity. And the community is fad-prone. Patterns! Injection! Annotations! Something else (for now)!

A certain skepticism is crucial for staying sane.

Re:Help me sort out the meaning of “{}” as a constructor arg... by hota_mazi on Tuesday November 22, 2016 @02:57PM (#13017077)
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.

Re:Help me sort out the meaning of “{}” as a constructor arg... by FT_intern on Tuesday November 22, 2016 @04:45PM (#13017950)
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 arg... by pjmlp on Tuesday November 22, 2016 @05:06PM (#13018094)
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 arg... by gpderetta on Tuesday November 22, 2016 @06:58PM (#13018765)
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 arg... by pjmlp on Wednesday November 23, 2016 @02:05AM (#13020711)
Assuming you live close to one of their sites and are willing to put yourself through their crazy hiring process.

As for the banks, the ones around where I live only care for Cobol, RPG, JEE and .NET.

Re:Help me sort out the meaning of “{}” as a constructor arg... by pklausler on Tuesday November 22, 2016 @12:18PM (#13015592)
Haskell, at least in my case.
Re:Help me sort out the meaning of “{}” as a constructor arg... by marcosdumay on Tuesday November 22, 2016 @03:15PM (#13017256)
Haskell has syntax that is as problematic as this one, and a huge number of extension combinations that nobody can be sure not to be problematic.

I'm running into it as much as I can too, but it does look like a language we should replace with something simpler once we get an specification that works.

Re:Help me sort out the meaning of “{}” as a constructor arg... by pklausler on Tuesday November 22, 2016 @03:49PM (#13017523)
> Haskell has syntax that is as problematic as this one...

Examples, please.

Re:Help me sort out the meaning of “{}” as a constructor arg... by marcosdumay on Tuesday November 22, 2016 @04:10PM (#13017685)
I've just looked at this line in darcs documentation:

    (Patchy p, (~) ((* -> *) -> *) (ApplyState p) Tree) => Patchy (PatchInfoAnd rt p)
Re:Help me sort out the meaning of “{}” as a constructor arg... by pklausler on Tuesday November 22, 2016 @04:17PM (#13017743)
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.
Re:Help me sort out the meaning of “{}” as a constructor arg... by marcosdumay on Tuesday November 22, 2016 @04:47PM (#13017965)
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 arg... by tome on Tuesday November 22, 2016 @05:19PM (#13018194)
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 arg... by PeCaN on Tuesday November 22, 2016 @08:11PM (#13019121)
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 behave differently, classes that overload unary &, etc… just weird stuff). Honestly the only reason I do this is simply because I like writing fast code and C++ is a good tool to do that. It would take me longer to become equally proficient in Rust, D, etc, than to just write 100% dependency-free C++. I mostly work on programming language implementation though, so libraries are less of an issue than in other possible situations.

D has been catching my attention a lot though. I just wish it had something kind of like C++'s move semantics, to make implementing owned pointers (C++ unique_ptr, Rust Box, etc) possible. Maybe it does and I just haven't seen it used yet. The other problem I have with D is that most libraries seem to rely on the GC.

Re:Help me sort out the meaning of “{}” as a constructor arg... by gmfawcett on Tuesday November 22, 2016 @11:00PM (#13019887)
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 arg... by vram22 on Wednesday November 23, 2016 @09:54AM (#13023016)
The main D people (Walter and Andrei) and/or the forums say that there is work in progress to remove GC dependency from some of the libraries as an option. Not sure of the progress or rate of it though.

Edit: Sorry, should say "main D architects" - there are many other people involved in developing D.

Re:Help me sort out the meaning of “{}” as a constructor arg... by emmelaich on Tuesday November 22, 2016 @11:11PM (#13019934)
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 arg... by PeCaN on Wednesday November 23, 2016 @01:21AM (#13020519)
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 arg... by emmelaich on Wednesday November 23, 2016 @05:36AM (#13021566)
STL is the separation of algorithms and data.
Re:Help me sort out the meaning of “{}” as a constructor arg... by Roboprog on Tuesday November 22, 2016 @12:15PM (#13015569)
I would like to thank Mr Meyers for his Effective C++ book, back in the 90s. Said book for me was the tipping point with C++. Having used Borland Pascal-with-Objects, and read about Eiffel, that book confirmed for me, at least, that C++ was a tool of last resort for trying to build on top of existing C code.

C++ devs are a hardy breed :-)

Re:Help me sort out the meaning of “{}” as a constructor arg... by revelation on Tuesday November 22, 2016 @12:31PM (#13015676)
I was skimming his most recent book and I got the impression that a large part of it was on pretty much the same esoteric nonsense of various && constructs as this blog post.

The blog post has an excuse, I'm not sure the book does.

Re:Help me sort out the meaning of “{}” as a constructor arg... by Roboprog on Wednesday November 23, 2016 @01:59AM (#13020685)
In fairness, it was a good book. But it's like combat training. You don't want to be in a combat zone. BUT, if you are, you had better know what you are doing.

Most apps don't need this heartache.

Re:Help me sort out the meaning of “{}” as a constructor arg... by bmm6o on Tuesday November 22, 2016 @04:16PM (#13017734)
Amen. I was just thinking the other day about how I used to really like C++ but how glad I was to not have to use it anymore. I haven't worried about "the most vexing parse" for years! There was this last week, and yes it's contrived but it suggests something has gone horribly wrong: http://stackoverflow.com/questions/40462612/moving-a-member-... .