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

Pages: 12
Is it possible to learn a low-level machine language like C++ as a first language?
Been going at it for the first few weeks mainly from lectures from my professor and youtube follow-throughs. It's been great at first... but as of lately I am not making progress with youtube videos.

Either the content I find is too advanced and I am completely confused or it goes over the basics and I am just repeating things I have seen before. I just don't know how to get to the next step beyond learning the absolute basic tier stuff. Any advice I did buy a book on C++ so hopefully, that will help.
C++ isn't all that low level. Medium level more like it.

Yes, it is entirely possible to learn C++ as a first programming language.

A lot of youtube videos are, to be honest IMO, a steaming pile of manure.

You might try online written tutorials to help push your knowledge along. Two that I would recommend are:

1. C++ Language Tutorial - http://www.cplusplus.com/doc/tutorial/ It is more than a bit outdated, no C+14 or later.

2. Learn C++ - https://www.learncpp.com/ This is is kept up to date, though still isn't fully in-depth on what the various C++ standards after C++11 have to offer. You should consider this one of the go-to online tutorials.

For a very technical reference site wander over to https://en.cppreference.com/w/ Lots of code snippet examples, but not geared for a beginner.
Hi,

This guy has good videos for beginners and beyond. He also does stuff related to game engines and physics too.

https://www.youtube.com/playlist?list=PLlrATfBNZ98dudnM48yfGUldqGD0S4FFb

Is it possible to learn a low-level machine language like C++ as a first language?


I would argue that C++ is not a low level machine language: maybe there is confusion about C language or even assembler?

Of course anyone could do C++ as a first language. I would recommend starting out with std::string and std::vector from the STL (Standard Template Library).

There is a tutorial on this site, and lerncpp is apparently a good site too.

C++ is one of the most mis-taught languages, don't start by learning the C language - it is an entirely different animal. As in there is a whole different way of thinking involved between the two.
Furry Guy (3105)
(Sorry I don't know how to @someone on here)

Just wondering what IDE do you use? I currently just use Visual studio code to write my code and then I compile it using an ubuntu terminal I installed. I know a lot of people use code blocks is that any better? I am not sure which version of C++ I am using although I am pretty sure it is the most recent(sorry if I sound like an idiot).

TheIdeasMan (6470)

https://www.youtube.com/playlist?list=PLlrATfBNZ98dudnM48yfGUldqGD0S4FFb
I'll be sure to check out that channel more I used it to solve a few problems already but it wasn't the main one I used.


Also from the STL did you mean #include <string> and #include <vector>? I use string frequently although I don't think I have not used vector yet what does that one do?

You could be right me mixing it up with C my one friend who gave me some advice uses both so I could have mixed them up.
Also from the STL did you mean #include <string> and #include <vector>? I use string frequently although I don't think I have not used vector yet what does that one do?


Yes, If one is to use those, then need to include the header file for them. Have a look a the tutorial on this site, look at the examples.

Do some research to find out what the STL is.

I use VS Code too. It is possible to get it to compile as well, but it is good learning to compile from the shell as well.

It is sometimes instructive to use a different IDE such as Code Blocks, it has some good things, but I wouldn't have said it is better than VS Code. A couple of things I didn't like about C::B was the inability to use version control such as git; and a lack of any kind of background compilation to show errors as one types. Not sure if the later versions of C::B have this.

With the c++ version using the shell, it is an argument to the g++ or clang++ command that one is using.

$ g++ -v

Will show which version of the compiler you have, (I have 11.2, the latest one) then:

$ g++ -std=c++20 -Wall -Wextra *.cpp -o MyProg

specifies the c++20 standard, compiles all the cpp files, and produces the executable MyProg.

If you don't have the latest compiler, it should be easy to upgrade it.
I dislike videos for this kind of material. Two key reasons (there are others that are more personal preference than issue):
- you can't copy what they typed from a video. It may be online elsewhere or not, but its a hassle either way.
- speaking is about 10-20 times slower than printed text. For the same 1/2 hour, a video presents a short paragraph vs the 2-3 pages you could read and absorb.

so I do recommend reading text or a book (books are pricey, and everything in them is online and more up to date online, so I would fish the web like learncpp site but books work if they help you to be organized).

a simple c++ study would be something like
1)basic types and structures. Int, double, string, 3 loop types, if/else conditions.
2)simple functions, Data only structs, switch statement
3) add functions to structs, simple recursion, references
4) wrap up language basics.. arrays, classes (from a know about struct standpoint), simple pointer work, mention template classes in the context of using them eg vector<type>
5a) advanced provided stuff (text and binary files, cmath, string tools, those 10 headers every program has)
5b) more of the above... simple exception handling, command line args, ...
6) overview of what is provided for you: intro to vectors, algorithms, tuple.. etc
7) advanced overview of what is provided: the other containers and more
8) advanced classes 1, intro to inheritance, OOP principles 101, rule of 3/5/etc
9) advanced classes 2, polymorphism, multi inheritance, initializer lists, more
10) advanced template classes
11) circle back to a sample of common C style idioms like c-strings, macros, unions, <memory>, pointers, etc. Things you won't write much of but may need to understand in existing code.

