As someone who never learned a coding language before how do you recommend learning C++?

Pages: 12
I will wait for VS 2022 to be officially released, out of preview status, before I go with it.


Yeah - some updates are flaky! A couple of weeks ago a version was released where if you tried to type #include <iostream> the whole IDE crashed! You had to type iostream and then add the other parts! Fixed now though.
The VS 2022 preview candidate I tried couldn't compile a couple of C++20 snippets that VS 2019 has no problems with. That is the main reason why I will wait for the official release. I don't give a flying fig if they fixed the issue.
Simple data structures (linked list etc) were covered in year 1. The more advanced structures (trees etc) were in year 2 (again with Pascal). Advanced algorithms (eg graphs etc) were covered in year 3 with Algol68/Snobol/Lisp.

Your 3 years were crammed into 3 semesters for me LOL. I don't even know what my CS classes are now, they have almost nothing to do with programming.
The Grey Wolf

Well, I am learning C++ because my freshman year CS course mandated it as the first language. I figured if I am going to use something for a semester or longer I should at least get very good at it beyond grades. I also think C and C++ are good for understanding the fundamentals of computer science I want to give it a solid 6 months effort to see if I have what it takes.

To simplify how I like understanding things I like first understanding the broad big picture stuff then I try to work my way up in a linear fashion. Although to be fair I have not learned very many skills in my life so it is hard to say. Everything I have done was based on stuff I already had a good idea of. So coding is a new thing for me because I am actually learning something not based on a lot of old knowledge beyond basic math.

What I am doing rn now is not mandatory for class I mean some of it is but it's really for my own sake. I also just think the C family embodies the fundamentals of coding and will make everything down the road easier.
Kavaxes121, I'm no experts on teaching, just want to put that out there, so feel free to ignore me.

As someone who never learned a coding language before how do you recommend learning C++?My personal preference is to learn from a few good books. I find the single 'voice' and structured path through the material better than searching out bits and pieces on the web and try to fit them together. To this end I would say take a look at:
Programming: Principles and Practice Using C++ by Bjarne Stroustrup


There is a book (not C++) that I wished was available when I started with computers. Again I would try to find a copy to look at first, don't jump in and buy it 'cause it is a bit pricey for it's size so I comes down to if you find the information within worth the cost.
Computer Science Distilled: Learn the Art of Solving Computational Problems by Wladston Ferreira Filho

When I first tried learning C++ I used a book, a nice fat one. I didn't even read a single page. Something about learning from a book is just such a turn-off from learning.

Learncpp.com was the best source I could have ever found.
I much prefer learning from a book than using an on-line resource. Probably because of my age and what I'm used to. When I was learning Computer Science there was no such thing as 'internet'.

For a book for learning C++, my recommendation is:

Beginning C++20: From Novice to Professional by Ivor Horton
https://www.amazon.co.uk/Beginning-C-20-Novice-Professional/dp/1484258835
You've had some good advice in these posts, I'll try to avoid repeating.

If books are good for you, start there. If zapshe's site (which I've not seen) is a better approach, fine.

Either way, the key is to experiment, and to find fascination. Write, debug (learn to use a debugger), and continue. The early examples are usually boringly simple. Most avoid GUI development until very late, while Stroustrup, using a simple GUI framework, mixes that in as early as he deemed possible, having feedback from students about the nature of boring example projects.

Each of us who work in this field and know very well how to produce working software took different paths, some associated with the era in which we began. In your case, C++ has been mandated to you, so you're committed on that path. I have a few points relative to posts here, including yours, about that.

C was originally developed to write the UNIX operating system. It was intended to operate close to the nearly mechanical nature of the hardware, but to remain independent of that hardware so as to support porting UNIX to new computers as they were developed from the 70's forward.

Over time, many applications were written in C, showing it had some applicability outside operating systems. Perhaps too many applications, actually, making it a central language to know.

C++ was designed to exploit the popularity of C, but to be more suited for application development while retaining the option of writing fast, efficient, machine like code for performance.

Of late, the goal has been to offer that to non-specialists. The critique has been that C++ requires expertise, and so only experts manage to use it well. It is a large, complex language, and to some extent is two language mashed together, despite posts here stating these are two separate languages. My point is not to contradict that, but to expand that into a point Stroustrup made several times...C is inside C++ for a reason. The are there together. You can write C code with hardly any exception (save the latest versions) while "in C++". To do that, though, you must understand the differences...because there are differences, despite the fact they are "combined".

