SlideShare a Scribd company logo
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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

More Related Content

What's hot

Fun with Lambdas: C++14 Style (part 2)
Fun with Lambdas: C++14 Style (part 2)Fun with Lambdas: C++14 Style (part 2)
Fun with Lambdas: C++14 Style (part 2)
Sumant Tambe
 
Programs of C++
Programs of C++Programs of C++
C++11
C++11C++11
Computer science Investigatory Project Class 12 C++
Computer science Investigatory Project Class 12 C++Computer science Investigatory Project Class 12 C++
Computer science Investigatory Project Class 12 C++
Rushil Aggarwal
 
C++11 concurrency
C++11 concurrencyC++11 concurrency
C++11 concurrencyxu liwei
 
CBSE Computer Project for Class 12 ( C++)
CBSE Computer Project for Class 12 ( C++)CBSE Computer Project for Class 12 ( C++)
CBSE Computer Project for Class 12 ( C++)
Karan Bora
 
CS6311- PROGRAMMING & DATA STRUCTURE II LABORATORY
CS6311- PROGRAMMING & DATA STRUCTURE II LABORATORYCS6311- PROGRAMMING & DATA STRUCTURE II LABORATORY
CS6311- PROGRAMMING & DATA STRUCTURE II LABORATORY
Radha Maruthiyan
 
81818088 isc-class-xii-computer-science-project-java-programs
81818088 isc-class-xii-computer-science-project-java-programs81818088 isc-class-xii-computer-science-project-java-programs
81818088 isc-class-xii-computer-science-project-java-programsAbhishek Jena
 
Lab manual data structure (cs305 rgpv) (usefulsearch.org) (useful search)
Lab manual data structure (cs305 rgpv) (usefulsearch.org)  (useful search)Lab manual data structure (cs305 rgpv) (usefulsearch.org)  (useful search)
Lab manual data structure (cs305 rgpv) (usefulsearch.org) (useful search)
Make Mannan
 
12th CBSE Practical File
12th CBSE Practical File12th CBSE Practical File
12th CBSE Practical File
Ashwin Francis
 
project report in C++ programming and SQL
project report in C++ programming and SQLproject report in C++ programming and SQL
project report in C++ programming and SQL
vikram mahendra
 
C++11
C++11C++11
C++11
ppd1961
 
C++17 introduction - Meetup @EtixLabs
C++17 introduction - Meetup @EtixLabsC++17 introduction - Meetup @EtixLabs
C++17 introduction - Meetup @EtixLabs
Stephane Gleizes
 
Practical Class 12th (c++programs+sql queries and output)
Practical Class 12th (c++programs+sql queries and output) Practical Class 12th (c++programs+sql queries and output)
Practical Class 12th (c++programs+sql queries and output)
Aman Deep
 
C programs
C programsC programs
C programs
Vikram Nandini
 
C# console programms
C# console programmsC# console programms
C# console programms
Yasir Khan
 
C++ Programming - 1st Study
C++ Programming - 1st StudyC++ Programming - 1st Study
C++ Programming - 1st Study
Chris Ohk
 

What's hot (20)

Fun with Lambdas: C++14 Style (part 2)
Fun with Lambdas: C++14 Style (part 2)Fun with Lambdas: C++14 Style (part 2)
Fun with Lambdas: C++14 Style (part 2)
 
Programs of C++
Programs of C++Programs of C++
Programs of C++
 
C++11
C++11C++11
C++11
 
Computer science Investigatory Project Class 12 C++
Computer science Investigatory Project Class 12 C++Computer science Investigatory Project Class 12 C++
Computer science Investigatory Project Class 12 C++
 
C++11 concurrency
C++11 concurrencyC++11 concurrency
C++11 concurrency
 
CBSE Computer Project for Class 12 ( C++)
CBSE Computer Project for Class 12 ( C++)CBSE Computer Project for Class 12 ( C++)
CBSE Computer Project for Class 12 ( C++)
 
CS6311- PROGRAMMING & DATA STRUCTURE II LABORATORY
CS6311- PROGRAMMING & DATA STRUCTURE II LABORATORYCS6311- PROGRAMMING & DATA STRUCTURE II LABORATORY
CS6311- PROGRAMMING & DATA STRUCTURE II LABORATORY
 
