Why choose the c++ language

Hi, why would i want to learn c++, what is it useful for? i've tried a bit, but i think the output is a bit wierd, ive got the book jumping into c++ but it doesnt seem be possible to paint your programs. Is there an other language you use to paint the program? i have heard that its possible to make ios apps with c++, can you?

-A guy who wants to know...
C++ can be used to do almost anything, everywhere. It is a low-level language that makes no assumptions about you having a monitor, or a keyboard, or even an operating system. So now you know why there is not a built-in C++ function to draw colours on a screen; because there is no assumption that you even have a screen. What good are drawing functions to me if I'm writing code to run your dishwasher? [1]

Some other languages do not take this approach; they exchange ease of use for power. In many cases this is a very reasonable exchange to make. In doing so, they may make it easier for you, the programmer, to draw lines on the screen.

Drawing graphics on a screen requires asking the operating system to do it for you. Some languages make that very easy for you by making assumptions about what OS you have, what screen you have, and so on. C++ does not, so in C++ you must ask the operating system directly (which requires you to know about your operating system). Many C++ libraries exist in which people have written functions that do this for you; again, they will have made assumptions and place restrictions on you that reduce your power but increase convenience.

C++ can be used to do almost anything, everywhere. The only limit is that a complier exists that produces an executable for the target hardware, and that you can get the basic library support on that hardware.

[1] Embedded code for dishwashers more typically written in C, but certainly could be done in C++.
Last edited on
thank you! But its possible to make apps?
Last edited on
Here's a lists of some of the current C++ users: http://stroustrup.com/applications.html (see also lists referenced from it, such as http://www.boost.org/users/uses_inhouse.html )

And yes, it is used in the backend of ios apps, when performance and/or portability is worth the extra effort. For example the Dropbox app uses C++.
Yes. In fact, the only way to write code that will run in both Android and iOS is to write it in C or C++.
Moschops wrote:
Embedded code for dishwashers more typically written in C

I don't know how sophisticated (or dumb) today's dishwashers are, but back when I was in OS development 15 years ago, a contemporary high-end laser printer would run a C++ app with 30+ realtime threads.
If a program can be written in any other language, it can be written in C++. It is the daddy of programming languages, and can do anything you can imagine. because of that it is fiddly and time consuming so isn't the first choice for many applications.

Windows, Linux, iOS, are all written in C. MSOffice is C++

Some languages like Java and Lua dont actually generate machine code, they are translated into "bytecode" that another program can run, usually written in C++ :)

Cubbi wrote:
a contemporary high-end laser printer would run a C++ app with 30+ realtime threads

Thats because high end laser printers have lots of RAM and a decent CPU for rendering Postscript.

C is the norm for devices with limited memory and cpu capabilities. C++ relies quite heavily on dynamic memory allocation and fragments memory quickly.

If you want your application to be small and fast write it in C++, if you want it to be smaller and faster write it in C :)
Last edited on
Writing C++ that performs the same allocations as idiomatic C code is demonstrably easier than writing said C code. The C type system is garbage.
C++ relies quite heavily on dynamic memory allocation

Naive C++ (where lots of vector::push_backs are used with the default allocator). When I want to avoid dynamic memory allocation, I go for C++ over C every time. C++ can be quite a bit faster than C, as well, at the expense of compile time.
Topic archived. No new replies allowed.