Live data from Hacker News

C++ and the Culture of Complexity (2013)

blog.greaterthanzero.com

131–140 of 285 posts

Re: C++ and the Culture of Complexity (2013)

#131
post #106

Earlier quoted context omitted.

> It can be compiled to native code... In that sense, you are absolutely right. However, for simplicity I only thought about the out of the box experience, or by the de-facto implementation of the said languages, since it’s the most popular usage scenario as well.

Well, since Windows 8 .NET store apps don't support JIT, they only run AOT compiled to native. And NGEN is a standard component of the .NET SDK since the beta days. So AOT compilation has been part of the default tooling since ever.

I guess native needs to be qualified. I would say that Native means it speaks the ABI of and fits into a specific platform.

I would say that the C family languages are traditionally native of most operating systems [1] as they are polyglot and can directly speak whatever C ABI dialect is used there; they also work with the native platform tools.

C# is really native of the .Net platform and although it can be AoT compiled it either can't talk directly with Win32 or the interfacing is not seamless. Also it has its own set of tools.

Android and iOS are interesting because although they are clearly unix derivatives, the unix interface is not the primary interface; so arguably C and C++ are not really native there while Java and ObjectiveC/Swift respectively are.

[1] Or to be fair, of unix and any operating system that can be made to look like unix (Windows).

Re: C++ and the Culture of Complexity (2013)

#132

>Rvalue references provide move semantics, and they solve the perfect forwarding problem. Neither the performance issue that move semantics address nor the perfect forwarding problem exist in classic OO languages that use reference semantics and garbage collection for user-defined types. I don't get this. The performance issue move semantics solve doesn't exist if you just use automatic garbage collection? Is this wh…

Those specific issues do not obviously exist if the language lacks value semantics. Other issues of course do exist, namely allocation overhead and pointer chasing and the difficulty of doing escape analysis.

Re: C++ and the Culture of Complexity (2013)

#133

The bullet list near the end closely matches my own experience with C++. There's an inordinate number of features creating an even worse profusion of edge cases where they interact. Then the "solutions" for those edge cases usually add even more complexity. Worse, they force programmers to coddle their compilers. The ratio between what a C++ compiler will accept and what it will produce sane code for is huge . That's…

C++ is a mess but it's one of the few languages that gives you low-level control of memory and fast code with zero or near zero cost abstractions. So for a certain class of application it's still the best choice. Music software, for example, is pretty much exclusively written in C++. I don't enjoy C++ the language very much but you can build some very cool things with it. Personally I'm hoping Rust displaces it from…

> it's one of the few languages that gives you low-level control of memory and fast code with zero or near zero cost abstractions. So for a certain class of application it's still the best choice.

For a certain class of program, you mean. For applications specifically, the advantages you mention are barely relevant. Usually only small parts of a whole application need low-level control of memory etc. Those can be written in C, with the rest written in a cleaner higher-level language that interfaces easily with C (there are many such)

C++ is proof that a single language can't satisfy all needs. It tries to do the low-level stuff as well as C, and fails because it can't produce libraries that are as easy to link to. Then it tries to do all the high-level stuff as well as other languages, and utterly fails because it can't get away from its low-level roots. D, Rust, and Nim all make better compromises that suit just about all C++ use cases. Go and Pony do a better job for some but not others. I won't say there's no room for C++ in a sane computing world, but its legitimate niche is very small indeed.

Re: C++ and the Culture of Complexity (2013)

#134

The bullet list near the end closely matches my own experience with C++. There's an inordinate number of features creating an even worse profusion of edge cases where they interact. Then the "solutions" for those edge cases usually add even more complexity. Worse, they force programmers to coddle their compilers. The ratio between what a C++ compiler will accept and what it will produce sane code for is huge . That's…

> C++, on the other hand, seems to have been designed by compiler writers for their own enjoyment and/or job security. Being a C++ compiler writer (Zortech C++, Symantec C++, Digital Mars C++) I can assure you this is not true at all. As to why C++ is so complex, my opinion is it is because it was designed a long time ago, what is considered better practice in designing languages has moved on, and C++ is unwilling to…

> For example, why does C++ still support EBCDIC?

You might imagine EBCDIC was a thing of the distant past, and you'd be wrong. As of at least 2013 there was still production systems using EBCDIC being actively developed. In COBOL. And not just at IBM.

Re: C++ and the Culture of Complexity (2013)

#135
post #43
post #20

Earlier quoted context omitted.

Oh boy, you must be really young. No parallel in C++?!!!?? That is where EJBs and Spring come from. The enterprise architects that created those kind of designs, were the same ones that on earlier decade were doing them with C++. Apparently micro-services are now a thing, well on the late 90's we had Sun RPC, CORBA, DCOM. All tied together with a cluster distributed transaction management. Sprinkled with code generat…