It is possible to learn C without ever considering C++. It is less possible to learn C++ without some knowledge of C, though not impossible. There are what colloquially we say are "C" styles or "C" ways of doing things, and then there are "C++ ways of doing things. I think it more accurate to say there are approaches to writing which are very machine oriented, very close to the way the hardware (CPU/RAM) works, which is what C was designed to target, and then there are higher level concepts of writing that focus on particular subjects, like math (say, linear algebra), or graphics (colors, filters, sharpening, fog, light), or biochemistry (simulating the function of proteins), or robotics (reverse kinematics...how to use trig to set the angles of the elbow and wrist so the fingers touch a target).

After you get past the basics, a game is likely a useful learning tool. I personally chose a Pacman like game for students in the late 90's, but back in the late 70's when I was a child my choice was a game themed after the Skywalker's flight in the trenches of the Death Star in the first Star Wars film.

The latter was a bit much for the computers of the late 70's, and for my limitations in math, but the fact it fascinated me was the key which unlocked my entire career. If not for the motivation of that fascination I wouldn't have kept at it for such an ambitious target (for that era), but I did...and it worked, both the task of learning and that game (I sold it for $3 a copy for a year, had to avoid any trademark references...paid for my first car). It wasn't in C, though...it was in 6502 assembler.

A simple, 2D game, though, is usually within most student's grasp. The GUI toolkit Stroustrup uses in his book, "FLTK", is enough to manage a rudimentary student project of that type.

Though, perhaps you'd choose a board game...animation is, itself, a bit of a stretch sometimes, depending on the student.

In a previous text, Stroustrup once suggested the "learning curve" for C++, expressed in how long it took to learn the language, at 18 months. That was before C++11. I think it takes longer now.

That said, I am referring to the entire modern version and assuming a dedicated student.

What you're in need of learning is the early portion, and not the full C++ to C pathway an expert would require. That would come later.

If you avoid the "C" way of doing things, which is highly advisable, you'll learn the part of C++ which has the same kind of flavor of Java or C#, that of a simplified study with fewer bugs.

Since you're not already familiar with that, let me preview that for you.

The raw machine (CPU/RAM, etc) is quite primitive. It only knows basic operations, like addition, multiplication, comparison, copying, jumping (from to memory locations, often after a test for > or < or not =, which is similar to jumping to "step 6" or "step 7" in a list of English instructions).

That raw machine doesn't know words, or strings. It doesn't "do" much on it's own.

You do, as a C programmer, or an assembler programmer. You and the CPU become close partners in pulling off what you need done. It isn't pretty. If you need to store a name, say "Anderson", you need 8 characters. There must be room for a zero byte to terminate the string, so you ask the OS for at least 9. If you're wrong, and you need more room than you asked for, the program will crash.

In C++, however, you have a string class. You don't need to ask for room first, it will allocate space as required. This can be a bit wasteful, sometimes, but it is convenient. As an early student, this "protection" is quite helpful. It is standard with languages like C# or Java, but in C++ you have to choose to use this class. You could, if you prefer, "do" this in a "C" style, just like C...and suffer a crash if you're wrong.

There are usually multiple ways of doing things in C++, some which are "like C", others which are more convenient and easier (and more reliable), which makes the study of C++ much harder than with languages that are intentionally focused on one approach that is safe and convenient by nature.

A good text or website will guide the novice toward these safer and simpler means of every task, leaving the more complex "C" style approaches for later.

To this point I address your comment, "I also think C and C++ are good for understanding the fundamentals of computer science"...I would rephrase and separate the two languages into this:

You'll need to know more computer science to write in C.
You'll need computer science to write anything of value in any language, but the less leverage a language provides to you, the more computer science you'll require to get things done.

Here's where you'll find the STL useful. Computer science is not computer programming. Programmers use computer science, but depending on the language and its features, they may not need much for the targets they address.

The STL (standard template library) provides much of what computer science would teach you. For example, where computer science may teach you how a binary tree works and why you'd use it, the stl provides containers like "map" which implement a tree for you. You can learn to use the "map" in a few days. You'd need months to learn the computer science that goes into making the software provided in "map".

C, on the other hand, does not have a "map". The most it provides to you is "qsort", and some memory operations that can be applied to strings, but not all that much else.

Computer science would teach you about queues. The STL provides you with "deque", which handles some (perhaps a lot) of what queues do. Compute science would teach you how to sort. C provides qsort, and C++ adds "sort", which works with the stl containers. Also, "finding" things once they're sorted.

Good luck








Topic archived. No new replies allowed.
Pages: 12