1. A bit of C++ evolution history.
2. Why C++ became popular and why C++ started to lose its popularity.
3. Why C++ is a Monster? If C ++ is a monster, then why does 4. someone need C++?
5. How to use C++ safely and efficiently?
6. Where and when C++ can be used. If it can...
7. Pressure to C++ from competitors. Real and imaginary.
Rainer Grimm, “Functional Programming in C++11”Platonov Sergey
C++ это мультипарадигменный язык, поэтому программист сам может выбирать и совмещать структурный, объектно-ориентированный, обобщенный и функциональный подходы. Функциональный аспект C++ особенно расширился стандартом C++11: лямбда-функции, variadic templates, std::function, std::bind. (язык доклада: английский).
Rainer Grimm, “Functional Programming in C++11”Platonov Sergey
C++ это мультипарадигменный язык, поэтому программист сам может выбирать и совмещать структурный, объектно-ориентированный, обобщенный и функциональный подходы. Функциональный аспект C++ особенно расширился стандартом C++11: лямбда-функции, variadic templates, std::function, std::bind. (язык доклада: английский).
Bartosz Milewski, “Re-discovering Monads in C++”Platonov Sergey
Once you know what a monad is, you start seeing them everywhere. The std::future library of C++11 was an example of an incomplete design, which stopped short of recognizing the monadic nature of futures. This is now being remedied in C++17, and there are new library additions, like std::expected and the range library, that are much more monad-conscious. I’ll explain what a monad is using copious C++ examples.
Presented by Stephen Murtagh, Etsy.com, Inc.
TF-IDF (term frequency, inverse document frequency) is a standard method of weighting query terms for scoring documents, and is the method that is used by default in Solr/Lucene. Unfortunately, TF-IDF is really only a measure of rarity, not quality or usefulness. This means it would give more weight to a useless, rare term, such as a misspelling, than to a more useful, but more common, term.
In this presentation, we will discuss our experiences replacing Lucene's TF-IDF based scoring function with a more useful one using information gain, a standard machine-learning measure that combines frequency and specificity. Information gain is much more expensive to compute, however, so this requires periodically computing the term weights outside of Solr/Lucene and making the results accessible within Solr/Lucene.
Razvan Rotari shows an experiment to see how far you can go with binding in C++; Cristian Neamtu follows with an insight on how to achieve this in Rust using Serde.
What's new with C++ since, oh, before the dot-com bubble? Learn more in this Lunch and Learn, with a refresher of C++ basics, C++/CLI for C# developers, and the new features of C++11/14 and possibly C++17.
PVS-Studio team experience: checking various open source projects, or mistake...Andrey Karpov
To let the world know about our product, we check open-source projects. By the moment we have checked 245 projects. A side effect: we found 9574 errors and notified the authors about them.
44CON 2013 - The Forger's Art: Exploiting XML Digital Signature Implementatio...44CON
Many security critical systems rely on the correct implementation of the XML Digital Signature standard for the purposes of verification and identity management. Technologies such as SAML and Web Service Security use the standard, and its sibling XML Encryption, to manage the security of these technologies. Being a standard there is, unsurprisingly, no canonical implementation for any platform or language, with so many different developments there are likely to be differences in how the standard is interpreted.
This presentation is about research done against the main open and closed source implementations of XML Digital Signatures, how they can be exploited to gain remote code execution, signature verification bypass or denial of service. It will show some of the more nasty vulnerabilities found during the research including a novel attack against the built-in Java and .NET libraries which allow for trivial signature spoofing exposing any user of those implementations into accepting an invalid signature which is independent of their usage.
This is a roughly O(n) algorithm that generates the kth lexicographically ordered permutation of an n-element array from the integer k. Example, for a three-element
array:
0 --> 0 1 2
1 --> 0 2 1
2 --> 1 0 2
3 --> 1 2 0
4 --> 2 0 1
5 --> 2 1 0
25 лет истории C++, пролетевшей на моих глазахcorehard_by
Автор доклада познакомился с C++ в 1991-ом году, а с 1992-го года C++ является для докладчика основным языком разработки. Что происходило с языком за это время? Как и почему он стал популярным? Как начался застой в развитии C++? Как C++ потерял свою популярность? Есть ли место для C++ в современном мире? Попробуем поговорить об этом опираясь на 25-летний опыт программирования на C++.
Bartosz Milewski, “Re-discovering Monads in C++”Platonov Sergey
Once you know what a monad is, you start seeing them everywhere. The std::future library of C++11 was an example of an incomplete design, which stopped short of recognizing the monadic nature of futures. This is now being remedied in C++17, and there are new library additions, like std::expected and the range library, that are much more monad-conscious. I’ll explain what a monad is using copious C++ examples.
Presented by Stephen Murtagh, Etsy.com, Inc.
TF-IDF (term frequency, inverse document frequency) is a standard method of weighting query terms for scoring documents, and is the method that is used by default in Solr/Lucene. Unfortunately, TF-IDF is really only a measure of rarity, not quality or usefulness. This means it would give more weight to a useless, rare term, such as a misspelling, than to a more useful, but more common, term.
In this presentation, we will discuss our experiences replacing Lucene's TF-IDF based scoring function with a more useful one using information gain, a standard machine-learning measure that combines frequency and specificity. Information gain is much more expensive to compute, however, so this requires periodically computing the term weights outside of Solr/Lucene and making the results accessible within Solr/Lucene.
Razvan Rotari shows an experiment to see how far you can go with binding in C++; Cristian Neamtu follows with an insight on how to achieve this in Rust using Serde.
What's new with C++ since, oh, before the dot-com bubble? Learn more in this Lunch and Learn, with a refresher of C++ basics, C++/CLI for C# developers, and the new features of C++11/14 and possibly C++17.
PVS-Studio team experience: checking various open source projects, or mistake...Andrey Karpov
To let the world know about our product, we check open-source projects. By the moment we have checked 245 projects. A side effect: we found 9574 errors and notified the authors about them.
44CON 2013 - The Forger's Art: Exploiting XML Digital Signature Implementatio...44CON
Many security critical systems rely on the correct implementation of the XML Digital Signature standard for the purposes of verification and identity management. Technologies such as SAML and Web Service Security use the standard, and its sibling XML Encryption, to manage the security of these technologies. Being a standard there is, unsurprisingly, no canonical implementation for any platform or language, with so many different developments there are likely to be differences in how the standard is interpreted.
This presentation is about research done against the main open and closed source implementations of XML Digital Signatures, how they can be exploited to gain remote code execution, signature verification bypass or denial of service. It will show some of the more nasty vulnerabilities found during the research including a novel attack against the built-in Java and .NET libraries which allow for trivial signature spoofing exposing any user of those implementations into accepting an invalid signature which is independent of their usage.
This is a roughly O(n) algorithm that generates the kth lexicographically ordered permutation of an n-element array from the integer k. Example, for a three-element
array:
0 --> 0 1 2
1 --> 0 2 1
2 --> 1 0 2
3 --> 1 2 0
4 --> 2 0 1
5 --> 2 1 0
25 лет истории C++, пролетевшей на моих глазахcorehard_by
Автор доклада познакомился с C++ в 1991-ом году, а с 1992-го года C++ является для докладчика основным языком разработки. Что происходило с языком за это время? Как и почему он стал популярным? Как начался застой в развитии C++? Как C++ потерял свою популярность? Есть ли место для C++ в современном мире? Попробуем поговорить об этом опираясь на 25-летний опыт программирования на C++.
Computer Vision using Ruby and libJIT - RubyConf 2009Jan Wedekind
Ruby originated in Japan, the country which is world-leading in robotic research. It suggests itself to put the two together and to start using Ruby as a language to program robots. However at the moment the performance of available Ruby interpreters is not sufficient. It is hard to achieve performance comparable to compiled C++-code since manipulation of Ruby-integers and Ruby-arrays requires frequent bounds-checking. It can be shown that universal bounds-check elimination is actually impossible.
FITC events. For digital creators.
Save 10% off ANY FITC event with discount code 'slideshare'
See our upcoming events at www.fitc.ca
An Intro To ES6
with Grant Skinner
OVERVIEW
ECMAScript 6 is the approved and published standard for the next version of JavaScript. It offers new syntax and language features that provide new ways of tackling coding problems, and increase your productivity.
This session will introduce ES6 and delve into many of the new features of the language. It will also cover real-world use, including transpilers, runtimes, and browser support.
OBJECTIVE
Create confidence in evaluating and getting started using ES6.
TARGET AUDIENCE
JavaScript developers.
ASSUMED AUDIENCE KNOWLEDGE
JavaScript.
FOUR THINGS AUDIENCE MEMBERS WILL LEARN
Status of ES6
How to get started with ES6
ES6 feature overview
Practical considerations for adopting ES6
The presentation shows major features of the new C++ standard (language and the library). The full list of new things is very broad, so I've categorized them to be easier to understand.
GECon2017_Programming from the cradle_Aliaksei_Rabchanka, Pavel_YukhnovichGECon_Org Team
This talk is aimed to provide an understanding of Epam's Corporate Social Responsibility Program “eKIDS”.
The reason this program was initialized- interesting facts about students and trainers as well as future plans – everything is covered in this talk.
GECon2017_Mobile testing overview Viktar_KnyshauGECon_Org Team
I would like to share with you understanding what Mobile Application Testing is.
It will be some kind of beginner’s guide to mobile testing. I will tell about the importance of mobile testing, diversity of the mobile market, mobile application types, key mobile challenges, etc. It will guide you to mobile specific tests as well. We will talk a bit about devices, tools & related services that help to perform mobile testing, tips and tricks which can be useful when you are testing on a mobile device.
GECon2017_ Learning english-the way to success (mr. language)GECon_Org Team
Mastering a language is not a talent. On the opposite, it’s something that we all can do. There are some insights to how anyone can achieve it. We will tell you how to overcome the Fear of speaking English, solve your listening problems and how to study English language effectively.
GECon2017_ Lean_architecturemanagement_Andrei KavaleuGECon_Org Team
• Is it hard to make right architecture?
• Case for today: from Darkness to Light
• Agile transition: Complex things via simple steps
• Lean applied: Changing architecture
• Vision is not enough: Channing processes
GECon2017_High-volume data streaming in azure_ Aliaksandr LaishaGECon_Org Team
The session will be focused on solutions that require high-throughput ingestion & streaming of data in real-time. You'll get familiar with different business uses-cases and architecture examples to get a common idea as well as understand the concepts of stream processing systems. Next, you'll get deep insights into functional and non-functional capabilities of Azure Event Hub service to see how it fits into the whole picture. Moreover we’ll take a look how to leverage Azure CosmosDB for high-throughput streaming when Event Hub is not suitable by different reasons.
GECon2017_Best ideas started in garages the heart of innovation_Andrei Medved...GECon_Org Team
1. Garage Overview
2. Stress Wristband
3. Plan a Drilling with Hololens
4. Digital Twin
5. Formula E Virtual Experience
6. Drilling Rig Virtual Experience
7. Virtual Fitting Room
8. Holoportation
9. Making a Virtual Tour with three JS and webGL
Globus Connect Server Deep Dive - GlobusWorld 2024Globus
We explore the Globus Connect Server (GCS) architecture and experiment with advanced configuration options and use cases. This content is targeted at system administrators who are familiar with GCS and currently operate—or are planning to operate—broader deployments at their institution.
First Steps with Globus Compute Multi-User EndpointsGlobus
In this presentation we will share our experiences around getting started with the Globus Compute multi-user endpoint. Working with the Pharmacology group at the University of Auckland, we have previously written an application using Globus Compute that can offload computationally expensive steps in the researcher's workflows, which they wish to manage from their familiar Windows environments, onto the NeSI (New Zealand eScience Infrastructure) cluster. Some of the challenges we have encountered were that each researcher had to set up and manage their own single-user globus compute endpoint and that the workloads had varying resource requirements (CPUs, memory and wall time) between different runs. We hope that the multi-user endpoint will help to address these challenges and share an update on our progress here.
Navigating the Metaverse: A Journey into Virtual Evolution"Donna Lenk
Join us for an exploration of the Metaverse's evolution, where innovation meets imagination. Discover new dimensions of virtual events, engage with thought-provoking discussions, and witness the transformative power of digital realms."
Enhancing Project Management Efficiency_ Leveraging AI Tools like ChatGPT.pdfJay Das
With the advent of artificial intelligence or AI tools, project management processes are undergoing a transformative shift. By using tools like ChatGPT, and Bard organizations can empower their leaders and managers to plan, execute, and monitor projects more effectively.
AI Pilot Review: The World’s First Virtual Assistant Marketing SuiteGoogle
AI Pilot Review: The World’s First Virtual Assistant Marketing Suite
👉👉 Click Here To Get More Info 👇👇
https://sumonreview.com/ai-pilot-review/
AI Pilot Review: Key Features
✅Deploy AI expert bots in Any Niche With Just A Click
✅With one keyword, generate complete funnels, websites, landing pages, and more.
✅More than 85 AI features are included in the AI pilot.
✅No setup or configuration; use your voice (like Siri) to do whatever you want.
✅You Can Use AI Pilot To Create your version of AI Pilot And Charge People For It…
✅ZERO Manual Work With AI Pilot. Never write, Design, Or Code Again.
✅ZERO Limits On Features Or Usages
✅Use Our AI-powered Traffic To Get Hundreds Of Customers
✅No Complicated Setup: Get Up And Running In 2 Minutes
✅99.99% Up-Time Guaranteed
✅30 Days Money-Back Guarantee
✅ZERO Upfront Cost
See My Other Reviews Article:
(1) TubeTrivia AI Review: https://sumonreview.com/tubetrivia-ai-review
(2) SocioWave Review: https://sumonreview.com/sociowave-review
(3) AI Partner & Profit Review: https://sumonreview.com/ai-partner-profit-review
(4) AI Ebook Suite Review: https://sumonreview.com/ai-ebook-suite-review
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...Juraj Vysvader
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I didn't get rich from it but it did have 63K downloads (powered possible tens of thousands of websites).
Software Engineering, Software Consulting, Tech Lead.
Spring Boot, Spring Cloud, Spring Core, Spring JDBC, Spring Security,
Spring Transaction, Spring MVC,
Log4j, REST/SOAP WEB-SERVICES.
Code reviews are vital for ensuring good code quality. They serve as one of our last lines of defense against bugs and subpar code reaching production.
Yet, they often turn into annoying tasks riddled with frustration, hostility, unclear feedback and lack of standards. How can we improve this crucial process?
In this session we will cover:
- The Art of Effective Code Reviews
- Streamlining the Review Process
- Elevating Reviews with Automated Tools
By the end of this presentation, you'll have the knowledge on how to organize and improve your code review proces
Experience our free, in-depth three-part Tendenci Platform Corporate Membership Management workshop series! In Session 1 on May 14th, 2024, we began with an Introduction and Setup, mastering the configuration of your Corporate Membership Module settings to establish membership types, applications, and more. Then, on May 16th, 2024, in Session 2, we focused on binding individual members to a Corporate Membership and Corporate Reps, teaching you how to add individual members and assign Corporate Representatives to manage dues, renewals, and associated members. Finally, on May 28th, 2024, in Session 3, we covered questions and concerns, addressing any queries or issues you may have.
For more Tendenci AMS events, check out www.tendenci.com/events
SOCRadar Research Team: Latest Activities of IntelBrokerSOCRadar
The European Union Agency for Law Enforcement Cooperation (Europol) has suffered an alleged data breach after a notorious threat actor claimed to have exfiltrated data from its systems. Infamous data leaker IntelBroker posted on the even more infamous BreachForums hacking forum, saying that Europol suffered a data breach this month.
The alleged breach affected Europol agencies CCSE, EC3, Europol Platform for Experts, Law Enforcement Forum, and SIRIUS. Infiltration of these entities can disrupt ongoing investigations and compromise sensitive intelligence shared among international law enforcement agencies.
However, this is neither the first nor the last activity of IntekBroker. We have compiled for you what happened in the last few days. To track such hacker activities on dark web sources like hacker forums, private Telegram channels, and other hidden platforms where cyber threats often originate, you can check SOCRadar’s Dark Web News.
Stay Informed on Threat Actors’ Activity on the Dark Web with SOCRadar!
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...Globus
Large Language Models (LLMs) are currently the center of attention in the tech world, particularly for their potential to advance research. In this presentation, we'll explore a straightforward and effective method for quickly initiating inference runs on supercomputers using the vLLM tool with Globus Compute, specifically on the Polaris system at ALCF. We'll begin by briefly discussing the popularity and applications of LLMs in various fields. Following this, we will introduce the vLLM tool, and explain how it integrates with Globus Compute to efficiently manage LLM operations on Polaris. Attendees will learn the practical aspects of setting up and remotely triggering LLMs from local machines, focusing on ease of use and efficiency. This talk is ideal for researchers and practitioners looking to leverage the power of LLMs in their work, offering a clear guide to harnessing supercomputing resources for quick and effective LLM inference.
A Comprehensive Look at Generative AI in Retail App Testing.pdfkalichargn70th171
Traditional software testing methods are being challenged in retail, where customer expectations and technological advancements continually shape the landscape. Enter generative AI—a transformative subset of artificial intelligence technologies poised to revolutionize software testing.
Globus Compute wth IRI Workflows - GlobusWorld 2024Globus
As part of the DOE Integrated Research Infrastructure (IRI) program, NERSC at Lawrence Berkeley National Lab and ALCF at Argonne National Lab are working closely with General Atomics on accelerating the computing requirements of the DIII-D experiment. As part of the work the team is investigating ways to speedup the time to solution for many different parts of the DIII-D workflow including how they run jobs on HPC systems. One of these routes is looking at Globus Compute as a way to replace the current method for managing tasks and we describe a brief proof of concept showing how Globus Compute could help to schedule jobs and be a tool to connect compute at different facilities.
May Marketo Masterclass, London MUG May 22 2024.pdfAdele Miller
Can't make Adobe Summit in Vegas? No sweat because the EMEA Marketo Engage Champions are coming to London to share their Summit sessions, insights and more!
This is a MUG with a twist you don't want to miss.
Check out the webinar slides to learn more about how XfilesPro transforms Salesforce document management by leveraging its world-class applications. For more details, please connect with sales@xfilespro.com
If you want to watch the on-demand webinar, please click here: https://www.xfilespro.com/webinars/salesforce-document-management-2-0-smarter-faster-better/
Unleash Unlimited Potential with One-Time Purchase
BoxLang is more than just a language; it's a community. By choosing a Visionary License, you're not just investing in your success, you're actively contributing to the ongoing development and support of BoxLang.
top nidhi software solution freedownloadvrstrong314
This presentation emphasizes the importance of data security and legal compliance for Nidhi companies in India. It highlights how online Nidhi software solutions, like Vector Nidhi Software, offer advanced features tailored to these needs. Key aspects include encryption, access controls, and audit trails to ensure data security. The software complies with regulatory guidelines from the MCA and RBI and adheres to Nidhi Rules, 2014. With customizable, user-friendly interfaces and real-time features, these Nidhi software solutions enhance efficiency, support growth, and provide exceptional member services. The presentation concludes with contact information for further inquiries.
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoamtakuyayamamoto1800
In this slide, we show the simulation example and the way to compile this solver.
In this solver, the Helmholtz equation can be solved by helmholtzFoam. Also, the Helmholtz equation with uniformly dispersed bubbles can be simulated by helmholtzBubbleFoam.
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
GECon2017_Cpp a monster that no one likes but that will outlast them all _Yauheni Akhotnikau
1. C++ ‒ a Monster
that no one likes
but that will outlast them all
Yauheni Akhotnikau
2. 2
Started programming somewhere in 1990.
The first meet with C++ in 1991.
C++ is the main tool since 1992 with a few short pauses.
Used some other languages. For example: Pascal, Visual Basic, Java, Ruby, D,
Eiffel, Scala.
I can use C++ without a pain but I don't think that C++ is the greatest
language ever.
A few words about me
3. 3
A bit of C++ evolution history.
Why C++ became popular and why C++ started to lose its popularity.
Why C++ is a Monster? If C ++ is a monster, then why does someone need
C++?
How to use C++ safely and efficiently?
Where and when C++ can be used. If it can...
Pressure to C++ from competitors. Real and imaginary.
Agenda
5. 5
By the help of a simple demo application:
• there is a collection of struct place (each struct contains name, price and rating);
• sort this collection by rating, then by price, then by name. And then print the collection after
sorting;
• sort this collection by name, then print it.
A way to see the evolution in examples
6. 6
Work on C++ began in 1979.
Bjarne Stroustrup decided to build a language with power of Simula 67 and
efficiency of C.
The first name of the new language was "C with Classes". Name C++
appeared in 1983.
The first public release in 1985.
The birth of C++
7. 7
struct place {
char * name_;
long price_;
int rating_;
place() : name_(0) {}
place(const char * name, long price, int rating)
: name_(copy_name(name)), price_(price), rating_(rating) {}
place(const place & o)
: name_(copy_name(o.name_)), price_(o.price_), rating_(o.rating_) {}
~place() { delete[] name_; }
place & operator=(const place & o) {
char * copy = copy_name(o.name_);
delete[] name_;
name_ = copy; price_ = o.price_; rating_ = o.rating_;
return *this;
}
static char * copy_name(const char * src) {
char * r = 0;
if(src) {
r = new char[strlen(src) + 1];
strcpy(r, src);
}
return r;
}
};
A taste of ancient C++ (pre-C++98)
8. 8
ostream & operator<<(ostream & to, const place & p) {
to << setw(20) << left << p.name_ << "[" << p.rating_ << "]"
<< setw(7) << right << p.price_;
return to;
}
void print(const place * places, size_t count) {
for(size_t i = 0; i != count; ++i)
cout << places[i] << endl;
cout << endl;
}
A taste of ancient C++ (pre-C++98)
9. 9
int compare_by_rating_price_name(const void * av, const void * bv) {
const place & a = *(const place *)av;
const place & b = *(const place *)bv;
int result;
if(a.rating_ < b.rating_) result = -1;
else {
if(a.rating_ == b.rating_) {
if(a.price_ < b.price_) result = -1;
else {
if(a.price_ == b.price_) {
result = strcmp(a.name_, b.name_);
}
else result = 1;
}
}
else result = 1;
}
return result;
}
int compare_by_name(const void * av, const void * bv) {
const place & a = *(const place *)av;
const place & b = *(const place *)bv;
return strcmp(a.name_, b.name_);
}
A taste of ancient C++ (pre-C++98)
11. 11
int main() {
place * places;
size_t count;
get_places(places, count);
qsort(places, count, sizeof(place), compare_by_rating_price_name);
print(places, count);
qsort(places, count, sizeof(place), compare_by_name);
print(places, count);
delete[] places;
}
A taste of ancient C++ (pre-C++98)
12. 12
Moscow [3] 1500
Sydney [3] 5000
Minsk [4] 500
London [4] 3500
Tokyo [4] 3500
St. Petersburg [5] 1300
Paris [5] 3000
London [4] 3500
Minsk [4] 500
Moscow [3] 1500
Paris [5] 3000
St. Petersburg [5] 1300
Sydney [3] 5000
Tokyo [4] 3500
A taste of ancient C++ (pre-C++98)
13. 13
1985-1995: fast evolution:
– multiple inheritance, const-methods, protected keyword, namespaces, templates, exceptions,
RTTI, explicit keyword, ...
1990: ANSI/ISO standardization started.
1992: Alex Stepanov started STL.
1994-1998: process of inclusion of STL into the standard.
1998: the first international standard ‒ C++98.
2003: an updated standard ‒ C++03.
1985-2003: main milestones
14. 14
using namespace std;
struct place {
string name_;
long price_;
int rating_;
place() {}
place(const char * name, float price, int rating)
: name_(name), price_(price), rating_(rating) {}
};
A taste of old C++ (C++98)
15. 15
ostream & operator<<(ostream & to, const place & p) {
to << setw(20) << left << p.name_ << "[" << p.rating_ << "]"
<< setw(7) << right << p.price_;
return to;
}
template<class C>
void print(const C & places) {
for(typename C::const_iterator i = places.begin(); i != places.end(); ++i)
cout << *i << endl;
cout << endl;
}
A taste of old C++ (C++98)
16. 16
bool compare_by_rating_price_name(const place & a, const place & b) {
bool result = false;
if(a.rating_ < b.rating_) result = true;
else if(a.rating_ == b.rating_) {
if(a.price_ < b.price_) result = true;
else if(a.price_ == b.price_) result = (a.name_ < b.name_);
}
return result;
}
bool compare_by_name(const place & a, const place & b) {
return a.name_ < b.name_;
}
A taste of old C++ (C++98)
17. 17
vector<place> get_places() {
vector<place> places;
places.push_back(place("Moscow", 1500, 3));
places.push_back(place("St. Petersburg", 1300, 5));
places.push_back(place("Minsk", 500, 4));
places.push_back(place("Tokyo", 3500, 4));
places.push_back(place("Sydney", 5000, 3));
places.push_back(place("Paris", 3000, 5));
places.push_back(place("London", 3500, 4));
return places;
}
A taste of old C++ (C++98)
18. 18
int main() {
vector<place> places = get_places();
sort(places.begin(), places.end(), compare_by_rating_price_name);
print(places);
sort(places.begin(), places.end(), compare_by_name);
print(places);
}
A taste of old C++ (C++98)
19. 19
2003-2011: long-term construction under the name of C++0x.
2011: C++11 released. It's a very different beast!
many, many language improvements;
significant extension of stdlib;
2014: C++14 released. A minor update with some very useful features.
2017: draft of C++17. An important update with lot of new features and
additions to stdlib.
2017: work on C++20 started.
2003-2017: main milestones
21. 21
ostream & operator<<(ostream & to, const place & p) {
fmt::print(to, "{:<20}[{}]{:7}", p.name_, p.rating_, p.price_);
return to;
}
void print(auto & places) {
for(const auto & p : places)
cout << p << endl;
cout << endl;
}
A taste of modern C++ (C++17)
22. 22
bool compare_by_rating_price_name(const place & a, const place & b) {
return tie(a.rating_, a.price_, a.name_) < tie(b.rating_, b.price_, b.name_);
}
bool compare_by_name(const place & a, const place & b) {
return a.name_ < b.name_;
}
A taste of modern C++ (C++17)
23. 23
vector<place> get_places() {
return {
{"Moscow", 1500, 3},
{"St. Petersburg", 1300, 5},
{"Minsk", 500, 4},
{"Tokyo", 3500, 4},
{"Sydney", 5000, 3},
{"Paris", 3000, 5},
{"London", 3500, 4}
};
}
A taste of modern C++ (C++17)
24. 24
int main() {
auto places = get_places();
sort(begin(places), end(places), compare_by_rating_price_name);
print(places);
sort(begin(places), end(places), compare_by_name);
print(places);
}
A taste of modern C++ (C++17)
25. 25
A short look to the full demo source code…
1985-2017: the comparison
26. 26
#include <iostream.h>
#include <iomanip.h>
#include <string.h>
#include <stdlib.h>
struct place {
char * name_;
long price_;
int rating_;
place() : name_(0) {}
place(const char * name, long price, int rating)
: name_(copy_name(name)), price_(price), rating_(rating)
{}
place(const place & o)
: name_(copy_name(o.name_)), price_(o.price_),
rating_(o.rating_) {}
~place() {
delete[] name_;
}
place & operator=(const place & o) {
char * copy = copy_name(o.name_);
delete[] name_;
name_ = copy;
price_ = o.price_;
rating_ = o.rating_;
return *this;
}
static char * copy_name(const char * src) {
char * r = 0;
if(src) {
r = new char[strlen(src) + 1];
strcpy(r, src);
}
return r;
}
};
ostream & operator<<(ostream & to, const place & p) {
to << setw(20) << left << p.name_ << "[" << p.rating_ <<
"]"
<< setw(7) << right << p.price_;
return to;
}
void print(const place * places, size_t count) {
for(size_t i = 0; i != count; ++i)
cout << places[i] << endl;
cout << endl;
}
int compare_by_rating_price_name(const void * av, const
void * bv) {
const place & a = *(const place *)av;
const place & b = *(const place *)bv;
int result;
if(a.rating_ < b.rating_) result = -1;
else {
if(a.rating_ == b.rating_) {
if(a.price_ < b.price_) result = -1;
else {
if(a.price_ == b.price_) {
result = strcmp(a.name_, b.name_);
}
else result = 1;
}
}
else result = 1;
}
return result;
}
int compare_by_name(const void * av, const void * bv) {
const place & a = *(const place *)av;
const place & b = *(const place *)bv;
return strcmp(a.name_, b.name_);
}
void get_places(place *& places, size_t & count) {
places = new place[7];
places[0] = place("Moscow", 1500, 3);
places[1] = place("St. Petersburg", 1300, 5);
places[2] = place("Minsk", 500, 4);
places[3] = place("Tokyo", 3500, 4);
places[4] = place("Sydney", 5000, 3);
places[5] = place("Paris", 3000, 5);
places[6] = place("London", 3500, 4);
count = 7;
}
int main() {
place * places;
size_t count;
get_places(places, count);
qsort(places, count, sizeof(place),
compare_by_rating_price_name);
print(places, count);
qsort(places, count, sizeof(place), compare_by_name);
print(places, count);
delete[] places;
}
A taste of… Full text of pre-C++98 demo
27. 27
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
using namespace std;
struct place {
string name_;
long price_;
int rating_;
place() {}
place(const char * name, float price, int rating)
: name_(name), price_(price), rating_(rating) {}
};
ostream & operator<<(ostream & to, const place & p) {
to << setw(20) << left << p.name_ << "[" << p.rating_ << "]"
<< setw(7) << right << p.price_;
return to;
}
template<class C>
void print(const C & places) {
for(typename C::const_iterator i = places.begin(); i != places.end(); ++i)
cout << *i << endl;
cout << endl;
}
bool compare_by_rating_price_name(const place & a, const place & b) {
bool result = false;
if(a.rating_ < b.rating_) result = true;
else if(a.rating_ == b.rating_) {
if(a.price_ < b.price_) result = true;
else if(a.price_ == b.price_) result = (a.name_ < b.name_);
}
return result;
}
bool compare_by_name(const place & a, const place & b) {
return a.name_ < b.name_;
}
vector<place> get_places() {
vector<place> places;
places.push_back(place("Moscow", 1500, 3));
places.push_back(place("St. Petersburg", 1300, 5));
places.push_back(place("Minsk", 500, 4));
places.push_back(place("Tokyo", 3500, 4));
places.push_back(place("Sydney", 5000, 3));
places.push_back(place("Paris", 3000, 5));
places.push_back(place("London", 3500, 4));
return places;
}
int main() {
vector<place> places = get_places();
sort(places.begin(), places.end(), compare_by_rating_price_name);
print(places);
sort(places.begin(), places.end(), compare_by_name);
print(places);
}
A taste of… Full text of C++98 demo
28. 28
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <tuple>
#include <fmt/format.h>
#include <fmt/ostream.h>
using namespace std;
struct place {
string name_;
long price_;
int rating_;
};
ostream & operator<<(ostream & to, const place & p) {
fmt::print(to, "{:<20}[{}]{:7}", p.name_, p.rating_, p.price_);
return to;
}
void print(auto & places) {
for(const auto & p : places)
cout << p << endl;
cout << endl;
}
bool compare_by_rating_price_name(const place & a, const place & b) {
return tie(a.rating_, a.price_, a.name_) < tie(b.rating_, b.price_, b.name_);
}
bool compare_by_name(const place & a, const place & b) {
return a.name_ < b.name_;
}
vector<place> get_places() {
return {
{"Moscow", 1500, 3},
{"St. Petersburg", 1300, 5},
{"Minsk", 500, 4},
{"Tokyo", 3500, 4},
{"Sydney", 5000, 3},
{"Paris", 3000, 5},
{"London", 3500, 4}
};
}
int main() {
auto places = get_places();
sort(begin(places), end(places), compare_by_rating_price_name);
print(places);
sort(begin(places), end(places), compare_by_name);
print(places);
}
A taste of… Full text of C++17 demo
30. 30
A very weak computers. Fight for efficiency is the fight for a life.
Personal Computer was not a toy anymore. It was a new market.
But PCs were yet more weak: "640K ought to be enough for anybody"
OOP was regarded as a "silver bullet" for a software development crisis.
There was a necessity of a complex tool for solving complex problems.
Because almost every problem was a complex one.
C++ was a such tool.
Where was IT-industry at mid of 1980s?
31. 31
Almost everywhere:
– system software;
– middleware;
– server-side;
– desktop (especially on Windows with OLE/COM/DCOM);
– embedded;
– high-performance computing;
– ...
With obvious exceptions in areas where tools like dBase, FoxBase, Clarion,
VisualBasic were in active use.
Where C++ was used before 2000s?
32. 32
Computers become much more powerful.
– Java is not slow now (or it is believed that Java is not slow);
– Microsoft created .NET and C#. Development for Windows is now .NET-centric;
– many application are developed in Python, Ruby, Erlang and so on.
Internet and WWW are not toys anymore. They are a new market.
– Web-development is a new niche;
– migration from desktop to Web has started...
IT-landscape changed at the end of 90s
33. 33
Started at the beginning of 2000s.
Many developers switched to more safe and powerful languages and
platforms like JVM (Java, Scala), .NET (C#, F#), Python, Ruby, Erlang and so
on...
New projects didn't use C++.
Migration of some old projects to other languages started.
Visual Studio as an example.
New big platforms: Apple iOS (Objective-C) and Google's Android (Java).
Hype around Erlang, OCaml, Haskell and similar languages.
The oblivion of C++
35. 35
There are objective and subjective reasons.
It is hard to speak about subjective reasons seriously:
– too many features, a developer must think (think?!!!);
– it is not Java nor C# nor SmallTalk nor ...
– the OOP is C++ is totally wrong (so speak Alan Key);
– no Garbage Collector.
But there are some objective reasons which make life of a programmer
harder...
C++ became a monster long time ago
36. 36
C++98 is almost 800 pages.
C++11 is about 1400 pages.
C++17 is about 1700 pages.
Must read books for a C++ developer (only some of them):
"The C++ Programming Language" (Bjarne Stroustrup), "C++ Standard Library Tutorial and
Reference" (Nicolai Josuttis), "C++ Templates: The Complete Guide" (David Vandevoorde and
Nicolai M. Josuttis), "C++ Coding Standards" (Herb Sutter and Andrei Alexandrescu), "Effective
Modern C++" (Scott Meyers) and the previous books from the same author: "Effective C++",
"Effective STL", "More Effective C++".
See more here: The Definitive C++ Book Guide and List.
C++ is a complex language
38. 38
There are many ways to corrupt memory of a program:
– dereference of an invalid pointer;
– out of bound writes;
– violation of type rules (an attempt to cast int* to double*);
– use of uninitialized value;
– double free of memory;
– ...
A program with corrupted memory may crash. Or it may not crash (it much
worse).
Even if it crashes there is no beautiful stack trace or something similar.
A program may crash or may not...
39. 39
There are plenty of UB in the language:
– signed overflow;
– access out of bounds;
– uninitialized scalar;
– null pointer dereference;
– access to pointer passed to realloc;
– infinite loop without side-effects;
– oversized shift;
– violation of type rules;
– modification of the same scalar more than once in an expression;
– ...
Undefined behavior
40. 40
#include <cstdlib>
typedef int (*Function)();
static Function Do;
static int EraseAll() {
return system("rm -rf /");
}
void NeverCalled() {
Do = EraseAll;
}
int main() {
return Do();
}
Undefined behavior (`rm -rf /`)
41. 41
#include <cstdlib>
typedef int (*Function)();
static Function Do;
static int EraseAll() {
return system("rm -rf /");
}
void NeverCalled() {
Do = EraseAll;
}
int main() {
return Do();
}
Undefined behavior (`rm -rf /`)
43. 43
sort(begin(places), end(places), [](const auto & a, const auto & b) {
const auto t = [](const auto & p) { return tie(p.rating_, p.price_, p.name_); };
return t(a) < tie(b);
});
Hard to read error messages
44. 44
Hard to read error messages
In file included from t1_cpp14_2.cpp:5:0:
C:/mingw64-posix-7.2.0/lib/gcc/x86_64-w64-mingw32/7.2.0/include/c++/tuple: In instantiation of 'constexpr bool std::operator<(const std::tuple<_Tps ...>&, const
std::tuple<_Elements ...>&) [with _TElements = {const int&, const long int&, const std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&}; _UElements =
{const place&}]':
t1_cpp14_2.cpp:40:16: required from 'main()::<lambda(const auto:1&, const auto:2&)> [with auto:1 = place; auto:2 = place]'
C:/mingw64-posix-7.2.0/lib/gcc/x86_64-w64-mingw32/7.2.0/include/c++/bits/predefined_ops.h:143:18: required from 'constexpr bool
__gnu_cxx::__ops::_Iter_comp_iter<_Compare>::operator()(_Iterator1, _Iterator2) [with _Iterator1 = __gnu_cxx::__normal_iterator<place*, std::vector<place> >; _Iterator2 =
__gnu_cxx::__normal_iterator<place*, std::vector<place> >; _Compare = main()::<lambda(const auto:1&, const auto:2&)>]'
C:/mingw64-posix-7.2.0/lib/gcc/x86_64-w64-mingw32/7.2.0/include/c++/bits/stl_algo.h:81:17: required from 'void std::__move_median_to_first(_Iterator, _Iterator, _Iterator,
_Iterator, _Compare) [with _Iterator = __gnu_cxx::__normal_iterator<place*, std::vector<place> >; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<main()::<lambda(const auto:1&,
const auto:2&)> >]'
C:/mingw64-posix-7.2.0/lib/gcc/x86_64-w64-mingw32/7.2.0/include/c++/bits/stl_algo.h:1921:34: required from '_RandomAccessIterator
std::__unguarded_partition_pivot(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<place*,
std::vector<place> >; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<main()::<lambda(const auto:1&, const auto:2&)> >]'
C:/mingw64-posix-7.2.0/lib/gcc/x86_64-w64-mingw32/7.2.0/include/c++/bits/stl_algo.h:1953:38: required from 'void std::__introsort_loop(_RandomAccessIterator,
_RandomAccessIterator, _Size, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<place*, std::vector<place> >; _Size = long long int; _Compare =
__gnu_cxx::__ops::_Iter_comp_iter<main()::<lambda(const auto:1&, const auto:2&)> >]'
C:/mingw64-posix-7.2.0/lib/gcc/x86_64-w64-mingw32/7.2.0/include/c++/bits/stl_algo.h:1968:25: required from 'void std::__sort(_RandomAccessIterator, _RandomAccessIterator,
_Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<place*, std::vector<place> >; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<main()::<lambda(const
auto:1&, const auto:2&)> >]'
C:/mingw64-posix-7.2.0/lib/gcc/x86_64-w64-mingw32/7.2.0/include/c++/bits/stl_algo.h:4868:18: required from 'void std::sort(_RAIter, _RAIter, _Compare) [with _RAIter =
__gnu_cxx::__normal_iterator<place*, std::vector<place> >; _Compare = main()::<lambda(const auto:1&, const auto:2&)>]'
t1_cpp14_2.cpp:41:4: required from here
C:/mingw64-posix-7.2.0/lib/gcc/x86_64-w64-mingw32/7.2.0/include/c++/tuple:1413:7: error: static assertion failed: tuple objects can only be compared if they have equal sizes.
static_assert(sizeof...(_TElements) == sizeof...(_UElements),
^~~~~~~~~~~~~
sort(begin(places), end(places), [](const auto & a, const auto & b) {
const auto t = [](const auto & p) { return tie(p.rating_, p.price_, p.name_); };
return t(a) < tie(b);
});
45. 45
sort(begin(places), end(places), [](const auto & a, const auto & b) {
const auto t = [](const auto & p) { return tie(p.rating_, p.price_, p.name_); };
return t(a) < tie(b);
});
Hard to read error messages
In file included from t1_cpp14_2.cpp:5:0:
C:/mingw64-posix-7.2.0/lib/gcc/x86_64-w64-mingw32/7.2.0/include/c++/tuple: In instantiation of 'constexpr bool std::operator<(const std::tuple<_Tps ...>&, const
std::tuple<_Elements ...>&) [with _TElements = {const int&, const long int&, const std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&}; _UElements =
{const place&}]':
t1_cpp14_2.cpp:40:16: required from 'main()::<lambda(const auto:1&, const auto:2&)> [with auto:1 = place; auto:2 = place]'
C:/mingw64-posix-7.2.0/lib/gcc/x86_64-w64-mingw32/7.2.0/include/c++/bits/predefined_ops.h:143:18: required from 'constexpr bool
__gnu_cxx::__ops::_Iter_comp_iter<_Compare>::operator()(_Iterator1, _Iterator2) [with _Iterator1 = __gnu_cxx::__normal_iterator<place*, std::vector<place> >; _Iterator2 =
__gnu_cxx::__normal_iterator<place*, std::vector<place> >; _Compare = main()::<lambda(const auto:1&, const auto:2&)>]'
C:/mingw64-posix-7.2.0/lib/gcc/x86_64-w64-mingw32/7.2.0/include/c++/bits/stl_algo.h:81:17: required from 'void std::__move_median_to_first(_Iterator, _Iterator, _Iterator,
_Iterator, _Compare) [with _Iterator = __gnu_cxx::__normal_iterator<place*, std::vector<place> >; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<main()::<lambda(const auto:1&,
const auto:2&)> >]'
C:/mingw64-posix-7.2.0/lib/gcc/x86_64-w64-mingw32/7.2.0/include/c++/bits/stl_algo.h:1921:34: required from '_RandomAccessIterator
std::__unguarded_partition_pivot(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<place*,
std::vector<place> >; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<main()::<lambda(const auto:1&, const auto:2&)> >]'
C:/mingw64-posix-7.2.0/lib/gcc/x86_64-w64-mingw32/7.2.0/include/c++/bits/stl_algo.h:1953:38: required from 'void std::__introsort_loop(_RandomAccessIterator,
_RandomAccessIterator, _Size, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<place*, std::vector<place> >; _Size = long long int; _Compare =
__gnu_cxx::__ops::_Iter_comp_iter<main()::<lambda(const auto:1&, const auto:2&)> >]'
C:/mingw64-posix-7.2.0/lib/gcc/x86_64-w64-mingw32/7.2.0/include/c++/bits/stl_algo.h:1968:25: required from 'void std::__sort(_RandomAccessIterator, _RandomAccessIterator,
_Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<place*, std::vector<place> >; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<main()::<lambda(const
auto:1&, const auto:2&)> >]'
C:/mingw64-posix-7.2.0/lib/gcc/x86_64-w64-mingw32/7.2.0/include/c++/bits/stl_algo.h:4868:18: required from 'void std::sort(_RAIter, _RAIter, _Compare) [with _RAIter =
__gnu_cxx::__normal_iterator<place*, std::vector<place> >; _Compare = main()::<lambda(const auto:1&, const auto:2&)>]'
t1_cpp14_2.cpp:41:4: required from here
C:/mingw64-posix-7.2.0/lib/gcc/x86_64-w64-mingw32/7.2.0/include/c++/tuple:1413:7: error: static assertion failed: tuple objects can only be compared if they have equal sizes.
static_assert(sizeof...(_TElements) == sizeof...(_UElements),
^~~~~~~~~~~~~
841 lines
46. 46
No standard dependency manager and central dependency repository.
There is some activity last years: buckaroo, build2, cget, conan, conda, cpm, cppan, hunter,
vcpkg, ...
But there is no a clear winner yet.
No standard build tool.
There are lot of tools in use: bazel, build2, buckaroo, cmake, make, meson, scons, waf, ...
But there is no de-jure standard.
It seems that CMake becomes a de-facto standard.
Infrastructure from a 1980s
47. 47
Addition of STL into C++98 made life of developers easier.
Extension of stdlib in C++11 made life yet more easier.
Another extension of stdlib in C++17 will made life yet more easier...
But C++'s stdlib still looks very poor with comparison with other popular
languages like Java, C#, Python, Ruby and so on.
Shine and poverty of C++ stdlib
48. 48
Many developers just don't know how to use C++ safely and efficiently.
Mantra "learn C first and only then C++" is terribly wrong!
C++ as a first language? May be not a good idea.
Plain old C as a first language? It's much worse!
People's factor
50. 50
Procedural Programming
Object-Oriented Programming (incl. multiple inheritance)
one of the most comprehensive between statically typed OO-languages. Only Eiffel has more
advanced support for OOP.
Generic Programming (function and class templates and all that stuff...)
compile-time duck-typing and static polymorphism.
Functional Programming
All these paradigms can be easily combined in a single program.
C++ is a multiparadigm language
51. 51
+ low resources consumption
+ total control
+ an easy access to OS and hardware.
Lot of resources were invested in optimizing C++ compiler and tools.
There are a very few alternatives with comparable expressiveness and
execution speed (if any).
High performance...
52. 52
You can add your own "thing" and this "thing" will behave just a language's
first-class citizen.
An ability to create int_set attracted me 25 years ago...
Powerful and cheap abstraction
53. 53
class int_set {
int * items_;
...
public:
int_set() : items_(new int[initial_capacity]) {...}
~int_set() { delete[] items_; }
...
};
int_set operator+(const int_set & a, const int_set & b) {...}
int_set operator-(const int_set & a, const int_set & b) {...}
int_set operator&(const int_set & a, const int_set & b) {...}
int_set received_items;
int_set checked_items;
...
int_set delayed_items = received_items - checked_items;
Powerful and cheap abstraction (int_set)
54. 54
Class matrix is another classical example. Allows to write a compact and
readable code:
const unsigned N = ...;
matrix a(N,N), b(N,N), c(N,N), d(N,N);
...
matrix x = a*b + c*d;
Powerful and cheap abstraction (matrix)
55. 55
Class matrix is another classical example. Allows to write a compact and
readable code:
const unsigned N = ...;
matrix a(N,N), b(N,N), c(N,N), d(N,N);
...
matrix x = a*b + c*d;
Powerful and cheap abstraction (matrix)
A plain C alternative:
matrix a, b, c, d;
matrix ab, cd, x;
matrix_init(&a, N, N);
matrix_init(&b, N, N);
matrix_init(&c, N, N);
matrix_init(&d, N, N);
...
matrix_init(&ab, N, N);
matrix_init(&cd, N, N);
matrix_init(&x);
matrix_mul(&a, &b, &ab);
matrix_mul(&c, &d, &cd);
matrix_add(&ab, &cd, &x);
matrix_destroy(&ab);
matrix_destroy(&cd);
...
matrix_destroy(&x);
matrix_destroy(&d);
matrix_destroy(&c);
matrix_destroy(&b);
matrix_destroy(&a);
56. 56
Get a resource in the constructor.
allocate memory, acquire mutex, open file, create painting device, ...
Release the resource in the destructor.
destructor is called automatically when object is out of scope or destroyed manually.
We have already seen this in int_set example:
class int_set {
int * items_;
...
public:
int_set() : items_(new int[initial_capacity]) {...}
~int_set() { delete[] items_; }
RAII (Resource Acquisition Is Initialization)
57. 57
RAII is used for different types of resources, not only memory:
void raii_example() {
ifstream file{"input.dat", ios::binary};
if(file.is_open()) {
vector<uint8_t> content = load_data(file);
...
lock_guard<mutex> lock{global_data_lock};
global_data = move(content);
global_data_updated.notify();
}
}
RAII (Resource Acquisition Is Initialization)
58. 58
RAII is used for different types of resources, not only memory:
void raii_example() {
ifstream file{"input.dat", ios::binary};
if(file.is_open()) {
vector<uint8_t> content = load_data(file);
...
lock_guard<mutex> lock{global_data_lock};
global_data = move(content);
global_data_updated.notify();
}
}
RAII (Resource Acquisition Is Initialization)
59. 59
C++ is great for creation of high-level domain specific tools.
High-level domain-specific tools
60. 60
class User {
public:
...
static User fromJSON(const rapidjson::Value& doc) {
if(!doc.IsObject())
throw std::runtime_error("document should be an object");
static const char* members[] = { "id", "name", "phone", "birthday" };
for(size_t i = 0; i < sizeof(members)/sizeof(members[0]); i++)
if(!doc.HasMember(members[i])) throw std::runtime_error("missing fields");
uint64_t id = doc["id"].GetUint64();
std::string name = doc["name"].GetString();
uint64_t phone = doc["phone"].GetUint64();
Date birthday = Date::fromJSON(doc["birthday"]);
User result(id, name, phone, birthday);
return result;
}
};
Domain specific tools (JSON example)
RapidJSON
63. 63
Use only that you know.
Any safe subset of C++ is still C++.
Common sense rulezzz!
64. 64
There are a lot of for different application areas:
– C++ Core Guidelines;
– guidelines from famous companies or projects (Google's, Boost's,
Mozilla's, Bloomberg's, CERT's, ...);
– industry-specific standard and/or guidelines (Joint Strike Fighter Air
Vehicle C++ Coding Standards, MISRA C++, High Integrity C++,...)
Use guidelines
65. 65
Static code analyzers:
– cppcheck;
– clang static analyzer;
– Coverity;
– PVS-Studio.
Sanitizers (GCC, clang):
– address;
– thread;
– leak;
– undefined.
Compiler flags like -Wall, -Weverything and -Werror are your friends!
Use analyzers and sanitizers
66. 66
/// Open a device and get handle for it.
///
/// attention A dynamically allocated object returned. Caller must deallocate it.
device * open_device(
/// Name of device to be created.
const char * dev_name,
/// Creation options.
device_options options);
...
auto dev = open_device("lpt1", defaults);
dev->write(...);
...
delete dev;
Use right abstractions (1)
67. 67
/// Open a device and get handle for it.
unique_ptr<device> open_device(
/// Name of device to be created.
const char * dev_name,
/// Creation options.
device_options options);
...
auto dev = open_device("lpt1", defaults);
dev->write(...);
...
Use right abstractions (2)
68. 68
Many developers abandon type-safe API if it requires a lot of boilerplate
code:
ostream & operator<<(ostream & o, const place & p) {
o << setw(20) << left << p.name_ << "[" << p.rating_ << "]"
<< setw(7) << right << p.price_;
return o;
}
Use right libraries (type safety)
69. 69
And use something more "useful" and/or "powerful":
ostream & operator<<(ostream & o, const place & p) {
char buf[30];
snprintf(buf, sizeof(buf), "%-20s[%d]%7d", p.name_, p.rating_, p.price_);
return (o << buf);
}
Use right libraries (type safety)
70. 70
And use something more "useful" and/or "powerful":
ostream & operator<<(ostream & o, const place & p) {
char buf[30];
snprintf(buf, sizeof(buf), "%-20s[%d]%7d", p.name_, p.rating_, p.price_);
return (o << buf);
}
Use right libraries (type safety)
30 characters required for textual
representation. But addition character is
necessary for terminating 0-symbol.
place::price_ is unsigned long, "%7ld"
must be used instead of "%7d".
place::name_ is std::string, not
char*, place.name_.c_str() must be
used.
71. 71
There are powerful and type-safe libraries. fmtlib as an example:
#include <fmt/format.h>
#include <fmt/ostream.h>
ostream & operator<<(ostream & o, const place & p) {
fmt::print(o, "{:<20}[{}]{:7}", p.name_, p.rating_, p.price_);
return o;
}
Use right libraries (type safety)
72. 72
How many lines of modern C++ are necessary to write the simplest HTTP-
server?
A server that responds "Hello, world" for all requests?
Use right libraries (simplicity)
77. 77
IT-landscape has changed but there are still many areas where high
performance and low resource consumptions matter.
Smartphones and mobile development are here. Battery life matters.
High diversity of devices in use: PC, laptops/netbooks, tablets, smartphones,
smart watches, smart TVs, game consoles, ...
Big server farms.
Free lunch is over. It's not an easy to take a performance gain now.
The return of interest in native code apps.
2011-2017: what's changed?
78. 78
C++ Futures on Instagram: high-performing recommendation service was
rewritten in C++.
number of servers reduced from 720 to 38.
Speedup PHP at Facebook: HipHop (PHP-to-C++ transpiler) and HHVM
(HipHop Virtual Machine).
Some examples. Server-side
79. 79
ScyllaDB: a high performance drop-in replacement for Cassandra.
10x better performance on high-end hardware, 1.5x-3x better on smaller machines.
Quantcast File System: a high performance alternative to HDFS (Hadoop
Distributed File System) written in C++.
50% space reduction, +75% write and +45% read throughput.
Some examples. Middleware
80. 80
Doodle Kindom: cross-plaform games with kernel in C++.
works on iPhone, iPad, Windows, MacOS, NOOK.
Oncam: a videochat system for iOS+Android with kernel in C++.
supports videochat up to 6 participant with at least 15FPS.
Some examples. Mobile
81. 81
High performance computing
– weather forecasting, molecular modeling, physic simulation, big-data, machine learning, ...
Low resource consumption
– mobile application, internet of things, ...
System programming (and around)
– OS kernels, drivers and utilities, middleware, compilers, antiviruses, ...
Real-time and embedded systems
– SCADA, industrial internet of things, avionics, automotive, finance, telecom, defense, ...
Complex desktop applications
– CADs, photoshop, AAA games, browsers, office apps, ...
Cross-platform apps
– app's kernel in C++ + GUI in native technology (Dropbox's jinie), ...
Legacy
Where C++ can be used now?
82. 82
There is no place for quick-and-
dirty solutions!
What is in common?
84. 84
Java and C#:
It is not actual anymore :) Java and C# already ate everything they could.
plain C:
It is actual again. Suddenly?
Go:
Shines in its very narrow niche. Attracts much more Python/Ruby developers than C++ devs.
Rust:
The only real modern alternative to C++ now. But it is a hard question.
Main alternatives
85. 85
Ada:
Very strong competitor for embedded and real-time areas. Almost unknown in East Europe.
D:
It's too late. Lack of popularity and presence of GC.
Swift:
Almost nonexistent outside the Apple's ecosystem.
Some other alternatives
87. 87
There is no commercial force behind it (like Oracle for Java, Microsoft for
C#, JetBrains for Kotlin and so on).
If you need something in C++ you can propose it: https://stdcpp.ru/
C++ is community driven language