81818088 isc-class-xii-computer-science-project-java-programs
81818088 isc-class-xii-computer-science-project-java-programs81818088 isc-class-xii-computer-science-project-java-programs
81818088 isc-class-xii-computer-science-project-java-programs
 
Lab manual data structure (cs305 rgpv) (usefulsearch.org) (useful search)
Lab manual data structure (cs305 rgpv) (usefulsearch.org)  (useful search)Lab manual data structure (cs305 rgpv) (usefulsearch.org)  (useful search)
Lab manual data structure (cs305 rgpv) (usefulsearch.org) (useful search)
 
C program
C programC program
C program
 
12th CBSE Practical File
12th CBSE Practical File12th CBSE Practical File
12th CBSE Practical File
 
project report in C++ programming and SQL
project report in C++ programming and SQLproject report in C++ programming and SQL
project report in C++ programming and SQL
 
C++11
C++11C++11
C++11
 
C++17 introduction - Meetup @EtixLabs
C++17 introduction - Meetup @EtixLabsC++17 introduction - Meetup @EtixLabs
C++17 introduction - Meetup @EtixLabs
 
Practical Class 12th (c++programs+sql queries and output)
Practical Class 12th (c++programs+sql queries and output) Practical Class 12th (c++programs+sql queries and output)
Practical Class 12th (c++programs+sql queries and output)
 
C programs
C programsC programs
C programs
 
Data struture lab
Data struture labData struture lab
Data struture lab
 
C# console programms
C# console programmsC# console programms
C# console programms
 
C++ file
C++ fileC++ file
C++ file
 
C++ Programming - 1st Study
C++ Programming - 1st StudyC++ Programming - 1st Study
C++ Programming - 1st Study
 

Similar to High performance web programming with C++14

Better Code: Concurrency
Better Code: ConcurrencyBetter Code: Concurrency
Better Code: Concurrency
Platonov Sergey
 
MS Day EPITA 2010: Visual Studio 2010 et Framework .NET 4.0
MS Day EPITA 2010: Visual Studio 2010 et Framework .NET 4.0MS Day EPITA 2010: Visual Studio 2010 et Framework .NET 4.0
MS Day EPITA 2010: Visual Studio 2010 et Framework .NET 4.0Thomas Conté
 
Kandroid for nhn_deview_20131013_v5_final
Kandroid for nhn_deview_20131013_v5_finalKandroid for nhn_deview_20131013_v5_final
Kandroid for nhn_deview_20131013_v5_finalNAVER D2
 
Build 2016 - B880 - Top 6 Reasons to Move Your C++ Code to Visual Studio 2015
Build 2016 - B880 - Top 6 Reasons to Move Your C++ Code to Visual Studio 2015Build 2016 - B880 - Top 6 Reasons to Move Your C++ Code to Visual Studio 2015
Build 2016 - B880 - Top 6 Reasons to Move Your C++ Code to Visual Studio 2015
Windows Developer
 
Hidden Dragons of CGO
Hidden Dragons of CGOHidden Dragons of CGO
Hidden Dragons of CGO
All Things Open
 
Modern Release Engineering in a Nutshell - Why Researchers should Care!
Modern Release Engineering in a Nutshell - Why Researchers should Care!Modern Release Engineering in a Nutshell - Why Researchers should Care!
Modern Release Engineering in a Nutshell - Why Researchers should Care!
Bram Adams
 
Multiplatform shared codebase with Kotlin/Native - UA Mobile 2019
Multiplatform shared codebase with Kotlin/Native - UA Mobile 2019Multiplatform shared codebase with Kotlin/Native - UA Mobile 2019
Multiplatform shared codebase with Kotlin/Native - UA Mobile 2019
Eugene Kurko
 
Multiplatform shared codebase with Kotlin/Native - UA Mobile 2019
Multiplatform shared codebase with Kotlin/Native - UA Mobile 2019Multiplatform shared codebase with Kotlin/Native - UA Mobile 2019
Multiplatform shared codebase with Kotlin/Native - UA Mobile 2019
UA Mobile
 
Cross-Platform Mobile Development in Visual Studio
Cross-Platform Mobile Development in Visual StudioCross-Platform Mobile Development in Visual Studio
Cross-Platform Mobile Development in Visual Studiobryan costanich
 
