0
$\begingroup$

I am learning C++. I learned basics concepts and OOP. The main things peoples are working on are GUI and API development with the help of C++. My question is, as a C++ learner is it a must for me to learn these in C++, because there are other languages to learn and develop these concepts (GUI , APIs ...)?

$\endgroup$
9
  • $\begingroup$ If you look at Linux running... Lets see... from desktops to Android to most of the world's cloud servers to random devices IOTs modems... etc, Linus Torvalds is arguably the world's greatest programmer. And this is his view of C++ harmful.cat-v.org/software/c++/linus . Ten years on he seems to not have changed his mind medium.com/nerd-for-tech/… .Do I believe Linus??? That's a non-trivial question and you will have to ask it with some care and research to get good answers. If you dont your questionsstart getting closed $\endgroup$
    – Rusi
    Jan 30 at 14:56
  • $\begingroup$ @Rusi : But in my case i prefer the languages which is best in there fields/use . for example we use python for DS , ML etc. And also use its framework for backend web development .On the other hand we use Java or Swift for app Development . and most of programmer who prefer me to learn C++ as a beginner and for DSA . $\endgroup$
    – Hamza
    Jan 30 at 15:07
  • 2
    $\begingroup$ What are your actual goals. Do you want to just become a developer or do you want a deep understanding of computing in all of its facets? Is your goal graduate school and beyond or not? $\endgroup$
    – Buffy
    Jan 30 at 15:55
  • 1
    $\begingroup$ @Buffy : yes I want deep understanding of computing !!! $\endgroup$
    – Hamza
    Jan 30 at 16:00
  • 1
    $\begingroup$ @Rusi sorry, I hope I didn't come across meanly, certainly nothing inappropriate! My own experience is that such discussions can confuse and disenchant beginners (regardless of their merit), but I don't have anything like the teaching experience you do. $\endgroup$ Jan 31 at 9:20

3 Answers 3

2
$\begingroup$

I will try to answer this question from a Computer Science Educator point of view.

C++ is a tool

First and foremost, C++ is a tool. Like any other language, it's designed to make accomplishing certain types of tasks easier, but it always comes with a cost.

C++ tries to be usable almost everywhere with a great deal of flexibility. This inevitably comes with a cost of complexity. Some say it's the most complicated language out there (to know all the rules, not to accomplish certain tasks - this confusion leads to incorrect assertions that C and Assembly are more complex).

It can give you everything

Teaching C++ has its benefits. You can use one tool to teach pretty much everything there is - high level abstractions like generics, dependency injection with polymorphism, framework interactions, various package managing, resource acquisition and control, interactions with hardware in the lowest level.

It's convenient to be able to teach pretty much everything while using one tool. But it has its costs.

It is incredibly complex and makes some tasks disproportionately harder

Computer Science students have many reasons to learn a programming language. It is important to not only provide reliable information, but to also encourage them to explore the possibilities on their own. C++ makes it hard. Very hard.

Scott Meyers (a notable author from the C++ community) was once asked, what, in his opinion, is most lacking in C++. He said something among the lines of:

I am an author, so naturally I would want to know how is my book selling. I need to fetch those information from some online source, so in C++ I... yeah...

Okay, forget networking. I have the data and I want to display them in a nice chart, so in C++ I... yeah...

C++ does not have many of the common (some would even say fundamental) features that are expected to be bundled in the language. Most students will be way more amazed by easily making some simple GUI application than by creating a console game for the 5th time. There is still no networking or GUI application in standard C++, and C++20 is almost implemented by the Big Three compilers.

Not everything can be solved by a third party library

Some would argue that third-party libraries exist for a reason. What's the problem with introducing a simple dependency and using it? After all, every programmer should be aware of such possibility and get familiar with project dependencies.

Except for the fact that C++ makes it incredibly hard to bundle additional dependencies. It was designed before Internet-aware package managers were a thing. Some decisions have been made that made sense during that time. But new tools were being created and integration reached a new level. Multiple times I had to mentally sigh when I was asked by a student why it takes 4 hours of researching accompanied by trial and error to install OpenCV with CMake, while in Python it takes one pip command. The situation is bad and it's unlikely that it'll improve.

Every tool has its purpose

Every tool has its purpose and while C++ may as well be an academic language, I do not believe the pros outweight the cons in terms of learning programming. Make a distinction that is already omnipresent - don't use one tool to do everything, even though such a tool can be used with everything. Want to learn programming and get hooked? Chances are that Python, Kotlin, C# or TypeScript will be much more engaging and pleasurable experience. Want to start with or migrate to low-level language? Choose C or C++, but remember - nowadays C++ is not really used as a "just more powerful C". The "modern" part of it is more common and it's not really a tool used to primarily interact with hardware directly. Its aim is to provide a high level of abstraction with almost zero-cost overhead. This comes with complexity.

What to choose, then?

Ultimately, this is your question about your situation. You have learnt some basics of C++, good. It's not bad to make a transition to another language, nor is it bad to stay with C++. Ask yourself whether you're enjoying C++. If yes, try to delve deeper. If not, make a change. A programmer ough to know more than one tool, so learning more languages is inevitable.


A word of disclaimer - I have been programming in C++ for almost ten years. It is (and has always been) my primary language. I am engaged in both business solutions and education and, unfortunately, I more and more believe that my favorite tool (C++) is becoming more and more ill-suited for being an academic tool. Want to teach high-level? Use Kotlin, Python, TS, C# or Java (or other tools that make it easier by doing some work for you). Want to teach low-level? Use C.

Don't bother with the fact that C++ can do both of those things, unless you have a very good curriculum planned. "Can" doesn't mean "should".

