Live data from Hacker News

Hacker Poll: Is C++ the Language of the Future?

readwriteweb.com

61–69 of 69 posts

Re: Hacker Poll: Is C++ the Language of the Future?

#61
post #46
post #18

Have you tried to staff a C++ project? If you don't have the ability to easily fire people, it's a horrible pain. There are tons of people who think they know C++. There are a smaller subset that do. If you get people who A> Refuse to follow the subset of the language your group is using on the project or B> deeply misunderstand one or two features, you're in total utter hell if you can't fire the person. Most places…

The "C++ is only usable in a subset" meme must die.

That's not a meme, that's life.

Re: Hacker Poll: Is C++ the Language of the Future?

#63
post #60

Earlier quoted context omitted.

It seems you missed his qualifier: "for building complicated software that is robust, easy to use, easy to maintain, fast and scalable" Complicated + robust + easy to maintain is plain impossible in C++. Also, add-ons fit "enhance software" better than "building software".

Complicated + robust + easy to maintain is plain impossible in C++. I don't think so. Also, add-ons fit "enhance software" better than "building software". Your "building software" could also be labeled as enhancing the operating system.

There are times when it is appropriate to select C/C++ for the job, that is when enhancing a project written in C++.

Re: Hacker Poll: Is C++ the Language of the Future?

#64
post #22

Big C++ fan here. I came to C++ after learning Python. I simply love it and the Boost libraries only make it better. If I could only have one programming language, it would definitely be C++. I can do anything with it on any operating system. No vendor or IDE or build environment lock in. It's a solid ISO standard with multiple compiler support. I still use bash, Python and Ruby for quick test scripts and prototyping…

It's not a solid ISO standard. One of my coworkers recently gave me a c++ library to use. I linked to it and started making calls and found out that the STL from his compiler ( VS 2003) was incompatible with the STL from my compiler (VS 2010). They were simple things, like function calls that had their types changed, but nonetheless it rendered his library useless to me.

Compare to C, where everything is heavily standardized and you can use libraries from different compilers without much difficulty.

Re: Hacker Poll: Is C++ the Language of the Future?

#66
post #16

I think Yes, C++ is the language of the future. It has several strong points, which are still relevant. Namely: 1. cross platform 2. the programmer can choose from several levels of abstractions, as appropriate for a particular project: low-level c-style coding, OOP, templates, meta-programming. 3. even the very high level abstraction usually doesn't induce performance penalty. 4. not using some property of the langu…

I have to challenge some of your points: 2. Just use 2 languages, like C + Lua. or C + anything-higher-level-than-Java. As a "language", such a combination is easily simpler than C++, and the high level part is way cleaner. My point is, don't use one complex tool when 2 simpler one can do. On a side note, you should think about what OOP, templates, and "meta-programming" are good for. Most of the time, naked lambdas…

What do you mean when you say RAII is copy-ridden?

Re: Hacker Poll: Is C++ the Language of the Future?

#67
How about we just end this speculation over what is the next big language, and just check back in 5 or 10 years and see what is actually popular and useful.

There's so much that can change in one year let alone five or ten, therefore it isn't easy to make predictions that far out.

For the record I use C++ in a day job, and there's an awful lot of code written in it, so it will exist in some form or other for a very long time to come. Need I mention COBOL? There's also enough stuff written in Java, C#, Visual Basic, JavaScript, Ruby, and Python for them to easily last into the next decade.

Re: Hacker Poll: Is C++ the Language of the Future?

#68
post #60

Earlier quoted context omitted.

It seems you missed his qualifier: "for building complicated software that is robust, easy to use, easy to maintain, fast and scalable" Complicated + robust + easy to maintain is plain impossible in C++. Also, add-ons fit "enhance software" better than "building software".

Complicated + robust + easy to maintain is plain impossible in C++. I don't think so. Also, add-ons fit "enhance software" better than "building software". Your "building software" could also be labeled as enhancing the operating system.

(1) Okay, let's speculate about the actual requirements for robust, easy to maintain software. Robust means it won't fail easily. A robust program handles edge cases correctly, and have few errors. An easy to maintain program is one that is easy to correct or modify. To achieve this, you must make it so that most modifications require the inspection of relatively few code. It means the code base must be either small or very well de-coupled.

