Question C++ now is different from 6 years ago?

anandtechreader

Senior member
Apr 12, 2018
293
5
81
Hi, I took a course on C++ six years ago. Taking another course on using C++ to program but in the course notes there are keywords and things I am not familiar with. What happened to the language? A new version got updated over the past six years?
 
  • Like
Reactions: cbz6109

NTMBK

Lifer
Nov 14, 2011
10,240
5,026
136
There have been several versions of C++, C++14 and C++17. Plus your course may just be using C++11 features that you hadn't previously used- C++ is a big and complicated language!
 
  • Like
Reactions: robvas

mv2devnull

Golden Member
Apr 13, 2010
1,498
144
106
https://en.wikipedia.org/wiki/C++
C++ is standardized by the International Organization for Standardization (ISO), with the latest standard version ratified and published by ISO in December 2017 as ISO/IEC 14882:2017 (informally known as C++17).

The C++ programming language was initially standardized in 1998 as ISO/IEC 14882:1998, which was then amended by the C++03, C++11 and C++14 standards. The current C++17 standard supersedes these with new features and an enlarged standard library.
C++20 is the next planned standard thereafter, keeping with the current streak of a new version every three years.
It is also quite possible that the course six years ago was based on old (pre-C++11) material.
 

Cogman

Lifer
Sep 19, 2000
10,277
125
106
So far my impression is that they are making things more complicated by adding unnecessary fancy features.
Quite the opposite actually.

A lot of work in C++ has been around smoothing out rough edges.

Take, for example, unique_ptr, It was added because they found that people very frequently mishandled pointers while having very consistent expectations about how long the memory should live. unique_ptr solves a very common usage problem while providing protection.

nullptr solves the problem the NULL was very often just hardcoded to 0. The assumption, though, that NULL == 0 causes security issues, particular in kernels and embedded systems. nullptr removes that assumption entirely.

auto makes doing the right thing much easier. Ever try iterating a vector? It is quite painful without auto because the type declaration is a mile long. Yet using the iterator is both more flexible and safer than doing index calculations.

There are numerous cases like this where the C++ type declarations are too long for things where the type is obvious. Auto solves those problems.

Lambdas provide better composition features to the language. Yes they are complex, but a good list comprehension is much easier to grok than mile long if statements with huge for loops.

New libraries like "thread" add basic functionality which most expect. It makes it much easier to do things in a cross platform manner since it is part of language.

new keywords like final and override are really nice to have. It makes the compiler break when you expect something is overridden and allows for better communication of intent.

This is all assuming that you were taught C++03 6 years ago. It is unfortunately rare for people to teach "modern" c++.

"Modern" C++ is practically a different language from C++03, but it is for the better.

However, if this is too much, there's always rust ;)
 
  • Like
Reactions: Staples and mxnerd

Staples

Diamond Member
Oct 28, 2001
4,952
119
106
Very interesting. When I was in college 20 years ago, I took a few courses in C++. I've never touched it since. I have worked with Python, PHP, C#, JS mostly. It always irks me that every year a new version comes out with lots of new key words and constructs that do exactly what you could do 10 years ago with just a few more lines of code. I always was under the impression that C++ had not changed since the 80s and I'd kill to develop in a language that isn't constantly changing.
I never knew that C++ actually was an evolving language too.
I wonder if C changes any over the years.
 

Cogman

Lifer
Sep 19, 2000
10,277
125
106
States that the C standard has been revised in C99, C11, and C18 (although the last being just a bugfix).

C11 is a fairly minor update to the earlier C standard (C99). The changes to C have been very minimal compared to C++ changes.

There are a few QoL improvements in there, but nothing on the level of unique_ptr, move syntax, or a lot of the new template features that C++ now has.
 

Ajay

Lifer
Jan 8, 2001
15,468
7,869
136
OT, but...I learned, an programmed, mainly on C99 (actually, a very early draft standard). I hardly recognize C++ code today (the compiler must be huge!). I always wanted Ada95 and derivatives to win out - it seemed much easier to write really solid code in. Now I'm learning C# (&Unity), no opinion yet, except it's Java like.