$\endgroup$
8
  • $\begingroup$ You say "but remember - nowadays C++ is not really used as a more powerful C." And I say, any time someone says "remember" they are about to say something completely unsubstantiated. Case in point: I write a lot of stuff that I could write in C, but C++ 1. has automatic memory management, so no leaks 2. parameter passing without having to count "**"s. Seriously, how do you teach students to write a routine that outputs a malloc'ed array in a parameter? 3. Arrays know how long they are through ".size()". 4. The copy constructor. In C you have to write your own copy routine. Horrors. Etc. $\endgroup$ Jan 31 at 21:09
  • $\begingroup$ "GUI application [versus] console game for the 5th time." There is more to life than graphics and games. I teach "scientific programming", and my students do stuff like infectuous disease propagation, delivery truck planning, climate change, et cetera. (At the end of their first semester.) All of those require substantial programming, and with no ancillary libraries. If they want to visualize something, they pipe their numbers into some simple graphing tool. I guess it depends on your audience. Just don't think that your audience is representative. Mine isn't either, but I don't generalize. $\endgroup$ Jan 31 at 21:14
  • $\begingroup$ @VictorEijkhout there are no universal points that hold true for every single instance, although by "nowadays C++ is not really used as a more powerful C" I didn't mean that C++ cannot replace C in certain areas. It can, just as you explained. But many people tend to treat C++ as the same hell with **s and lack of memory safety, but with classes and templates. This is what I meant by "more powerful C". C++ is not C. It's not an add-on. It's a completely distinct language in which you need a different mindset to program compared to C. And I feel like you proved my point in your comments :) $\endgroup$
    – Fureeish
    Jan 31 at 21:35
  • $\begingroup$ Ok, if you're talking about "C with classes", yes, that is pretty much universally recognized as a bad idea. See Kate Gregory's "Stop Teaching C" talk. I see you've edited your answer to clarify, so I guess we agree. Except that I think C++ is great for getting close to the hardware, on anything but a Linus Torvalds level. I do my bandwidth/associativity/false sharing epxeriments all in C++. It's just easier to write for the reasons given. So I'm far less down on C++ than you are. But I'll grant you the network/graphics/package manager points. That's why I also speak python. $\endgroup$ Jan 31 at 21:52
  • 1
    $\begingroup$ @Hamza C++ can be very close to the hardware. Python is very far from it - by design. C++ has language features that enable you to interact with hardware directly, but Python needs library features to do the same. What's more, those libraries that Python relies on are usually written in C or C++! $\endgroup$
    – Fureeish
    Feb 1 at 18:53
1
$\begingroup$

There is nothing wrong with learning C++ as your first or main language. It's an extremely big and complicated language, but that's only if you want to learn everything about it. "Modern" C++, meaning C++11 or newer can actually be used as an elegant language to teach programming in. Try to find a book that teaches C++17: there is a lot in older C++ versions that has been improved and there are lots of tutorials out there that teach stuff you really should not use.

One of the main attractions of C++ is that you can write very high performance code in it. For example, C++ is really the language of choice for video games. But that's mostly for the deeper stuff, the actual video stuff. If you're interested in GUI applications you can use C++ but you don't have to. In your case I would let the choice of language be dictated by the platform you want to code for. If there is a de facto standard, use that.

$\endgroup$
2
  • $\begingroup$ yes you are right but which resource is for learn new features of C++ ? there is site know as cpp reference but this one is not for me :( because i don't understand the concepts form documentation . can you plz guide me ! $\endgroup$
    – Hamza
    Jan 30 at 16:26
  • 2
    $\begingroup$ The books by Stroustrup (the author of C++) are good, for instance "Programming, principles and practices using C++". However, they are expensive, so I hope your library has them. You can also check out my book: tinyurl.com/vle322course $\endgroup$ Jan 30 at 17:18
1
$\begingroup$

As a software developer, I used C++ on several projects.

  • First I learnt C.
  • Then on the first C++ project I learn encapsulation.
  • Then on the third C++ project I learn some more.
  • Then on the forth C++ project I learnt Eiffel. In Eiffel I learnt polymorphism, inheritance, generics (templates), return type covariance, etc. ...
  • I then learnt how to do these in C++.
  • Then realised that C++ is a bad idea: It has some improvements to C, but also a load of blot, that gets in the way.

I wish I had learn Eiffel first, it is a much quicker language to learn. It is quicker to learn Eiffel and then C++. Eiffel is also a much quicker language to program in. And compiles to programs of similar speed to C++: faster for big complex programs, slower for simple programs (but not much).

Conclusion:

  1. Learn to program: Eiffel, Lisp.
  2. Use a high level language for most jobs.
  3. Use a hybrid of languages when you need to do low-level stuff.
  4. Use golang, Eiffel, or if you must C, for speed. There may be others.
$\endgroup$
4
  • $\begingroup$ Eiffel ? can you plz explain what is this ? btw I know the concepts of OOP but I don't know about modern C++ . $\endgroup$
    – Hamza
    Jan 31 at 14:46
  • $\begingroup$ Eiffel is an OO language. When you have used it, you will realize that java is not real OO. (smalltalk is another interesting OO) It compiles to C. It is fast. It is easy to learn. It is easy to use. It is powerful. $\endgroup$ Jan 31 at 14:50
  • $\begingroup$ much batter then C++ . ? : | $\endgroup$
    – Hamza
    Jan 31 at 14:54
  • 1
    $\begingroup$ Eiffel... Yeah it's a good reminder. 70-80s Pascal was the de facto teaching language. 80s shifted to scheme. Eiffel never became as big as these but it (was) still a good teaching language in the 90s. Post 2000 everyone's jumped onto some industry omnibus such as Java, Python, C++. And this baby — to teach programming one needs a teaching oriented language — is forsaken and destitute $\endgroup$
    – Rusi
    Feb 5 at 14:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.