Live data from Hacker News

C++ and the Culture of Complexity (2013)

blog.greaterthanzero.com

231–240 of 285 posts

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

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

Backward compatibility with C semantics and tooling was fundamental for C++ success. We wouldn't be having this discussion otherwise as nobody would have used C++. Tools are great for minor upgrades of APIs and syntax, but key to C++ was compiling with existing system headers (no, realistically you do not want to maintain your own 'fixed' version), and most importantly OS and library ABI.

AT&T had a Java like variant of C, before Java was even a thing, called C+@.

This DrDobbs article in an 1993 issue dedicated to possible successors to C, is the only proof that it ever existed.

http://www.drdobbs.com/article/print?articleId=184409085&sit...

Print view is the only way to read it properly.

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

#232
post #103

Earlier quoted context omitted.

I find Spring to be great. I grant that I've used it since 2.0, but really it does everything quickly, easily, and is well documented. Especially with Spring Boot. I'm writing a core service in Go because Java 9 broke a Maven plug-in (that I don't need now). Holy crap is it painful. I know that I'm learning, but it's hard to layer the application. Most tutorials show passing the database connection through all of the…

>>Really, I don't think that Java brings that much complexity now. It use to. That's because these days you don't learn Java, you learn things that manage Java madness. Like Eclipse, IntelliJ or Maven etc. You don't really do much using Java these days. You do things using tools, which write bulk of the Java code. In essence learning Java today is learning Java ecosystem tools. >>But you can get a new developer up an…

> Haven't heard any major project being started in Java in most places in a long time.

Come to European enterprise shops, Java and .NET rule with no signs of changing.

Including greenfield projects.

Even alternative JVM and CLR languages are hardly an option.

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

#233

When I was young, I thought I understood C++, because I had been taught it in school. I did not. Having interviewed several recent graduates who thought they knew C++, I believe this is fairly common, particularly among people with advanced degrees in engineering and the sciences. It's very easy, in C++, not to know the scope of one's ignorance.

This is very true. I've seen very ignorant (on c++) people say that they dont find c++ complex at all, but very simple. Most of the time this only shows the lack of deep knowledge on the language.

You can do the same with someone that says C is easy to master.

Just pick a copy of ANSI C and randomly ask a couple of UB questions.

You have a catalog of about 200 cases to chose from.

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

#234
post #169

Earlier quoted context omitted.

Well, most compiler bugs are cases where the compile "is wrong" and "being too limited for what I'm trying to do" also sounds like a bug. So this reads to me as "aside from when they are wrong, compilers are not wrong" ;)

> Well, most compiler bugs are cases where the compile "is wrong" Most compiler bugs are situations where the compiler allows stuff it should not or generates incorrect code. > "being too limited for what I'm trying to do" also sounds like a bug. So this reads to me as "aside from when they are wrong, compilers are not wrong" ;) Most every compiler is "too limited" to do some things, that is a big reason why dynamica…

Hm ... I wouldn say thats a limitation of the compiler but of the language itself (no ducktyping). Definitely not a bug though.

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

#235
post #116

Earlier quoted context omitted.

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