Session 1 - c++ intro
Session   1 - c++ introSession   1 - c++ intro
Session 1 - c++ intro
VijayaNagarajan5
 
The Present and The Future of Functional Programming in C++
The Present and The Future of Functional Programming in C++The Present and The Future of Functional Programming in C++
The Present and The Future of Functional Programming in C++
Alexander Granin
 
Mixing C++ & Python II: Pybind11
Mixing C++ & Python II: Pybind11Mixing C++ & Python II: Pybind11
Mixing C++ & Python II: Pybind11
corehard_by
 
Life of a Chromium Developer
Life of a Chromium DeveloperLife of a Chromium Developer
Life of a Chromium Developermpaproductions
 
Whats new for CDT 7.0. for Helios Release
Whats new for CDT 7.0. for Helios ReleaseWhats new for CDT 7.0. for Helios Release
Whats new for CDT 7.0. for Helios Release
Teodor Madan
 
C++Basics2022.pptx
C++Basics2022.pptxC++Basics2022.pptx
C++Basics2022.pptx
Danielle780357
 
Introduction-to-C-Part-1 (1).doc
Introduction-to-C-Part-1 (1).docIntroduction-to-C-Part-1 (1).doc
Introduction-to-C-Part-1 (1).doc
MayurWagh46
 
Easing offline web application development with GWT
Easing offline web application development with GWTEasing offline web application development with GWT
Easing offline web application development with GWT
Arnaud Tournier
 
SPSToronto 2015 - Managing Office365 with PowerShell and CSOM
SPSToronto 2015 - Managing Office365 with PowerShell and CSOMSPSToronto 2015 - Managing Office365 with PowerShell and CSOM
SPSToronto 2015 - Managing Office365 with PowerShell and CSOM
amitvasu
 
Creating a Plug-In Architecture
Creating a Plug-In ArchitectureCreating a Plug-In Architecture
Creating a Plug-In Architecture
ondrejbalas
 
Introduction-to-C-Part-1.pptx
Introduction-to-C-Part-1.pptxIntroduction-to-C-Part-1.pptx
Introduction-to-C-Part-1.pptx
NEHARAJPUT239591
 

Similar to High performance web programming with C++14 (20)

Better Code: Concurrency
Better Code: ConcurrencyBetter Code: Concurrency
Better Code: Concurrency
 
MS Day EPITA 2010: Visual Studio 2010 et Framework .NET 4.0
MS Day EPITA 2010: Visual Studio 2010 et Framework .NET 4.0MS Day EPITA 2010: Visual Studio 2010 et Framework .NET 4.0
MS Day EPITA 2010: Visual Studio 2010 et Framework .NET 4.0
 
Kandroid for nhn_deview_20131013_v5_final
Kandroid for nhn_deview_20131013_v5_finalKandroid for nhn_deview_20131013_v5_final
Kandroid for nhn_deview_20131013_v5_final
 
Build 2016 - B880 - Top 6 Reasons to Move Your C++ Code to Visual Studio 2015
Build 2016 - B880 - Top 6 Reasons to Move Your C++ Code to Visual Studio 2015Build 2016 - B880 - Top 6 Reasons to Move Your C++ Code to Visual Studio 2015
Build 2016 - B880 - Top 6 Reasons to Move Your C++ Code to Visual Studio 2015
 
Hidden Dragons of CGO
Hidden Dragons of CGOHidden Dragons of CGO
Hidden Dragons of CGO
 
Modern Release Engineering in a Nutshell - Why Researchers should Care!
Modern Release Engineering in a Nutshell - Why Researchers should Care!Modern Release Engineering in a Nutshell - Why Researchers should Care!
Modern Release Engineering in a Nutshell - Why Researchers should Care!
 
Multiplatform shared codebase with Kotlin/Native - UA Mobile 2019
Multiplatform shared codebase with Kotlin/Native - UA Mobile 2019Multiplatform shared codebase with Kotlin/Native - UA Mobile 2019
Multiplatform shared codebase with Kotlin/Native - UA Mobile 2019
 
