Skip to content

C++11 features #13

Open
Open

Description

@bnoordhuis

Filing the issue here because node-forward/node is currently private and I want this to be a public discussion.

Per the upgrade to V8 3.29 in commit node-forward/node@6bcea4f, we are now building the project with -std=gnu++0x. (Coincidentally, that means VS 2013 is now required on Windows.)

The question: what C++11 features do we want to use and why?

Chromium follows these guidelines. That's a good if perhaps somewhat conservative starting point.

/cc @indutny @piscisaureus @trevnorris

Activity

  1. bnoordhuis commented on Oct 22, 2014

    @bnoordhuis
    MemberAuthor

    NB: I filed node-forward/node#30 ("src: replace NULL with nullptr") earlier today. Replacing NULL with nullptr seems like an uncontroversial and unequivocally good change to me.

  2. indutny commented on Oct 22, 2014

    @indutny

    I would vote for none. But nullptr sounds reasonable indeed.

  3. dshaw commented on Oct 22, 2014

    @dshaw
    Member

    @bnoordhuis Do we also need to consider embracing anything from the Blacklist too? http://chromium-cpp.appspot.com/#blacklist

  4. bnoordhuis commented on Oct 22, 2014

    @bnoordhuis
    MemberAuthor

    @indutny I added more commits that introduce other C++11 features so you can see for yourself what it would look like.

    Taking override as an example, it makes the compiler yell at you when you change a base class in an incompatible way. It helps you catch bugs and that's undeniably a good thing, right?

    @dshaw Most of those features are blacklisted because of a certain crappy compiler... That's also an important reason of why C++11 library functions are verboten. I'm afraid we'll have to restrict ourselves as well, for now at least.

    Things that are under consideration, like move semantics or whether or not to use C++11 STL features, don't really affect node because we are not heavy users of containers anyway. (Though I could probably make a case for things like std::atomic and std::unique_ptr, I can see us using those.)

  5. bnoordhuis commented on Oct 22, 2014

    @bnoordhuis
    MemberAuthor

    @indutny Also, when you say "I would vote for none", you should at least try to argue your case. :-)

  6. trevnorris commented on Oct 22, 2014

    @trevnorris

    Usually "more features" is inevitably followed by "more overhead". Though the ones you've discussed so far don't seem to fall into that category.

    Though, now that Node requires C++11 does that also mean libuv can start using C99?

  7. bnoordhuis commented on Oct 22, 2014

    @bnoordhuis
    MemberAuthor

    Regrettably, no. The reason libuv stuck with C89 is that MSVC doesn't really support C99 and never will. You could perhaps carve out a common subset but that's it. I move that we do libuv2 as a from-the-ground-up rewrite in C++11. :-)

  8. piscisaureus commented on Oct 22, 2014

    @piscisaureus
    Member

    I wonder if we could move to use clang on every platform.

  9. bnoordhuis commented on Oct 22, 2014

    @bnoordhuis
    MemberAuthor

    Probably. According to the compatibility page, it's not 100% compatible with MSVC yet but it's probably good enough for our purposes. With clang HEAD from a few weeks ago, I was able to compile a non-trivial add-on and load it with a node.exe built with MSVC.

  10. sam-github commented on Oct 22, 2014

    @sam-github

    Using clang on every platform would even the field, both linux and windows users would usually lack the tools to compile addons.

  11. bnoordhuis commented on Oct 23, 2014

    @bnoordhuis
    MemberAuthor

    You've got that wrong, Sam. This is about building node with clang, not add-ons.

    The key is ABI compatibility. Clang emits code that is compatible with the platform's ABI on the Unices and it's getting there on Windows. That means users can build their add-ons with the compiler that suits them best and the result should Just Work(TM) with clang-compiled node.

  12. kkoopa commented on Oct 23, 2014

    @kkoopa

    Can't you hold off until M$ releases Visual Studio 14? I refuse to upgrade from 2010 until the menus STOP SCREAMING AT ME.

  13. sam-github commented on Oct 23, 2014

    @sam-github

    @bnoordhuis I was lead astray by this:

    With clang HEAD from a few weeks ago, I was able to compile a non-trivial add-on and load it with a node.exe built with MSVC.

    Depending on clang head is a bit of a barrier to entry to node dev, aptitude install build-essential is not too bad, but svn cloning and building clang is a bit time consuming. Hopefully building on windows isn't too epic.

    Perhaps depending on clang can wait until clang has binary releases for the platforms node supports, or recent linux distros package a useable version.

  14. rvagg commented on Oct 23, 2014

    @rvagg

    FYI, re Microsoft, they have new options for Visual Studio versions (as they do with every release ...), to successfully compile Node with the latest V8 you need "Microsoft Visual Studio 2013 Windows Desktop Edition" plus the Windows SDK 8.1. It's pretty specific now, I'd love for clang to be a viable alternative, that'd likely radically simplify things, particularly for native addon builds which is just crazy for the average Windows Node developer.

    The fact that C++11 is going to be mandatory will mean that it opens up interesting possibilities for addon developers too, unless they want to ensure 0.10 (and prior) support where addon consumers don't have to have such modern compilers. But still, all documentation and recommendations will shift to C++11 compilers anyway so even people using 0.10 are likely going to have modern toolchains that enable C++11 features.

  15. rmg commented on Oct 23, 2014

    @rmg
    Member

    Ignoring the platform SDK requirements.. the idea that clang binaries could be distributed via a node-gyp like module would awesome.

  16. kkoopa commented on Oct 24, 2014

    @kkoopa

    This is going to open up an avalanche of spurious issues along the lines of "Installation Error With Turbo C++ 3.0 / GeOS"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions