Featured Post

Why this blog? What's it about? What's the format?

FORMAT For Fall 2021, the focus is mainly on Python, C++, and Digital Hardware There are videos here from other sources / creators There are...

Right click image below, then "open link in new tab"

Right click image below, then "open link in new tab"
Right click image above, then "open link in new tab"

Search This Blog

Friday, September 24, 2021

C++ About, Resources, Pros & Cons











Link to the C++ Foundation Website: www.ISOCPP.org

Information below is from this link and this link:

  • C++ (pronounced "see plus plus") is a computer programming language based on C. It was created for writing programs for many different purposes. In the 1990s, C++ became one of the most used programming languages in the world
  • The C++ programming language was developed by Bjarne Stroustrup at Bell Labs in the 1980s, and was originally named "C with classes". The language was planned as an improvement on the C programming language, adding features based on object-oriented programming. Step by step, a lot of advanced features were added to the language, like operator overloading, exception handling and templates
  • C++ runs on a variety of platforms, such as Windows, Mac OS, and the various versions of UNIX
  • C++ is a general-purpose programing language which means that it can be used to create different variety of applications
  • C++ is used for variety of application domains
C++ is a general-purpose programming language created by Bjarne Stroustrup as an extension of the C programming language, or "C with Classes". The language has expanded significantly over time, and modern C++ now has object-oriented, generic, and functional features in addition to facilities for low-level memory manipulation. It is almost always implemented as a compiled language, and many vendors provide C++ compilers, including the Free Software Foundation, LLVM, Microsoft, Intel, Oracle, and IBM, so it is available on many platforms.

C++ was designed with an orientation toward system programming and embedded, resource-constrained software and large systems, with performance, efficiency, and flexibility of use as its design highlights.

C++ has also been found useful in many other contexts, with key strengths being software infrastructure and resource-constrained applications, including desktop applications, video games, servers (e.g. e-commerce, web search, or databases), and performance-critical applications (e.g. telephone switches or space probes).

From the link:

C++ is arguably the most versatile language in common use. C++ allows for both high-performance code as well as expressive abstractions and design constructs. The language is not perfect but it does represent an excellent compromise between these potentially conflicting language capabilities. C++ combines "low-level" programming tailored to specific machine architectures with "high-level" programming, which can allow code to be completely abstracted from any particulars of the machine executing the program. Both approaches have pros and cons that we'll cover in this tutorial. If interested, Wikibooks also has material on this subject.


Why should you learn C++?

The C++ language originally derives from the imperative language C. The defining feature which distinguishes C++ from C is support for Object-Oriented Programming (OOP). This makes C++ a multi-paradigm programming language. An example that can help to demonstrate what OOP means:

If you were writing a program to track the statistics of a racing cyclist, you might make different parts of the program for their age, years of racing, wins, falls, what teams they've raced with and so on. In real life, though, that's not how we think. Instead, we would think of the cyclist as a whole, and the different statistics as being part of him. We could also apply that general "model" of a cyclist, maybe with a few modifications, to any cyclist, and have a complete representation of them. This is the essence of object-oriented programming, and as you understand it more fully, it will allow you to create powerful, yet easily-understood programs. Instead of relying on data that is scattered throughout a program, you can create a block of code that defines everything you need, and then reuse that throughout the program.

EXAMPLE: Think of a motor car. You unlock it with the key and get in. Then, you turn the ignition, put the car in reverse, release the brake, and press the accelerator. As you drive, you use the steering wheel, the brake, and the accelerator (and maybe the clutch). You don't know or need to know all the specifics of the car to make it work. You just use what you need, and it's simple, too. Object-oriented programming is like that. You can make powerful code, but it's all hidden, and you can interact and reuse that code using simple controls.

Other languages, such as Java, Python, Smalltalk and C#, allow the programmer to write code in this object-orientated way. The key difference between C++ and these languages is that C++ is designed to be compiled into efficient low-level code which can run directly on the processor of a computer. This ability means that C++ differs in many ways from these other languages, and lacks many of the advanced facilities you might be familiar with if you already know one of them.
Pros and Cons of C++

PROS:

  • Is extremely popular, and therefore lots of support is available
  • Has a large base of freely available code for download, while also supporting direct integration with ASM and C
  • Is very powerful, and can be used to create just about any program, including low-level system programs
  • There is a compiler for C++ on every major operating system. C++ programs that are purposely written for portability will work on many major operating systems with little change in code
  • C++ is a language which is compiled (transformed from human readable code to low-level machine code), so it can often run faster than languages such as Java, Python, and C#, as it does not depend on an interpreter or a "run-time environment" which must be loaded beforehand
  • Has a long-established usage base that likely guarantees support for the language will continue for quite some time
  • Many languages are based off of C/C++, such as Java, so knowledge in C++ will make it easier to understand these languages
  • Has a relatively small associated C++ Standard Library as compared to languages such as Java's Standard Platform SDK or C#'s .NET Framework, permitting greater versatility and reducing the system footprint of resulting compilations
  • Has been standardized by the International Standards Association as ISO/IEC 14882 with significant versions of the standard released in 1998, 2003 and 2011
  • Has a significant number of open source libraries available, including the Boost which are freely and widely available

CONS:

  • It is not very safe by itself, as it lacks automatic boundary checks, invalid pointer checks, etc., allows for invisible side-effects (causing non-deterministic behavior) and allows implicit type casting. Many security issues and memory leaks are a direct result of this, unless an extra effort is made to prevent them
  • By default, there is no built-in memory management, even if smart pointers introduced from C++11 allow automatic resource managment
  • Its OOP system is rather archaic, requiring explicit virtualization of methods among other things usually reserved for older languages
  • Lacks the ability to define completely custom operators. (Not to be confused with the ability to define custom implementations for a hard-wired set of operators, which C++ has.)
  • Does not offer full algebraic data types
  • Functions are not first-class types. (Although pointers allow for workarounds.)
  • Has a somewhat more difficult learning curve than some other languages. For instance, C++'s most powerful features, such as templates, have a very complex syntax
  • Is very picky how code is formatted (but not quite as picky as FORTRAN, RPG or Haskell). For example, if you forget to add a semicolon, the program won't compile.
  • GUI, Networking aren't standardized, requiring the use of non-standard, third-party libraries (though many such libraries, both free and commercial, are available, as is the possibility to use C libraries), Boost being one of the preferred. The lack of a standard, however, may hamper learnability and interoperability or at least require some extended investigation

No comments:

Post a Comment