The C ++ is a language that has seen its specifications pile up and stratify in the years.It is still widely used.But faced with competitors like Rust or Go, what is its place in an environment that evolves?
This dispatch which required a lot of discussion, aura, you will see, a somewhat special form.
Origin of this dispatch
Dispatch C ++ 17, genesis of a minor version received 227 comments representing a volume ten times higher than the dispatch itself.And these comments, very often well written, nourish well velus trolls!
The idea of creating this dispatch comes from two observations:
- l’énergie dépensée et les nombreuses heures consacrées à rédiger ces 227 commentaires est phénoménale ;
- en revanche, la lecture de tous ces commentaires est laborieuse.
With hindsight, we could have concentrated all this investment in a collaborative dispatch of the style "Today, is it relevant to choose the C ++ for a new application?», In order to structure and consolidate all the arguments dispersed over the comments.
Objective of this dispatch
This dispatch offers a much wider subject: "Should you continue to learn C ++?"»».And many quality comments of the C ++ 17 dispatch, genesis of a minor version deserve to be copied, improved or merged here.Unfortunately, these are rarely under compatible CC-by-Sa 4 compatible license.0.
Make a synthetic article on this issue is not easy.Indeed, the choice of a language for a project depends a lot on the context, in particular the field of application and the existing technical environment.In discussions on the choice of language, some will advance criteria, but they will be considered by others as unrelevant.
Even "historical" criteria of C ++ are no longer sufficient arguments in many projects.For example, C ++ is often mentioned for its performance when you want to create a video game.But nowadays, with the power available on the slightest device and the quality of game engines, it is only relevant than all those who want to work in video games learn C ++.
Likewise, if you take an area in which C ++ is generally not recommended, such as web development.And, however, very large web companies like Google or Facebook use C ++.
It is therefore advisable to return first to the criteria to be taken into account in the choice of a language, then to see the qualities and faults of the C ++ on these criteria.
Dialogue on various aspects of C ++ burning issues in 2018
Standardization, a process too slow?And what about the new ISO vs standard update of software (compilo, VM, etc..)))).
GBDIVERS: Standard vs lib?Why not put all the features in the standard.Example of Regex, NOTetwork, Unicode.
gbdivers : Les nouveaux langages sont‐ils meilleurs que les anciens langages ? De grands débats apparaissent : const
vs mutable
, ref vs copie, explicit
vs implicit
.
GBDIVERS: Can we consider breaking the retrocompatibility?The example of the python2 vs python3 shows the extent of the problems that this implies ...
Gbdivers: Complex?Oh yes !Multiplication of syntaxes, syntaxes not necessarily intuitive.
GBDIVers: complex passage between languages.
GBDIVERS: Learning C ++ is deemed to be difficult ...
GBDIVERS: Conclusion: is that C ++ is over?NOTope !
C ++ in short
Le C++ est un vieux langage (bientôt 40 ans)))) hérité du langage C avec lequel il entretient une compatibilité.
From all this long history, C ++ has evolved as best as possible between programming paradigms and new needs.In the end, its syntax evolves slowly, is complex, full of subtleties and slow to compile.
But it is also a language allowing optimizations of madness (costless abstraction)))).C ++ is used on a daily basis, it would only be most graphic environments and web browsers (to stroll on Linuxfr.Org)))).And C ++ will continue for many years to be used in production, especially for critical applications.
C ++ is not dying.On the contrary, C ++ has experienced a keen interest since C ++ 11.More and more people are involved in further improving this language, as on compilation speed which should be greatly improved with C ++ 20.
Alors, faut‐il tout effacer et recommencer un nouveau langage qui, par design, prend en compte les contraintes de concurrence (multicœur, NOTUMA)))) et de montée en charge (scalability)))) ? Des langages de programmation tentent d’obtenir des performances similaires avec une syntaxe expressive et concise.
The power of the C ++
The positive points that stand out the C ++ are its generic programming and its meta -programming which allow to have abstractions without performance penalty. Mais aussi les possibilités de libération déterministe et implicite de n’importe quel type de ressource au travers du RAII, si on le compare au C — les autres langages à exceptions disposent d’un ramasse‐miettes (garbage collector)))) et suivent le dispose pattern pour les autres ressources, voire offrent des facilités équivalentes au RAII (try‐with‐resources en Java 7, using
en C#, etc.)))).Some believe that if we do not benefit from these features, it is better to use another language.
The alternatives
Among these languages, excluding those who are only interpreted and those who use a pick -up, the only ones who could replace C ++ with equal performance are therefore: C, Rust and D.
Criteria to adopt a new language
But for a language to be adopted several ingredients are necessary:
In this field, C ++ is well equipped with many tools, libraries and communities.
Popularity of C ++
Et toi, chère lectrice, cher lecteur, penses‐tu que les nouvelles fonctionnalités du C++ ne font que compliquer inutilement le langage le plus complexe que l’humanité ait inventé ?Ou, au contraire, es‐tu persuadé·e que, grâce à ces évolutions, le C++ va progresser dans le classement du TIOBE Index et garder loin derrière des prétendants comme D, Dart, NOTim, Rust ou Pony ?
Other sources:
Questions
Go
Go was created by Google because the C ++ compilation became unacceptable for its server applications.
C ++ was initially created as an extension of the C, keeping compatibility with it, and not a pure object language.There is therefore a mixture between objects and primitive types (as in Java)))).However, unlike Java or C#, C ++ does not make fundamental differences between primitive types and objects defined by the user: it is up to the programmer to decide whether the types are copy, the use of references is explicit, the'Pile allocation is possible.
Certaines briques « de base », telles que les conteneurs ou les string
, sont toutefois arrivées tardivement dans la spécification, ou de manière incomplète. Ainsi, beaucoup de bibliothèques réinventent la roue, ce qui peut mener à des difficultés ou un surcoût (conversions multiples)))) dans l’interopérabilité entre bibliothèques.
The compiler makes it possible to make real metaprogramming.And it’s really used.The metaprogramming in C ++ is based on a structural typing model.
En revanche, il n’y a pratiquement aucune aide à la gestion d’erreurs, bien que C++11 ait introduit static_assert
.Error messages related to metaprogramming are often particularly cryptic and require a certain degree of habit or expertise to be understood, and even higher degree to know how to write highly generic libraries causing intelligible error messages.See on this subject the presentation of Roland Block given during the CPPCon 2015: PRUNOTINOTG ERROR messages from your C ++ Template code [slides].NOTote however that recent progress on the side of compilers, such as G ++ or Clang ++, make that error messages are a little less long than before.
Memory management, and resources in general, in C ++ is left to the developer.This has long led to the multiplication of problems such as memory leaks or use after liberation, which are manifested today in as many security flaws. Toutefois, C++ fournit maintenant des outils intégrés à la bibliothèque standard, qui suivent le principe de RAII (Ressource Acquisition Is Initialization)))) pour gérer finement l’utilisation des ressources. Ce principe a été repris et généralisé dans le langage Rust (créé par Mozilla)))), qui veut se poser en alternative, mais reste aujourd’hui inférieur en termes d’écosystème (SIMD, multicœur / OpenMP, toolkit graphique façon Qt)))).
D’un autre côté, si C++ trouve un moyen de détecter les vieilles constructions à éviter, que les types somme et le filtrage de type par motif (type pattern matching)))) est ajouté, que les pointeurs soient vus comme des types somme avec détection des « appels sur NOTULL » à la compilation, si des conteneurs sont introduits avec des interfaces fold/map/reduce pour réduire les erreurs off‐by‐one lors des parcours, si la compilation est plus rapide (peut‐être avec une gestion multi‐fichier du compilateur)))), si le modèle mémoire devient plus précis pour gérer les alignements mémoire, l’appartenance des objets en mémoire pour chaque fil d’exécution, et pour un éventuel ramasse‐miettes, C++ est là pour longtemps.
The specifications
Taken from the comment: https: // Linuxfr.ORG/NOTews/C-17-Genese-D-a-a-Vineure#comment-1676200.
The desire for compatibility of the different versions of the standard pushes the standardization committee to add parts rather than replacing them.This poses several problems:
In addition, the standardization committee is closed. Même si le langage est ouvert (son implémentation)))), les spécifications sont payantes et soumises à des droits.An aberration that sometimes leads to suspicions of corruption or at least a desire to maintain a special complexity to justify experts. Ces critiques sont toutefois largement injustifiées, les brouillons des spécifications (quasiment identiques à la version finale)))) étant en accès libre, et le comité de normalisation s’étant énormément ouvert à la communauté C++ depuis le début des années 2010.
The standard not homogeneous library
Taken from the comment: https: // Linuxfr.ORG/NOTews/C-17-Genese-D-a-a-Vineure#comment-1676200.
La bibliothèque standard est très poussée pour des domaines assez pointus (comme les mathématiques)))), mais ne propose rien pour des usages très courants comme le multitâche qui est, lui, géré nativement par Rust.
Daily problems seem complicated
Taken from the comment: https: // Linuxfr.ORG/NOTews/C-17-Genese-D-a-a-Vineure#comment-1676523.
Des problèmes tout à fait quotidiens (comme le fait de n’inclure qu’une seule fois chaque fichier à la compilation)))) n’ont pas de solution triviale.Each developer or each project therefore manages this in its own way with potentially errors and without capitalization within the C ++ community.
Dependence, portability, construction and reproducibility
NOT.D.M.: Paragraph to work, I throw loose ideas
C ++ dependencies management is complex.You have to be able to compile software in a reproducible context, which, in the best of cases:
This type of problem is often managed in other languages by outbuilding tools, such as Python with Pip, Haskell with Stack, etc..These tools allow you to build your program in a limited environment by providing all or part of the guarantees listed above.
To my knowledge, there is no multi -flat -formal tool of this type in C ++.Thus, each library comes with its own method of non -generic compilation and installation and the packaging of a program often amounts to doing yourself, by hand, the construction of all dependencies in a dedicated project of the project,which becomes tedious when you also try to ensure version numbers of the compilation tools used.
Under Windows, there is nothing really solid, each year sees its share of packet manager, like Chocolatey, but nothing sufficiently robust or exhaustive allowing to choose the exact versions of libraries and tools.
Sous GNOTU/Linux, chaque distribution propose son gestionnaire de paquets, garantissant que les dépendances fonctionnent au sein du système.However, if the library version provided does not correspond to that necessary for the program, we come back to hand management.
On peut aussi utiliser une technologie de conteneur léger comme Docker et installer une distribution GNOTU/Linux spécifique avec un ensemble de paquets choisis.But this method poses the problem of performance.However, one of the reasons for the use of C ++ being performance, we can find ourselves blocked [Quote/Link Needed].
Advantages of C ++ on other languages
The C ++ still has advantages that we do not find in any other or practically:
std::vector
)))) n’est pas forcement compatible au niveau binaire avec son équivalent Rust, imposant la création d’une interface.NOTote aux lecteurs‐commentateurs
I give examples of libraries from this industry because it is the one I know and it is currently the only reason that justifies our use of C ++.Other people are invited to add examples coming from other industries.In a fun way, it is often said that languages like Python are used to make glu on the entries of a program and that the heart is written in a more "serious" language type C ++. NOTous, nous aurions plutôt tendance à vouloir utiliser du Rust ou du Haskell pour le cœur et à utiliser C++ pour la glu et les entrées‐sorties.It is a fairly fun and counter -current point of view of the usual ideas.
And this is this point on performance while being relatively high level that makes C ++ a language that cannot be replaced in many projects.The only candidates are so very old languages who ultimately have evolved less (Pascal, Fortran ...)))).Very often, we develop an application in a high level language (python, php, ruby or other)))).Then comes a time when, for reasons of performance, we must rewrite the most stressed parties.For example, in our society, we develop in PHP and AWK.And when the servers are increasing, the heart is reparaced in C/C ++ and keep a bash or PHP layer above.The reason why we do not develop directly in C/C ++, is that its development and maintenance are longer.In C/C ++, a bug can occur on a detail difficult to identify, where the PHP, very tolerant, accepts problems.There is also in C/C ++ the risk of no longer knowing which exact version of the code had been used to compile the previous version and therefore a difficulty to know if during an update the latest developments of the code will not disturb theoperation in place.In other words, it is difficult to know between two executables what are the modifications made.
The C ++ also appears in the embedded.Where there was only a dies and C, the logical suite for ever more complex components is C ++.First through the simple use of classes, allowing better architecture either by encapsulation or by inheritance.But more and more, we see pieces from the standard library arrive, as the embedded accepts the dynamic allocation of memory.
Another C ++ force is the basis of users knowing it, because of its longevity - it dates from 1983.
Samsung Galaxy S22, Uncharted et pl...
Tesla: you can now enjoy YouTube in...
EM – Butler vs Purdue Basketball Li...
Nantes. A child victim of an acci...