We should all be thankful that the Java and C# communities have offered a welcoming home to all the architecture astronauts :)

It seems to me there is a minority of the community of any language that want to turn it into Java.

Re: C++ and the Culture of Complexity (2013)

#136
post #7

Earlier quoted context omitted.

C++ is a complex language no doubt. But software written in C++ need not be complex. Java, on the other hand, is a simple language. But the kind of unnecessary complexity I have seen in Java-land (EJBs, Spring, etc.) has no parallel in the C++-land. So going by your argument, I would choose C++ over Java to avoid the complexity jump, then profile the app, and if any part's too slow, improve that again in C++.

Java just pushes the complexity into the user's code. For example, a friend of mine once gushed to me about Java IDEs - with one click of a button, a hundred lines of boilerplate are automatically added! I replied a good language shouldn't need boilerplate code automatically inserted.

On the other hand the refactoring tools for Java/C# are miles ahead of anything for C/C++.

Re: C++ and the Culture of Complexity (2013)

#137
post #46

I agree that c++ is complex, but remember that while trying to update the language the standard committee is trying not to do breaking changes. If you can do a greenfield implementation like rust, you don't have the baggage of an installed base, yet. If you compare c++ to a language that is also around for more that 25 years it starts to make more sense why it is complex. Add to that, that it started as an extension…

Yeah by keeping backwards compatibility they avoided something like the Python 2/3 mess which I would say is worth the effort and cruft.

Both extremes (preserving backwards compatibility at the cost of maintainability/complexity, and abandoning back compat at the cost of existing code breakage) are bad. One may be worse than the other, but they're both bad options. The minimum-pain solution is somewhere in the middle.

Re: C++ and the Culture of Complexity (2013)

#138
post #40

Earlier quoted context omitted.

Object Pascal, Eiffel, Ada, Mesa/Cedar, Oberon, Modula-2, Modula-3, Oberon, Oberon-2, Oberon07, Active Oberon, Component Pascal, Sather, Swift, D, Go, Rust are OO languages[1] and value based as well. [1] - As usual, there are many ways of doing OO, not just C++/Java style.

Object Pascal is definitely reference based, not value-based, at least not when I used it back in Delphi 7.

You used Delphi, not Object Pascal.

Object Pascal was created by Apple for Lisa and Mac OS, with collaboration from Niklaus Wirth.

Borland then adopted it to Turbo Pascal 5.5 for MS-DOS.

Turbo Pascal 6.0 and 7.0 for MS-DOS, followed by Turbo Pascal 1.0 and 1.5 for Windows 3.x took up ideas from C++.

Borland then rebooted Turbo Pascal with Delphi, but to avoid creating too much confusion among Pascal developers, they kept calling their dialect Object Pascal, even though they completly rebooted the object model.

This is how you declare objects in Object Pascal.

    type
        PTPoint = ^TPoint;
        TPoint = object
           x: Integer;
           y: Integer;
        end;
        
    var
      valuePointOnGlobalMemory: TPoint;
      valuePointOnTheHeap: PTPoint;

    begin
      {Can use it right away}
      valuePointOnGlobalMemory.x := 10;
      valuePointOnGlobalMemory.y := 20;
      
      {Need to heap allocate first}
      New(valuePointOnTheHeap);
      valuePointOnTheHeap^.x := 10;
      valuePointOnTheHeap^.y := 20;
      Dispose(valuePointOnTheHeap);
      
      {....}
    end.
Easy to test with Free Pascal using Turbo Pascal compatibility mode.

Re: C++ and the Culture of Complexity (2013)

#139
post #81

Lots of posts here frame it like "Yes, it's a bit of a complex language, but the C++ committee has the difficult job of keeping everything backwards compatible, so it's understandable." But that's not the reality. The reality is that they (or Stroustroup) made that decision, and that decision was a mistake. The correct way to deal with backwards compatibility issues is the way Go does it, namely to write tools to aut…

Apple can't write a tool to properly update automatically between Swift versions today, but according to you, this could have been done in the 80s or 90s for C++ which is notoriously hard to parse...

Re: C++ and the Culture of Complexity (2013)

#140
post #80

Earlier quoted context omitted.

C++ is a mess but it's one of the few languages that gives you low-level control of memory and fast code with zero or near zero cost abstractions. So for a certain class of application it's still the best choice. Music software, for example, is pretty much exclusively written in C++. I don't enjoy C++ the language very much but you can build some very cool things with it. Personally I'm hoping Rust displaces it from…

Very very slowly. Only now embedded development is starting to accept C++, and C still rules there anyway. Which means it took about 20 years to reach this point. And still Rust will need to go through the same certification processes that C, C++, Ada and Java enjoy for such scenarios.

There has been recent pushes to use Rust in embedded systems, but I agree it'll take a long time. Check out this blog [1].

[1] - http://blog.japaric.io/

Post reply on HN