Multiplatform shared codebase with Kotlin/Native - UA Mobile 2019
Multiplatform shared codebase with Kotlin/Native - UA Mobile 2019Multiplatform shared codebase with Kotlin/Native - UA Mobile 2019
Multiplatform shared codebase with Kotlin/Native - UA Mobile 2019
 
Cross-Platform Mobile Development in Visual Studio
Cross-Platform Mobile Development in Visual StudioCross-Platform Mobile Development in Visual Studio
Cross-Platform Mobile Development in Visual Studio
 
Session 1 - c++ intro
Session   1 - c++ introSession   1 - c++ intro
Session 1 - c++ intro
 
The Present and The Future of Functional Programming in C++
The Present and The Future of Functional Programming in C++The Present and The Future of Functional Programming in C++
The Present and The Future of Functional Programming in C++
 
Mixing C++ & Python II: Pybind11
Mixing C++ & Python II: Pybind11Mixing C++ & Python II: Pybind11
Mixing C++ & Python II: Pybind11
 
Life of a Chromium Developer
Life of a Chromium DeveloperLife of a Chromium Developer
Life of a Chromium Developer
 
Whats new for CDT 7.0. for Helios Release
Whats new for CDT 7.0. for Helios ReleaseWhats new for CDT 7.0. for Helios Release
Whats new for CDT 7.0. for Helios Release
 
C++Basics2022.pptx
C++Basics2022.pptxC++Basics2022.pptx
C++Basics2022.pptx
 
Introduction-to-C-Part-1 (1).doc
Introduction-to-C-Part-1 (1).docIntroduction-to-C-Part-1 (1).doc
Introduction-to-C-Part-1 (1).doc
 
Easing offline web application development with GWT
Easing offline web application development with GWTEasing offline web application development with GWT
Easing offline web application development with GWT
 
SPSToronto 2015 - Managing Office365 with PowerShell and CSOM
SPSToronto 2015 - Managing Office365 with PowerShell and CSOMSPSToronto 2015 - Managing Office365 with PowerShell and CSOM
SPSToronto 2015 - Managing Office365 with PowerShell and CSOM
 
Creating a Plug-In Architecture
Creating a Plug-In ArchitectureCreating a Plug-In Architecture
Creating a Plug-In Architecture
 
Introduction-to-C-Part-1.pptx
Introduction-to-C-Part-1.pptxIntroduction-to-C-Part-1.pptx
Introduction-to-C-Part-1.pptx
 

Recently uploaded

Cracking the code review at SpringIO 2024
Cracking the code review at SpringIO 2024Cracking the code review at SpringIO 2024
Cracking the code review at SpringIO 2024
Paco van Beckhoven
 
Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus
 
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
Anthony Dahanne
 
Enhancing Research Orchestration Capabilities at ORNL.pdf
Enhancing Research Orchestration Capabilities at ORNL.pdfEnhancing Research Orchestration Capabilities at ORNL.pdf
Enhancing Research Orchestration Capabilities at ORNL.pdf
Globus
 
Accelerate Enterprise Software Engineering with Platformless
Accelerate Enterprise Software Engineering with PlatformlessAccelerate Enterprise Software Engineering with Platformless
Accelerate Enterprise Software Engineering with Platformless
WSO2
 
First Steps with Globus Compute Multi-User Endpoints
First Steps with Globus Compute Multi-User EndpointsFirst Steps with Globus Compute Multi-User Endpoints
First Steps with Globus Compute Multi-User Endpoints
Globus
 
Corporate Management | Session 3 of 3 | Tendenci AMS
Corporate Management | Session 3 of 3 | Tendenci AMSCorporate Management | Session 3 of 3 | Tendenci AMS
Corporate Management | Session 3 of 3 | Tendenci AMS
Tendenci - The Open Source AMS (Association Management Software)
 
How Recreation Management Software Can Streamline Your Operations.pptx
How Recreation Management Software Can Streamline Your Operations.pptxHow Recreation Management Software Can Streamline Your Operations.pptx
How Recreation Management Software Can Streamline Your Operations.pptx
wottaspaceseo
 
How to Position Your Globus Data Portal for Success Ten Good Practices
How to Position Your Globus Data Portal for Success Ten Good PracticesHow to Position Your Globus Data Portal for Success Ten Good Practices
How to Position Your Globus Data Portal for Success Ten Good Practices
Globus
 
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, BetterWebinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
XfilesPro
 