> why does C++ still support Stop right there! There is plenty of evidence that removing features from a language is fatal to adoption. Both Perl and Python have suffered from this. Specifically for trigraphs (apart from these, EBCDIC support doesn't affect compilers on other systems) IBM have a vote and they voted not to remove it: https://isocpp.org/files/papers/N4210.pdf

How has Python suffered from this? They broke things going from 2 to 3... and it was still the fastest growing language from 2017. It clearly wasn't popular just because they removed features, but you can't say that removing things is fatal to adoption.

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

#236
post #207
post #186

Earlier quoted context omitted.

Very interesting, thanks. I got introduced to C++ via Turbo C++ 1.0 for MS-DOS, in 1993. So if it was good enough for 640 KB max, with 64KB executables, it shouldn't be an issue in most micro-controllers, but the biggest issue is the existing dev culture.

Forgot to mention couple other design decisions: No new, delete operators in any C++ code. ISR code was also in C++. All objects are statically allocated - with 4MB of SRAM, one can easily see why. It allows tightly control memory usage by the developer. All regression tests are automated. There were test scripts for all functional HW/SW components. Found one bug triggered in 24.9 days time frame (31 bit timer counte…

Very interesting. Was the build environment all inside MPW?

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

#237

Earlier quoted context omitted.

IBM can support it as an extension in their C++ compiler. No need to burden the rest of the community with it. It's not like C++ compiler vendors are shy about adding extensions :-) Despite C++ supporting EBCDIC, I seriously doubt the overwhelming majority of string processing C++ code will work with EBCDIC anyway, because the programmers probably never heard of it, let alone tested the software with it.

The Committee recently got rid of trigraphs (required for EBCDIC compatibility). IBM was strongly against the proposal but was finally outvoted. They do keep the functionality as a conforming extension in their compiler, but now that they have been removed from the standard, the language might evolve in ways that might make the extension non-conforming.

Trigraphs can be supported with the simple expedient of putting a filter in front of the compiler that converts the trigraph sequences to the corresponding character. It doesn't have to be in the compiler itself.

In fact, trigraphs were designed to operate this way.

That is, until the addition of raw string literals broke that.

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

#238
post #174

Earlier quoted context omitted.

I used C++ for embedded CPU 68332 (25 MHz CPU) with 4MB of SRAM in ~1996 for DNA sequencer machine. ~100 + classes, single inheritance, 1,2, 3 Axis motor controls, CCD Camera, Laser, serial com channel, scripting engines, etc. No template, no virtual functions. Worked very well at that time. The compiler setup at that time is AT&T cfront generate C from C++ code ran in Mac and embedded C cross compiler generated the…

The C++ you wrote in 1996 is basically a different language from the C++ that you're encouraged to write today.

> The C++ you wrote in 1996 is basically a different language from the C++ that you're encouraged to write today.

We can differentiate between (a) what the language spec says, and (b) what various individuals advocate.

The code we write is generally constrained by (a), but we can usually substitute our own best judgment for (b).*

* Except when the people mentioned in group (b) have sway over the C++ standard.

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

#239
post #227

Earlier quoted context omitted.

Well, I’m not very knowledgeable about Windows world, as I said before, I’m not using Windows for 15 years or so. So, my bad, sorry.

If you, or others want to know a bit more about it, NGEN https://docs.microsoft.com/en-us/dotnet/framework/tools/ngen... AOT Compilation for Windows 8.x store apps, based on Singularity's Bartok compiler https://channel9.msdn.com/Events/Build/2012/3-005 https://channel9.msdn.com/Shows/Going+Deep/Mani-Ramaswamy-an... AOT Compilation for Windows 10 store apps, using Visual C++ backend https://channel9.msdn.com/Shows/Go…

Thanks a lot. I will read them as soon as possible.

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

#240
post #59

While my pet peeves might be different than the author's I agree that C++ makes you work very hard to keep things simple and produce something that is beautiful. Just "avoid the complexity you don't absolutely need" doesn't really work: some basic things are so fundamentally convoluted that I rather just write idiomatic C because it's simple and doesn't get in my way. I want the language to originate from simple axio…

Could you give an example of "some basic things are so fundamentally convoluted"? Also note that almost all C code is legal C++, so when you "just write idiomatic C", you're still writing C++. (Perhaps not idiomatic C++...)

A simple case is hiding the implementation and exposing a public API. Let's use objects to make it something C++ ought to be good at and C ought to be bad at. In C, you write a header file adder.h:

    struct Adder;
    struct Adder *adder_create(void);
    void adder_setup(struct Adder *, int, int);
    int adder_operate(struct Adder *);
    void adder_delete(struct Adder *);
You can easily imagine how one would trivially implement these functions in adder.c, allocating an object, mutating its state and deleting it. The caller doesn't know anything about struct Adder nor does it know how the adding of two ints is implemented. It only needs know that struct Adder can be pointed to. The header file defines a clear interface that can be compiled against. The implementation can be changed without having to recompile all callers. Tried-and-true and boring but it works: this is the way C has done it for decades.

Now, C++. You create a class Adder, declare public constructor and destructor as well as setup() and operate(). Then you declare a couple of private ints to hold state and maybe some private helper methods, and then you realise that 1) you've just exposed parts of the private implementation in the public header and 2) you can potentially break compiled binaries even if you only change the private/protected parts of the class. Yes, that's a textbook example of how to define a class that completely sucks for any real-life encapsulation purposes. You see how things are getting complex quick? This is where people began to think of more novel applications of C++ to fix the language itself.

So you define an abstract class IAdder in adder.h with pure virtual methods to act as a truly public interface, and derive an implementation class AdderImpl in adder.cpp. Great. Except you can't instantiate the private implementation. You'll need a public factory function outside the class or a static method such as IAdder::create() to construct an AdderImpl and return it as an IAdder. This isn't very clean and beautiful anymore and this was a simple example. There are more branches to be explored in the solution space but at this point we've basically had to create an ugly reimplementation of something that we thought would come free in a language that namely supports object oriented programming whose one fundamental selling point is easy encapsulation. And all that while the C counterpart is actually easy, understandable and simple, and requires no re-engineering to get it even work.

Post reply on HN