Something along those lines. The order is different but each of the sections I listed should have a learncpp page. Each number after about 4 is probably a couple of weeks of material including doing some practice programs, so this is a good year long investment. The good news is that by tick number 4 or so you can do a lot of practice programs with what you know. You may do it better later with something you learn after, but the first basic things are still very powerful.

Remember: C++ is huge, and memorizing it all is not possible for most mortals. Its better to use a reference to see if it has what you wanted than to try to memorize all that on the algorithms, containers, and high level tools side. Focus on the things you use most ... "hey this program uses string, math, user I/O, and my last program did too!!" and get those to stick first.
Remember: C++ is huge, and memorizing it all is not possible for most mortals. Its better to use a reference to see if it has what you wanted than to try to memorize all that on the algorithms, containers, and high level tools side. Focus on the things you use most ... "hey this program uses string, math, user I/O, and my last program did too!!" and get those to stick first.

jonnin (9428)
So what I got from this was to try learning all the concepts above you had listed. And as well try to learn the fundamentals first and foremost so that everything else will fall into place... Is that what you were getting at?
Last edited on
> And as well try to learn the fundamentals first and foremost so that everything else will fall into place...

Learn the most useful ideas first; learn to use std::string and std::vector first, built-in arrays and pointers can come later.

The posts in this old thread may be of interest: https://www.cplusplus.com/forum/lounge/183836/

As Cubbi points out, the farther you get in modern C++, the simpler it gets to *use* the language.
Right, get the basics down, and look up the rest. I still look stuff up frequently ..
C++ is a low level language masquerading as medium. To use it well, you need to understand something of the hardware you’re programming.

If you want to learn programming, start with Ruby or Python, or something like that. Then you’ll be better placed to grapple with the details of computing in general, rather being overwhelmed at the start.
To use it well, you need to understand something of the hardware you’re programming.


yes as an expert - but not needed as a beginner if C++ is taught as C++ instead of as often C with bits added on....... string, vector, array, streams, containers, algorithms etc all can be learnt/used without any need to know anything about cpus/memory/32_64 bit etc etc etc

In my day, C was taught as the first language. Most folk dropped out, or simply never bothered with programming after that.

Why put a beginner thru the misery of learning about programming thru C++? Aren’t references, pointers and the increasing Pythonization of the language just details that you don’t need to get started?
Yes, pointers are indeed details you don't need to know/learn to get started with C++.
references are very important. You need them for parameters and range for loops and so on.

Pointers are also very important. Hands-on dynamic memory management, not for a beginner, it can be put off for a long while. But you will need actual pointers; many functions (binary files, networking, threading, others) require a basic knowledge of pointers as addresses of things. They also help understand the concept of an iterator.

---------------
there are schools of thought on the best way, I guess. Most universities have moved to java as the first language. The way it is presented makes no sense to the students... but it has a defined pattern they can memorize and function with.

If you learn c++ first, everything else will be relatively easy. I can say that from experience; I have written a few dozen small but important programs in languages I did not know at all, just poke the internet and glue stuff together. I could not do that if all I knew were C, as most of those languages are OOP heavy (objects when none needed, like java). And if I had learned java first, I would have struggled with anything using a pointer or procedural languages. C++ has almost everything any other language has, give or take a few exotics. The other languages frequently are missing large swaths of features. It does not hurt that approximately 50% of the top languages follow C or C++ like syntax to some degree.

