Slashdot Mirror


Why ESR Hates C++, Respects Java, and Thinks Go (But Not Rust) Will Replace C (ibiblio.org)

Open source guru Eric S. Raymond followed up his post on alternatives to C by explaining why he won't touch C++ any more, calling the story "a launch point for a disquisition on the economics of computer-language design, why some truly unfortunate choices got made and baked into our infrastructure, and how we're probably going to fix them." My problem with [C++] is that it piles complexity on complexity upon chrome upon gingerbread in an attempt to address problems that cannot actually be solved because the foundational abstractions are leaky. It's all very well to say "well, don't do that" about things like bare pointers, and for small-scale single-developer projects (like my eqn upgrade) it is realistic to expect the discipline can be enforced. Not so on projects with larger scale or multiple devs at varying skill levels (the case I normally deal with)... C is flawed, but it does have one immensely valuable property that C++ didn't keep -- if you can mentally model the hardware it's running on, you can easily see all the way down. If C++ had actually eliminated C's flaws (that is, been type-safe and memory-safe) giving away that transparency might be a trade worth making. As it is, nope.
He calls Java a better attempt at fixing C's leaky abstractions, but believes it "left a huge hole in the options for systems programming that wouldn't be properly addressed for another 15 years, until Rust and Go." He delves into a history of programming languages, touching on Lisp, Python, and programmer-centric languages (versus machine-centric languages), identifying one of the biggest differentiators as "the presence or absence of automatic memory management." Falling machine-resource costs led to the rise of scripting languages and Node.js, but Raymond still sees Rust and Go as a response to the increasing scale of projects.
Eventually we will have garbage collection techniques with low enough latency overhead to be usable in kernels and low-level firmware, and those will ship in language implementations. Those are the languages that will truly end C's long reign. There are broad hints in the working papers from the Go development group that they're headed in this direction... Sorry, Rustaceans -- you've got a plausible future in kernels and deep firmware, but too many strikes against you to beat Go over most of C's range. No garbage collection, plus Rust is a harder transition from C because of the borrow checker, plus the standardized part of the API is still seriously incomplete (where's my select(2), again?).

The only consolation you get, if it is one, is that the C++ fans are screwed worse than you are. At least Rust has a real prospect of dramatically lowering downstream defect rates relative to C anywhere it's not crowded out by Go; C++ doesn't have that.

114 of 608 comments (clear)

  1. This seems to reinforce how clueless he is by Anonymous Coward · · Score: 3, Insightful

    He seems to think he has some great insight into why C is C, why C++ is C++. But really, he is so fucking clueless I don't know where to start.

    1. Re:This seems to reinforce how clueless he is by e70838 · · Score: 2, Interesting

      I have studied deeply C++98. I try to avoid C++ and favor Java each time I can. I am programming since 1994 and I agree with every single word ESR said. I do not know if rust or go are the future. I think we can do better and that there are a lot of insight to get from Ada (and ravenscar).

    2. Re:This seems to reinforce how clueless he is by Hal_Porter · · Score: 3, Funny

      People that met him claim he has halitosis too. That's what happens to people who oppose the C/C++ binarchy. Their heresy festers inside them, causes severe halitosis and they are driven out of society to live in the mountains. Where, from the look of him, ESR is headed.

      Praise Kernighan, Ritchie and Stroustrup! Death to the heretic ESR!

      --
      echo -e 'global _start\n _start:\n mov eax, 2\n int 80h\n jmp _start' > a.asm; nasm a.asm -f elf; ld a.o -o a;
    3. Re:This seems to reinforce how clueless he is by jcr · · Score: 4, Insightful

      He seems to think C is in need of replacement. It is not.

      Some of us care about security, and C suffers from a lack of strings or arrays*, making buffer overflows a way of life. This needs to be remedied, and "just don't do that" isn't a remedy.

      -jcr

      * C has pointers and some syntactic camouflage that makes them appear to be strings or arrays. Don't be suckered.

      --
      The only title of honor that a tyrant can grant is "Enemy of the State."
    4. Re:This seems to reinforce how clueless he is by ThosLives · · Score: 3, Informative

      If you are doing things in which you need to be sure about security and/or safety you should be using static and dynamic tests and checks, which would find most of those issues with pointers and arrays. You should do those things even with a managed language.

      Also, I would much prefer a language that allows me low level things (there is no reason you cannot implement a Pascal-style string in C, for instance) instead of forcing some restricted choice of operations decided by the language or library committees.

      As for garbage collection - if you are really into security or safety, the most robust approach is to have no dynamic memory allocation at all. But when dynamic memory allocation is required, it really would be nice if deterministic (in both runtime and time-of-run) garbage collectors were available.

      --
      "There are a dozen opinions on a matter until you know the truth. Then there is only one." - CS Lewis (paraprhase)
    5. Re:This seems to reinforce how clueless he is by Anonymous Coward · · Score: 2, Insightful

      So create an opaque data structure and a collection of methods to manage the structure with methods for inserting, removing, resizing, etc., bundle it up into a library and you're done. That is, after all, what a C++ class is, a data structure with supporting methods. I've actually done similar in Java with the primitive data types (int, float, etc) because I don't want to us ArrayList and have to auto-box each type into an object. Simple class with an int[] data element and a few add, retrieve methods.

    6. Re:This seems to reinforce how clueless he is by lucasnate1 · · Score: 4, Interesting

      The C standard doesn't prevent anyone from implementing a calling convention where there's a separate stack for parameters and return addresses. That alone would solve many security problems.

    7. Re:This seems to reinforce how clueless he is by david_thornley · · Score: 3, Informative

      I have studied deeply C++98.

      I can understand why you'd prefer Java. C++11 and the following standards make it a much different and easier-to-use language.

      --
      "When you have eliminated the unacceptable, whatever is left, however improbable, must be the truthiness" - Holmes
    8. Re: This seems to reinforce how clueless he is by Miamicanes · · Score: 2

      Java's continued lack of an unsigned primitive 8-bit byte type is just inexcusable. It makes doing anything that involves binding with C++ (e.g., OpenGL ES) *excruciatingly* painful.

      I would love to meet one person... ONE... who has EVER thought, "I'm *so* thankful Java's primitive bytes are signed instead of unsigned. That was a bold, awesome design decision."

      If Java had an 'octet' type of unsigned 8-bit values, my life would have been IMMEASURABLY easier over the past 20 years, and I would have been spared weeks of troubleshooting insidious bugs that happened because I forgot a "&0xff" somewhere (or accidentally put it on the wrong side of parentheses).

    9. Re: This seems to reinforce how clueless he is by david_thornley · · Score: 3, Informative

      The changes made by C++11, 14 and 17 are all pretty minor.

      That is not the opinion of anybody I've seen who actually uses the language. The changes make C++ a much better language.

      It always astounds me how those new revisions of the language got people to write better code, which would have worked fine with C++98 as well.

      Some of the new library features were adapted from Boost, but you're welcome to try writing lambdas and using move semantics (and std::unique_ptr) in C++98. "auto" was completely repurposed, since as far as anyone could tell nobody actually used it, and you can use it to write templates you couldn't in C++98. Plenty of other changes.

      --
      "When you have eliminated the unacceptable, whatever is left, however improbable, must be the truthiness" - Holmes
  2. business code by afidel · · Score: 4, Insightful

    There's enough business logic programmed in C++ and Java to keep both languages around until my kids retire and they're not yet in the workforce. Rust and Go, yeah doubt there's a single company of any size running their business processes on either.

    --
    There are 4 boxes to use in the defense of liberty: soap, ballot, jury, ammo. Use in that order. Starting now.
    1. Re:business code by abies · · Score: 3, Informative

      Rust and Go, yeah doubt there's a single company of any size running their business processes on either.

      Regarding Go. Ever heard about Google? They are running a lot of it...

      Docker is written in Go. Docker is probably single biggest thing happening in devops area in few last years and many, many companies are deploying it in production. And docker is exactly the thing you are 'running you business process on' ;)

    2. Re:business code by friesofdoom · · Score: 4, Insightful

      Great, until google decide to axe go for whatever reason they come up with, pay a bunch of interns to port all the code to another language and leave you eating dust...

    3. Re:business code by friesofdoom · · Score: 4, Informative

      I dont think ac has a grasp on how many times google has pulled that trick before xD

    4. Re:business code by BESTouff · · Score: 3, Informative

      Rust and Go, yeah doubt there's a single company of any size running their business processes on either.

      You didn't even check before posting. Go is used at many companies, and even the younger Rust makes some money: https://www.rust-lang.org/en-U...

    5. Re:business code by MartinG · · Score: 3, Informative

      I work for a FTSE250 UK company and we're running lots of Go in production and the company now depends upon it for important business processes. We continue to see an aggressive growth the use of Go in most areas of IT in our company.

      We also have one specific bit of code in Rust also running in production because Go is not appropriate for it, but we're unlikely to increase the use of rust much more.

      My previous company (a major UK based international publisher) is in a similar position since I introduced Go there a few years back.

      So, that's two companies of reasonable size running their business processes on Go.

      --
      -- MartinG To mail me: echo kewyjlcxyzvjfxbqwh | tr bcefhjklqvwxyz .@adgimnoprstu
  3. Why refer to him as ESR? by Roodvlees · · Score: 3, Insightful

    He's a person, not a technical description.
    We have enough abbreviations in tech.
    Hate it when people do that.

    --
    Thank you, Bradley Manning, Edward Snowden and so many others, for courageously defending humanity, my freedom and more!
    1. Re:Why refer to him as ESR? by jawtheshark · · Score: 3, Insightful

      Consider it a sign of respect in the open source community. You are someone if you get your own three letter acronym. At least it was, twenty years ago.

      --
      Ahhh...the great dumpster continuum. Many a free computer will be found there. -- sowth (748135)
    2. Re:Why refer to him as ESR? by Anonymous Coward · · Score: 3, Informative

      Computer usernames were the nicknames that geeks of yon' generations used for each other. Especially if you used early chat programs on the old timesharing systems:

      ken - Ken Thompson
      dmr- Dennis Ritchie
      bwk - Brian Kernighan
      esr - Eric Raymond

    3. Re:Why refer to him as ESR? by brunomagalhaeslopes · · Score: 3, Informative

      ESR is adopted by Eric himself, in his e-mail (esr@snark.thyrsus.com) and his personal home page (http://www.catb.org/~esr/).

    4. Re:Why refer to him as ESR? by Anonymous Coward · · Score: 3, Funny

      Because if you say his name in full three times, he'll appear, rant about the second amendment for a while, and shoot your dog.

    5. Re:Why refer to him as ESR? by Bing+Tsher+E · · Score: 3, Insightful

      ESR is a gadfly. He has produced almost no useful code himself. He is an extremely productive gadfly because he has nestled into the culture deep and knows how to stir up shit in ways that provokes actually productive into participating in discussions.

      But he's still just a gadfly.

    6. Re:Why refer to him as ESR? by kcelery · · Score: 2

      If you have to ask who ESR is in slashdot, you must be a stranger here.

  4. Provided you have infinite hardware resources... by Opportunist · · Score: 4, Insightful

    The higher the level of abstraction in your language, the higher the overhead it will create. Now, it needn't be so absolutely stupidly overengineered as .net is, but still the metric fits, the more safeguards and handrails your language comes with, the higher the overhead it incurs to have them. This is admittedly not really a huge problem in today's working environment because our computer speeds are far greater than our needs.

    Still, somehow it feels silly that I need increasingly more powerful computers just to run the same kind of program, only because programmers can't be assed to learn their trade and instead rely on ridiculously overblown frameworks that is the equivalent of delivering a pack of soda with a semi because you have to bring a soda factory along with the workforce since the framework doesn't know how to deliver a single soda.

    --
    We used to have a Bill of Rights. Now, with the rights gone, all we have left is the bill.
  5. In defense of C++ by Dutch+Gun · · Score: 5, Interesting

    The reason we have to say "don't do that" is because C++ remains compatible with C and older version of C++. There are literally billions of lines of existing C++ code out there, and the language committee realizes it can't just snap its finger and order everyone to rewrite all that old code (which is stable, functional, and debugged, btw) because we have something newer and better now.

    It's pretty straightforward to write safe, new C++ code if you understand how to use the new features and abstractions. I wrote an entire game / game engine recently using modern C++, and it's amazing how few bugs I've had thanks to recent language improvements and techniques.

    I'm not sure where this "large projects can't enforce code discipline" idea comes from. What does he think "coding standards" are, which nearly every major company, organization, or project has? And if someone doesn't understand how to use a smart pointer instead of a raw pointer or avoiding class inheritance hell at this point, then really, they shouldn't be contributing to your C++ projects.

    I get it that some people dislike or distrust C++. It's a complex language that's hard to master. They don't like that it makes a lot of compromises in the name of practicality, but that real-world practicality is why many of us use it for large, performance-critical real-world projects. I'd never argue that C++ is the right language for every project. In fact, it's a fairly specialized language at this point. But that level of hyperbole is a bit annoying.

    --
    Irony: Agile development has too much intertia to be abandoned now.
    1. Re:In defense of C++ by K.+S.+Kyosuke · · Score: 3, Insightful

      and debugged

      Amply demonstrated by the numerous memory exploits? ;)

      --
      Ezekiel 23:20
    2. Re:In defense of C++ by gnupun · · Score: 2

      I get it that some people dislike or distrust C++. It's a complex language that's hard to master.

      And once you master it, there's limited benefits. It's useful for large, complex programs where speed is important. Examples are games, browsers, large desktop apps etc. That's it -- it's useful in a very small amount of software. For any other type of software, you can use C, Java, Python, Rust, Nim etc.

      Languages like Rust (which is already used in browsers like Firefox) and Nim (which has a very efficient reference counting GC) are the future where performance is important. If you want high performance and an easy to use language, use Nim -- it's slower than C by about 20%, which is not bad. If your software cannot tolerate GC pauses, then use Rust although it's a lot harder to code than Nim.

      ESR statements about Go are bogus. Go is a gimped version of Java although it is less verbose. If speed is not important in your app, use Python. Java has better features than Go (like exception handling) and similar GC performance.

    3. Re:In defense of C++ by The+Cynical+Critic · · Score: 2, Insightful

      It's useful for large, complex programs where speed is important. That's it -- it's useful in a very small amount of software.

      Not sure what your frame of reference is, but that's a LOT of software. Hell, it's basically everything that isn't trivial or severely memory constrained. Had to switch form C++ to C once for a pretty heavily memory constrained embedded application, but otherwise I've been able to get away with using C++ practically everywhere.

      --
      "Why should I want to make anything up? Life's bad enough as it is without wanting to invent any more of it."
    4. Re:In defense of C++ by MichaelSmith · · Score: 2

      I'm not sure where this "large projects can't enforce code discipline" idea comes from. What does he think "coding standards" are

      Won't help you when your code is 30 years old and has been hacked around by slave labour in the form of military conscripts and customer provided "consultants".

    5. Re:In defense of C++ by religionofpeas · · Score: 2

      And if someone doesn't understand how to use a smart pointer instead of a raw pointer or avoiding class inheritance hell at this point, then really, they shouldn't be contributing to your C++ projects.

      Maybe the projects aren't mine. Maybe the project is run by a business, and I'm just one of the people in the team, and the boss has hired a few idiots as well.

    6. Re:In defense of C++ by gnupun · · Score: 3, Insightful

      Not sure what your frame of reference is, but that's a LOT of software.

      No, it's not. Few programmers work on projects that are millions of lines of code and it has to be as fast as possible (real-time).

      For servers, memory is cheap ($200 extra) so you can just use Java for that 2 million LOC project.

      That leaves C++ only for AI, professional games and large desktop apps (Photoshop, browsers, office etc.). While these types of software are used a lot, no more than 100,000 programmers are working on this, at any given time.

      For in-house desktop apps of medium complexity (upto say 500k LOC), you can use C# or VB.net.

      Even for games, where low time for development is paramount, the engine is written by one company in C++. Then dozens of other companies use that engine and Lua or some other scripting language to actually write the game quickly.

      The remaining 95% programmers can use a sane programming language like C, Python, Swift, Java, Rust, Nim or even Go.

      Bottom line: programmer time is money for the company and C++ probably has the 2nd highest cost per line of code compared to other languages (assembly language is 1st in cost/LOC).

    7. Re:In defense of C++ by TheRaven64 · · Score: 4, Interesting
      I've recently started using C++ for a bunch of things where I would previously have used a scripting language. It has basically everything I want from such a language:
      • Closures (including compile-time specialisation with C++14 auto parameter lambdas).
      • A rich set of collection classes (written by people who actually care about performance).
      • Regular expressions.
      • Smart pointers (so I don't need to think about memory management)
      • Futures / promises and threads.
      • A tiny dependency footprint (so my code will run on pretty much any *NIX system)

      Most of the time, I can compile at -O0 and run in less time than it takes the Python interpreter to start and if I find that performance actually does matter then I can quickly profile it, find the bottleneck, and replace it with something a lot more efficient.

      --
      I am TheRaven on Soylent News
    8. Re:In defense of C++ by The+Cynical+Critic · · Score: 2

      For servers, memory is cheap ($200 extra) so you can just use Java for that 2 million LOC project.

      You may have been right a few years ago, but for the last couple of years memory, specially server memory, has become way more expensive due to supply simply not being apple to keep up with supply after much of the manufacturing capacity was shifted to making memory for mobile devices like smartphones and tablets. We're talking about a situation where's it's been badly eating into server vendor profit margins and sales due to increased cost. Thus memory use is important and so is performance when companies are more and more trying to get as much out of the hardware they buy.

      In my experience the whole "C++ is really expensive" meme is just a bunch of FUD spread by people trying to push other languages and is mostly based on an assumption of very low code quality, which would cause similar problems any other language. On a cost-per-line basis C++ really isn't any more expensive than C or Java and the other ones come with their own downsides and much lower availability of skilled developers (so you need to pay more devs or put up with devs making more mistakes in a language they're not very familiar with).

      The bottom line here is that C++ does 95% of jobs just as well or better than any other language with an availability of skilled developers no other language can really match.

      --
      "Why should I want to make anything up? Life's bad enough as it is without wanting to invent any more of it."
    9. Re:In defense of C++ by Dutch+Gun · · Score: 5, Insightful

      No computer language is going to help a project programmed by idiots.

      --
      Irony: Agile development has too much intertia to be abandoned now.
    10. Re:In defense of C++ by TheRaven64 · · Score: 2
      Your approach seems fine at first glance, but it looks like it would struggle when you get more complex data flow. Even in your three-line example, I have a few questions:

      What is the type of stringVariable? If it's char*, then how do I know when it's been stored on the heap and read back that it's dynamically allocated on the heap and so needs freeing?

      What are the ownership semantics of the first argument to StringAction_m? Since you're assigning the result to the input variable, I presume that it's taking an owning reference and explicitly destroying it?

      What happens when you have types that have more complex destruction than a simple free? For example, if you're doing a lot of string processing you probably want some kind of twine abstraction so that you don't end up doing a lot of temporary copies, but now your string data type is a linked list internally and just calling free on the first element will give you a memory leak.

      With a C++ equivalent, none of these problems arise. Your string type would be a wrapper that would know if it owned the memory. On-heap character arrays would probably be represented with std::shared_ptr, so that you could store them in multiple twines before writing them to flat containers. Your different string representations would expose a common iterator type and allow you to query the strings without having to always store them in sequential memory.

      TL;DR: It's not a question of what you can do in a language, it's a question of what you can do without thinking. I'd much rather have a language where the compiler deals with these issues and raises an error if I write something invalid than one where I have to be very careful to get things right that are going to be security issues if I get them wrong.

      --
      I am TheRaven on Soylent News
    11. Re:In defense of C++ by loonycyborg · · Score: 3, Insightful

      C++ still reigns supreme due to its flexibility. While in some less pragmatic language you are very likely to hit some roadblock because language designers wanted to enforce some principle which ended up counter productive in your particular case, it won't be so with C++. This language has no other principle than practicality, and it will never block you from getting the job done. Even it being superset of C ends up being another aspect of practicality. Because C ABI still is de facto standard for language interop and system APIs and is implementation language for astronomic number of important libs.

    12. Re:In defense of C++ by Jay+Maynard · · Score: 2

      Amen to that. I'm a developer on a 1.2MLOC project written almost entirely in C++. It's 15 years old by now, and has has literally a thousand pairs of hands in it. It's open source, and so the quality of code has varied mightily over those 15 years. It's a big, bloated, barely maintainable mess, and leaks memory like a sieve that's been blasted with a shotgun.

      I learned C++ hacking on that code. I also learned to hate it.

      This large project, at least, can't enforce code discipline, nor would it do any good if it could. It would take a total rewrite.

      --
      Disinfect the GNU General Public Virus!
    13. Re:In defense of C++ by religionofpeas · · Score: 4, Insightful

      No language can compensate for having idiots in your team, but some languages, like C++, make it worse.

      And remember: if you see no idiots on your team, you are the idiot.

    14. Re:In defense of C++ by volodymyrbiryuk · · Score: 2, Insightful

      For in-house desktop apps of medium complexity (upto say 500k LOC), you can use C# or VB.net.

      Ok stop right there. No one should use any of the .net crap except if you are forced to due to some Microsoft constraints.

      --
      sudo rm -r -f --no-preserve-root /
    15. Re:In defense of C++ by squiggleslash · · Score: 3, Insightful

      No computer language is going to help a project programmed by idiots.

      That's just not true. Programming languages can enforce constraints that make common errors either difficult or impossible.

      I have to admit a disenchantment with software development in general these days, largely because the consensus within the community is that fast and cheap is better than reliable and secure. We pick programming languages like PHP and C++ where we know we're going to make errors we're never going to be able to debug, and often will be completely unaware of until they strike, because meh who cares I can write in {insecure language} and I like it so sucks to be users right? Besides I'm a genius and would never make those mistakes (yes you will, asshole.)

      I refuse to read another ESR article on principle, he's a jack-ass, and I seriously doubt Go is going to be taking over from C any time soon, but I generally agree with the sentiment that we made a mistake going away from Java, back to languages that are optimized towards making errors. Java is too bureaucratic, and C# is nearly as bad, and while it's overstated I do generally agree that there needs to be more control over GC for the average programmer, but there has to be a happy medium here - better than Java doesn't have to mean insane type checkers and/or going back to directly manipulating pointers.

      And yeah, I know C++ has smartpointers. But it also has regular old shit pointers. And sure, you would only use the latter in the right circumstances, but, let's be honest, all those other programmers you work with, who you are soooooo much smarter than, wouldn't...

      --
      You are not alone. This is not normal. None of this is normal.
    16. Re:In defense of C++ by gnupun · · Score: 2

      So, it's only useful in the most commonly used software products to date, that in some cases is responsible for running all of those fancy "webapps" that everyone likes so much, and is used practically everywhere regardless as to the purpose of the program / user actually using it / proficiency required, and it's some how a niche area that's irrelevant?!?!? What a response, I have no words....

      It's like an OS, something that is very important. Yet how many developers code OSes for a living or as a hobby? Extremely few. Let's see if Rust can unseat C++ from its throne since it is as fast as C++ with a lot of safety features. As efficient C++ is at runtime, it's badly designed for the programmer at development time.

      If your software needs to rely on GC, then you're doing it wrong

      Trying to figure out where any of the hundreds of dynamically allocated objects should be freed is something that should be automated, otherwise you end up with something like Firefox (a C++ app) -- a huge memory leaker that uses up GBs of RAM even if you have closed all the tabs.

      This is the issue I have with these languages. They assume the developer is an idiot, and hand hold them to the point that they forget the limits and boundaries of the machine that they are programming. Then they want to know why their code keeps crashing when they get a NULL pointer in a for loop, and demand that the compiler fix it for them. I'd argue that we need to get rid of these languages.

      Why use software programmers at all? Just do all your tasks in Verilog/VHDL hardware languages and manufacture ASIC chips using that code. Except nobody will do that, because it's expensive as hell (10000x or more costly). People are definitely going to use Python if it's 10x faster than C++ in development time for some simple task. C++ is now in a position that assembly used be many decades ago -- use it only if there is no other option. But unlike assembly, it's really badly designed.

    17. Re:In defense of C++ by serviscope_minor · · Score: 2

      I'm not sure where this "large projects can't enforce code discipline" idea comes from. What does he think "coding standards" are, which nearly every major company, organization, or project has? And if someone doesn't understand how to use a smart pointer instead of a raw pointer or avoiding class inheritance hell at this point, then really, they shouldn't be contributing to your C++ projects.

      I think basically he doesn't really like C++ a priori and is finding excuses.

      Plus he says this:

      . C is flawed, but it does have one immensely valuable property that C++ didn't keep -- if you can mentally model the hardware it's running on, you can easily see all the way down.

      to me that means he doesn't understand C++ even slightly and regards it as "C + weird magic". Whereas actually it's C + a bunch of automation. Excluding exceptions, you can translate any C++ program straightforwardly into C.

      Exceptions aren't complicated, but translating them into C is a bit more work, and it can't be done as efficiently as C++ exceptions. Going to asm is fine though.

      --
      SJW n. One who posts facts.
    18. Re:In defense of C++ by TheRaven64 · · Score: 2

      If you can compile a C++ program in less time than it takes to start Python, you either have a really slow Python interpreter or a really tiny C++ program! C++ is legendary for being slow to compile, and now that they have link-time code generation, even linking is slow!

      I'm talking about really tiny C++ programs: A few dozen to a couple of hundred lines of code.

      Part of the problem with C++ is that you have to compile a whole program. You can't compile libraries separately because even changing compiler options can make a lib no longer binary compatible. Is there any other language where you have to ship precompiled binaries but can't ship precompiled libraries?

      That's only true on Windows. Every other OS has a standard C++ ABI and C++ libraries interoperate happily between compilers. Windows defines COM and C as the standard ABIs for libraries, but doesn't define a standard C++ ABI.

      --
      I am TheRaven on Soylent News
  6. Well, don't do that! by TheRaven64 · · Score: 4, Interesting

    Arguing that it's harder for large-scale projects to manage a 'well, don't do that' approach implies that he's completely missed the last 40 years of tool development. This is much more of a problem for small C++ projects than large ones. Large ones have pre-push hooks that run static checkers that enforce rules like no bare pointer and no operator new / delete. It's the smaller ones that rely on programmer discipline to do this that are more likely to have problems.

    Go is a horrible language. It has multithreading as a core part of the language, but no memory model and no type system that can express notions of sharing or immutability. The designers clearly realised that generic types are important, and so added precisely one to the language (the map type, which is parameterised on the key/value types). It has a map type that maps from one object type to another, but no way for users to define what equality (or ordered comparison or hash) means on objects.

    --
    I am TheRaven on Soylent News
    1. Re:Well, don't do that! by TheRaven64 · · Score: 5, Informative

      Sorry, I should have been more explicit. Messages sent over channels establish a happens-before relationship, but not with respect to any other memory operations. Everything else is non-atomic. That's fine in a language like Erlang, which doesn't allow mutable shared state (in Erlang, the only mutable object is the process dictionary, which cannot be shared), or Pony (and, I think, Rust) where the type system guarantees that no object is both shared between threads and mutable at the same time. In Go, the language makes it easy to share pointers to mutable objects, but then doesn't provide any guarantees about ordering or synchronisation for accesses to them.

      Go tells people to 'share data by communicating', which basically means that you shouldn't share mutable data you should share channels that are used to serialise operations on mutable data. That's fine as a programming model, but the language provides absolutely no help (either in the type system or the tooling) to ensure that code actually follows this model. If ESR's complaint about C++ is that it requires programmers to follow 'well, don't do that' rules, then he should hate Go, because the only way of using it to write correct programs is to carefully avoid doing something that the language makes easy to do accidentally. At least with C++, it's relatively easy to audit code for violations of the C++ Core Guidelines. It's practically impossible to audit Go code for sharing of pointers to mutable state (in the general case, Go's subtyping model means that it reduces to the halting problem, in the common case it's just really, really hard).

      --
      I am TheRaven on Soylent News
    2. Re:Well, don't do that! by K.+S.+Kyosuke · · Score: 3, Interesting

      I thought the idea was that sharing a reference to mutable data over a channel guarantees that all writes to the shared data by one goroutine are safely in memory before the recipient starts working with said data. There seem to be some extra operations for locked or atomic operations with shared values but the language seems to be pushing people into operating on shared data using workers that use channels to hand off ownership. There may be limitations to that approach, and nobody is checking automatically that you don't do something that you shouldn't be doing, but at least the space of good and bad things to do seems vastly simpler than in case of C++. Certainly it seems that working properly with ownership hand-offs in Go in most situations is easier than, say, working with dynamic memory management in C in most situations, even if it still depends on people not doing something stupid intentionally.

      --
      Ezekiel 23:20
    3. Re:Well, don't do that! by roca · · Score: 4, Informative

      Mozilla has run a very large-scale C++ project for many years, with an elite team of developers. Mozilla makes extensive use of enormous test suites, static checkers, Valgrind, ASAN, TSAN, etc. Mozilla created Rust because we concluded C++ was not reliable enough or secure enough for large-scale multithreaded applications.

    4. Re:Well, don't do that! by TheRaven64 · · Score: 3

      Mozilla has run a very large-scale C++ project for many years, with an elite team of developers

      If you've ever looked at the Mozilla code base, then you'd be a lot more reluctant to describe their team of developers as 'elite'. The most positive thing I can say about it is that it's not as bad as OpenOffice.

      --
      I am TheRaven on Soylent News
    5. Re:Well, don't do that! by roca · · Score: 2

      I worked on it for years. Given the size and the age of the code, and the problem domain, it's not bad. As for "elite", well, almost any of Mozilla's C++ developers could get a job at Google/Facebook/Apple/Microsoft easily. Many have.

    6. Re:Well, don't do that! by Viol8 · · Score: 3

      "we concluded C++ was not reliable enough or secure enough for large-scale multithreaded applications."

      That should have been "we concluded multithreading was not reliable enough or secure for large scale applications".

      When your browser switched from multiprocess to multithreaded back in the day (presumably to make it easier to port to windows) its reliability went down the toilet. Now you're making a big deal about going back to multiprocess. Well whoop-de-doo.

      There is nothing wrong with C++ for large scale applications , in fact that was one of its design ideals.

    7. Re:Well, don't do that! by david_thornley · · Score: 2

      If you can't enforce simple rules like that, your project is in serious trouble, no matter what language it's written in. Every language has its infelicities, and if you can't keep programmers away from them by whatever means you're not writing good software.

      --
      "When you have eliminated the unacceptable, whatever is left, however improbable, must be the truthiness" - Holmes
  7. Re:He is right by SuperDre · · Score: 2, Insightful

    You mean to say, I don't know how to handle memory management and go does is all for me, without me knowing what it actually does, but it seems to work......... Oh please, Go is just Yet Another Programming Language which wasn't really necessary, but purely because some devs just didn't like other languages (or didn't know how to handle them properly).

  8. Vectorization by shatteredsilicon · · Score: 3, Interesting

    The big problem when it comes to using anything other than Fortran, C or C++ is that 20 years after the first MMX and SSE instruction sets have been added to CPUs, there are only a handful of compilers that known how to vectorize even loops that are hand-crafted to be vectorizable - and the ones that can do it are all commercially licenced (GCC might theoretically have some support for it, but in reality it doesn't vectorize most things). And since most of the performance advancement in silicon has for a long time now been focused in SIMD units, that means that for any performance sensitive workload there are no feasible alternatives. If it has taken GCC 20 years to get not very far, how long will be be before much younger compilers get anywhere with this performance critical feature?

    1. Re:Vectorization by Anonymous Coward · · Score: 2, Informative

      GCC can vectorize pretty well.

      You may have to give it some hints and be careful how you code your loops but it works. See this article. https://locklessinc.com/articles/vectorize/

      That was using GCC 4 some years ago. I have not checked but I'd wager it's even better now.

      Clang/LLVM also does a good job of vectorization.
       

    2. Re:Vectorization by shatteredsilicon · · Score: 4, Informative

      I tested this extensively, including quite recently, and unfortunately where intel's C compiler as far back as 2008 produced excellent results (all the loops in my code vectorized even back then), GCC to this day fails to vectorize most of them. last time I tried with clang (last year), it fared even worse than GCC.

    3. Re:Vectorization by TeknoHog · · Score: 4, Interesting

      Agreed, but I'd like to take a step back. IMHO, it is idiotic to first write a loop and then vectorize it -- we should have vector types to begin with. We've had them in Fortran for over 20 years, though not necessarily in all compilers as you point out (I remember using a nice SIMD-aware commercial compiler back in 2001). Today, you can use Julia as a modern replacement of Fortran with a free compiler, though you may need to give the @simd hint in some cases.

      I guess my physics background shows here. When we manipulate vectors in physics, we generally don't think of looping over all components sequentially; the components are a matter of representation, while the physical vector concept is independent of the coordinate system. Vectors also come with certain assumptions of independent operations per component.

      Your post is also a good reminder to the folks who laud C's ability to work at the low level; in my impression, C was designed to act like a very simple processor, so as real CPUs become more complex, the low-level idea gets ugly with backward constructs like loop vectorization. To effectively deal with SIMD etc. you need a higher-level perspective of vectors/matrices, as paradoxical as that may seem.

      Similar issues apply to multiprocessor systems, which have also been used in the scientific/HPC field for decades. So it's funny how it suddenly becomes completely new and hard to program for, when the same tech is sold to the general public in the form of multi"core" systems.

      --
      Escher was the first MC and Giger invented the HR department.
  9. Indeed. C++ is a better C by Anonymous Coward · · Score: 5, Interesting

    Take the low-level access provided by C, and then add the ability to construct both compile-time and run-time abstractions to an incredibly high level, but with as little cost as possible. That's C++.

    C++ is an amazing achievement.

    Every academic language approaches Lisp, but every practical language (you know, the ones that actually make the world turn) approaches C++; Bjarne said as much, and he was right.

    1. Re:Indeed. C++ is a better C by TheRaven64 · · Score: 4, Interesting

      C++ has improved a lot, but there's still one place where it lags behind something like Lisp: you have to decide between compile-time and run-time specialisation very early. Constexpr functions were a big step in the right direction here, letting you move between compile-time and run-time computation without shifting syntax, but there's still no equivalent for data. If you want to do compile-time specialisation, you use templates, if you want to do run-time specialisation then you use fields. If you picked one and now want to move to the other, then it's very difficult to refactor, and if you want either compile-time or run-time specialisation in the same object for different uses then it gets clunky very quickly.

      --
      I am TheRaven on Soylent News
    2. Re:Indeed. C++ is a better C by The+Evil+Atheist · · Score: 2

      That's exactly the reason why I prefer C++ over Lisp. I've tried learning Lisp many times. The thing that got me every time was when macros were run. Templates and constexpr doesn't have that problem, and they're also hygienic, by definition. You know precisely when they run, and you get a compile error when they can't. The only way I could get my head around List Processing patterns was through metaprogramming with variadic templates, and that was because, despite the scary error messages, you can actually figure out exactly where you went wrong.

      You can easily get a sense of what you know at compile time, and what you don't.

      --
      Those who do not learn from commit history are doomed to regress it.
    3. Re:Indeed. C++ is a better C by TheRaven64 · · Score: 2

      Okay, so how in C++ would you implement a variation on std::array that lets you select per use whether the size is a compile-time constant or a field that is set in the constructor?

      --
      I am TheRaven on Soylent News
    4. Re: Indeed. C++ is a better C by TheRaven64 · · Score: 2

      I'm not sure what point you're trying to make. It is very common to have an object where you want compile-time specialisation for some common (or hot-path) cases, but want a generic version for other cases, and want to share the implementations. Having an object that is both GC'd and non-GC'd at the same time seems like an odd requirement, though MSR had a paper at PLDI providing memory-safe manual memory management in the .NET context, where objects could be explicitly deallocated and would eventually be collected, so if you used a dangling to them you'd get an exception. Perhaps that what you want?

      --
      I am TheRaven on Soylent News
    5. Re:Indeed. C++ is a better C by jcr · · Score: 4, Interesting

      C++ is an amazing achievement.

      You really need to get out more.

      C++ is a steaming pile of needless complexity. I blame Stroustrup for his inability to say no whenever anyone came up with yet another feature to toss onto the dungheap.

      The best thing about C++ is that you don't have to use all of it.

      -jcr

      --
      The only title of honor that a tyrant can grant is "Enemy of the State."
    6. Re:Indeed. C++ is a better C by lucasnate1 · · Score: 3, Insightful

      C++, like C, like UNIX, is an amazing achievement with lots of mistakes. Hell, Windows NT managed to replace UNIX to some extent, but nothing really managed to replace C++ and C.

    7. Re:Indeed. C++ is a better C by Jamu · · Score: 2

      You can use a template with a type parameter that indicates if the size is compile-time or runtime. Eigen takes this approach with matrices.

      --
      Who ordered that?
    8. Re:Indeed. C++ is a better C by bzipitidoo · · Score: 2

      I've been complaining about a similar problem. Even with constexpr, it's still a pain to initialize complicated structures. What I end up doing is letting them be variables and computing their values first thing at runtime, though I wanted constants initialized during compile time. For instance, I might have the data all specified in YAML, then use a YAML library function to load all that into the program when it starts.

      Here's a simple JavaScript example of the sort of thing I mean. Suppose I want a list of the elements. Using just the first 8, I could have: const ELEMENTS=["-","H","He","Li","Be","B","C","N","O"]; or I could do this: const ELEMENTS="- H He Li Be B C N O".split(" "); I much prefer the 2nd way, for clarity of code, and I thought everyone would, but I've found not everyone was sold on that. The good part is that at least they're constants. The bad part is that it's initialized at runtime.

      Get more complicated, like, suppose I wanted an array of objects instead of strings, and each object is all the data about one element, the atomic weight, a list of isotopes and whether they are stable or what their half lives are, the full name, and so on, and it gets involved. Of course I'd want all that to be constant. If some of that data could be computed from other data at compile time, I'd prefer to do so, rather than do the calculations offline, so to speak, and plug the numbers in to the code. For instance, the atomic weight can be computed from the weights of the stable and long term radioactive isotopes and their percentages in nature, so why directly enter that value in the code and risk a mismatch from a typo? If the reason to take that chance is that the programming language pushed the coder into that compromise, then that's a deficiency in the language.

      --
      Intellectual Property is a monopolistic, selfish, and defective concept. It is "tyranny over the mind of man"
    9. Re:Indeed. C++ is a better C by DrXym · · Score: 4, Insightful
      Depends if you mean "replaced" in a binary sense because C and C++ have been utterly annihilated in a lot of problem domains, particularly middleware, business logic, web front ends, application development.

      All the domains where speed isn't the biggest deal and where reliability / uptime / portability / maintainability are more important. That's why languages like Java, .NET, Python, Ruby, JS have made headway.

      So where C/C++ tended to be all-encompassing, they're now relegated to performance critical areas where until recently there wasn't much choice. Kernels, embedded, systems services, games. Places where performance and/or memory footprint were critical.

      But even there choice is opening up. Rust in particular produces code, that is for all intents and purposes as fast as C/C++ but which tends to be safer, more portable and reliable. If you prefer to tradeoff some speed for programming niceties then you can go for Swift and Go too.

      If I were writing software from scratch these days I definitely consider other languages before C++. I might reject them for reasons but C++ and C would be the bottom of the pile.

    10. Re:Indeed. C++ is a better C by david_thornley · · Score: 3, Informative

      That's an awfully content-free posting to get (4, Interesting), given that it boils down to "I don't like C++ because it's complex". If you read Stroustrup's Design and Evolution book, you can actually find out why Stroustrup added what he did and rejected what he did.

      --
      "When you have eliminated the unacceptable, whatever is left, however improbable, must be the truthiness" - Holmes
    11. Re:Indeed. C++ is a better C by Pseudonym · · Score: 2

      It's usually considered a weakness of language design to disallow certain combinations of orthogonal features just because you can't see a use for those combinations.

      Imposing exceptions to rules makes a language spec more complicated, not less.

      --
      sub f{($f)=@_;print"$f(q{$f});";}f(q{sub f{($f)=@_;print"$f(q{$f});";}f});
    12. Re:Indeed. C++ is a better C by david_thornley · · Score: 2

      Ah, so you'd prefer to keep ignorance for convenience in scoffing. Okay.

      --
      "When you have eliminated the unacceptable, whatever is left, however improbable, must be the truthiness" - Holmes
  10. Re:Provided you have infinite hardware resources.. by JaredOfEuropa · · Score: 4, Insightful

    Anything that allows us to reduce errors, increase functional complexity, reduce development time, improve readability and maintainability, and/or make it easier to code for a greater amount of people, is progress in my book. Working at a higher abstraction level achieves some or all of those goals.

    And good frameworks help with that. When I build a house, I don't want a craftsman who takes time to learn how to use an adze so he can plane down lumber to the correct size for the job; I want a builder who knows he can get lumber of the correct dimensions right at the store. The skills to build instead of buy are useful in many trades (both building and programming), but they are expensive and a possible source of additional errors. Frameworks are often a good answer to that... as long as the developer understands the nature of the framework, its limitations, the licensing model, its viability, and thus can assess the consequences of using it.

    --
    If construction was anything like programming, an incorrectly fitted lock would bring down the entire building...
  11. Hasn't Ada fixed all of this decades ago? by butzwonker · · Score: 4, Interesting

    What I find kind of annoying is that Ada fixed all these flaws decades ago with Ada 95, now it is at Ada 2012 and still gets no love, just because it's a bit more verbose than C if you use it correctly. (Though not necessarily more verbose than C++.) Sure it has some flaws, e.g. concerning aliases and their scoping rules, but these are mostly inconveniences and some of them have been fixed in Ada 2012. But it doesn't stop there, the same story can be said about dynamic languages. Take fancy new dynamic language X and you can be fairly certain that CommonLisp solved all the problems of the new language already in the 80s.

    Maybe developers are in the end less rational than they think? It seems to me that a language must have serious flaws, lots of incoherent shortcuts and tricks, or at least a cryptic syntax to become really successful.

    1. Re:Hasn't Ada fixed all of this decades ago? by mandolin · · Score: 2

      I used Ada circa 1997 for a DoD project.

      Ada felt like industrial-strength Pascal. It was generally cool -- why *wouldn't* I want the compiler to range-check array index operations by default, at least for non-critical code paths? This could help me today, on *real problems*. Why *wouldn't* I want an enforced, specified order of initialization for global/static objects? I also strongly preferred the generics and exception syntax over their C++ equivalents. Ada's OS-agnostic task support was ahead of its time (hard for the language to support threads when the underlying OS doesn't).

      Going back to C afterwards felt like returning to something ... primitive. But, I develop in C++ today.

      Ada had historical issues and feature lags, some of which still plague it today, such as:
      -- historically, no free compiler (today, there is FSF GNAT)

      -- the object.method() - style syntax didn't show up until 2005; standardized bitwise operations didn't show up until 1995

      -- small standard library, which in general has lagged behind even what C++ supports. Containers didn't appear until 2005. Also, AFAIK Ada still has no equivalent of say, C++'s Boost or Rust's crates.io (though there are at least some Ada projects and libraries on Github). Want to call epoll() directly on Linux? In C++ you can use it directly; in Rust you can find a wrapper, in Ada you need to roll your own (to be fair, Ada's C interface support is excellent). Want standardized smart pointers? Maybe in Ada2020. If you want to make Ada more popular, I think this general problem of "I have to write my own version of xyz" is the single most important thing you could tackle.

      -- Some things are just relatively awkward to express in Ada, even beyond the normal verbosity of the language (some of which there are good reasons for). Here for example is a comparative look at closures. As another example, C++'s operator overloading is ripe for abuse, but it also enables a nice abstraction of, say, bignums or half-precision floats. AFAIK Ada has nothing like that. To be fair, you can make this criticism about any language for a given feature that might be important to your problem domain.

  12. Perhaps such explicit separation is better. by Anonymous Coward · · Score: 3, Insightful

    Usually, when you try to merge the 2 ideas, you end up with something as stupidly inefficient as run-time introspection.

    So, because the guiding principle of C++ is "zero-overhead abstraction", perhaps it is the case that you must explicitly choose where the computation will occur—run-time or compile-time.

  13. If you don't know where to start... by Anonymous Coward · · Score: 2, Interesting

    ... then how are you not clueless?

      Right now ESR is way ahead of you by having some actual thoughts to share, no matter how wrong they may turn out to be. You're nowhere near that. So you go on, pick any thing, start there.
      Here, let me help you: Me, I think that ideology makes for poor abstracting in programs, so rust is out. Incidentally that "community" is full of people who are so full of it they "can't even". (Which is one reason why ESR would be wrong picking rust as a successor to C: rust people "can't even", C people very much just do.) Now you pick anything else, maybe the next thing you can think of right off the bat, and enlighten us with your insights.

  14. ESR is incompetent by loufoque · · Score: 3, Interesting

    I remember I interacted with him back when he started the irker project.

    That pretty trivial piece of software, written in Python, was riddled with bugs, and no amount of bug reporting and discussing with him the design mistakes got anything fixed for a whole week, despite him actively trying.
    I rewrote the whole thing in C++ in two days and it always worked robustly from the get go.

    1. Re: ESR is incompetent by Reverend+Green · · Score: 2

      Link to your version, broham?

    2. Re: ESR is incompetent by loufoque · · Score: 2

      google rekri.
      haven't used it in a while though.

  15. Re:Provided you have infinite hardware resources.. by Opportunist · · Score: 3, Insightful

    Personally, I think way more problems arise of terse syntax and high symbolic abstraction that C/C++ and derived languages like so much. I mean, I'm as lazy as the next programmer and that's why I like C (and its derived languages) but even I cannot ignore that
    { (a!=1)?b=!b:b=0}

    is way less readable than

    begin
    if a is not equal 1 then set b equal complement of b else set b equal 0
    end

    You'd immediately spot an error in the second because the sentence would look "wrong".

    --
    We used to have a Bill of Rights. Now, with the rights gone, all we have left is the bill.
  16. Re:He is right by Dutch+Gun · · Score: 2

    C++ is just a mess. There are no real memory management tools

    Yeah, except for smart pointers + RAII and the ability to override global, per-class, or even per-object allocators and add whatever sort of memory tooling you can dream up. Other than that, no memory management tools.

    --
    Irony: Agile development has too much intertia to be abandoned now.
  17. Re:Ok, you want a garbage collector by K.+S.+Kyosuke · · Score: 3, Funny

    If GC is the reason for 6 GB smartphones, why does booting your non-GC'd Windows desktop take more memory than booting a GC'd Lisp Machine OS?

    --
    Ezekiel 23:20
  18. Re:Provided you have infinite hardware resources.. by TheRaven64 · · Score: 4, Insightful

    It's not always so clear cut. What you say is definitely true for naive compilers, but higher-level abstraction also often mean more information for the compiler and more freedom for the compiler. These can translate to better optimisations. To give a trivial example, languages like Java provide an abstraction that looks like a C struct, but don't require that the memory layout be visible to the programmer. Imagine that you create a struct-like Java object with RGB values to represent a colour and you do the same in C. Now you put them in an array and try to do some processing on them. The C version is constrained to lay out the objects as three fields with no padding (this is visible in the language with sizeof and will break ABIs if it dynamically changes). The Java version, in contrast, is allowed to put an unused padding field at the end of the struct. Why does that matter? If you want to vectorise the loop, then being able to guarantee 4-element alignment for every object in the array is a huge win. This is a legal transform for a Java compiler, but not a legal transform for a C compiler unless it can prove that no pointers to the array escape (and a few other constraints).

    The big advantage of C was that a fairly simple compiler for a simple architecture could get very good performance. The disadvantage for C is that compilers quickly hit diminishing returns and the abstract machine makes a number of desirable optimisations unsound.

    For example, if your language has a first-class notion of immutability, then this gives the compiler the opportunity to elide copies or add copies if they make sense for NUMA systems, and gives the compiler a lot more freedom with regard to reordering or eliding loads. Similarly, if your source language has higher-level notions of sharing then this means that you can avoid a lot of defensive memory barriers that you'd need for correct C/C++ code. If your language has stricter guarantees on aliasing, then a whole lot of optimisations suddenly become easier.

    Any compiler optimisation is a mixture of two things: an analysis and a transformation. The analysis must be able to tell you if the preconditions for the transform are met. The more information you can give to the compiler, the more often the analysis can prove that the preconditions hold and enable the transform.

    --
    I am TheRaven on Soylent News
  19. Construction metaphore by DrYak · · Score: 4, Interesting

    And good frameworks help with that. When I build a house, I don't want a craftsman who takes time to learn how to use an adze so he can plane down lumber to the correct size for the job; I want a builder who knows he can get lumber of the correct dimensions right at the store.

    On the other hand, when all you want to build is a garden shed, you can do it yourself in a quick week-end afternoon project by quickly nailing a few planks together. You definitely don't want a several month-long adventure involving half a dozen sub-contractors (and each further down, their own individual group of a dozen of sub-contractors), plus hiring a few special planification manager (because sub-contracors D and Y each out-source their screw to a different sub-sub-contractor. Incompatiubles) which will all require two hectars of work space around your shed. And somehow the garden shed need to be connected to an industrial triphase 380V power connector in order to be able to function.

    Some time, over reliance on frameworks and helpers means that some very simple projects that would be handled by a few dozens of C or C++ lines of code (perhaps a couple of hundreds top), suddenly need to pull more than 20 MiBs of libraries in the package and are dependent on 200 different github repositories (hoping that they'll not blocked on the dev's whim - see Node.js and string alignement). And you need to use special command line settings to tell the VM to allocate 2 GiB of memory for the process.

    --
    "Sufficiently advanced satire is indistinguishable from reality." - [Tips: 1DrYakQDKCQ6y52z6QbnkxHXAocMZJE61o ]
    1. Re:Construction metaphore by JaredOfEuropa · · Score: 2

      Quite. Which is why the inclusion of a framework should be a matter of design not coding. This decision should be left to a software architect rather than a developer.

      --
      If construction was anything like programming, an incorrectly fitted lock would bring down the entire building...
  20. Re:Provided you have infinite hardware resources.. by Dutch+Gun · · Score: 4, Insightful

    The higher the level of abstraction in your language, the higher the overhead it will create.

    This is exactly why C++ remains popular among those who create large, complex, high-performance applications. C++ is well known for using zero-cost abstractions. That means you get the performance of low-level C code, but can design much safer interfaces and type safety in your code which allow the compiler, not a runtime, to validate that the code is correct and safe.

    For certain types of applications, it's an effective compromise between the pragmatism of retaining backwards compatibility with decades-old ecosystems, while at the same time providing better safety and abstractions than C.

    --
    Irony: Agile development has too much intertia to be abandoned now.
  21. Re:you know you've arrived.. by amalcolm · · Score: 2

    Equivalent series resistance and root mean square, obviously

    --
    Time for bed, said Zebedee - boing
  22. Re:Provided you have infinite hardware resources.. by Opportunist · · Score: 2

    If you want to say that it explodes violently in your face from time to time, it has an attitude that few can stomach, is way overengineered for its supposed purposed and manages to go around in circles of trying to fight itself and stand in its own way instead of getting to the point and be done with it, yes.

    --
    We used to have a Bill of Rights. Now, with the rights gone, all we have left is the bill.
  23. Re:He is right by TheRaven64 · · Score: 2

    Java doesn't guarantee anything with regards to timeliness of object destruction. A small object that just encapsulates a file descriptor may never be collected (until program exit - I think Java requires all objects are collected on program exit), and so its finaliser may never run and free the file handle while the program is executing. The same applies to closures - they're just objects and are not guaranteed to be deallocated.

    --
    I am TheRaven on Soylent News
  24. Re:Provided you have infinite hardware resources.. by religionofpeas · · Score: 4, Insightful

    With some extra spaces, and the whole thing changed to an expression (which is how ?: is supposed to be used) it's a lot easier to read.

    b = (a != 1) ? !b : 0

    The advantage of the ternary operator is that you only need the LHS part once, which helps if it's a more complex variable.

  25. Re: Provided you have infinite hardware resources. by Zero__Kelvin · · Score: 3, Informative

    Pimpl is solvable by creating an implementation class and and interface class that has a reference to that class, and if you are crying about memory safety starting with C++ 11 there are smart pointers.

    --
    Guns don't kill people; Physics kills people! - John Lithgow as Dick Solomon on Third Rock From The Sun
  26. Drivers/Firmware by zifn4b · · Score: 5, Insightful

    How do I write drivers and firmware in Go? I think C is going to be around for awhile.

    --
    We'll make great pets
    1. Re:Drivers/Firmware by zifn4b · · Score: 2

      He addressed that point. As you'd know if you'd read the fucking summary, let alone his article.

      No he didn't. This is bullshit:

      Eventually we will have garbage collection techniques with low enough latency overhead to be usable in kernels and low-level firmware, and those will ship in language implementations

      This claim was made at least 15 years ago when .NET arrived on the scene. It was bullshit then and it's bullshit now. He doesn't know anything. You can't interact with physical hardware in a language that compiles just-in-time. At least not while using CPU architecture agnostic code. There are ways to interop with physical hardware but if you're doing that you might as well write the code in C to remove the layers of marshaling abstraction that will impact performance. You know the huge performance gains that Vulkan and DX12 made recently? That was done removing superfluous API layers. This person is suggesting we ought not only introduce that but more further slowing down game frame rates. You need to interact with it on the machine level at some point. You need to know how to push a value in a register on the CPU across the system bus to a register on a circuit board. In order to do that, you need to know the architecture of both pieces of hardware. You need to know little endian vs. big-endian. There is no way to do this programming without being all the way down to the metal. Anyone making a claim to the contrary has never actually done any driver programming and I wouldn't recommend that they start.

      --
      We'll make great pets
  27. Re:I left C and C++ for a reason by zifn4b · · Score: 2

    a) C and C++ are not and never have been worth a damn as a standard. Even in the absolutely best C and C++ code, there are so many platform abstractions and #ifdefs that it's a nightmare. Neither C or C++ are useful as a platform.

    This is probably the most useful of your points which can be summarized as it's very hard to write something in C or C++ that is cross-platform even a standard. Doing so requires use of macros that can get quite complex at times (#ifdef __LINUX ). It also gets more complicated with Makefiles and makedepend. There are two problems:

    1) The libraries available on the specific platform
    2) C and C++ are compile time languages meaning that a C/C++ compiler compiles down into the native processor's instruction set whereas languages such as C# or Java compile down into platform agnostic byte code and then when run on another machine are dynamically compiled into that machine's native instruction set using the JVM (java) or the CLR (C#). Everything is a trade-off.

    --
    We'll make great pets
  28. Re:20% slower!???? Are you INSANE!!!!!!111???1111! by MightyYar · · Score: 2

    I'd like that stolen battery life back please

    OK, just pay more for the extra development time, or use a version with fewer features. Every decision has trade-offs.

    --
    W..w..W - Willy Waterloo washes Warren Wiggins who is washing Waldo Woo.
  29. Re:Provided you have infinite hardware resources.. by CptLoRes · · Score: 3, Interesting

    But what happens when everybody buys lumber at the store? There still must be somebody that make sure the lumber is the right size and quality for your project. This problem is exactly why we today need giga range cpu's and ram just to watch a web page. Nobody knows how to deal with the details any longer, and so they end up building a new house every time there is a new problem.

  30. Keywords by hcs_$reboot · · Score: 2

    A language that has keywords like `static_cast` or `thread_local` has reasons to be hated.

    --
    Slashdot, fix the reply notifications... You won't get away with it...
  31. Re:Provided you have infinite hardware resources.. by swillden · · Score: 3, Insightful

    If your point was to make that part more readable, I think I want you on the other team in the next debate.

    If you find that unreadable, I don't want you on my team in the next software project.

    Well, I do have to say that the code would not pass my code review. Not because of the use of the ternary operator, because of the meaningless variable names. I'd also ask that "0" be replaced with "false".

    --
    Note to ACs: I usually delete AC replies without reading them. If you want to talk to me, log in.
  32. Re:Provided you have infinite hardware resources.. by torstenvl · · Score: 2

    I think you meant: b = (a==1) ? 0 : ~b

  33. Re: Provided you have infinite hardware resources. by red_dragon · · Score: 2

    C does not have a boolean type. Instead it tests for truthiness by checking whether the value is zero (false) or non-zero (true). That bit of code might not make sense, but it will compile.

    --
    In Soviet Russia, Jesus asks: "What Would You Do?"
  34. Re:Provided you have infinite hardware resources.. by Ambassador+Kosh · · Score: 4, Interesting

    For HPC (high performance computing) I don't see C++ going anywhere. For HPC the only viable languages I see are C, C++ and Fortran since they have the best optimizing compilers.

    Mostly I use python for command and control with a simulator written in C++ and this seems to be a pretty common setup for HPC applications.Command and control often has a lot of code but is 1% of the compute time so write it in a high level language and then do the simulator is something that is FAST.

    --
    Computer modeling for biotech drug manufacturing is HARD! :)
  35. Re:Provided you have infinite hardware resources.. by coofercat · · Score: 3, Interesting

    A colleague and I were joking around one day, when a hardcore-dev (with a lot less humour, and chronic flatulence, as I remember) overheard us. He maintained that super-terse code is easier to read than the alternative. Since we were just messing about, we both just let him say his peace and then stated that the One True Language was of course Turbo Pascal 6 (which sort of ended the conversation).

    My take on it is that the terse syntax does make sense (more quickly) to someone who knows the syntax really well. If you don't know it quite as well, then the long-form is better because as OP says "the sentence would look wrong". Also, actual words are 'googleable' where as it's hard to lookup the meaning of "~->" or whatever. Thus, the long-form plays to more average programmers.

    The question then becomes... who should a language be for? For the super-expert, or for the midrange programmer, or possibly even the junior? IMHO, midrange is a good place to aim at because that's where the majority are, and if they're using your language then you'd want them to be able to do so reasonably easily and safely. That way, of all the billions of opcodes executed around the world as a result of your language, the majority of them will be reasonably safe and sensible.

  36. Re:Provided you have infinite hardware resources.. by TheRaven64 · · Score: 3, Informative
    Okay, three of you have jumped on that, so let me be more explicit:

    A C compiler may add padding, but its ability to do so is constrained (or mandated) by the platform ABI. The layout of a struct is exposed directly in the language because you can ask for sizeof() the struct (which, if you subtract the size of all of the fields will tell you the total padding) and you cast a pointer to a field and a pointer to the struct to char*, subtract one from the other, and get the offset of each field. This means that it is effectively impossible for a C compiler to add padding to make optimisations easier (the only case in which they will reliably do it is for on-stack structs that are not address-taken).

    --
    I am TheRaven on Soylent News
  37. Why he's got it wrong at step 1 by Dr.+Crash · · Score: 2

    ESR is making an early invalid assumption - that "fast transparent garbage collection will happen".

    Sorry, no. The smartest people in the CS world - possibly the
    smartest in the world, period (specifically those at MIT AI Lab,
    Xerox PARC, BBN, TJ Watson, and Stanford) worked the GC problem
    for literally 20 years, throwing hardware at it, software, tagged
    architectures, secondary processors, all that.

    They never cracked it. GCing at realtime speed is just a tough problem.
    Unless ESR can show me code that can GC in faster than O(n) time
    AND not have to freeze the allocator process for O(n) time, he's just
    pitiably wrong.

    (and no, I don't count flip and sweep GC as workable in this, as it
    means that a buffer that DMA hardware is writing to will move without
    warning. Nor is "generational" GCing, all that does is to stave off the
    inevitable full-out GC for a few minutes to hours, which is fine for a
    hacker sitting at a terminal but no good at all for a self-driving car or
    SaaS server).

    Now, I could be wrong; if he *has* a realtime garbage collection algorithm
    then he deserves the Turing award.

    But I'm betting "not".

    1. Re:Why he's got it wrong at step 1 by angel'o'sphere · · Score: 2

      You have no clue about GCs, nor has ESR ... so you arguing with it about it is moot.

      Hint: I can probably describe 5 real time garbage collection algorithms/variations from my mind, and implement one in about 3 days. Hm, perhaps one day ... but my C++ is rusty.

      Another hint: real time most likely does not mean what you think it means.

      --
      Cost free eBook I read (by iBook/Kobo/Amazon/ObookO/Gutenberg etc.): "The Green Odyssey" by Philip Jose Farmer.
  38. Re:Provided you have infinite hardware resources.. by robkeeney · · Score: 4, Insightful

    People who do electrical engineering learn to read and understand the funky symbols they use in electricity. We don't expect them to write out everything in plain English. It's the same with programming. Your Pascal-y pseudo-code took how much more space and time to convey no extra information? Your pseudo-code actually took longer for me to parse and understand than the C version.

  39. Re:Provided you have infinite hardware resources.. by networkBoy · · Score: 2

    depends if b is expected to only be 1/0 at the end of this function even if it *may* be some other true value (why this would be the case I do not know), also !b is going to be faster than ~b in many cases. But! write it as it makes sense and profile to see if that speed is an issue or not.

    Given the a b operators (yeah I know this is an example, but I'm running with it) this is likely an inline function that will be called very heavily in a nested loop or somesuch... as a result the speed of operators can have a very noticeable impact.

    True story:
    Had a co-worker that did something very similar to this, but b was a UINT64 and he used it to store a bool. used ~ operator to toggle it.
    When he needed to make it look like he was busy and improved performance he switched it to a UINT32, then UINT16, then UCHAR, then to use the ! operator instead of the ~ operator.
    I didn't rat him out because our manager was a dolt and my co worker was actually working on a hard problem, but manager was one of those "didn't see an improvement, so you were wasting time" people.

    --
    whois gawk date unzip strip find touch finger mount join nice man top fsck grep eject more yes exit umount sleep dump
  40. The wrong problem; use the right tool for the job by redmasq · · Score: 2

    While I certainly not found of C++ myself, I can certainly code in it. As it stands, most of the problems that I have to solve on a regular basis does not involve usage of that language directly. That said, I still think there is use for it, even beyond legacy compatibility. I typically work on user-land applications, data ETL jobs, and web services. For those, Java, C#, SQL, and the occasional bit of Python each are well suited for the job. There is less cognitive overhead to simply code for solving the problem, and then tweaking for minimizing performance issues and garbage-collector/resource leaks.

    I have, on occasion, needed to interface with low-level hardware. In a Windows environment, C++ typically proves to be an excellent tool for the purpose. For the same purpose in Linux and DOS, I typically use "old fashioned" C if not using any APIs/libraries that would make C++ the better choice. I do not mind mind managing my heap in those cases and for C++ I can make use of RAII (stack).

    This is not to say the Rust and Go (which I have not got around to trying) are bad choices for a project; however, I would not simply assume they are a silver bullet for a problem. I will also mention that sometimes a sub-optimal tool can be used for the job in a pinch. In the physical sense, I would normally use a hammer for a nail and a screwdriver for a screw-- I have used a hammer to beat in a screw and I have used the back of a screwdriver to insert a nail (and lamented the entire process).

    Now, concerning ESR's position, I certainly see his reasons. Since my thoughts are difficult to articulate, I shall make a comparison to my browser: Firefox. I first started using it (under the name of Phoenix) because it was not Internet Explorer, but lighter weight than the then bloated Mozilla-branded browser. It had problems and it was lacking features, but it did provide enough customization that I was comfortable using it. Since then, missing features were added, security holes were patched, features that I had liked were removed since they were either troublesome or not popular, and it has gained bloat (likely to fulfilling features) similar to its predecessor. Other browsers are starting to look "shinier" to me. C++ is a language, but it, like application, will evolve to the niche of the target audience. Individual users, whether speaking of applications such as browsers or languages, will each have different needs and different limitations they are willing to tolerate. I prefer to focus on solving the problem, but I do not mind taking on the extra responsibilities if it brings me benefit. I have had talented co-workers that are absolutely allergic to idea of managing their own memory, but loves to "create clean elegant solutions." I have also had other talented co-workers that absolutely refuses to trust language/library provided mechanisms such as garbage collection, but they have the attention to detail and the background of knowledge to rapidly create lean and correct solutions to problems where they do have that level of control.

    For the TL;DR, have a reasonable set of ability to use for the time and effort you are willing and able to invest in the niche that you can or want to fill. Find the right balance of flexibility and proficiency that matches the limited resources to invest and the opportunities available. Also, remember that ESR is a quasi-public figure with strong, sometimes bitter opinions: earnestly consider them, but take them with a grain of salt. I will also note that concerning his mention of the futility of trying to predict the future (the next big language), it is like predicting the stock market in that some things will stick around forever, but have only modest returns; however, a penny stock have the possibility of a minimal investment with a big return, but also carries a high risk of just being a useless waste of resources.

  41. Re:I left C and C++ for a reason by angel'o'sphere · · Score: 2

    c) C and C++ are more versatile than any other languages because you can program at a register level if you choose to.
    Just try it, then look at the assembly code ... "register" most likely got ignored.

    --
    Cost free eBook I read (by iBook/Kobo/Amazon/ObookO/Gutenberg etc.): "The Green Odyssey" by Philip Jose Farmer.
  42. Ramblings. by AnotherBlackHat · · Score: 2

    The thing I note about better programming languages is that they mostly aren't better.

    I've occasionally thought "This would be much easier to write in Perl than C."
    I've never thought "This would be much easier to write in C++ than C".

    Fewer lines of code doesn't mean much.
    Thousands of line of assembler, is roughly as hard to write as hundreds of C.
    A six line function can often replace a 500 line table.
    Copy and paste code instead of using subroutine calls, and you too can be writing 500 lines of code a day.

    It isn't significantly harder to write in assembly, that is not why we avoid writing assembly code.

    IMO the successor to C won't be a higher level language at all.
    It will be a language that gives as low, or even lower level access, but is more portable.
    Something that let's me specify endian-ness, or bit rotation, or do atomic operations without the need to invoke a semaphore/system call.

  43. Re:Write a build-time program by bzipitidoo · · Score: 2

    Can do that, yes, and I've thought of going that route. But why not have a programming language that's expressive enough so that you don't have to resort to code generation, if it's not hard to do? And it's not hard. Many already do it in limited ways. In C/C++, macros and templates come to mind as means of generating code. Why not do more? Are they afraid of the compiler having to make multiple passes over the source code?

    --
    Intellectual Property is a monopolistic, selfish, and defective concept. It is "tyranny over the mind of man"
  44. Go is a sign that the old beliefs are breaking by snadrus · · Score: 3, Interesting

    GC was hacked-on for decades to no avail (in bringing it low-level).But now here it works well (very fast, concurrent).
    What changed? The language spec was made very simple.

    Compiling was a very tricky, slow business. Now here it's fast and relatively simple.
    What changed? A simpler language. Smart people who know which options to take away.

    Only painfully low-level languages could work with raw memory pointers. Now we have that in 2 friendly, "default-safe" languages.
    What changed? Realization a lot of power comes from low-level operations.

    So C & it's layered C++ will break as safer variants with the same power begin to exist.

    High level languages depended on dozens of C libraries and libc. Go needs none of those.
    What changed? A realization this is important.

    A fork of Go now runs without a kernel on bare-metal ARM. That's the right space to grow into a kernel-module-capable language. Languages aren't fast or slow, their implementations are. Go's ease of portage suggests it could show up in the kernel.

    --
    Science & open-source build trust from peer review. Learn systems you can trust.
  45. Re:Provided you have infinite hardware resources.. by TheRaven64 · · Score: 2

    Basically everything regarding padding - and even ordering of fields - is implementation dependent and not specified in any standard.

    There are two relevant standards: the C language standard and the platform ABI standard. C compilers must comply with both for anything that is intended to interoperate. The platform ABI standard places much stricter requirements on structure layout than the language standard. This is important because the following is allowed in C (from your example):

    In one compilation unit subtract a pointer to start of the struct from a pointer to the the l1 field and pass it to a function in another compilation unit.

    In another compilation unit, construct a new instance of the same struct, cast the pointer to a char*, add the offset, and then cast it to a pointer to long, and assign to it.

    The result of this must be a version of the struct with the l1 field assigned. This is a guarantee of the C language, and the platform ABI standard provides the rules that allow it to work between different compilation units from different compilers (e.g. in different libraries).

    Oh, and the C standard actually does place some constraints that prevent the reordering that you describe. If you look at paragraph 6 of section 6.5.2.3, you'll see that, if a two structs start with the same fields then it is permitted to access the fields in either from a union. By induction, this means that struct fields must be ordered from the start, because anywhere else in the program (including other compilation units into which the compiler has no visibility) I can have structs that contained all of the prefixes of your struct (short, short long, short long short) and can declare a union of them and your struct and access the fields through them (and 6.7.2.1 paragraph 15 prevents there from being any padding at the start, so s1 must be at offset 0).

    --
    I am TheRaven on Soylent News
  46. Packaging, modularity, build tools by dremon · · Score: 2

    Why nobody mentions such valid and important points as packaging, modularity/reuse and build tooling?

    Both C and C++ suck in this regard. Integrating 3rd-party project is usually an exercise in self-control and calm-keeping.

    Autotools, CMake, Make, VS Studio, Ninja, Meson, Scons, whatever shit, a new Grand Shiny Build Tool is coming every year as The Only Solution.

    No versioning. Everything is manual - binary dependencies, source dependencies, all has to be done manually for every project, with fuckload of weird compiler switches and preprocessor directives.

    Most of the modern languages have acceptable solutions for that (I love Rust and crates.io in particular) - not perfect perhaps but working, except for stupid C/C++ legacy shit, and the fucking committee just keeps adding template madness instead of sanitizing it. The C++ compile times are getting bigger with each revision because another fuckton of header files are added.

  47. Garbage Collection by Agripa · · Score: 2

    Eventually we will have garbage collection techniques with low enough latency overhead to be usable in kernels and low-level firmware, and those will ship in language implementations.

    How long have they been working on low latency garbage collection? If they have not developed it after decades of basically static hardware, then it will never exist. Garbage collection will always have lower performance than the alternatives so it is not suitable for low level code.

    I agree with ESR that C and C++ are flawed but no modern language has solved those flaws either so I do not care.