C++ much faster under Linux?

From C++ to PHP, debugging to webhosting; help and discussion about writing your latest program to running your website. NOT for help when your PC won't work.

Announcements Posted on
Please change your TSR password 23-05-2013
Sign in to Reply
  1. beepbeeprichie's Avatar
    • Vengeful, Imperial Overlord of The Student Room
    • Posts: 3,838
    C++ much faster under Linux?
    Has anyone else noticed that running c++ apps under linux is much faster than under windows? Like twice as fast running apps with the same code?

    Anyone care to explain this?
  2. barnisaurusrex's Avatar
    • Benevolent Member
    • Posts: 606
    Re: C++ much faster under Linux?
    Windows is a piece of ****. No serious programmer uses windows as their OS. Use mac OS or a free linux distro.
  3. maturestudy's Avatar
    • Peer Of The TSR Realm
    • Location: Festive Road
    • Posts: 1,707
    Re: C++ much faster under Linux?
    (Original post by beepbeeprichie)
    Has anyone else noticed that running c++ apps under linux is much faster than under windows? Like twice as fast running apps with the same code?

    Anyone care to explain this?
    Which C++ apps in particular? Microsoft Word, Adobe Photoshop, Mass Effect 3? These are native Windows apps and I don't see them running faster under linux.

    Software that has been ported from UNIX/Linux to Windows can run slower (e.g. Apache) because it has designed to run on UNIX/Linux not on Windows.

    If it's your own apps, how are they being compiled on Linux and Windows? Are they using a compatibility layer (such as Cygwin)? Which other libraries are they using?
  4. beepbeeprichie's Avatar
    • Vengeful, Imperial Overlord of The Student Room
    • Posts: 3,838
    Re: C++ much faster under Linux?
    (Original post by maturestudy)
    Which C++ apps in particular? Microsoft Word, Adobe Photoshop, Mass Effect 3? These are native Windows apps and I don't see them running faster under linux.

    Software that has been ported from UNIX/Linux to Windows can run slower (e.g. Apache) because it has designed to run on UNIX/Linux not on Windows.

    If it's your own apps, how are they being compiled on Linux and Windows? Are they using a compatibility layer (such as Cygwin)? Which other libraries are they using?
    Yeh my own apps. Compiled with GCC. No compatability layer (moved from linux to windows). Using GMP lib.
  5. beepbeeprichie's Avatar
    • Vengeful, Imperial Overlord of The Student Room
    • Posts: 3,838
    Re: C++ much faster under Linux?
    BTW does this:

    void *myfunc(void *vptr_value) {
    int value = *((int *)vptr_value);
    }

    make any sense to anybody?
  6. TheUnbeliever's Avatar
    • TSR Demigod
    • Location: Scotland
    • Posts: 5,838
    Re: C++ much faster under Linux?
    Assuming you're benchmarking properly, this is likely to be a toolchain issue rather than an operating system one. There are differences in e.g. scheduler functionality which might account for some differences, but I'd be looking in a number of other places first. There's no way to say anything more without vastly more information.

    (Original post by beepbeeprichie)
    void *myfunc(void *vptr_value) {
    int value = *((int *)vptr_value);
    }
    That looks an awful lot like something which you probably don't want to be doing. The common exception is interop with a native C library, where a void* 'user state' parameter for callbacks is a standard idiom. In terms of the sample actually making sense, there's not nearly enough context. For starters, the function has no side effects and fails to return the advertised pointer to void.
  7. beepbeeprichie's Avatar
    • Vengeful, Imperial Overlord of The Student Room
    • Posts: 3,838
    Re: C++ much faster under Linux?
    (Original post by TheUnbeliever)
    That looks an awful lot like something which you probably don't want to be doing. The common exception is interop with a native C library, where a void* 'user state' parameter for callbacks is a standard idiom. In terms of the sample actually making sense, there's not nearly enough context. For starters, the function has no side effects and fails to return the advertised pointer to void.
    It comes from pthreads.
  8. TheUnbeliever's Avatar
    • TSR Demigod
    • Location: Scotland
    • Posts: 5,838
    Re: C++ much faster under Linux?
    (Original post by beepbeeprichie)
    It comes from pthreads.
    Which comes from the C world, where it's a standard idiom. Do you have a problem with it, or were you just curious if it was a common construct?
  9. beepbeeprichie's Avatar
    • Vengeful, Imperial Overlord of The Student Room
    • Posts: 3,838
    Re: C++ much faster under Linux?
    (Original post by TheUnbeliever)
    Which comes from the C world, where it's a standard idiom. Do you have a problem with it, or were you just curious if it was a common construct?
    Yeh, just curious.

    Thought to myself WTF is going on here!
  10. maturestudy's Avatar
    • Peer Of The TSR Realm
    • Location: Festive Road
    • Posts: 1,707
    Re: C++ much faster under Linux?
    (Original post by TheUnbeliever)
    Which comes from the C world, where it's a standard idiom. Do you have a problem with it, or were you just curious if it was a common construct?
    pthreads, a common idiom? The POSIX threads library. Seriously?

    If you use UNIX libraries on Windows don't expect to get the same performance as native applications. :facepalm:
  11. TheUnbeliever's Avatar
    • TSR Demigod
    • Location: Scotland
    • Posts: 5,838
    Re: C++ much faster under Linux?
    (Original post by maturestudy)
    pthreads, a common idiom? The POSIX threads library. Seriously?
    I think you've misread: "[pthreads] comes from the C world, where [casting void*-typed 'user state' pointers] is a common idiom."
  12. Psyk's Avatar
    • TSR Royalty
    • Location: Leamington Spa
    • Posts: 19,098
    Re: C++ much faster under Linux?
    (Original post by barnisaurusrex)
    Windows is a piece of ****. No serious programmer uses windows as their OS. Use mac OS or a free linux distro.
    So almost the entire games industry are not serious programmers?
  13. Aquar's Avatar
    • Exalted Member
    • Posts: 313
    Re: C++ much faster under Linux?
    (Original post by Psyk)
    So almost the entire games industry are not serious programmers?
    I think that's what he's saying :turban:
  14. barnisaurusrex's Avatar
    • Benevolent Member
    • Posts: 606
    Re: C++ much faster under Linux?
    (Original post by Psyk)
    So almost the entire games industry are not serious programmers?
    You think professional game developers don't use a unix based OS? Lulz.
  15. Chrosson's Avatar
    • PS Helper
    • Vengeful, Imperial Overlord of The Student Room
    • Posts: 4,215
    Re: C++ much faster under Linux?
    (Original post by barnisaurusrex)
    You think professional game developers don't use a unix based OS? Lulz.
    ...are you suggesting 'professional game developers' use unix based systems in order to compile programs for Windows? You cannot be serious.
  16. beepbeeprichie's Avatar
    • Vengeful, Imperial Overlord of The Student Room
    • Posts: 3,838
    Re: C++ much faster under Linux?
    (Original post by Chrosson)
    ...are you suggesting 'professional game developers' use unix based systems in order to compile programs for Windows? You cannot be serious.
    This and this
    Last edited by beepbeeprichie; 04-04-2012 at 20:52.
  17. maturestudy's Avatar
    • Peer Of The TSR Realm
    • Location: Festive Road
    • Posts: 1,707
    Re: C++ much faster under Linux?
    (Original post by TheUnbeliever)
    I think you've misread: "[pthreads] comes from the C world, where [casting void*-typed 'user state' pointers] is a common idiom."
    Yes, apologies. It was a response to the original topic (which seems to have derailed somewhat).
  18. barnisaurusrex's Avatar
    • Benevolent Member
    • Posts: 606
    Re: C++ much faster under Linux?
    (Original post by Chrosson)
    ...are you suggesting 'professional game developers' use unix based systems in order to compile programs for Windows? You cannot be serious.

    Don't be daft. You can develop an entire game/program in unix and then just do whatever changes you need to get it to compile on a different platform, of which windows is one of many.
  19. ebee's Avatar
    • Junior Member
    • Posts: 65
    Re: C++ much faster under Linux?
    (Original post by barnisaurusrex)
    Windows is a piece of ****. No serious programmer uses windows as their OS. Use mac OS or a free linux distro.
    Hi! I'm a software engineer working for a consultancy. The operating systems we use to develop depends entirely on


    1. what the client wants
    2. the technology stack used by the client
    3. the specific expertise of the consultants involved.


    Sometimes we get to suggest technologies, sometimes they are dictated by the client, sometimes we're contributing to an existing project. For example, currently I'm working on a very complicated, multiple tens of millions project that requires a heavyweight client written in C# with a server-side written in a combination of Java and Scala. I write my C# code on a Windows machine, I write Scala on Ubuntu/CentOS. Before that I was working on a Flex & Actionscript web client that talked to a Java server - that was a combination of MacOS and Linux.

    In short, what I'm trying to say is that professionals use whatever tool is right for the job.
  20. ebee's Avatar
    • Junior Member
    • Posts: 65
    Re: C++ much faster under Linux?
    (Original post by barnisaurusrex)
    Don't be daft. You can develop an entire game/program in unix and then just do whatever changes you need to get it to compile on a different platform, of which windows is one of many.
    Or, you'll have code that imports different sections based on what the compiler, or continuous integration build task, is told the target operating system is
Sign in to Reply
Share this discussion:  
Useful resources
Article updates
Moderators

We have a brilliant team of more than 60 volunteers looking after discussions on The Student Room, helping to make it a fun, safe and useful place to hang out.

Reputation gems:
The Reputation gems seen here indicate how well reputed the user is, red gem indicate negative reputation and green indicates a good rep.
Post rating score:
These scores show if a post has been positively or negatively rated by our members.