But, c++ is tough. I don't know which is better, I just know that people learning lite languages first struggle with c++ even after knowing a good bit of general design and programming.

Last edited on
What IDE do I use?

Multiple ones, including a stand-alone compiler that isn't an integrated development environment.

Visual Studio 2019 Community, Code::Blocks and MSYS2.

I tried Visual Studio Code and found it harder to work with than C::B.

I will wait for VS 2022 to be officially released, out of preview status, before I go with it. 2019 works with C++20 with just a minor hiccup. Some C++20 features require compiling as /std:latest to work instead of /std:c++20. Coroutines is one of those features, ranges relies on coroutines with VS.

FYI, I've been self-teaching C++ since long before C++11. IIRC from before the time of C++03, after C++98. No formal classroom instruction. Lots of book reading, with now online tutorials and technical articles.

C++11 is considered as being the beginning of "Modern C++." Teaching anything less is a crime against humanity IMO. The way C++ is taught TO A BEGINNER by a lot of schools/universities teach C++ as if it were merely "a better C".

The changes the language has undergone since C++98/03 is staggering. I own several "Learn C++ in X days/hours". The emphasis in the lessons shows a definite change away from writing custom containers towards using standard library components. The core concepts (variables, functions, etc.) are tweaked in minor respects as well.

Does a beginner really need to know how to, for example, construct a singly linked list? IMO absolutely not. The C++ standard library already has one.

An intermediate/advanced student should be exposed to the "how does it work" though.

For me I am more interested in using what C++ has to offer, in all its myriad revisions. Knowing what is going on "under the hood" is of lesser importance to me.

YMMV.

See "forward and reverse for loops with C++ containers" - http://www.cplusplus.com/forum/general/279811/ to get a glimpse of my use-based way to understanding C++.
Does a beginner really need to know how to, for example, construct a singly linked list?
...
An intermediate/advanced student should be exposed to the "how does it work" though.

An intermediate student should be able to craft a binary search tree container, which the STL lacks.
They may do that using a vector (push-back is 'new', [index] is a 'pointer', etc) but should be able to do it somehow, whether using pointers or not. An advanced student should be able to make it like an STL container, templated and iterated etc. Yes, there are libraries, so you wouldn't have to do it, but you should know how at that level. To be able to do that, you would know how to do a linked list and probably have to do one to get to that level.
Last edited on
> binary search tree container, which the STL lacks.

std::set<> and std::map<> provide the functionality of binary search trees.
In fact, they are almost universally implemented as red-black trees.
This is true. But the argument still stands... graphs or N-child trees or various other odd constructs are eventually going to require the coder to build something that is not available if working with that kind of data or problem sets. I still believe an advanced student should be able to do these things, if required, though the actual need for them will be low in most of the industry and again, you can always find a library for such things. I dunno :) Its hard to justify saying something rarely needed is a must have skill, but I feel that it would be a gap if the coder could not do it.
Last edited on
Kavaxes121, I have a few questions. Firstly, can you give us some idea about where you want to go with this? You mention lectures from your professor, is this something you want to do in the future or you want to do well in to pass a course. Do you want do write applications, do system programming, embedded, games, etc.

Secondly, how do you like to learn new thing? Do you like to dig down to the nitty-gritty parts and build up your understanding from the ground up, or do like high level gluing bit together to get big results and leave the details of what's going on until later?

everyone else, in a situation where someone is learning to program with C++ as their first language, do you see this as two separate but closely coupled things, learn to program and learn C++, or just one thing? If you push me, I'd probably go with the first, so you end up learning the C++ that supports your learning of programming and not the C++ that you end up using that abstracts away the detail that you now but don't want/need to worry about. But then I guess this opens the question about what do you need to know to be a programmer? Do you need to have an understanding of how computers represent number, a mental image of memory layout, etc.

One reason I don't have a fully nailed down opinion of this is that the university I went to didn't teach a language as such. There was lots of pseudo code and diagrams with concreate examples in a number of different languages. Across eight modules in the first year I think there were five different languages used.



At uni, we learnt programming via learning Pascal and PDP11 assembler. That was all we used in the first year. In the second we were introduced to Fortran 77 and Cobol and then in the third to Algol68, Snobol and Lisp. It was only in the third year that we really started to cover abstracts. 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.

Pages: 12