Mardi 3 décembre
Les programmes vus en cours: argc/argv, throw/catch, template<…>
From the point of view of the compiler, templates are not normal functions or classes. They are compiled on demand, meaning that the code of a template function is not compiled until an instantiation with specific template arguments is required. At that moment, when an instantiation is required, the compiler generates a function specifically for those arguments from the template.
When projects grow it is usual to split the code of a program in different source code files. In these cases, the interface and implementation are generally separated. Taking a library of functions as example, the interface generally consists of declarations of the prototypes of all the functions that can be called. These are generally declared in a “header file” with a .h extension, and the implementation (the definition of these functions) is in an independent file with c++ code.
Because templates are compiled when required, this forces a restriction for multi-file projects: the implementation (definition) of a template class or function must be in the same file as its declaration. That means that we cannot separate the interface in a separate header file, and that we must include both interface and implementation in any file that uses the templates.
Since no code is generated until a template is instantiated when required, compilers are prepared to allow the inclusion more than once of the same template file with both declarations and definitions in a project without generating linkage errors.
vendredi 29 novembre
Les programmes vus en cours: gestion du tas, classe dynamique
In computer science, a memory leak occurs when a computer program incorrectly manages memory allocations. In object-oriented programming, a memory leak may happen when an object is stored in memory but cannot be accessed by the running code. A memory leak has symptoms similar to a number of other problems (see below) and generally can only be diagnosed by a programmer with access to the program. Because they can exhaust available system memory as an application runs, memory leaks are often the cause of or a contributing factor to software aging. Memory leak, Wikipedia
Twice a year, three Top500 lists come out to rank the world's supercomputers by either their overall performance, their ability to parse enormous data sets, or their minimal environmental impact. And last week the Top500, Graph500 and Green500 were released at the SC13 conference in Denver.
For more than 20 years, the Top500 list has used analysis of brute force computing power, the number of floating-point operations each machine could process per second, to determine the rankings for supercomputers. But parsing data and reducing environmental impact are two trends that have led to the Graph500 and Green500 lists.
The Green500 list provides a window into how difficult it is to build a supercomputer that can compete in terms of efficiency and low energy consumption. Only one supercomputer on this year's Green500, the Piz Dainte from the Swiss National Supercomputing Centre, is also ranked in the top 10 of the Top500.
Most Efficient Supercomputers Ranked On Green500 List, Lily Hay Newman, IEEE Spectrum Nov 2013
Vendredi 15 novembre
operator < <
operator <<, par exemple
Le concepteur de C++ est aussi un grand communicant, ce qui a sans doute significativement contribué à la large adoption du langage. Son site personnel déborde d'informations. Vous y trouverez par exemple un grand nombre d'entretiens. Pour un exemple récent, voir Bjarne Stroustrup Discusses C++.
Il maintient une liste des principales questions qui ont été posées à propos de C++. Voir en particulier celles sur l'héritage.
Plus étonnant, il maintient aussi une liste des grandes applications développées en C++: Geant4, GCC, Google, Microsoft, etc.
Here is a list of systems, applications, and libraries that are completely or mostly written in C++. Naturally, this is not intended to be a complete list. In fact, I couldn't list a 1000th of all major C++ programs if I tried, and this list holds maybe 1000th of the ones I have heard of. It is a list of systems, applications, and libraries that a reader might have some familiarity with, that might give a novice an idea what is being done with C++, or that I simply thought “cool”. Bjarne Stroustrup, Applications
Mardi 5 novembre
Le plus important: la documentation C++ en ligne
The C++ programming language has a history going back to 1979, when Bjarne Stroustrup was doing work for his Ph.D. thesis. One of the languages Stroustrup had the opportunity to work with was a language called Simula, which as the name implies is a language primarily designed for simulations. The Simula 67 language - which was the variant that Stroustrup worked with - is regarded as the first language to support the object-oriented programming paradigm. Stroustrup found that this paradigm was very useful for software development, however the Simula language was far too slow for practical use.
Shortly thereafter, he began work on “C with Classes”, which as the name implies was meant to be a superset of the C language. His goal was to add object-oriented programming into the C language, which was and still is a language well-respected for its portability without sacrificing speed or low-level functionality. His language included classes, basic inheritance, inlining, default function arguments, and strong type checking in addition to all the features of the C language.
[…] In mid-2011, the new C++ standard (dubbed C++11) was finished. The Boost library project made a considerable impact on the new standard, and some of the new modules were derived directly from the corresponding Boost libraries. Some of the new features included regular expression support (details on regular expressions may be found here), a comprehensive randomization library, a new C++ time library, atomics support, a standard threading library (which up until 2011 both C and C++ were lacking), a new for loop syntax providing functionality similar to foreach loops in certain other languages, the auto keyword, new container classes, better support for unions and array-initialization lists, and variadic templates.
Written by Albatross, History of C++
Vendredi 25 octobre
Les discours de Turing Award de Thompson et Ritchie en 1983
Vendredi 18 octobre
Le livre d'Abelson et Sussman a eu un énorme impact sur l'enseignement de la programmation et la popularité de la programmation fonctionnelle en Scheme. Le livre est entièrement disponible en ligne, associé à un site Web qui rassemble une mine d'exercices et de projets passionnants. Voici un article qui explique l'importance de ce livre.
In 2011, to celebrate the 150th anniversary of MIT, the Boston Globe made a list of the most important innovations developed there. They asked me to explain the importance of SICP, and this is what I sent them:
SICP was revolutionary in many different ways. Most importantly, it dramatically raised the bar for the intellectual content of introductory computer science. Before SICP, the first CS course was almost always entirely filled with learning the details of some programming language. SICP is about standing back from the details to learn big-picture ways to think about the programming process. It focused attention on the central idea of abstraction – finding general patterns from specific problems and building software tools that embody each pattern. It made heavy use of the idea of functions as data, an idea that's hard to learn initially, but immensely powerful once learned. (This is the same idea, in a different form, that makes freshman calculus so notoriously hard even for students who've done well in earlier math classes.) It fit into the first CS course three different programming paradigms (functional, object oriented, and declarative), when most other courses didn't even really discuss even one paradigm.
[…] In my experience, relatively few students appreciate how much they're learning in my course while they're in it. But in surveys of all our CS students, it turns out to be among the most popular courses in retrospect, and I regularly get visits and emails from long-gone students to tell me about how they're using in their work ideas that they thought were impractical ivory-tower notions as students. The invention of the MapReduce software for data parallelism at Google, based on functional programming ideas, has helped eliminate that ivory-tower reputation.
Brian Harvey, University of California, Berkeley
Mardi 15 octobre
Real-World (Out of This World) Story: The Mars Pathfinder mission was widely proclaimed as “flawless” in the early days after its July 4th, 1997 landing on the Martian surface. Successes included its unconventional “landing” – bouncing onto the Martian surface surrounded by airbags, deploying the Sojourner rover, and gathering and transmitting voluminous data back to Earth, including the panoramic pictures that were such a hit on the Web. But a few days into the mission, not long after Pathfinder started gathering meteorological data, the spacecraft began experiencing system resets. The press reported these failures in terms such as “software glitches” and “the computer was trying to do too many things at once”. Read What really happened on Mars? Also, be sure to read this follow-up message from Glenn Reeves of JPL, who led the software team for the Mars Pathfinder spacecraft. Michael B. Jones, Microsoft
4 octobre 2013
Language designers are forever searching for the “proper language” for a domain, task, or class of programs, such that everything – such as correctness, optimisations, abstractions, high-level structures, solutions to a problem, etc. – becomes clearer when the language is used. The four Rs capture the key aspects of programming language’s affect on programs, in its ability to improve reading, writing, running, and reasoning.
These are four important areas that we need to consider when designing effective languages. The four Rs are not meant to argue whether a language is “good” or “bad”, or to unilaterally promote one over the other. Instead, the four Rs provide a framework for thinking critically about the effectiveness of languages and language features. Trade-offs between the four Rs have given a broad and beautiful spectrum of programming languages over the last 70 years. I await further languages with excitement and hope that with better languages everything might become clearer.
The four Rs of programming language design, Dominic Orchard
24 septembre 2013
Abstract nonsense, or general abstract nonsense, is a popular term used by mathematicians to describe certain kinds of arguments and concepts in category theory or applications. The term goes back a long way, and even predates the foundation of category theory as a subject itself. Referring to a joint paper with Samuel Eilenberg that introduced the notion of a “category” in 1942, Saunders Mac Lane wrote the subject was 'then called “general abstract nonsense”'.
The term is believed to have been coined by the mathematician Norman Steenrod, himself one of the developers of the categorical point of view. This term is used by practitioners as an indication of mathematical sophistication or coolness rather than as a derogatory designation.
“Logical abstract nonsense is a subfield of general abstract nonsense”, Language Log
20 septembre 2013
10 septembre 2013
Measuring programming language popularity It is difficult to determine which programming languages are most widely used, and what usage means varies by context. One language may occupy the greater number of programmer hours, a different one have more lines of code, a third may utilize the most CPU time, and so on. Some languages are very popular for particular kinds of applications. For example, COBOL is still strong in the corporate data center, often on large mainframes; FORTRAN in engineering applications; C in embedded applications and operating systems; and other languages are regularly used to write many different kinds of applications.
Documentation C++ de référence: The C++ Resources Network
Tout le cours est construit sur le compilateur GNU
g++ version 4.8 et les outils GNU standard:
gdb, etc. Nous utiliserons aussi des outils avancés comme
valgrind. L'environnement recommandé est Linux Ubuntu, mais vous pouvez tout à fait travailler sur Windows ou Mac.
Attention cependant, les projets sont corrigés sous Linux Ubuntu. C'est votre responsabilité que de vérifier que tout marche bien dans cet environnement si vous développez autrement.
Un environnement de développement recommandé: Geany
Geany is known to run under Linux, FreeBSD, NetBSD, OpenBSD, MacOS X, AIX v5.3, Solaris Express and Windows. More generally, it should run on every platform, which is supported by the GTK libraries. Only the Windows port of Geany is missing some features.
Un site ressource sur les environnements de développement C++: la page Wikipedia sur les environnements de développement intégré (EDI)