News for hackers. Stuff that matters.
Re:Fuchsia is not Linux by mortdeus on Thursday April 12, 2018 @12:36AM (#16818010)
how about we argue the impossibility of most people ever being able to understand what's going on in C++ code (even their own code) and the cataclysmic consequences of using an over convoluted language? I mean there is a reason why the original pioneers of C don't use C++. (i mean other than the fact that dmr is dead)
Re:Fuchsia is not Linux by billfruit on Thursday April 12, 2018 @10:00AM (#16820960)
On the other hand, large C code bases are a special kind of hell, lack of namespaces and user-defined types make it difficult to understand, modify and test.
Re:Fuchsia is not Linux by sedachv on Thursday April 12, 2018 @02:19PM (#16823514)
> On the other hand, large C code bases are a special kind of hell, lack of namespaces

Can you please name a project that you have worked on where you have run into problems because everything was in a single namespace? What was the problem, how did you run into it, and how did you resolve it?

There are a lot of advantages to namespaces. I used to believe that single-namespace languages would cause problems for large software, but working with Emacs (huge single namespace with all the libraries loaded into memory at once, so much worse than C, where you only link a subset of libraries), this problem has not surfaced. I mean literally the only difference is that ".", or whatever the language-enforced namespace accessor is, goes from being special syntactically, to being a convention. When you start to think about namespaces as trees, this makes more sense. Namespaces just push naming conflicts to the parent node. There is no magic that is going to solve conflicts or structure things well or give things clear names. All that is up to the programmer.

Re:Fuchsia is not Linux by carapace on Thursday April 12, 2018 @12:17PM (#16822396)
But we're discussing a microkernel, not a large C code base, yes?
Re:Fuchsia is not Linux by johannes1234321 on Thursday April 12, 2018 @12:34PM (#16822558)
We're discussing an operating system with a microkernel in it's heart and many things built around.
Re:Fuchsia is not Linux by 72deluxe on Thursday April 12, 2018 @04:43AM (#16819052)
I understand my code - the language doesn't dictate the understandability of the code that is written. Any language can be used to write indecipherable bad code. You are blaming the wrong thing. C++ seems to be very widely used to write some amazing things, despite your apparent hatred of it?
Re:Fuchsia is not Linux by fauigerzigerk on Thursday April 12, 2018 @07:32AM (#16819739)
Would you really say that this sort of complexity is just down to writing indecipherable bad code?

https://isocpp.org/blog/2012/11/universal-references-in-c11-...

In my view C++ is a very complex language that only few people can write safely and productively.

When you say "I understand my code" I have to believe you. The problem is that understanding other people's C++ code takes ages, even if they don't abuse the language. Trusting their code is another story entirely.

C++ is a very flexible language in that it puts few restrictions on redefining the meaning of any particular syntactic expression.

That's great, but it also means that there is a lot of non-local information that you have to be aware of in order to understand what any particular piece of code actually does.

I'm not surprised that C++ is both loved and hated and perhaps even more often simply accepted as the only practical choice.

There aren't many widely used languages around that allow us to optimize our code almost without limit and at the same time provide powerful abstraction facilities.

At the same time, there aren't many widely used languages around that make reading other people's code as difficult as C++ (even well written code) and come with a comparably long tail of accumulated historical baggage.

Re:Fuchsia is not Linux by 72deluxe on Wednesday April 18, 2018 @08:32AM (#16866811)
Yes universal references take a while to understand. I read Scott Meyer's book and the chapter dedicated to it took some getting used to, and note taking.

The language is dealing with some tricky concepts. To hide them or try to gloss over them would lead to writing virtual machines and bloated memory usage etc. in the style of C# / Java.

How else would you deal with movement of variables and when an rvalue becomes an lvalue inside a function?

Re:Fuchsia is not Linux by pjmlp on Sunday April 15, 2018 @08:25AM (#16842363)
Haskell, Common Lisp, Ada, Scala, OCaml, F# come to mind.

Even Java and C# are slowly getting down that path.

Languages get those features because they make sense and solve real production problems.

Re:Fuchsia is not Linux by code_sloth on Thursday April 12, 2018 @08:27AM (#16820118)
Most (I hesitate to say all) programmers understand their own code. The problem is usually that nobody else understands that code you wrote.

> Any language can be used to write indecipherable bad code. You are blaming the wrong thing. Some languages allow stupid things. Some even encourage it. So, no, languages can and should be blamed.

Re:Fuchsia is not Linux by 72deluxe on Wednesday April 18, 2018 @08:33AM (#16866819)
I have to maintain other people's code, people who have left the company and not commented it. It is horrible to do, but it is possible. It's even better if they wrote it in a logical way.
Re:Fuchsia is not Linux by pjmlp on Thursday April 12, 2018 @04:33AM (#16819001)
> I mean there is a reason why the original pioneers of C don't use C++. (i mean other than the fact that dmr is dead)

Bjarne created C++ exactly because he didn't want to repeat the experience he had, when he lost his Simula productivity to BCPL.

Of course the C designers thought otherwise of their own baby.

Re:Fuchsia is not Linux by paulhilbert on Thursday April 12, 2018 @04:12AM (#16818893)
So goto spaghetti is understandable? And dropping those isn't an argument since proper C++ usage also implies agreeing on a proper subset of the language to use. Modern C++ with sane restrictions is way more easy to understand. Especially w.r.t. resource ownership and lifetimes (as pointed out).
Re:Fuchsia is not Linux by laumars on Thursday April 12, 2018 @04:38AM (#16819021)
I'm not going to argue that one language is better than another but I do honestly get sick of all this "goto" bashing that often rears it's head. Like all programming constructs, goto can be ugly when it is misused. But there's times when I've simplified code and made it far more readable by stripping out multiple lines of structured code and replacing it with a single goto.

So if you're going to argue in favour of C++ with the caveat of good developer practices then you must also make the same caveat of C (ie you cannot play the "goto spaghetti" card) otherwise you're just intentially skewing your comparison to win a pointless internet argument.

Re:Fuchsia is not Linux by paulhilbert on Thursday April 12, 2018 @07:31AM (#16819736)
No, I would never argue for C++. The reason being mostly its toolsets (constantly changing, instable and often incoherent). I just don't think readability is an argument - and I am as sick of (pointless) arguments against C++'s readability as you are about goto arguments :) Edit: Just to be clear - there are actual arguments against C's readability. For example when figuring out where and when data gets deleted - but as others have pointed out dynamic memory management is a whole different beast in kernel wonderland.
Re:Fuchsia is not Linux by coldtea on Thursday April 12, 2018 @05:16AM (#16819200)
>So goto spaghetti is understandable?

There's no goto spaghetti in C -- it's only used for local error handling, not for jumping around, at least since the 70s...

Re:Fuchsia is not Linux by pjmlp on Thursday April 12, 2018 @07:53AM (#16819884)
You should look at some codebases I occasionally find on enterprise projects.
Re:Fuchsia is not Linux by coldtea on Thursday April 12, 2018 @09:48AM (#16820837)
Enterprise projects written in C?

All 10 of them?

Re:Fuchsia is not Linux by pjmlp on Thursday April 12, 2018 @09:57AM (#16820939)
I wonder where you are counting those 10 from.

Enterprises also write native code, it is not everything Java, .NET and SAP stuff.

Re:Fuchsia is not Linux by coldtea on Thursday April 12, 2018 @02:14PM (#16823472)
Sure, but most of it is in Java, .NET and such.

The rest of it could hide any number of dragons (and be written in any kind of legacy, nightmarish, and/or proprietary tools and languages), so it's not much of a proof of widespread bad C "goto" abuse.

Let's make a better criterion: how many of the top 200 C projects in GitHub suffer from "spaghetti goto" abuse? How many of all the C projects in GitHub?

Re:Fuchsia is not Linux by pjmlp on Thursday April 12, 2018 @02:23PM (#16823557)
Enterprise software is much more than just desktop CRUD applications.

For example, iOS applications, portable code between Android and iOS, distribution tracking, factory automation, life science devices, big data, graphics are all a small list of examples where C and C++ get used a lot.

Sometimes it says C++ on the tin, but when one opens it, it is actually the flavour I call "C with C++ compiler".

Github is not representative of enterprise code quality.

Re:Fuchsia is not Linux by bigato on Friday April 13, 2018 @08:15AM (#16829223)
Your argument about enterprise code cannot be verified since we can't have access to it. Also, the sample of enterprise code you have access to is probably limited and thus most likely biased. Doesn't seem like a very good general argument, but maybe it is a good one for your own individual situation, if we are to believe your word.
Re:Fuchsia is not Linux by JdeBP on Saturday April 14, 2018 @07:49AM (#16836935)
You should say the same to coldtea, the person asserting that there are only 10 enterprise projects written in the C language and that there's no goto spaghetti in C language programs.