question about C/Cpp

This is a discussion on question about C/Cpp within the General Discussions forums, part of the Community Boards category; i was wondering what are the two primary reasons programs are written in C/Cpp?...

  1. #1
    Registered User
    Join Date
    May 2010
    Posts
    10

    Question question about C/Cpp

    i was wondering what are the two primary reasons programs are written in C/Cpp?

  2. #2
    Registered User
    Join Date
    Oct 2008
    Posts
    1,262
    Quote Originally Posted by truetrini20 View Post
    i was wondering what are the two primary reasons programs are written in C/Cpp?
    1. To make a computer program.
    2. To finish university.

  3. #3
    Registered User
    Join Date
    Oct 2006
    Posts
    2,503
    Quote Originally Posted by truetrini20 View Post
    i was wondering what are the two primary reasons programs are written in C/Cpp?
    1. because it's cool
    2. because everyone is doing it

    let me google that for you

  4. #4
    Registered User
    Join Date
    May 2010
    Posts
    10
    trust me i googled it but i thought there was a more important answer

  5. #5
    Making mistakes
    Join Date
    Dec 2008
    Posts
    476
    Google No. 2 says all. There is no more important reason. They are enough. Ever tried assembly?

  6. #6
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,708
    Quote Originally Posted by truetrini20 View Post
    i was wondering what are the two primary reasons programs are written in C/Cpp?
    1) If I don't, the little voice in my head just grows louder
    2) I need them to run my robots (which will one day rule the human race)
    Code:
    #include <cmath>
    #include <complex>
    bool euler_flip(bool value)
    {
        return std::pow
        (
            std::complex<float>(std::exp(1.0)), 
            std::complex<float>(0, 1) 
            * std::complex<float>(std::atan(1.0)
            *(1 << (value + 2)))
        ).real() < 0;
    }

  7. #7
    Registered User jeffcobb's Avatar
    Join Date
    Dec 2009
    Location
    Henderson, NV
    Posts
    875
    1. UNIX is written in C. Nobody cares what Windows is written in.
    2. More seriously, C++ (or OOP) can be used to solve larger more complex problems. Anyone who says differently has never had something complex to solve or if they did, they worked way too hard at it and never knew it.
    3. Both pay pretty well. Fad languages come and go but coding in both of these will keep you employed.
    C/C++ Environment: GNU CC/Emacs
    Make system: CMake
    Debuggers: Valgrind/GDB

  8. #8
    Registered User
    Join Date
    Dec 2009
    Posts
    11
    Why exactly just 2 reasons?

    In reality, there are many more than just 2 reasons to use C and/or C++ (mostly C++ though). For one thing, don't let anyone tell you it's no longer relevant (heck, even C is still relevant sometimes). Any language can be irrelevant to you, depending on what you want to accomplish. The C++ standard was recently updated, and despite the popularity of Java and C#, it's still a very commonly-used language. For example:

    If you want to do any bigtime 3D game programming, especially for things like graphics engines or physics engines, you're going to use C++ because it is a good balance of speed and OOP. That may change in the future as computers and consoles become faster. But I doubt it, because as performance increases, so does demand for more realistic graphics, AI, physics, etc.

    Other than Fortran, which my alma mater Purdue University STILL used for some Computational Fluid Dynamics stuff, C and C++ are also probably the best choice for scientific computing for those same reasons (very large data sets and good visualization require great performance). If you're familiar with MATLAB, even though it uses its own scripting language, the core engine is C++. I would guess Maple is too.

    Embedded stuff (someone mentioned robots) like avionics also use C/C++ quite often. I am pretty sure stock market companies (at least from the job listings I've seen over the years) use it in their own software because there's a crapload of information flying around during the trading day that needs to be quickly analyzed.

    And finally...

    In my personal opinion, if you learn C++ and you get good at it, you'll already understand most of C. You'll be able to dive right into Java and C#, because you'll already be familiar with OOP, and with the majority of Java and C# syntax. Doing so the other way around, if you aim to learn multiple languages, is not the way to go. But that's just my experience. For me, it was the perfect starter's language.

  9. #9
    Just a pushpin. bernt's Avatar
    Join Date
    May 2009
    Posts
    426
    Programs are written in C because programs are written in C. It's famous. It's universal. It's fast. And it's small. [And by small I mean the language has relatively few features to learn]
    And a big part of it is that
    UNIX is written in C.
    Consider this post signed

  10. #10
    Making mistakes
    Join Date
    Dec 2008
    Posts
    476
    That was the primary reason for developing the language, altho UNIX is slightly outdated right now in favor of POSIX systems which are again implemented in C.

  11. #11
    Super Moderator VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,596
    No programming question here. Moved to GD.

  12. #12
    spurious conceit MK27's Avatar
    Join Date
    Jul 2008
    Location
    segmentation fault
    Posts
    8,300
    Quote Originally Posted by bernt View Post
    Programs written in C... and it's small. [And by small I mean the language has relatively few features to learn]
    C executables are also significantly smaller than C++ equivalents memory usage wise, which is why it is better for fundamental things like OS kernels and so on.

    You might also want to check this out:

    Computer Language Benchmarks Game

    There are various criteria there, but with regard to execution speed C/C++ is still the "fastest" language/s in the world. (I think C++ actually has a 1% lead on C in the rankings there, and there is a language called ATS which is comparable to them. But beyond that, the C/C++/ATS group is still 30% faster than the next competitors, Java and C#).

    So if you want to optimize memory and speed you would use C. If memory is a less important issue that making life easier for the programmer, you would use C++.
    C programming resources:
    GNU C Function and Macro Index -- glibc reference manual
    The C Book -- nice online learner guide
    Current ISO draft standard
    CCAN -- new CPAN like open source library repository
    3 (different) GNU debugger tutorials: #1 -- #2 -- #3
    cpwiki -- our wiki on sourceforge

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. A question about a question
    By hausburn in forum C++ Programming
    Replies: 3
    Last Post: 04-25-2010, 05:24 AM
  2. Alice....
    By Lurker in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 06-20-2005, 02:51 PM
  3. Debugging question
    By o_0 in forum C Programming
    Replies: 9
    Last Post: 10-10-2004, 05:51 PM
  4. Question...
    By TechWins in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 07-28-2003, 09:47 PM
  5. Question, question!
    By oskilian in forum A Brief History of Cprogramming.com
    Replies: 5
    Last Post: 12-24-2001, 12:47 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21