Live data from Hacker News

How to design a replacement for C++

apenwarr.ca

1–10 of 75 posts

Re: How to design a replacement for C++

#2
I have two questions. Which qualities of C++ would one want to maintain in a replacement, and what is one using the replacement for?

For the second question, the article's answer is: kernels, drivers, highly performance-sensitive code like game engines, virtual machines, some kinds of networking code, and so on. And for me in particular, it also includes new plugins to existing C-based legacy systems, including Microsoft Office.

I think this is the first step to discussing "a replacement". I fear that every C++ programmer would give a different answer to each question.

The ideal replacement in the article can be summarised as most/all language features of C, plus some chosen subset of the features of C++.

Although with most of them implemented differently to how C++ has implemented them. Presumably that better implementation is to be done without compromising it's C-like qualities. Which sounds to me like the same trap that C++ itself fell in.

Re: How to design a replacement for C++

#3
I like the article a lot (i.e., the suggestions for a newer alternative). But C + Python is much tricker than you might think (because of the GIL mainly) for any non-trivial, high-performance desktop or mobile app. Because any non-trivial, high-performance app is going to involve queuing and you just can't do that cheaply in CPython (it's not just the GIL, it's that the interpreter is more or less a singleton -- Stackless Python is different -- but with a singleton interpreter on top, the design -- whoa, I feel like I just read a Paul Graham article on this :) -- the design gets a little top heavy).

I personally prefer C + C libraries + the non-invasive suggestions which are mentioned which are already found in C++, Obj-C, etc.

Re: How to design a replacement for C++

#4
1. Hey, I more or less agree with this guy

2. Hahahahahaha

3. Aside from the fact that his wording is backwards from his meaning, I agree that it should be possible to write code that doesn't ever garbage collect.

4. Ok

5. Does this guy know the function of a linker?

6. Again, he asserts something you are to avoid, when really he should be emphasizing what you need to support: code without runtime checks.

7. Wrong. This is one of the few opportunities you have to beat C at its own game. C hardcodes assumptions about the stack that prevent certain low level optimizations.

His #8 is then a summary of the entire article, and really is the only valid point he's made. C is close to a sweet spot for wrapping low level code in somewhat higher level clothing. You can't beat it at the same level of simplicity (not if you count the cost of any potential switch anyway). The way to beat C is to naturally support the high level / low level hybrid that he's doing with python+C in a single language.

Re: How to design a replacement for C++

#6
An immediate issue with the article: the author takes issue with the liberal attitude taken by C++ in adding features and then proceeds to state:

  Maybe you like [lambdas], maybe you don't, maybe you think
  they're God's gift to programming and any language
  without them is an infidel. But adding them would be
  harmless, anyway.
Well I agree on this point, it seems like a poor argument. You can't just declare a feature harmless if you ignore it. You make lambdas first-class and you end up baking them into libraries. Now you must use them.

Otherwise no issues, but it does feel like the author is advocating C++0x minus heavy template metaprogramming - which is a perfectly fine language in my book. Why not just use that and get on with life?

Re: How to design a replacement for C++

#9
post #2

I have two questions. Which qualities of C++ would one want to maintain in a replacement, and what is one using the replacement for? For the second question, the article's answer is: kernels, drivers, highly performance-sensitive code like game engines, virtual machines, some kinds of networking code, and so on. And for me in particular, it also includes new plugins to existing C-based legacy systems, including Micro…

The problem with C++ isn't so much that it's compatible with C or that you shouldn't pay for any features that you shouldn't use -- it's that they used the same dumb linker as C and so most advanced features are grossly limited and ended up as a twisty maze of text manipulation and includes.

Re: How to design a replacement for C++

#10
post #9
post #2

I have two questions. Which qualities of C++ would one want to maintain in a replacement, and what is one using the replacement for? For the second question, the article's answer is: kernels, drivers, highly performance-sensitive code like game engines, virtual machines, some kinds of networking code, and so on. And for me in particular, it also includes new plugins to existing C-based legacy systems, including Micro…

The problem with C++ isn't so much that it's compatible with C or that you shouldn't pay for any features that you shouldn't use -- it's that they used the same dumb linker as C and so most advanced features are grossly limited and ended up as a twisty maze of text manipulation and includes.

That's no longer true; the linker has been massively extended to support templates at this point. (Otherwise every file that instantiated a particular template would result in all the code for that template being duplicated in the final executable. This actually used to happen in older C++ compilers.)
Post reply on HN