Now let's add "complicated". To me, it means the problem cannot be solved by a small program. Therefore, the program will be rather big. To achieve robustness and ease of maintenance, you have to make it locally readable and modular.

Now, add "in C++". C++ is extremely permissive. You can tweak almost anything. It can be awesome, but there is a flip side: memory must be handled manually (more code), and you can make fewer assumptions about your program (less modular code). For an originally complicated problem, this is a significant burden.

Now, a very disciplined team could overcome this burden. Just mind a few things: Const correctness everywhere, and avoid side effects where you can (this is both extremely important[1] and not easy in C++[2]). Ban or restrict the use of the more problematic features (I would mostly scrap inheritance, except when emulating Java interfaces). Use the remaining features in a standardized manner (make sure copy constructors and destructors are correct, use initialization lists systematically or not at all, make everything exception-safe or ban exceptions, use std::auto_ptr as much as possible, and probably a gazillion other crucial things I forgot).

Some individuals are indeed that disciplined. But an entire team? Good luck finding it.

(2) The API of most operating systems are sufficiently language independent to allow several languages. Most languages are sufficiently OS independent to allow the port of programs in several operating systems. This is basically because an OS API and standard libraries are effectively the two halves of a plug-in system.

So, the constraints are very unlike those you find when adding functionality to a program which doesn't have any plug-in system. I concede that C and C++, as the default API for current operating systems, are favoured. But the burden on other languages is barely noticeable (except maybe for the language implementer).

[1]: http://www.loup-vaillant.fr/articles/assignment

[2]: http://www.loup-vaillant.fr/tutorials/avoid-assignment

Re: Hacker Poll: Is C++ the Language of the Future?

#69

Earlier quoted context omitted.

I have to challenge some of your points: 2. Just use 2 languages, like C + Lua. or C + anything-higher-level-than-Java. As a "language", such a combination is easily simpler than C++, and the high level part is way cleaner. My point is, don't use one complex tool when 2 simpler one can do. On a side note, you should think about what OOP, templates, and "meta-programming" are good for. Most of the time, naked lambdas…

What do you mean when you say RAII is copy-ridden?

It's this thing about each object being responsible for the memory allocation of the data it points to:

  // Untested code, I hope I didn't miss anything
  class Foo {
  public:
    Foo(const Bar& b) : b(new Bar(b)) {}
    Foo(const Foo& f) : b(new Bar(*(f.b))) {}
    Foo& operator=(const Foo& f) { b = new Bar(*(f.b));
                                   return *this; }
    ~Foo()throw() { delete b; }
    // other methods
  private:
    Bar* b;
  }
std::auto_ptr let you keep your default destructor:

  class Foo {
  public:
    Foo(const Bar& b) : b(new Bar(b)) {}
    Foo(const Foo& f) : b(new Bar(*(f.b))) {}
    Foo& operator=(const Foo& f) { b = new Bar(*(f.b));
                                   return *this; }
    // default destructor
    // other methods
  private:
    std::auto_ptr b;
  }
Or you could do away with pointers altogether (not always applicable, and it may fill up your stack too):

  class Foo {
  public:
    Foo(const Bar& b) : b(b) {}
    // default copy constructor, operator=, and destructor
    // other methods
  private:
    Bar b;
  }
So, whenever you need another instance of Foo, it will create another instance of Bar, which may create another instance of Baz… you get the idea. It is quite simple to do, and guarantees the absence of memory leaks, even in the presence of exceptions. But it copies a lot of data. C++ 0x move semantics will make it a little better, but it won't completely eliminate the problem.

Actually, copy is the essence of RAII. Rather than saying "hey, your piece of data is interesting, let me hook it" and later complain when the fish broke your line (dangling pointer), RAII says instead "hey, your piece of data is interesting, let me have a copy" so you are sure to keep your data safe, and the other is sure to be able to safely destroy its own copy at any time.

On a side note, you could avoid copying Bar instances by using Boost's shared pointers or a garbage collector. But it will only be practical if Bar is immutable. I am also told that there are other memory management schemes, which can be very efficient, but tend to be complex and error prone.

Post reply on HN