A small introduction on the C++14 improved static introspection of the IOD library and the C++14 web framework Silicon.
https://github.com/matt-42/silicon
https://github.com/matt-42/iod
Fun with Lambdas: C++14 Style (part 1)Sumant Tambe
If virtual functions in C++ imply design patterns, then C++ lambdas imply what? What does it really mean to have lambdas in C++? Frankly, I don't know but I've a hunch: It's BIG.
Just like virtual functions open doors to the OO paradigm, lambdas open doors to a different paradigm--the functional paradigm. This talk is not a praise of functional programming or some elusive lambda-based library. (Although, I'll mention one briefly that tops my list these days.) Instead, the goal is to have fun while working our way through some mind-bending examples of C++14 lambdas. Beware, your brain will hurt! Bring your laptop and code the examples right along because that may be the fastest way to answer the quiz.
Fun with Lambdas: C++14 Style (part 1)Sumant Tambe
If virtual functions in C++ imply design patterns, then C++ lambdas imply what? What does it really mean to have lambdas in C++? Frankly, I don't know but I've a hunch: It's BIG.
Just like virtual functions open doors to the OO paradigm, lambdas open doors to a different paradigm--the functional paradigm. This talk is not a praise of functional programming or some elusive lambda-based library. (Although, I'll mention one briefly that tops my list these days.) Instead, the goal is to have fun while working our way through some mind-bending examples of C++14 lambdas. Beware, your brain will hurt! Bring your laptop and code the examples right along because that may be the fastest way to answer the quiz.
Computer science Investigatory Project Class 12 C++Rushil Aggarwal
This project is based on File Handling . An innovative project on petrol pump management , deals with basic function in a petrol pump .
Do like , share and comment if my work helped you ;)
The new standard for C++ language has been signed in 2011. This new (extended) language, called C++11, has a number of new semantics (in terms of language constructs) and a number of new standard library support. The major language extensions are discussed in this presentation. The library will be taken up in a later presentation.
Practical Class 12th (c++programs+sql queries and output) Aman Deep
Just download this and do some specific changes in the name section and roll no section . and submit it as it is to your teacher this will surely work and help you out your class 12th board practicals exam . no worries ! ENJOY :) !
Despite all of the recent interest, concurrency in standard C++ is still barely in its infancy. This talk uses the primitives supplied by C++14 to build a simple, reference, implementation of a task system. The goal is to learn to write software that doesn’t wait.
Computer science Investigatory Project Class 12 C++Rushil Aggarwal
This project is based on File Handling . An innovative project on petrol pump management , deals with basic function in a petrol pump .
Do like , share and comment if my work helped you ;)
The new standard for C++ language has been signed in 2011. This new (extended) language, called C++11, has a number of new semantics (in terms of language constructs) and a number of new standard library support. The major language extensions are discussed in this presentation. The library will be taken up in a later presentation.
Practical Class 12th (c++programs+sql queries and output) Aman Deep
Just download this and do some specific changes in the name section and roll no section . and submit it as it is to your teacher this will surely work and help you out your class 12th board practicals exam . no worries ! ENJOY :) !
Despite all of the recent interest, concurrency in standard C++ is still barely in its infancy. This talk uses the primitives supplied by C++14 to build a simple, reference, implementation of a task system. The goal is to learn to write software that doesn’t wait.
Build 2016 - B880 - Top 6 Reasons to Move Your C++ Code to Visual Studio 2015Windows Developer
Visual Studio 2015 provides the best in class C++ development experience whether you are targeting Android, iOS, Linux, Windows, or IoT. With a good mix of demos and showcase for new C++ experiences, this talk goes over six great reasons why you should migrate to Visual Studio 2015 today.
Modern Release Engineering in a Nutshell - Why Researchers should Care!Bram Adams
Invited talk at the Leaders of Tomorrow Symposium of the 23rd IEEE International Conference on Software Analysis, Evolution, and Reengineering (SANER 2016).
The presentation (and its accompanying paper, see http://mcis.polymtl.ca/publications/2016/fose.pdf) explain the basics of release engineering pipelines, common challenges industry is facing as well as pitfalls software engineering researchers are falling into.
Speakers are Bram Adams (MCIS, http://mcis.polymtl.ca) and Shane McIntosh (McGill University, http://shanemcintosh.org).
A video-taped version of the talk will be available soon at https://www.youtube.com/channel/UCL8yG6qpHk7V66l1Jt3aZrA/featured.
Multiplatform shared codebase with Kotlin/Native - UA Mobile 2019Eugene Kurko
f you want to share the code between Android and iOS but you don't feel like doing C++/JNI, React Native, Flutter, you must try Kotlin/Native! In this presentation we will see how Kotlin/Native is different and in some aspects superior, and how easy it becomes to develop, debug and maintain a common codebase with JetBrains tools and without sacrificing runtime performance.
Multiplatform shared codebase with Kotlin/Native - UA Mobile 2019UA Mobile
If you want to share the code between Android and iOS but you don't feel like doing C++/JNI, React Native, Flutter, you must try Kotlin/Native! In this presentation we will see how Kotlin/Native is different and in some aspects superior, and how easy it becomes to develop, debug and maintain a common codebase with JetBrains tools and without sacrificing runtime performance.
The Present and The Future of Functional Programming in C++Alexander Granin
Keynote talk for C++ Siberia 2019.
I'm speaking about why Functional Programming is important in C++ world, what is the philosophy of FP in C++, and what features do we have. I'm presenting a connection of constexpr and template metaprogramming to pure FP, and talking about why monads are inevitable. I'm also discussing an upcoming features in C++.
Easing offline web application development with GWTArnaud Tournier
At this current time, HTML5 APIs are mature enough so that the web browser can now be a very good platform for applications that were before only implemented as native applications : offline applications with locally stored data, embedded SQL engines, etc. Although there are many good Javascript frameworks out there, the Java language allows to build, maintain, debug and work with ease on really big applications (> 100,000 LOC).
You'll discover in this presentation all the tools we assembled to make an application available with its data 100% of the time, even without internet!
Slides from my presentation, "Creating a Plug-In Architecture in .NET". Code is available as well at https://github.com/ondrejbalas/plugin-architecture
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.
Listen to the keynote address and hear about the latest developments from Rachana Ananthakrishnan and Ian Foster who review the updates to the Globus Platform and Service, and the relevance of Globus to the scientific community as an automation platform to accelerate scientific discovery.
Top 7 Unique WhatsApp API Benefits | Saudi ArabiaYara Milbes
Discover the transformative power of the WhatsApp API in our latest SlideShare presentation, "Top 7 Unique WhatsApp API Benefits." In today's fast-paced digital era, effective communication is crucial for both personal and professional success. Whether you're a small business looking to enhance customer interactions or an individual seeking seamless communication with loved ones, the WhatsApp API offers robust capabilities that can significantly elevate your experience.
In this presentation, we delve into the top 7 distinctive benefits of the WhatsApp API, provided by the leading WhatsApp API service provider in Saudi Arabia. Learn how to streamline customer support, automate notifications, leverage rich media messaging, run scalable marketing campaigns, integrate secure payments, synchronize with CRM systems, and ensure enhanced security and privacy.
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...Globus
The U.S. Geological Survey (USGS) has made substantial investments in meeting evolving scientific, technical, and policy driven demands on storing, managing, and delivering data. As these demands continue to grow in complexity and scale, the USGS must continue to explore innovative solutions to improve its management, curation, sharing, delivering, and preservation approaches for large-scale research data. Supporting these needs, the USGS has partnered with the University of Chicago-Globus to research and develop advanced repository components and workflows leveraging its current investment in Globus. The primary outcome of this partnership includes the development of a prototype enterprise repository, driven by USGS Data Release requirements, through exploration and implementation of the entire suite of the Globus platform offerings, including Globus Flow, Globus Auth, Globus Transfer, and Globus Search. This presentation will provide insights into this research partnership, introduce the unique requirements and challenges being addressed and provide relevant project progress.
Enterprise Resource Planning System includes various modules that reduce any business's workload. Additionally, it organizes the workflows, which drives towards enhancing productivity. Here are a detailed explanation of the ERP modules. Going through the points will help you understand how the software is changing the work dynamics.
To know more details here: https://blogs.nyggs.com/nyggs/enterprise-resource-planning-erp-system-modules/
Graspan: A Big Data System for Big Code AnalysisAftab Hussain
We built a disk-based parallel graph system, Graspan, that uses a novel edge-pair centric computation model to compute dynamic transitive closures on very large program graphs.
We implement context-sensitive pointer/alias and dataflow analyses on Graspan. An evaluation of these analyses on large codebases such as Linux shows that their Graspan implementations scale to millions of lines of code and are much simpler than their original implementations.
These analyses were used to augment the existing checkers; these augmented checkers found 132 new NULL pointer bugs and 1308 unnecessary NULL tests in Linux 4.4.0-rc5, PostgreSQL 8.3.9, and Apache httpd 2.2.18.
- Accepted in ASPLOS ‘17, Xi’an, China.
- Featured in the tutorial, Systemized Program Analyses: A Big Data Perspective on Static Analysis Scalability, ASPLOS ‘17.
- Invited for presentation at SoCal PLS ‘16.
- Invited for poster presentation at PLDI SRC ‘16.
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.
Quarkus Hidden and Forbidden ExtensionsMax Andersen
Quarkus has a vast extension ecosystem and is known for its subsonic and subatomic feature set. Some of these features are not as well known, and some extensions are less talked about, but that does not make them less interesting - quite the opposite.
Come join this talk to see some tips and tricks for using Quarkus and some of the lesser known features, extensions and development techniques.
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.
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.
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
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...Globus
The Earth System Grid Federation (ESGF) is a global network of data servers that archives and distributes the planet’s largest collection of Earth system model output for thousands of climate and environmental scientists worldwide. Many of these petabyte-scale data archives are located in proximity to large high-performance computing (HPC) or cloud computing resources, but the primary workflow for data users consists of transferring data, and applying computations on a different system. As a part of the ESGF 2.0 US project (funded by the United States Department of Energy Office of Science), we developed pre-defined data workflows, which can be run on-demand, capable of applying many data reduction and data analysis to the large ESGF data archives, transferring only the resultant analysis (ex. visualizations, smaller data files). In this talk, we will showcase a few of these workflows, highlighting how Globus Flows can be used for petabyte-scale climate analysis.
Prosigns: Transforming Business with Tailored Technology SolutionsProsigns
Unlocking Business Potential: Tailored Technology Solutions by Prosigns
Discover how Prosigns, a leading technology solutions provider, partners with businesses to drive innovation and success. Our presentation showcases our comprehensive range of services, including custom software development, web and mobile app development, AI & ML solutions, blockchain integration, DevOps services, and Microsoft Dynamics 365 support.
Custom Software Development: Prosigns specializes in creating bespoke software solutions that cater to your unique business needs. Our team of experts works closely with you to understand your requirements and deliver tailor-made software that enhances efficiency and drives growth.
Web and Mobile App Development: From responsive websites to intuitive mobile applications, Prosigns develops cutting-edge solutions that engage users and deliver seamless experiences across devices.
AI & ML Solutions: Harnessing the power of Artificial Intelligence and Machine Learning, Prosigns provides smart solutions that automate processes, provide valuable insights, and drive informed decision-making.
Blockchain Integration: Prosigns offers comprehensive blockchain solutions, including development, integration, and consulting services, enabling businesses to leverage blockchain technology for enhanced security, transparency, and efficiency.
DevOps Services: Prosigns' DevOps services streamline development and operations processes, ensuring faster and more reliable software delivery through automation and continuous integration.
Microsoft Dynamics 365 Support: Prosigns provides comprehensive support and maintenance services for Microsoft Dynamics 365, ensuring your system is always up-to-date, secure, and running smoothly.
Learn how our collaborative approach and dedication to excellence help businesses achieve their goals and stay ahead in today's digital landscape. From concept to deployment, Prosigns is your trusted partner for transforming ideas into reality and unlocking the full potential of your business.
Join us on a journey of innovation and growth. Let's partner for success with Prosigns.
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/
We describe the deployment and use of Globus Compute for remote computation. This content is aimed at researchers who wish to compute on remote resources using a unified programming interface, as well as system administrators who will deploy and operate Globus Compute services on their research computing infrastructure.
Developing Distributed High-performance Computing Capabilities of an Open Sci...Globus
COVID-19 had an unprecedented impact on scientific collaboration. The pandemic and its broad response from the scientific community has forged new relationships among public health practitioners, mathematical modelers, and scientific computing specialists, while revealing critical gaps in exploiting advanced computing systems to support urgent decision making. Informed by our team’s work in applying high-performance computing in support of public health decision makers during the COVID-19 pandemic, we present how Globus technologies are enabling the development of an open science platform for robust epidemic analysis, with the goal of collaborative, secure, distributed, on-demand, and fast time-to-solution analyses to support public health.
Developing Distributed High-performance Computing Capabilities of an Open Sci...
High performance web programming with C++14
1. Motivations C++11/14 Static introspection in the IOD library The Silicon Web Framework Conclusion
High performance web programming with C++14
Matthieu Garrigues, ENSTA-ParisTech
May 13, 2015
High performance web programming with C++14 1 / 61 Matthieu Garrigues
2. Motivations C++11/14 Static introspection in the IOD library The Silicon Web Framework Conclusion
Outline
1 Motivations
2 C++11/14
3 Static introspection in the IOD library
4 The Silicon Web Framework
5 Conclusion
High performance web programming with C++14 2 / 61 Matthieu Garrigues
3. Motivations C++11/14 Static introspection in the IOD library The Silicon Web Framework Conclusion
Outline
1 Motivations
2 C++11/14
3 Static introspection in the IOD library
4 The Silicon Web Framework
5 Conclusion
High performance web programming with C++14 3 / 61 Matthieu Garrigues
4. Motivations C++11/14 Static introspection in the IOD library The Silicon Web Framework Conclusion
Motivations
C++ is one of the most efficient language for web programming:
techempower.com/benchmarks
High performance web programming with C++14 4 / 61 Matthieu Garrigues
5. Motivations C++11/14 Static introspection in the IOD library The Silicon Web Framework Conclusion
Motivations
But, it is not really famous for its productivity and ease of use.
High performance web programming with C++14 5 / 61 Matthieu Garrigues
6. Motivations C++11/14 Static introspection in the IOD library The Silicon Web Framework Conclusion
Motivations
So, let’s leverage the new C++14 to ease the writting of web
services without impacting its speed of execution...
High performance web programming with C++14 6 / 61 Matthieu Garrigues
7. Motivations C++11/14 Static introspection in the IOD library The Silicon Web Framework Conclusion
Outline
1 Motivations
2 C++11/14
3 Static introspection in the IOD library
4 The Silicon Web Framework
5 Conclusion
High performance web programming with C++14 7 / 61 Matthieu Garrigues
8. Motivations C++11/14 Static introspection in the IOD library The Silicon Web Framework Conclusion
C++11/14
The C++11/14 greatly improves C++, but C/C++ web
frameworks were created with C++98:
TreeFrog
cppnetlib
Wt
CppCMS
lwan
h2o
Facebook Proxygen
....
High performance web programming with C++14 8 / 61 Matthieu Garrigues
9. Motivations C++11/14 Static introspection in the IOD library The Silicon Web Framework Conclusion
C++11/14
Let’s take a look at some of the C++11/14 new features.
High performance web programming with C++14 9 / 61 Matthieu Garrigues
10. Motivations C++11/14 Static introspection in the IOD library The Silicon Web Framework Conclusion
C++11/14: auto
Automatic type inference
auto i = 42;
for ( auto it = v . begin () ; it != v . end () ; it++)
{ . . . }
template <typename A , typename B>
auto fun ( A a , B b ) { return a + b ; }
High performance web programming with C++14 10 / 61 Matthieu Garrigues
11. Motivations C++11/14 Static introspection in the IOD library The Silicon Web Framework Conclusion
C++11/14: decltype
Automatic type computation
using a_type =
decltype (/ a complex expression .
You do not want to manually compute its
type . / )
High performance web programming with C++14 11 / 61 Matthieu Garrigues
12. Motivations C++11/14 Static introspection in the IOD library The Silicon Web Framework Conclusion
C++11/14: lambda functions
Lambda functions
std : : vector<int> V = { 3 , 6 , 2 , 5 , 6 , 7 , 5};
std : : sort ( V . begin () , V . end () ,
[ ] ( int a , int b ) { return a > b ; }) ;
High performance web programming with C++14 12 / 61 Matthieu Garrigues
13. Motivations C++11/14 Static introspection in the IOD library The Silicon Web Framework Conclusion
C++11/14: What’s new?
Generic lambda functions
auto print = [ ] ( auto e )
{
cout << e << endl ;
};
print (1) ; // i n t
print (2. 3 f ) ; // f l o a t
print ( "test" ) ; // const char ∗
High performance web programming with C++14 13 / 61 Matthieu Garrigues
14. Motivations C++11/14 Static introspection in the IOD library The Silicon Web Framework Conclusion
C++11/14: What’s new?
Variadic templates
void variadic_printf () {}
template <typename A , typename . . . T>
void variadic_printf ( const A& a , T &&... tail )
{
std : : cout << a ;
variadic_printf ( std : : forward<T>(tail ) . . . ) ;
}
High performance web programming with C++14 14 / 61 Matthieu Garrigues
15. Motivations C++11/14 Static introspection in the IOD library The Silicon Web Framework Conclusion
C++11/14: What’s new?
The constexpr keyword
constexpr int
compile_time_add ( int a , int b )
{
return a + b ;
}
High performance web programming with C++14 15 / 61 Matthieu Garrigues
16. Motivations C++11/14 Static introspection in the IOD library The Silicon Web Framework Conclusion
C++11/14: What’s new?
They are great features. But how do they help Web Programming?
High performance web programming with C++14 16 / 61 Matthieu Garrigues
17. Motivations C++11/14 Static introspection in the IOD library The Silicon Web Framework Conclusion
Outline
1 Motivations
2 C++11/14
3 Static introspection in the IOD library
4 The Silicon Web Framework
5 Conclusion
High performance web programming with C++14 17 / 61 Matthieu Garrigues
18. Motivations C++11/14 Static introspection in the IOD library The Silicon Web Framework Conclusion
Our problem
A kind of static introspection exists in C++.
But, it does not help to build:
Automatic serialization / deserialization
Object relational mapping
⇒ Let’s improve C++ introspection.
High performance web programming with C++14 18 / 61 Matthieu Garrigues
19. Motivations C++11/14 Static introspection in the IOD library The Silicon Web Framework Conclusion
Definition of a symbol
A symbol is a meta object member carrying its own static
introspection data.
Let dig into the symbol car:
struct _car_t
{
// symbol to s t r i n g .
const char∗ name () { return "car" ; }
template <typename T>
struct variable_type // Meta v a r i a b l e
{
T car ; // car member .
using symbol_type = _car_t ;
auto symbol () const { return _car_t () ; }
};
}
_car_t _car ; // Symbol d e f i n i t i o n .
High performance web programming with C++14 19 / 61 Matthieu Garrigues
20. Motivations C++11/14 Static introspection in the IOD library The Silicon Web Framework Conclusion
Symbol definition
By convention symbols start with . They are included in the
namespace s to avoid name conflicts.
A macro function helps the definition of symbols:
iod_define_symbol ( car ) ; // d e f i n e s s : : c a r
iod_define_symbol ( name ) ; // d e f i n e s s : : name
High performance web programming with C++14 20 / 61 Matthieu Garrigues
21. Motivations C++11/14 Static introspection in the IOD library The Silicon Web Framework Conclusion
Using symbols
Using the symbol car:
auto x = _car_t : : variable_type<string >() ;
x . car = "BMW" ;
// x . value () == ”BMW”
// x . symbol () r e t u r n s c a r t () ;
// x . symbol () . name () r e t u r n s ”car ”;
High performance web programming with C++14 21 / 61 Matthieu Garrigues
22. Motivations C++11/14 Static introspection in the IOD library The Silicon Web Framework Conclusion
Only one member?
Just one member per object is quite a limitation, so...
High performance web programming with C++14 22 / 61 Matthieu Garrigues
23. Motivations C++11/14 Static introspection in the IOD library The Silicon Web Framework Conclusion
Statically introspectable objects
Let’s stack them together into IOD’s statically introspectable
objects (SIO).
template <typename . . . Members>
struct sio : public Members . . .
{
sio ( Members . . . s ) : Members ( s ) . . . {}
};
using person_type =
sio<_id_t : : variable_type<int>,
_name_t : : variable_type<string>>;
IOD relies on inheritance to stack the members id and name
together.
High performance web programming with C++14 23 / 61 Matthieu Garrigues
24. Motivations C++11/14 Static introspection in the IOD library The Silicon Web Framework Conclusion
Statically introspectable objects
The D helper is our friend.
auto john = D ( _id = 42 ,
_name = "John" ) ;
// john . i d == 42;
// john . name == ”John ”;
High performance web programming with C++14 24 / 61 Matthieu Garrigues
25. Motivations C++11/14 Static introspection in the IOD library The Silicon Web Framework Conclusion
Inside SIOs
Behind the scene, D puts the introspection data in the SIO type:
decltype ( john )
==
iod : : sio<s : : _id_t : : variable_type<int>,
s : : _name_t : : variable_type<string>>
High performance web programming with C++14 25 / 61 Matthieu Garrigues
26. Motivations C++11/14 Static introspection in the IOD library The Silicon Web Framework Conclusion
Foreach
Then, iod::foreach can easily iterate on statically introspectable
objects.
Let’s write a generic serializer:
foreach ( any_sio_object ) | [ ] ( auto& m )
{
std : : cout << m . symbol () . name ()
<< ": " << m . value () << std : : endl ;
};
=> Unrolled at compile time, no runtime cost.
High performance web programming with C++14 26 / 61 Matthieu Garrigues
27. Motivations C++11/14 Static introspection in the IOD library The Silicon Web Framework Conclusion
Foreach
iod::foreach also handles multiple arguments, the creation of new
objects...
auto sum =
foreach ( o1 , o2 ) | [ ] ( auto& m1 , auto& m2 )
{
return m1 . symbol () = m1 . value () + m2 . value () ;
};
Note: o1 and o2 must have the same number of members.
High performance web programming with C++14 27 / 61 Matthieu Garrigues
28. Motivations C++11/14 Static introspection in the IOD library The Silicon Web Framework Conclusion
Foreach
... and tuples
auto sum =
foreach ( tuple1 , tuple2 ) | [ ] ( auto& e1 , auto& e2 )
{
return e1 + e2 ;
};
Note: tuple1 and tuple2 must have the same number of elements.
High performance web programming with C++14 28 / 61 Matthieu Garrigues
29. Motivations C++11/14 Static introspection in the IOD library The Silicon Web Framework Conclusion
Static instropection: What for?
On top of static introspection (and other utilities), the IOD library
implements:
JSON serialization / deserialization
Dependency injection
High performance web programming with C++14 29 / 61 Matthieu Garrigues
30. Motivations C++11/14 Static introspection in the IOD library The Silicon Web Framework Conclusion
Outline
1 Motivations
2 C++11/14
3 Static introspection in the IOD library
4 The Silicon Web Framework
5 Conclusion
High performance web programming with C++14 30 / 61 Matthieu Garrigues
31. Motivations C++11/14 Static introspection in the IOD library The Silicon Web Framework Conclusion
The Silicon Web Framework: Goal
The Silicon Web Framework leverages static introspection to
ease the writting of web services, without impacting the
performances.
High performance web programming with C++14 31 / 61 Matthieu Garrigues
32. Motivations C++11/14 Static introspection in the IOD library The Silicon Web Framework Conclusion
The Silicon Web Framework: Hello world
Let’s build a simple hello world api.
High performance web programming with C++14 32 / 61 Matthieu Garrigues
33. Motivations C++11/14 Static introspection in the IOD library The Silicon Web Framework Conclusion
The Silicon Web Framework: Hello world
To serve this simple procedure via http:
[ ] { return "hello world" ; }
High performance web programming with C++14 33 / 61 Matthieu Garrigues
34. Motivations C++11/14 Static introspection in the IOD library The Silicon Web Framework Conclusion
The Silicon Web Framework: Hello world
Wrap it in an API and map the function to the route /hello:
make_api ( _hello = [ ] { return "hello world" ; }) ;
Note the use of IOD statically introspectable objects to model the
API.
High performance web programming with C++14 34 / 61 Matthieu Garrigues
35. Motivations C++11/14 Static introspection in the IOD library The Silicon Web Framework Conclusion
The Silicon Web Framework: Hello world
Let’s launch the microhttpd HTTP backend to serve our API.
Because the API is actually a SIO, the backend can bind the route
/hello to our lambda function.
mhd_json_serve ( make_api ( _hello = [ ] {
return "hello world" ;
}) , 9999) ;
That’s it.
curl "http ://127.0.0.1:9999/ hello"
hello world
Up to 285000 requests/seconds on a 4 cores Intel I5 3GHz: Exactly
what you get with a plain C microhttpd hello world server.
High performance web programming with C++14 35 / 61 Matthieu Garrigues
36. Motivations C++11/14 Static introspection in the IOD library The Silicon Web Framework Conclusion
The Silicon Web Framework: Procedure Arguments?
Procedures can take arguments:
auto api = make_api (
_hello ( _name = string () ) = [ ] ( auto params ) {
return "hello " + params . name ; }
) ;
The backend is responsible for deserialization and validation of the
procedure arguments.
High performance web programming with C++14 36 / 61 Matthieu Garrigues
37. Motivations C++11/14 Static introspection in the IOD library The Silicon Web Framework Conclusion
The Silicon Web Framework: Returning objects
Procedures can also return statically introspectable objects:
auto api = make_api (
_hello ( _name = string () ) = [ ] ( auto params ) {
return D ( _message = "Hello" + params . name ) ; }
) ;
The backend is responsible for serialization of the procedure return
values.
High performance web programming with C++14 37 / 61 Matthieu Garrigues
38. Motivations C++11/14 Static introspection in the IOD library The Silicon Web Framework Conclusion
Middlewares And Dependency injection
We need to provide access to middlewares:
Databases
Sessions
Logging
...
High performance web programming with C++14 38 / 61 Matthieu Garrigues
39. Motivations C++11/14 Static introspection in the IOD library The Silicon Web Framework Conclusion
Middlewares And Dependency injection
However, not all procedures need an access to all middlewares.
High performance web programming with C++14 39 / 61 Matthieu Garrigues
40. Motivations C++11/14 Static introspection in the IOD library The Silicon Web Framework Conclusion
Middlewares And Dependency injection
We want to require access to the middlewares just by declaring
them as argument:
auto api = make_api (
_a_procedure = [ ] ( sqlite_connection& c ,
logger& l ) {
// . . .
}
) ;
The framework introspects the function signature to inject the
matching middlewares as arguments.
High performance web programming with C++14 40 / 61 Matthieu Garrigues
41. Motivations C++11/14 Static introspection in the IOD library The Silicon Web Framework Conclusion
Middlewares And Dependency injection
Most middlewares cannot be created from nothing. Some need
factories.
The bind_factories method attaches factories to a given API:
auto api = make_api (
_procedure1 = [ ] ( sqlite_connection& c ) {} ,
_procedure2 = [ ] ( my_logger& l ) {} ,
_procedure3 = [ ] ( my_logger& l , sqlite_connection& c )
{}
) . bind_factories (
sqlite_connection_factory ( "blog.sqlite" ) ,
my_logger_factory ( "/tmp/server.log" )
) ;
IOD’s dependency injection takes care of binding the right factory
to the right procedure arguments.
High performance web programming with C++14 41 / 61 Matthieu Garrigues
42. Motivations C++11/14 Static introspection in the IOD library The Silicon Web Framework Conclusion
Anatomy of middleware
A middleware factory is a plain C++ class with one instantiate
method: the dependency injection entry point.
Let’s have a look at session_factory::instantiate:
session instantiate ( cookie& ck , db_connection& con )
{
return session ( ck , con , this−>sql_session_table ) ;
}
session is the middleware type.
Its instantiation depends on two middlewares: cookie and
db_connection.
High performance web programming with C++14 42 / 61 Matthieu Garrigues
43. Motivations C++11/14 Static introspection in the IOD library The Silicon Web Framework Conclusion
Inter Middleware Dependencies
cookie and db_connection also have factories, and their instantiation
may depend on other middlewares.
⇒ This leads to a dependency tree, resolved by IOD’s dependency
injection at compile time.
High performance web programming with C++14 43 / 61 Matthieu Garrigues
44. Motivations C++11/14 Static introspection in the IOD library The Silicon Web Framework Conclusion
Inter Middleware Dependencies
In other words, if a procedure requires a session object:
auto api = make_api ( _procedure1 = [ ] ( session& s ) {}) ;
High performance web programming with C++14 44 / 61 Matthieu Garrigues
45. Motivations C++11/14 Static introspection in the IOD library The Silicon Web Framework Conclusion
Inter Middleware Dependencies
The framework generates a code similar to this:
cookie ck = cookie_factory . instantiate () ;
db_connection con= db_connection_factory . instantiate () ;
session s = session_factory . instantiate ( ck , con ) ;
api . procedure1 ( s ) ;
High performance web programming with C++14 45 / 61 Matthieu Garrigues
46. Motivations C++11/14 Static introspection in the IOD library The Silicon Web Framework Conclusion
SQL Middlewares
Silicon SQL middlewares provide a basic interface with SQL
databases.
Sqlite and MySQL are already available.
[ ] ( sqlite_connection& c ) {
int i ;
c ( "Select 1 + 2" ) >> i ;
}
High performance web programming with C++14 46 / 61 Matthieu Garrigues
47. Motivations C++11/14 Static introspection in the IOD library The Silicon Web Framework Conclusion
SQL Middlewares: Iterations on Result Sets
Straightforward iteration on a result set:
c ( "SELECT name , age from users" ) () |
[ ] ( std : : string& name , int& age )
{
std : : cout << name << " " << age << std : : endl ;
};
Again, introspection on the lambda function arguments helps to
write zero cost abstractions.
High performance web programming with C++14 47 / 61 Matthieu Garrigues
48. Motivations C++11/14 Static introspection in the IOD library The Silicon Web Framework Conclusion
SQL Middlewares: Prepared statements
For better performance, prepared statements are created, cached,
and reused whenever a request is triggered more than once.
// F i r s t c a l l , prepare the SQL statement .
c ( "INSERT into users(name , age) VALUES (?, ?)" )
( "John" , 12) ;
// Second c a l l , reuse the cached statement .
c ( "INSERT into users(name , age) VALUES (?, ?)" )
( "Bob" , 14) ;
High performance web programming with C++14 48 / 61 Matthieu Garrigues
49. Motivations C++11/14 Static introspection in the IOD library The Silicon Web Framework Conclusion
SQL ORM Middlewares
It is pretty easy to generate SQL requests from statically
introspectable objects.
Let’s declare our statically introspectable User data type:
typedef
decltype ( D ( _id = int () ,
_login = string () ,
_password = string () ) )
User ;
High performance web programming with C++14 49 / 61 Matthieu Garrigues
50. Motivations C++11/14 Static introspection in the IOD library The Silicon Web Framework Conclusion
SQL ORMs
And give the ORM hints for the SQL generation:
typedef
decltype ( D ( _id ( _auto_increment ,
_primary_key ) = int () ,
_login = string () ,
_password = string () ) )
User ;
High performance web programming with C++14 50 / 61 Matthieu Garrigues
51. Motivations C++11/14 Static introspection in the IOD library The Silicon Web Framework Conclusion
SQL ORM Middlewares: Example
// The middleware type .
typedef sqlite_orm<User> user_orm ;
typedef sqlite_orm_factory<User> user_orm_factory ;
// An API making use of the ORM.
auto api = make_api (
_test_orm ( _id = int () ) = [ ] ( auto p , user_orm& users )
{
User u = users . find_by_id ( p . id ) ;
u . login = "Rob" ;
users . update ( u ) ;
}
// The f a c t o r i e s .
) . bind_factories ( sqlite_connection_factory ( "db.sql" ) ,
user_orm_factory ( "user_table" ) ) ;
High performance web programming with C++14 51 / 61 Matthieu Garrigues
52. Motivations C++11/14 Static introspection in the IOD library The Silicon Web Framework Conclusion
SQL CReate Update Delete
sql_crud generates Create Update and Delete routes for a given
ORM type:
auto api = make_api ( _user = sql_crud<user_orm >() ) ;
mhd_json_serve ( api , 9999) ;
Creates the following routes:
/user/create
/user/update
/user/destroy
And saves you tens of lines of code.
High performance web programming with C++14 52 / 61 Matthieu Garrigues
53. Motivations C++11/14 Static introspection in the IOD library The Silicon Web Framework Conclusion
SQL CReate Update Delete
The parameters of sql_crud allow to handle:
validation of objects
user authentication
pre/post processing.
High performance web programming with C++14 53 / 61 Matthieu Garrigues
54. Motivations C++11/14 Static introspection in the IOD library The Silicon Web Framework Conclusion
SQL CReate Update Delete
This parameterization relies on lambda functions and dependency
injection (DI). Let’s write an example with the _write_access
option:
sql_crud<user_orm >(
_write_access = [ ] ( user& u , session& s ) {
return u . id == s . user_id ;
}
)
Thanks to dependency propagation, the middlewares (session in
this example) and the current user object are accessible from the
callback.
High performance web programming with C++14 54 / 61 Matthieu Garrigues
55. Motivations C++11/14 Static introspection in the IOD library The Silicon Web Framework Conclusion
Silicon Backends
We have APIs and middlewares, let’s plug everything into the
network.
High performance web programming with C++14 55 / 61 Matthieu Garrigues
56. Motivations C++11/14 Static introspection in the IOD library The Silicon Web Framework Conclusion
Silicon Backends
Silicon backends leverage the introspection on Silicon APIs to serve
them via:
Differents protocols: HTTP/1, HTTP/2, Websockets...
Differents message formats: JSON, XML, ...
Differents protocol implementations: microhttpd, h2o, ...
As of today, April 2015, Silicon includes microhttpd/json and
websocketpp/json.
High performance web programming with C++14 56 / 61 Matthieu Garrigues
57. Motivations C++11/14 Static introspection in the IOD library The Silicon Web Framework Conclusion
Limitations of the framework
Slow compilation
2s for the hello world one liner
35s for a complex 110 lines API
GCC error messages
Static introspection can generate very, very long types
GCC error messages get hard to digest
Much better with Clang shortening long types
High performance web programming with C++14 57 / 61 Matthieu Garrigues
58. Motivations C++11/14 Static introspection in the IOD library The Silicon Web Framework Conclusion
Future works
Lower compilation time
More database middlewares (PostgreSQL, Redis, ...)
More backends (HTTP/2, ...)
Suggestions?
⇒ Contributions are welcome
High performance web programming with C++14 58 / 61 Matthieu Garrigues
59. Motivations C++11/14 Static introspection in the IOD library The Silicon Web Framework Conclusion
Outline
1 Motivations
2 C++11/14
3 Static introspection in the IOD library
4 The Silicon Web Framework
5 Conclusion
High performance web programming with C++14 59 / 61 Matthieu Garrigues
60. Motivations C++11/14 Static introspection in the IOD library The Silicon Web Framework Conclusion
Conclusion
The new C++ features enabled us to build zero cost abstractions
for building web services:
Simple to write
Without impacting running time
Where most bugs are reported by the compiler at compile time
With a tiny framework of less than 10000 C++ lines.
Open source (MIT): github.com/matt-42/silicon
High performance web programming with C++14 60 / 61 Matthieu Garrigues
61. Motivations C++11/14 Static introspection in the IOD library The Silicon Web Framework Conclusion
Question?
_ask ( _question ) = [ ] ( auto p , my_smart_middleware& m )
{
return m . answer ( p . question ) ;
}
Or visit http://siliconframework.org
High performance web programming with C++14 61 / 61 Matthieu Garrigues