SOCRadar Research Team: Latest Activities of IntelBroker
SOCRadar Research Team: Latest Activities of IntelBrokerSOCRadar Research Team: Latest Activities of IntelBroker
SOCRadar Research Team: Latest Activities of IntelBroker
SOCRadar
 
May Marketo Masterclass, London MUG May 22 2024.pdf
May Marketo Masterclass, London MUG May 22 2024.pdfMay Marketo Masterclass, London MUG May 22 2024.pdf
May Marketo Masterclass, London MUG May 22 2024.pdf
Adele Miller
 
Prosigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology SolutionsProsigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology Solutions
Prosigns
 
A Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of PassageA Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of Passage
Philip Schwarz
 
Large Language Models and the End of Programming
Large Language Models and the End of ProgrammingLarge Language Models and the End of Programming
Large Language Models and the End of Programming
Matt Welsh
 
Quarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden ExtensionsQuarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden Extensions
Max Andersen
 
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoamOpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
takuyayamamoto1800
 
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERRORTROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
Tier1 app
 
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
Juraj Vysvader
 
Enterprise Resource Planning System in Telangana
Enterprise Resource Planning System in TelanganaEnterprise Resource Planning System in Telangana
Enterprise Resource Planning System in Telangana
NYGGS Automation Suite
 

Recently uploaded (20)

Cracking the code review at SpringIO 2024
Cracking the code review at SpringIO 2024Cracking the code review at SpringIO 2024
Cracking the code review at SpringIO 2024
 
Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024
 
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
 
Enhancing Research Orchestration Capabilities at ORNL.pdf
Enhancing Research Orchestration Capabilities at ORNL.pdfEnhancing Research Orchestration Capabilities at ORNL.pdf
Enhancing Research Orchestration Capabilities at ORNL.pdf
 
Accelerate Enterprise Software Engineering with Platformless
Accelerate Enterprise Software Engineering with PlatformlessAccelerate Enterprise Software Engineering with Platformless
Accelerate Enterprise Software Engineering with Platformless
 
First Steps with Globus Compute Multi-User Endpoints
First Steps with Globus Compute Multi-User EndpointsFirst Steps with Globus Compute Multi-User Endpoints
First Steps with Globus Compute Multi-User Endpoints
 
Corporate Management | Session 3 of 3 | Tendenci AMS
Corporate Management | Session 3 of 3 | Tendenci AMSCorporate Management | Session 3 of 3 | Tendenci AMS
Corporate Management | Session 3 of 3 | Tendenci AMS
 
How Recreation Management Software Can Streamline Your Operations.pptx
How Recreation Management Software Can Streamline Your Operations.pptxHow Recreation Management Software Can Streamline Your Operations.pptx
How Recreation Management Software Can Streamline Your Operations.pptx
 
How to Position Your Globus Data Portal for Success Ten Good Practices
How to Position Your Globus Data Portal for Success Ten Good PracticesHow to Position Your Globus Data Portal for Success Ten Good Practices
How to Position Your Globus Data Portal for Success Ten Good Practices
 
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, BetterWebinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
 
SOCRadar Research Team: Latest Activities of IntelBroker
SOCRadar Research Team: Latest Activities of IntelBrokerSOCRadar Research Team: Latest Activities of IntelBroker
SOCRadar Research Team: Latest Activities of IntelBroker
 
May Marketo Masterclass, London MUG May 22 2024.pdf
May Marketo Masterclass, London MUG May 22 2024.pdfMay Marketo Masterclass, London MUG May 22 2024.pdf
May Marketo Masterclass, London MUG May 22 2024.pdf
 
Prosigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology SolutionsProsigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology Solutions
 
A Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of PassageA Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of Passage
 
Large Language Models and the End of Programming
Large Language Models and the End of ProgrammingLarge Language Models and the End of Programming
Large Language Models and the End of Programming
 
Quarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden ExtensionsQuarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden Extensions
 
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoamOpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
 
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERRORTROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
 
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
 
Enterprise Resource Planning System in Telangana
Enterprise Resource Planning System in TelanganaEnterprise Resource Planning System in Telangana
Enterprise Resource Planning System in Telangana
 

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