Thread: So, I'm trying out Google's C++ test library...

  1. #31
    Its hard... But im here swgh's Avatar
    Join Date
    Apr 2005
    Location
    England
    Posts
    1,687
    Just to add my two cents to the language contest side discussion.

    Do not think of how the languages were internally designed, think of "what" they are used for and "why" the companies made such a choice.

    C:

    Embedded programming
    Device drivers and kernels
    Game Programming (yes, still used but not as much nowadays)
    Operating Systems (UNIX anyone)?
    Teaching tool in some colleges around the world
    Core compiler language for other languages due to the low level features

    C++:

    Major video game Engine development language (not so much the actual game logic due to scripting)
    High level back-end development of websites (Facebook, Google)
    Desktop application development (Java/C# seem to overtaking this)
    Almost all commercial business applications are heavily coded in C++ (Adobe, Microsoft and most Professional audio software are written exclusively in C++)
    Higher level Operating System development

    I could go on and on but you get the picture. The test case here is not really about speed, but the language being efficient and the right tool for the job. Would you want to code an entire OS in C++? No. Not because C++ is not capable because with the right development and algorithm in certainly can be done. C has been used for this due to low-level abstractions it allows. On the other hand, I would never use C to code the latest Xbox One game. C "can" be used for this, but again, C++ has been proven to work extremely well with the Game Engine rendering and psychics. Also, Lua is a major scripting language that C++ sits better with. If I threw a toolbox in languages in front of you and asked you to build the next leading enterprise software package - would you choose C or C++? Or Java or even Python? Yes, it's cliche' I know, but it's all about the right tool for the job. Speed only really comes into the equation when people begin looking at bottlenecks in their code. Can a function be executed faster if it was "inline" for example?

    Just my two cents.

    Ada x
    Double Helix STL

  2. #32
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Quote Originally Posted by swgh View Post
    Would you want to code an entire OS in C++? No. Not because C++ is not capable because with the right development and algorithm in certainly can be done. C has been used for this due to low-level abstractions it allows.
    This is really a non-argument. C++ is a strict superset of C, which means that C is the base class and C++ is the derived class. You can certainly do low-level algorithms in C++, and when you factor in such things as functors or lambdas, they can be ever faster than C. It really depends on how you write the code, of course, but in no sense is C++ inferior to C in this regard. In fact, the whole C++ standard library is written in C++ and it has tons of low-level abstractions and algorithms. And yet, the standard librarry needs to be as fast as possible. C is mostly used for historical reasons, not practical ones*. Unix is C pretty much because Linus Torvalds hates C++, for example.

    *) From what I've seen.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  3. #33
    Unregistered User Yarin's Avatar
    Join Date
    Jul 2007
    Posts
    2,158
    Quote Originally Posted by Elysia View Post
    C++ is a strict superset of C, which means that C is the base class and C++ is the derived class.
    Untrue. C has several features that C++ does not.


    Quote Originally Posted by Elysia View Post
    C is mostly used for historical reasons, not practical ones*. Unix is C pretty much because Linus Torvalds hates C++, for example.
    Maybe. C is still used because for its users, less is more.

  4. #34
    Registered User MutantJohn's Avatar
    Join Date
    Feb 2013
    Posts
    2,665
    I thought Unix was C because C was this brand new language and it was 1972. Linux was written in C because Linus is an overall troll who loves C. Or does Linus oversee current Unix development as well?

  5. #35
    Registered User MutantJohn's Avatar
    Join Date
    Feb 2013
    Posts
    2,665
    Quote Originally Posted by Epy View Post
    @John: just when you became comfortable with the command prompt on Windows: Microsoft Replaces Command Prompt with PowerShell in Latest Windows 10 Build
    Btw, this ........es me off so much. Command Prompt is awesome. I tried PowerShell for like 5 minutes, found out that it didn't work the exact same way and now I'm throwing a fit about it.

  6. #36
    Unregistered User Yarin's Avatar
    Join Date
    Jul 2007
    Posts
    2,158
    Quote Originally Posted by MutantJohn View Post
    Btw, this ........es me off so much. Command Prompt is awesome. I tried PowerShell for like 5 minutes, found out that it didn't work the exact same way and now I'm throwing a fit about it.
    I can't tell if you're serious, or parodying Elysia.

  7. #37
    Registered User MutantJohn's Avatar
    Join Date
    Feb 2013
    Posts
    2,665
    Quote Originally Posted by Yarin View Post
    I can't tell if you're serious, or parodying Elysia.
    Lol I don't think I know Elysia's posting style well enough to parody them.

    I actually was being kind of serious though. I actually kind of like command prompt. Getting rid of it now feels like it's too soon for me

  8. #38
    (?<!re)tired Mario F.'s Avatar
    Join Date
    May 2006
    Location
    Ireland
    Posts
    8,446
    You don't have to get rid of it. Neither it will be uninstalled for you with an update.
    You can enjoy the tremendous power of powershell for as long as you want. Although, it will be short-lived enough that you'll realize you ejaculated prematurely.
    Originally Posted by brewbuck:
    Reimplementing a large system in another language to get a 25% performance boost is nonsense. It would be cheaper to just get a computer which is 25% faster.

  9. #39
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Quote Originally Posted by Yarin View Post
    Untrue. C has several features that C++ does not.
    Then do please provide examples, so I can look them up.

    Quote Originally Posted by MutantJohn View Post
    I thought Unix was C because C was this brand new language and it was 1972. Linux was written in C because Linus is an overall troll who loves C. Or does Linus oversee current Unix development as well?
    It's true that C++ was not available when Linux was first released. However, in subsequent releases, there has been nothing stopping them from using C++ for some code, as well.
    Last edited by Elysia; 11-19-2016 at 02:22 PM.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  10. #40
    Unregistered User Yarin's Avatar
    Join Date
    Jul 2007
    Posts
    2,158
    Quote Originally Posted by Elysia View Post
    Then do please provide examples, so I can look them up.
    Well... Variable length arrays, Compound literals, Designated initializers, Elysias that can't google, and Type-generic macros, to name a few. Most of these are available to C++ as extensions, though the reversed is true too; GCC lets you really blur the distinction between C & C++.

  11. #41
    Registered User MutantJohn's Avatar
    Join Date
    Feb 2013
    Posts
    2,665
    Quote Originally Posted by Mario F. View Post
    You don't have to get rid of it. Neither it will be uninstalled for you with an update.
    You can enjoy the tremendous power of powershell for as long as you want. Although, it will be short-lived enough that you'll realize you ejaculated prematurely.
    Sr. Gruñón!

    One thing I'm wondering about is, what this mean for the Developer Command Prompt for Visual Studio? Is there going to be a Developer PowerShell? I just want CL in my path T_T

  12. #42
    Registered User
    Join Date
    Nov 2012
    Posts
    1,393
    Quote Originally Posted by MutantJohn View Post
    One thing I'm wondering about is, what this mean for the Developer Command Prompt for Visual Studio? Is there going to be a Developer PowerShell? I just want CL in my path T_T
    The "Developer Command Prompt" shortcut for Visual Studio's purpose is to set environment variables. Notice that it simply calls %VS120COMNTOOLS%\VsDevCmd.bat. To use it in Powershell, you can either call this batch file before starting PowerShell, or you can use Invoke-Environment (mind the outer and inner quotes) from within PowerShell to transfer the environment, e.g.

    Code:
    PS C:\Users\Me> Invoke-Environment 'call "%VS120COMNTOOLS%\VsDevCmd.bat"'
    PS C:\Users\Me> cl hello.cpp
    ...
    Invoke-Environment is discussed on this page: How to call batch script from Powershell? - Stack Overflow

  13. #43
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Quote Originally Posted by Yarin View Post
    Well... Variable length arrays, Compound literals, Designated initializers, Elysias that can't google, and Type-generic macros, to name a few. Most of these are available to C++ as extensions, though the reversed is true too; GCC lets you really blur the distinction between C & C++.
    ...So you're going to go into stuff that don't match 1:1 between the languages, the area I decided to skip. It's true that some stuff don't match 1:1, but that doesn't mean C++ can't do it.
    - Variable length arrays can be done with std::vector
    - Compund literals are supported with initializer lists, e.g.
    Code:
    MyType T{...};
    . You can emulate arrays as initializer_lists, and so on.
    - Designated initializers are unfortunately not supported, and the only example you brought up that have no equivalents, but you can create different constructors for this purpose.
    - As for Yarins that can't google, well, unfortunately there's just no support for support idiots in the language.
    - Templates replace type-generic macros.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  14. #44
    Registered User MutantJohn's Avatar
    Join Date
    Feb 2013
    Posts
    2,665
    Quote Originally Posted by c99tutorial View Post
    The "Developer Command Prompt" shortcut for Visual Studio's purpose is to set environment variables. Notice that it simply calls %VS120COMNTOOLS%\VsDevCmd.bat. To use it in Powershell, you can either call this batch file before starting PowerShell, or you can use Invoke-Environment (mind the outer and inner quotes) from within PowerShell to transfer the environment, e.g.

    Code:
    PS C:\Users\Me> Invoke-Environment 'call "%VS120COMNTOOLS%\VsDevCmd.bat"'
    PS C:\Users\Me> cl hello.cpp
    ...
    Invoke-Environment is discussed on this page: How to call batch script from Powershell? - Stack Overflow
    You can't even call batch scripts from Powershell? This is starting to feel like a step backwards... Okay, I'm sticking with Command Prompt. Now, if you'll excuse me, there's some kids on my lawn and they ain't gonna yell at themselves!

  15. #45
    Registered User MutantJohn's Avatar
    Join Date
    Feb 2013
    Posts
    2,665
    - Variable length arrays can be done with std::vector
    This isn't what Yarin meant. He meant stack-based allocations. Unless you have a fancy stack allocator implementation, you shouldn't do VLAs in C++. If C supports them, awesome.

    Also, isn't __restrict__ an actual thing in C but is optionally implemented by most compiler vendors in C++?

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Google Written Test question...!
    By manasij7479 in forum General Discussions
    Replies: 15
    Last Post: 10-25-2013, 06:00 PM
  2. Reading Google Sketchup (.skp) or Google Earth (.kmz)
    By Zeeshan in forum Game Programming
    Replies: 9
    Last Post: 03-07-2008, 05:25 PM
  3. Test at http://www.artlogic.com/careers/test.html
    By zMan in forum C++ Programming
    Replies: 6
    Last Post: 07-15-2003, 06:11 AM

Tags for this Thread