SlideShare a Scribd company logo
Sumant Tambe
Sr. Software Engineer and Microsoft MVP
LinkedIn
@sutambe
SF Bay Area ACCU
Dec 13, 2017
12/15/2017 2
Alternative Title
2015
12/15/2017 3
Alternative Title
Functional Programming in C++ by
Manning
12/15/2017 5
Author
Ivan Cukic
This work was done in
12/15/2017 6
Connectivity Software for the Industrial Internet of Things (IIoT)
Why should you care?
• If you write software for living and if you are
serious about any of the following
– Bug-free, Expressive code
– Productivity
• Modularity
• Reusability
• Extensibility
• Maintainability
– and having fun while doing all of the above!
12/15/2017 7
Agenda
• Property-based Testing (briefly)
• Why composable generators
• Implementation of a functional generator library
– Less than 1500 lines of code
– Wrapping a coroutine as a generator (if time permits)
• Mathematics of API design
– Functor, Monoid, and Monad
• Type generators
– Generators at compile-time
12/15/2017 8
What’s a Property
• Reversing a linked-list twice has no effect
– reverse(reverse(list)) == list
• Compression can make things smaller
– compress(input).size <= input.size
• Round-trip serialization/deserialization has no
effect
– deserialize(serialize(input)) == input
12/15/2017 9
Testing RefleX
• RefleX is short for Reflection for DDS-XTypes
– DDS-XTypes is like Avro, ProtoBuf, etc.
• Reflex is a library that acts like a code generator
• Serialization and Deserialization
– Serializes types and data
– Compile-time reflection on C++ structs/classes
• C++11/14
• Link
12/15/2017 10
C++ Code
(classes)
XTypes
Schema and
Data
RefleX Example
12/15/2017 11
class ShapeType
{
std::string color_;
int x_, y_, shapesize_;
public:
ShapeType() {}
ShapeType(const std::string & color,
int x, int y, int shapesize)
: color_(color), x_(x), y_(y),
shapesize_(shapesize)
{}
std::string & color();
int & x();
int & y();
int & shapesize();
};
#include "reflex.h"
REFLEX_ADAPT_STRUCT(
ShapeType,
(std::string, color(), KEY)
(int, x())
(int, y())
(int, shapesize()))
Uses boost Fusion (duh!)
A property-test in RefleX
12/15/2017 12
template <class T>
void test_roundtrip_property(const T & in)
{
T out;
reflex::TypeManager<T> tm; // create Xtypes schema
reflex::SafeDynamicData<T> safedd =
tm.create_dynamicdata(in); // create Xtypes data
reflex::read_dynamicdata(out, safedd);
assert(in == out); // must be true for all T
}
What is T?
What is in?
Property-based Testing
• Complementary to traditional example-based testing
• Specify post-conditions that must hold no matter what
• Encourages the programmer to think harder about the code
• More declarative
• Need data generators to produce inputs
• Need type generators to produce input types
• Free reproducers!
– Good property-based testing frameworks shrink inputs to minimal
automatically
• Famous
– Haskell’s QuickCheck
– Scala’s ScalaTest
12/15/2017 13
12/15/2017 14
Random Integer Generator
12/15/2017 15
• The simplest data generator
size_t seed = time(nullptr);
srandom(seed);
size_t rand()
{
return random();
}
• Alternatively
size_t seed =
std::chrono::system_clock::now().time_since_epoch().count();
size_t rand()
{
static std::mt19937 mt(seed);
return mt();
}
Fundamental Data Generators
12/15/2017 16
• A bool generator
bool bool_gen() {
return rand() % 2;
}
• An uppercase character generator
char uppercase_gen() // A=65, Z=90
return static_cast<char>(‘A’ + rand() % 26))
}
Data Generators
12/15/2017 17
• A range generator
– Generates any number in the range (inclusive)
int range_gen(int lo, int hi)
return lo + rand() % (hi – lo + 1);
}
• Inconvenient because args must be passed every time
Closure as generator
12/15/2017 18
• A stateful range generator
– Generates a random number in the given range
auto make_range_gen(int lo, int hi)
return [lo, hi]() {
return lo + rand() % (hi – lo + 1);
}
}
auto r = range_gen(20, 25);
std::cout << r(); // one of 20, 21, 22, 23, 24, 25
Closure as generator
12/15/2017 19
• The oneof generator
template <class T>
auto make_oneof_gen(std::initializer_list<T> list)
{
return [options = std::vector<T>(list)]() {
return *(options.begin() + rand() % options.size());
};
}
auto days = { “Sun”, “Mon”, “Tue”, “Wed”, “Thu”, “Fri”, “Sat” }
auto gen = make_oneof_gen(days);
std::cout << gen(); // one of Sun, Mon, Tue, Wed, Thu, Fri, Sat
Closure vs Object
• Is function/closure a sufficient abstraction for
any generator?
[]() {
return blah;
}
• Answer depends upon your language
– No. In C++
12/15/2017 20
12/15/2017 21
“Closures are poor man's
objects; Objects are poor
man's closure”
-- The venerable master Qc NaSource Google images
The Generator Class Template
12/15/2017 22
template <class T, class GenFunc>
struct Gen : private GenFunc
{
using value_type = T;
explicit Gen(GenFunc func)
: GenFunc(std::move(func))
{ }
T generate()
{
return GenFunc::operator()();
}
// ...
};
Creating Gen<T> from lambdas
template <class GenFunc>
auto make_gen_from(GenFunc&& func)
{
return
Gen<decltype(func()), GenFunc>(std::forward<GenFunc>(func));
}
template <class Integer>
auto make_range_gen(Integer lo, Integer hi)
{
return make_gen_from([lo, hi]() {
return static_cast<Integer>(lo + rand() % (hi - lo));
});
}
12/15/2017 23
The Real Power of Generators: Composition
• make_gen_from is low level
• Better—Producing complex generators from one or
more simpler Generators
12/15/2017 24
Generator
map
reduce
concat
where
zip_with
concat_map
take
scan
The Generator Class Template
12/15/2017 25
template <class T, class GenFunc>
struct Gen : private GenFunc
{
using value_type = T;
explicit Gen(GenFunc func)
: GenFunc(std::move(func))
{ }
T generate()
{
return GenFunc::operator()();
}
auto map(...) const;
auto zip_with(...) const;
auto concat(...) const;
auto take(...) const;auto concat_map(...) const;
auto reduce(...) const;
auto where(...) const;
auto scan(...) const;
};
Mapping over a generator
12/15/2017 26
vector<string> days = { “Sun”, “Mon”, “Tue”, “Wed”,
“Thu”, “Fri”, “Sat” };
auto range_gen = gen::make_range_gen(0,6);
// random numbers in range 0..6
auto day_gen = range_gen.map([&](int i) { return days[i]; });
// random days in range “Sun” to “Sat”
while(true)
std::cout << day_gen.generate();
// random days in range “Sun” to “Sat”
Gen<int>  Gen<string>
f(int  string)
std::function<string(int)>
12/15/2017 27
Generator is a
You can
over it.
Functor Laws
• Composition Law
gen.map(f).map(g) == gen.map(g o f)
12/15/2017 28
auto DAY_gen = range_gen
.map([&](int i) { return days[i]; });
.map([](const string & str) {
return std::toupper(str, std::locale());
});
auto DAY_gen = range_gen.map([&](int i) {
return std::to_upper(days[i], std::locale());
});
Functor Laws
• Identity Law
gen.map(a -> a) == gen
12/15/2017 29
auto gen2 == gen.map([](auto a) { return a; });
• Both gen and gen2 will generate the same data
– Their identities are different but they are still the same
Implementing map
template <class T>
template <class Func>
auto Gen<T>::map(Func&& func) const &
{
return make_gen_from(
[self = *this, // copy
func = std::forward<Func>(func)]() mutable {
return func(self.generate());
});
}
12/15/2017 30
auto Gen<T>::map(Func&& func) &&
{
return make_gen_from(
[self = std::move(*this), // move
func = std::forward<Func>(func)]() mutable {
return func(self.generate());
});
}
12/15/2017 31
Generator is a
Monoid Laws
• Identity Law
M o id = id o M = M
• Binary operation o = append
• Appending to identity (either way) must yield
the same generator
12/15/2017 32
auto identity = gen::make_empty_gen<int>();
gen::make_inorder_gen({ 1, 2, 3}).append(identity)
==
identity.append(gen::make_inorder_gen({ 1, 2, 3});
Monoid Laws
• Associative Law
(f o g) o h = f o (g o h)
• Binary operation o = append
• Order of operation does not matter. (The order of
operands does)
– Not to be confused with commutative property where the order of
operands does not matter
12/15/2017 33
auto f = gen::make_inorder_gen({ 1, 2});
auto g = gen::make_inorder_gen({ 3, 4});
auto h = gen::make_inorder_gen({ 5, 6});
(f.append(g)).append(h) == f.append(g.append(h));
Creating Identity Generator
make_empty_gen
template <class T>
auto make_empty_gen()
{
return make_gen_from([]() {
throw std::out_of_range("empty generator!");
return std::declval<T>();
});
}
12/15/2017 34
Gen::append
12/15/2017 35
template <class UGen>
auto append(UGen&& ugen) const
{
return make_gen_from(
[tgen = *this,
ugen = std::forward<UGen>(ugen),
tdone = false,
udone = false]() mutable {
if(!tdone)
{
try {
return tgen.generate();
}
catch(std::out_of_range &)
{
tdone = true;
}
}
if(!udone)
{
try {
return ugen.generate();
}
catch(std::out_of_range &) {
udone = true;
}
}
throw std::out_of_range(
"concat: both generators done!");
});
}
Zipping Generators
12/15/2017 36
auto x_gen = gen::make_stepper_gen(0,100);
auto y_gen = gen::make_stepper_gen(0,200,2);
auto point_gen =
x_gen.zip_with([](int x, int y)
return std::make_pair(x, y);
}, y_gen);
for(auto _: { 1,2,3 })
std::cout << point_gen.generate(); // {0,0}, {1,2}, {3,4}
end
zip_with is a generator of arbitrary struct/tuple values
Implementing zip_with
template <class T>
template <class Zipper, class... GenList>
auto Gen<T>::zip_with(Zipper&& func, GenList&&... genlist) const
{
return make_gen_from(
[self = *this,
genlist...,
func = std::forward<Zipper>(func)]() mutable {
return func(self.generate(), genlist.generate()...);
});
}
12/15/2017 37
12/15/2017 38
Generator is a
Dependent Generators (concat_map)
auto triangle_gen =
gen::make_inorder_gen({1,2,3,4,5,4,3,2,1})
.concat_map([](int i) {
std::cout << "n";
return gen::make_stepper_gen(1, i);
});
try {
while(true)
std::cout << triangle_gen.generate();
}
catch(std::out_of_range &) {
}
12/15/2017 39
1
12
123
1234
12345
1234
123
12
1
Monad Laws
auto f = [](int i) { return gen::make_stepper_gen(1, i); };
auto g = [](int i) { return gen::make_stepper_gen(i, 1, -1); };
auto M = gen::make_single_gen(300);
// left identity
M.concat_map(f) == f(300);
// right identity
M == M.concat_map([](int i) {
return gen::make_single_gen(i);
});
// associativity
M.concat_map(f).concat_map(g)
==
M.concat_map([f,g](int i) mutable {
return f(i).concat_map(g);
}));
12/15/2017 40
Monad’s “return” is make_single_gen
12/15/2017 41
template <class T>
auto make_single_gen(T&& t)
{
return make_gen_from([t = std::forward<T>(t),
done = false]() mutable {
if(!done)
{
done = true;
return t;
}
else
throw std::out_of_range("single generator completed!");
});
}
Monad’s “bind” is Gen::concat_map
• See generator.h
12/15/2017 42
12/15/2017 43
The Mathematics of the Generator API
Generators
• General design principal
– Create a language to solve a problem
– API is the language
– Reuse parsing/compilation of the host language (duh!)
• The “language” of Generators
– Primitive values are basic generators
– Complex values are composite generators
– All APIs result in some generator
• map, zip_with, concat_map, reduce, etc.
– I.e., generators form an algebra
12/15/2017 44
Algebra
A first-class, lawful abstraction
+
Compositional* API
12/15/2017 45
*Composition based on mathematical concepts
12/15/2017 46
What Math Concepts?
• Algebraic Structures from Category Theory
–Monoid
–Functor
–Monad
–Applicative
• Where to begin?
–Haskell
–But innocent should start with Scala perhaps
Back to the property-test in RefleX
12/15/2017 47
template <class T>
void test_roundtrip_property(const T & in)
{
T out;
reflex::TypeManager<T> tm;
reflex::SafeDynamicData<T> safedd =
tm.create_dynamicdata(in);
reflex::read_dynamicdata(out, safedd);
assert(in == out);
}
What is T?
What is in?
12/15/2017 48
if we can generate
we can generate
Random Numbers at Compile-time
#include <stdio.h>
enum test { Foo = RANDOM };
int main(void)
{
enum test foo = Foo;
printf("foo = %dn", foo);
return 0;
}
12/15/2017 49
$ gcc –DRANDOM=$RANDOM main.c –o main
$ ./main
foo = 17695
Random Numbers at Compile-time
enum test { Foo = RANDOM, Bar = LFSR(Foo) };
int main(void) {
enum test foo = Foo;
enum test bar = Bar;
printf("foo = %d, bar = %dn", foo, bar);
}
12/15/2017 50
constexpr int LFSR_bit(int prev) {
return (((prev >> 0) ^ (prev >> 2) ^
(prev >> 3) ^ (prev >> 5)) & 1);
}
constexpr int LFSR(int prev) {
return ((prev >> 1) | (LFSR_bit(prev) << 15));
}
$ gcc –DRANDOM=$RANDOM main.c –o main
$ ./main
foo = 17695, bar = 41615
Linear Feedback Shift Register (LFSR)
• Simple random number generator
• 4 bit Fibonacci LFSR
• Feedback polynomial = X4 + X3 + 1
• Taps 4 and 3
12/15/2017 51Image source: wikipedia
Linear Feedback Shift Register (LFSR)
• A 16 bit feedback polynomial
– X16 + X14 + X13 + X11 + 1
• Taps: 16, 14, 13, and 11
12/15/2017 52Image source: wikipedia
Random Type Generation at Compile-Time
template <int I> struct TypeMap;
template <> struct TypeMap<0> {
typedef int type;
};
template <> struct TypeMap<1> {
typedef char type;
};
template <> struct TypeMap<2> {
typedef float type;
};
template <> struct TypeMap<3> {
typedef double type;
};
12/15/2017 53
Random Type Generation at Compile-Time
#include <boost/core/demangle.hpp>
template <int seed>
struct RandomTuple {
typedef typename TypeMap<LFSR(seed) % 4>::type First;
typedef typename TypeMap<LFSR(LFSR(seed)) % 4>::type Second;
typedef typename TypeMap<LFSR(LFSR(LFSR(seed))) % 4>::type Third;
typedef std::tuple<First, Second, Third> type;
};
12/15/2017 54
$ g++ –DRANDOM=$RANDOM main.cpp –o main
$ ./main
foo = 11660, bar = 5830
tuple = std::tuple<float, double, char>
int main(void) {
auto tuple = RandomTuple<RANDOM>::type();
printf("tuple = %s",
boost::core::demangle(typeid(tuple).name()).c_str());
}
Live code
Tuples all the way down…
• Nested type generation using recursive
TypeMap
• Classic template meta-programming
• See type_generator.h
12/15/2017 56
Type Generators Demystified
• Random seed as command line preprocess argument
• Compile-time random numbers using LFSR constexpr
• C++ meta-programming for type synthesis
• std::string generator for type names and member
names
• RefleX to map types to typecode and dynamic data
• Source: https://github.com/sutambe/cpp-generators
12/15/2017 57
RefleX Property-test Type Generator
• “Good” Numbers
– 31415 (3 nested structs)
– 32415 (51 nested structs)
– 2626 (12 nested structs)
– 10295 (15 nested structs)
– 21525 (41 nested structs)
– 7937 ( 5 nested structs)
– ...
• “Bad” Numbers
– 2152 (test seg-faults) sizeof(tuple) > 2750 KB!
12/15/2017 58
Github: https://github.com/rticommunity/rticonnextdds-reflex/blob/develop/test/generator
12/15/2017 59
Thank You!

More Related Content

What's hot

Introduction to kotlin
Introduction to kotlinIntroduction to kotlin
Introduction to kotlin
NAVER Engineering
 
The Style of C++ 11
The Style of C++ 11The Style of C++ 11
The Style of C++ 11
Sasha Goldshtein
 
stacks and queues class 12 in c++
stacks and  queues class 12 in c++stacks and  queues class 12 in c++
stacks and queues class 12 in c++
Khushal Mehta
 
Software Design in Practice (with Java examples)
Software Design in Practice (with Java examples)Software Design in Practice (with Java examples)
Software Design in Practice (with Java examples)
Ganesh Samarthyam
 
Dr archana dhawan bajaj - csharp fundamentals slides
Dr archana dhawan bajaj - csharp fundamentals slidesDr archana dhawan bajaj - csharp fundamentals slides
Dr archana dhawan bajaj - csharp fundamentals slides
Dr-archana-dhawan-bajaj
 
C++11: Feel the New Language
C++11: Feel the New LanguageC++11: Feel the New Language
C++11: Feel the New Languagemspline
 
Modern C++
Modern C++Modern C++
Modern C++
Michael Clark
 
Big Data Day LA 2016/ Hadoop/ Spark/ Kafka track - Iterative Spark Developmen...
Big Data Day LA 2016/ Hadoop/ Spark/ Kafka track - Iterative Spark Developmen...Big Data Day LA 2016/ Hadoop/ Spark/ Kafka track - Iterative Spark Developmen...
Big Data Day LA 2016/ Hadoop/ Spark/ Kafka track - Iterative Spark Developmen...
Data Con LA
 
Practical pairing of generative programming with functional programming.
Practical pairing of generative programming with functional programming.Practical pairing of generative programming with functional programming.
Practical pairing of generative programming with functional programming.
Eugene Lazutkin
 
Understanding Javascript Engines
Understanding Javascript Engines Understanding Javascript Engines
Understanding Javascript Engines
Parashuram N
 
Javascript engine performance
Javascript engine performanceJavascript engine performance
Javascript engine performanceDuoyi Wu
 
Story of static code analyzer development
Story of static code analyzer developmentStory of static code analyzer development
Story of static code analyzer development
Andrey Karpov
 
Java 8 Stream API. A different way to process collections.
Java 8 Stream API. A different way to process collections.Java 8 Stream API. A different way to process collections.
Java 8 Stream API. A different way to process collections.
David Gómez García
 
Idiomatic C++
Idiomatic C++Idiomatic C++
Idiomatic C++
Federico Ficarelli
 
Gentle introduction to modern C++
Gentle introduction to modern C++Gentle introduction to modern C++
Gentle introduction to modern C++
Mihai Todor
 
Jug trojmiasto 2014.04.24 tricky stuff in java grammar and javac
Jug trojmiasto 2014.04.24  tricky stuff in java grammar and javacJug trojmiasto 2014.04.24  tricky stuff in java grammar and javac
Jug trojmiasto 2014.04.24 tricky stuff in java grammar and javac
Anna Brzezińska
 
Aggregate Programming in Scala
Aggregate Programming in ScalaAggregate Programming in Scala
Aggregate Programming in Scala
Roberto Casadei
 
Design Patterns - Compiler Case Study - Hands-on Examples
Design Patterns - Compiler Case Study - Hands-on ExamplesDesign Patterns - Compiler Case Study - Hands-on Examples
Design Patterns - Compiler Case Study - Hands-on Examples
Ganesh Samarthyam
 
Lisp Macros in 20 Minutes (Featuring Clojure)
Lisp Macros in 20 Minutes (Featuring Clojure)Lisp Macros in 20 Minutes (Featuring Clojure)
Lisp Macros in 20 Minutes (Featuring Clojure)
Phil Calçado
 
(ThoughtWorks Away Day 2009) one or two things you may not know about typesys...
(ThoughtWorks Away Day 2009) one or two things you may not know about typesys...(ThoughtWorks Away Day 2009) one or two things you may not know about typesys...
(ThoughtWorks Away Day 2009) one or two things you may not know about typesys...Phil Calçado
 

What's hot (20)

Introduction to kotlin
Introduction to kotlinIntroduction to kotlin
Introduction to kotlin
 
The Style of C++ 11
The Style of C++ 11The Style of C++ 11
The Style of C++ 11
 
stacks and queues class 12 in c++
stacks and  queues class 12 in c++stacks and  queues class 12 in c++
stacks and queues class 12 in c++
 
Software Design in Practice (with Java examples)
Software Design in Practice (with Java examples)Software Design in Practice (with Java examples)
Software Design in Practice (with Java examples)
 
Dr archana dhawan bajaj - csharp fundamentals slides
Dr archana dhawan bajaj - csharp fundamentals slidesDr archana dhawan bajaj - csharp fundamentals slides
Dr archana dhawan bajaj - csharp fundamentals slides
 
C++11: Feel the New Language
C++11: Feel the New LanguageC++11: Feel the New Language
C++11: Feel the New Language
 
Modern C++
Modern C++Modern C++
Modern C++
 
Big Data Day LA 2016/ Hadoop/ Spark/ Kafka track - Iterative Spark Developmen...
Big Data Day LA 2016/ Hadoop/ Spark/ Kafka track - Iterative Spark Developmen...Big Data Day LA 2016/ Hadoop/ Spark/ Kafka track - Iterative Spark Developmen...
Big Data Day LA 2016/ Hadoop/ Spark/ Kafka track - Iterative Spark Developmen...
 
Practical pairing of generative programming with functional programming.
Practical pairing of generative programming with functional programming.Practical pairing of generative programming with functional programming.
Practical pairing of generative programming with functional programming.
 
Understanding Javascript Engines
Understanding Javascript Engines Understanding Javascript Engines
Understanding Javascript Engines
 
Javascript engine performance
Javascript engine performanceJavascript engine performance
Javascript engine performance
 
Story of static code analyzer development
Story of static code analyzer developmentStory of static code analyzer development
Story of static code analyzer development
 
Java 8 Stream API. A different way to process collections.
Java 8 Stream API. A different way to process collections.Java 8 Stream API. A different way to process collections.
Java 8 Stream API. A different way to process collections.
 
Idiomatic C++
Idiomatic C++Idiomatic C++
Idiomatic C++
 
Gentle introduction to modern C++
Gentle introduction to modern C++Gentle introduction to modern C++
Gentle introduction to modern C++
 
Jug trojmiasto 2014.04.24 tricky stuff in java grammar and javac
Jug trojmiasto 2014.04.24  tricky stuff in java grammar and javacJug trojmiasto 2014.04.24  tricky stuff in java grammar and javac
Jug trojmiasto 2014.04.24 tricky stuff in java grammar and javac
 
Aggregate Programming in Scala
Aggregate Programming in ScalaAggregate Programming in Scala
Aggregate Programming in Scala
 
Design Patterns - Compiler Case Study - Hands-on Examples
Design Patterns - Compiler Case Study - Hands-on ExamplesDesign Patterns - Compiler Case Study - Hands-on Examples
Design Patterns - Compiler Case Study - Hands-on Examples
 
Lisp Macros in 20 Minutes (Featuring Clojure)
Lisp Macros in 20 Minutes (Featuring Clojure)Lisp Macros in 20 Minutes (Featuring Clojure)
Lisp Macros in 20 Minutes (Featuring Clojure)
 
(ThoughtWorks Away Day 2009) one or two things you may not know about typesys...
(ThoughtWorks Away Day 2009) one or two things you may not know about typesys...(ThoughtWorks Away Day 2009) one or two things you may not know about typesys...
(ThoughtWorks Away Day 2009) one or two things you may not know about typesys...
 

Similar to Systematic Generation Data and Types in C++

Beyond unit tests: Deployment and testing for Hadoop/Spark workflows
Beyond unit tests: Deployment and testing for Hadoop/Spark workflowsBeyond unit tests: Deployment and testing for Hadoop/Spark workflows
Beyond unit tests: Deployment and testing for Hadoop/Spark workflows
DataWorks Summit
 
Static analysis works for mission-critical systems, why not yours?
Static analysis works for mission-critical systems, why not yours? Static analysis works for mission-critical systems, why not yours?
Static analysis works for mission-critical systems, why not yours?
Rogue Wave Software
 
C# 6.0 Preview
C# 6.0 PreviewC# 6.0 Preview
C# 6.0 Preview
Fujio Kojima
 
Robust C++ Task Systems Through Compile-time Checks
Robust C++ Task Systems Through Compile-time ChecksRobust C++ Task Systems Through Compile-time Checks
Robust C++ Task Systems Through Compile-time Checks
Stoyan Nikolov
 
Property-based Testing and Generators (Lua)
Property-based Testing and Generators (Lua)Property-based Testing and Generators (Lua)
Property-based Testing and Generators (Lua)
Sumant Tambe
 
Beyond php it's not (just) about the code
Beyond php   it's not (just) about the codeBeyond php   it's not (just) about the code
Beyond php it's not (just) about the code
Wim Godden
 
Beyond Breakpoints: A Tour of Dynamic Analysis
Beyond Breakpoints: A Tour of Dynamic AnalysisBeyond Breakpoints: A Tour of Dynamic Analysis
Beyond Breakpoints: A Tour of Dynamic Analysis
Fastly
 
Beyond php - it's not (just) about the code
Beyond php - it's not (just) about the codeBeyond php - it's not (just) about the code
Beyond php - it's not (just) about the code
Wim Godden
 
Toub parallelism tour_oct2009
Toub parallelism tour_oct2009Toub parallelism tour_oct2009
Toub parallelism tour_oct2009nkaluva
 
Architecture for scalable Angular applications
Architecture for scalable Angular applicationsArchitecture for scalable Angular applications
Architecture for scalable Angular applications
Paweł Żurowski
 
Skiron - Experiments in CPU Design in D
Skiron - Experiments in CPU Design in DSkiron - Experiments in CPU Design in D
Skiron - Experiments in CPU Design in D
Mithun Hunsur
 
Apache Spark Structured Streaming for Machine Learning - StrataConf 2016
Apache Spark Structured Streaming for Machine Learning - StrataConf 2016Apache Spark Structured Streaming for Machine Learning - StrataConf 2016
Apache Spark Structured Streaming for Machine Learning - StrataConf 2016
Holden Karau
 
Evolving a Clean, Pragmatic Architecture at JBCNConf 2019
Evolving a Clean, Pragmatic Architecture at JBCNConf 2019Evolving a Clean, Pragmatic Architecture at JBCNConf 2019
Evolving a Clean, Pragmatic Architecture at JBCNConf 2019
Victor Rentea
 
10 ways to make your code rock
10 ways to make your code rock10 ways to make your code rock
10 ways to make your code rockmartincronje
 
Spark SQL Catalyst Code Optimization using Function Outlining with Kavana Bha...
Spark SQL Catalyst Code Optimization using Function Outlining with Kavana Bha...Spark SQL Catalyst Code Optimization using Function Outlining with Kavana Bha...
Spark SQL Catalyst Code Optimization using Function Outlining with Kavana Bha...
Databricks
 
Beyond PHP - It's not (just) about the code
Beyond PHP - It's not (just) about the codeBeyond PHP - It's not (just) about the code
Beyond PHP - It's not (just) about the code
Wim Godden
 
The Challenge of Bringing FEZ to PlayStation Platforms
The Challenge of Bringing FEZ to PlayStation PlatformsThe Challenge of Bringing FEZ to PlayStation Platforms
The Challenge of Bringing FEZ to PlayStation Platforms
Miguel Angel Horna
 
Golang dot-testing-lite
Golang dot-testing-liteGolang dot-testing-lite
Golang dot-testing-lite
Richárd Kovács
 
Hierarchical free monads and software design in fp
Hierarchical free monads and software design in fpHierarchical free monads and software design in fp
Hierarchical free monads and software design in fp
Alexander Granin
 
Eclipse Con 2015: Codan - a C/C++ Code Analysis Framework for CDT
Eclipse Con 2015: Codan - a C/C++ Code Analysis Framework for CDTEclipse Con 2015: Codan - a C/C++ Code Analysis Framework for CDT
Eclipse Con 2015: Codan - a C/C++ Code Analysis Framework for CDT
Elena Laskavaia
 

Similar to Systematic Generation Data and Types in C++ (20)

Beyond unit tests: Deployment and testing for Hadoop/Spark workflows
Beyond unit tests: Deployment and testing for Hadoop/Spark workflowsBeyond unit tests: Deployment and testing for Hadoop/Spark workflows
Beyond unit tests: Deployment and testing for Hadoop/Spark workflows
 
Static analysis works for mission-critical systems, why not yours?
Static analysis works for mission-critical systems, why not yours? Static analysis works for mission-critical systems, why not yours?
Static analysis works for mission-critical systems, why not yours?
 
C# 6.0 Preview
C# 6.0 PreviewC# 6.0 Preview
C# 6.0 Preview
 
Robust C++ Task Systems Through Compile-time Checks
Robust C++ Task Systems Through Compile-time ChecksRobust C++ Task Systems Through Compile-time Checks
Robust C++ Task Systems Through Compile-time Checks
 
Property-based Testing and Generators (Lua)
Property-based Testing and Generators (Lua)Property-based Testing and Generators (Lua)
Property-based Testing and Generators (Lua)
 
Beyond php it's not (just) about the code
Beyond php   it's not (just) about the codeBeyond php   it's not (just) about the code
Beyond php it's not (just) about the code
 
Beyond Breakpoints: A Tour of Dynamic Analysis
Beyond Breakpoints: A Tour of Dynamic AnalysisBeyond Breakpoints: A Tour of Dynamic Analysis
Beyond Breakpoints: A Tour of Dynamic Analysis
 
Beyond php - it's not (just) about the code
Beyond php - it's not (just) about the codeBeyond php - it's not (just) about the code
Beyond php - it's not (just) about the code
 
Toub parallelism tour_oct2009
Toub parallelism tour_oct2009Toub parallelism tour_oct2009
Toub parallelism tour_oct2009
 
Architecture for scalable Angular applications
Architecture for scalable Angular applicationsArchitecture for scalable Angular applications
Architecture for scalable Angular applications
 
Skiron - Experiments in CPU Design in D
Skiron - Experiments in CPU Design in DSkiron - Experiments in CPU Design in D
Skiron - Experiments in CPU Design in D
 
Apache Spark Structured Streaming for Machine Learning - StrataConf 2016
Apache Spark Structured Streaming for Machine Learning - StrataConf 2016Apache Spark Structured Streaming for Machine Learning - StrataConf 2016
Apache Spark Structured Streaming for Machine Learning - StrataConf 2016
 
Evolving a Clean, Pragmatic Architecture at JBCNConf 2019
Evolving a Clean, Pragmatic Architecture at JBCNConf 2019Evolving a Clean, Pragmatic Architecture at JBCNConf 2019
Evolving a Clean, Pragmatic Architecture at JBCNConf 2019
 
10 ways to make your code rock
10 ways to make your code rock10 ways to make your code rock
10 ways to make your code rock
 
Spark SQL Catalyst Code Optimization using Function Outlining with Kavana Bha...
Spark SQL Catalyst Code Optimization using Function Outlining with Kavana Bha...Spark SQL Catalyst Code Optimization using Function Outlining with Kavana Bha...
Spark SQL Catalyst Code Optimization using Function Outlining with Kavana Bha...
 
Beyond PHP - It's not (just) about the code
Beyond PHP - It's not (just) about the codeBeyond PHP - It's not (just) about the code
Beyond PHP - It's not (just) about the code
 
The Challenge of Bringing FEZ to PlayStation Platforms
The Challenge of Bringing FEZ to PlayStation PlatformsThe Challenge of Bringing FEZ to PlayStation Platforms
The Challenge of Bringing FEZ to PlayStation Platforms
 
Golang dot-testing-lite
Golang dot-testing-liteGolang dot-testing-lite
Golang dot-testing-lite
 
Hierarchical free monads and software design in fp
Hierarchical free monads and software design in fpHierarchical free monads and software design in fp
Hierarchical free monads and software design in fp
 
Eclipse Con 2015: Codan - a C/C++ Code Analysis Framework for CDT
Eclipse Con 2015: Codan - a C/C++ Code Analysis Framework for CDTEclipse Con 2015: Codan - a C/C++ Code Analysis Framework for CDT
Eclipse Con 2015: Codan - a C/C++ Code Analysis Framework for CDT
 

More from Sumant Tambe

Kafka tiered-storage-meetup-2022-final-presented
Kafka tiered-storage-meetup-2022-final-presentedKafka tiered-storage-meetup-2022-final-presented
Kafka tiered-storage-meetup-2022-final-presented
Sumant Tambe
 
Tuning kafka pipelines
Tuning kafka pipelinesTuning kafka pipelines
Tuning kafka pipelines
Sumant Tambe
 
New Tools for a More Functional C++
New Tools for a More Functional C++New Tools for a More Functional C++
New Tools for a More Functional C++
Sumant Tambe
 
C++ Coroutines
C++ CoroutinesC++ Coroutines
C++ Coroutines
Sumant Tambe
 
Reactive Stream Processing in Industrial IoT using DDS and Rx
Reactive Stream Processing in Industrial IoT using DDS and RxReactive Stream Processing in Industrial IoT using DDS and Rx
Reactive Stream Processing in Industrial IoT using DDS and Rx
Sumant Tambe
 
RPC over DDS Beta 1
RPC over DDS Beta 1RPC over DDS Beta 1
RPC over DDS Beta 1
Sumant Tambe
 
Remote Log Analytics Using DDS, ELK, and RxJS
Remote Log Analytics Using DDS, ELK, and RxJSRemote Log Analytics Using DDS, ELK, and RxJS
Remote Log Analytics Using DDS, ELK, and RxJS
Sumant Tambe
 
Reactive Stream Processing for Data-centric Publish/Subscribe
Reactive Stream Processing for Data-centric Publish/SubscribeReactive Stream Processing for Data-centric Publish/Subscribe
Reactive Stream Processing for Data-centric Publish/Subscribe
Sumant Tambe
 
Reactive Stream Processing Using DDS and Rx
Reactive Stream Processing Using DDS and RxReactive Stream Processing Using DDS and Rx
Reactive Stream Processing Using DDS and Rx
Sumant Tambe
 
Fun with Lambdas: C++14 Style (part 1)
Fun with Lambdas: C++14 Style (part 1)Fun with Lambdas: C++14 Style (part 1)
Fun with Lambdas: C++14 Style (part 1)
Sumant Tambe
 
An Extensible Architecture for Avionics Sensor Health Assessment Using DDS
An Extensible Architecture for Avionics Sensor Health Assessment Using DDSAn Extensible Architecture for Avionics Sensor Health Assessment Using DDS
An Extensible Architecture for Avionics Sensor Health Assessment Using DDS
Sumant Tambe
 
Standardizing the Data Distribution Service (DDS) API for Modern C++
Standardizing the Data Distribution Service (DDS) API for Modern C++Standardizing the Data Distribution Service (DDS) API for Modern C++
Standardizing the Data Distribution Service (DDS) API for Modern C++Sumant Tambe
 
Communication Patterns Using Data-Centric Publish/Subscribe
Communication Patterns Using Data-Centric Publish/SubscribeCommunication Patterns Using Data-Centric Publish/Subscribe
Communication Patterns Using Data-Centric Publish/Subscribe
Sumant Tambe
 
C++11 Idioms @ Silicon Valley Code Camp 2012
C++11 Idioms @ Silicon Valley Code Camp 2012 C++11 Idioms @ Silicon Valley Code Camp 2012
C++11 Idioms @ Silicon Valley Code Camp 2012
Sumant Tambe
 
Retargeting Embedded Software Stack for Many-Core Systems
Retargeting Embedded Software Stack for Many-Core SystemsRetargeting Embedded Software Stack for Many-Core Systems
Retargeting Embedded Software Stack for Many-Core Systems
Sumant Tambe
 
Ph.D. Dissertation
Ph.D. DissertationPh.D. Dissertation
Ph.D. Dissertation
Sumant Tambe
 
Native XML processing in C++ (BoostCon'11)
Native XML processing in C++ (BoostCon'11)Native XML processing in C++ (BoostCon'11)
Native XML processing in C++ (BoostCon'11)
Sumant Tambe
 

More from Sumant Tambe (17)

Kafka tiered-storage-meetup-2022-final-presented
Kafka tiered-storage-meetup-2022-final-presentedKafka tiered-storage-meetup-2022-final-presented
Kafka tiered-storage-meetup-2022-final-presented
 
Tuning kafka pipelines
Tuning kafka pipelinesTuning kafka pipelines
Tuning kafka pipelines
 
New Tools for a More Functional C++
New Tools for a More Functional C++New Tools for a More Functional C++
New Tools for a More Functional C++
 
C++ Coroutines
C++ CoroutinesC++ Coroutines
C++ Coroutines
 
Reactive Stream Processing in Industrial IoT using DDS and Rx
Reactive Stream Processing in Industrial IoT using DDS and RxReactive Stream Processing in Industrial IoT using DDS and Rx
Reactive Stream Processing in Industrial IoT using DDS and Rx
 
RPC over DDS Beta 1
RPC over DDS Beta 1RPC over DDS Beta 1
RPC over DDS Beta 1
 
Remote Log Analytics Using DDS, ELK, and RxJS
Remote Log Analytics Using DDS, ELK, and RxJSRemote Log Analytics Using DDS, ELK, and RxJS
Remote Log Analytics Using DDS, ELK, and RxJS
 
Reactive Stream Processing for Data-centric Publish/Subscribe
Reactive Stream Processing for Data-centric Publish/SubscribeReactive Stream Processing for Data-centric Publish/Subscribe
Reactive Stream Processing for Data-centric Publish/Subscribe
 
Reactive Stream Processing Using DDS and Rx
Reactive Stream Processing Using DDS and RxReactive Stream Processing Using DDS and Rx
Reactive Stream Processing Using DDS and Rx
 
Fun with Lambdas: C++14 Style (part 1)
Fun with Lambdas: C++14 Style (part 1)Fun with Lambdas: C++14 Style (part 1)
Fun with Lambdas: C++14 Style (part 1)
 
An Extensible Architecture for Avionics Sensor Health Assessment Using DDS
An Extensible Architecture for Avionics Sensor Health Assessment Using DDSAn Extensible Architecture for Avionics Sensor Health Assessment Using DDS
An Extensible Architecture for Avionics Sensor Health Assessment Using DDS
 
Standardizing the Data Distribution Service (DDS) API for Modern C++
Standardizing the Data Distribution Service (DDS) API for Modern C++Standardizing the Data Distribution Service (DDS) API for Modern C++
Standardizing the Data Distribution Service (DDS) API for Modern C++
 
Communication Patterns Using Data-Centric Publish/Subscribe
Communication Patterns Using Data-Centric Publish/SubscribeCommunication Patterns Using Data-Centric Publish/Subscribe
Communication Patterns Using Data-Centric Publish/Subscribe
 
C++11 Idioms @ Silicon Valley Code Camp 2012
C++11 Idioms @ Silicon Valley Code Camp 2012 C++11 Idioms @ Silicon Valley Code Camp 2012
C++11 Idioms @ Silicon Valley Code Camp 2012
 
Retargeting Embedded Software Stack for Many-Core Systems
Retargeting Embedded Software Stack for Many-Core SystemsRetargeting Embedded Software Stack for Many-Core Systems
Retargeting Embedded Software Stack for Many-Core Systems
 
Ph.D. Dissertation
Ph.D. DissertationPh.D. Dissertation
Ph.D. Dissertation
 
Native XML processing in C++ (BoostCon'11)
Native XML processing in C++ (BoostCon'11)Native XML processing in C++ (BoostCon'11)
Native XML processing in C++ (BoostCon'11)
 

Recently uploaded

APIs for Browser Automation (MoT Meetup 2024)
APIs for Browser Automation (MoT Meetup 2024)APIs for Browser Automation (MoT Meetup 2024)
APIs for Browser Automation (MoT Meetup 2024)
Boni García
 
Navigating the Metaverse: A Journey into Virtual Evolution"
Navigating the Metaverse: A Journey into Virtual Evolution"Navigating the Metaverse: A Journey into Virtual Evolution"
Navigating the Metaverse: A Journey into Virtual Evolution"
Donna Lenk
 
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptxTop Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
rickgrimesss22
 
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdfDominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
AMB-Review
 
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
Globus
 
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
 
AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI AppAI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
Google
 
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
 
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
 
OpenMetadata Community Meeting - 5th June 2024
OpenMetadata Community Meeting - 5th June 2024OpenMetadata Community Meeting - 5th June 2024
OpenMetadata Community Meeting - 5th June 2024
OpenMetadata
 
Vitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume MontevideoVitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume Montevideo
Vitthal Shirke
 
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
 
A Study of Variable-Role-based Feature Enrichment in Neural Models of Code
A Study of Variable-Role-based Feature Enrichment in Neural Models of CodeA Study of Variable-Role-based Feature Enrichment in Neural Models of Code
A Study of Variable-Role-based Feature Enrichment in Neural Models of Code
Aftab Hussain
 
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Globus
 
Introducing Crescat - Event Management Software for Venues, Festivals and Eve...
Introducing Crescat - Event Management Software for Venues, Festivals and Eve...Introducing Crescat - Event Management Software for Venues, Festivals and Eve...
Introducing Crescat - Event Management Software for Venues, Festivals and Eve...
Crescat
 
2024 RoOUG Security model for the cloud.pptx
2024 RoOUG Security model for the cloud.pptx2024 RoOUG Security model for the cloud.pptx
2024 RoOUG Security model for the cloud.pptx
Georgi Kodinov
 
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Shahin Sheidaei
 
Understanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSageUnderstanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSage
Globus
 
Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604
Fermin Galan
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
Safe Software
 

Recently uploaded (20)

APIs for Browser Automation (MoT Meetup 2024)
APIs for Browser Automation (MoT Meetup 2024)APIs for Browser Automation (MoT Meetup 2024)
APIs for Browser Automation (MoT Meetup 2024)
 
Navigating the Metaverse: A Journey into Virtual Evolution"
Navigating the Metaverse: A Journey into Virtual Evolution"Navigating the Metaverse: A Journey into Virtual Evolution"
Navigating the Metaverse: A Journey into Virtual Evolution"
 
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptxTop Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
 
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdfDominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
 
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
 
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
 
AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI AppAI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
 
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
 
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
 
OpenMetadata Community Meeting - 5th June 2024
OpenMetadata Community Meeting - 5th June 2024OpenMetadata Community Meeting - 5th June 2024
OpenMetadata Community Meeting - 5th June 2024
 
Vitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume MontevideoVitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume Montevideo
 
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
 
A Study of Variable-Role-based Feature Enrichment in Neural Models of Code
A Study of Variable-Role-based Feature Enrichment in Neural Models of CodeA Study of Variable-Role-based Feature Enrichment in Neural Models of Code
A Study of Variable-Role-based Feature Enrichment in Neural Models of Code
 
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
 
Introducing Crescat - Event Management Software for Venues, Festivals and Eve...
Introducing Crescat - Event Management Software for Venues, Festivals and Eve...Introducing Crescat - Event Management Software for Venues, Festivals and Eve...
Introducing Crescat - Event Management Software for Venues, Festivals and Eve...
 
2024 RoOUG Security model for the cloud.pptx
2024 RoOUG Security model for the cloud.pptx2024 RoOUG Security model for the cloud.pptx
2024 RoOUG Security model for the cloud.pptx
 
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
 
Understanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSageUnderstanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSage
 
Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
 

Systematic Generation Data and Types in C++

  • 1. Sumant Tambe Sr. Software Engineer and Microsoft MVP LinkedIn @sutambe SF Bay Area ACCU Dec 13, 2017
  • 4. Functional Programming in C++ by Manning 12/15/2017 5 Author Ivan Cukic
  • 5. This work was done in 12/15/2017 6 Connectivity Software for the Industrial Internet of Things (IIoT)
  • 6. Why should you care? • If you write software for living and if you are serious about any of the following – Bug-free, Expressive code – Productivity • Modularity • Reusability • Extensibility • Maintainability – and having fun while doing all of the above! 12/15/2017 7
  • 7. Agenda • Property-based Testing (briefly) • Why composable generators • Implementation of a functional generator library – Less than 1500 lines of code – Wrapping a coroutine as a generator (if time permits) • Mathematics of API design – Functor, Monoid, and Monad • Type generators – Generators at compile-time 12/15/2017 8
  • 8. What’s a Property • Reversing a linked-list twice has no effect – reverse(reverse(list)) == list • Compression can make things smaller – compress(input).size <= input.size • Round-trip serialization/deserialization has no effect – deserialize(serialize(input)) == input 12/15/2017 9
  • 9. Testing RefleX • RefleX is short for Reflection for DDS-XTypes – DDS-XTypes is like Avro, ProtoBuf, etc. • Reflex is a library that acts like a code generator • Serialization and Deserialization – Serializes types and data – Compile-time reflection on C++ structs/classes • C++11/14 • Link 12/15/2017 10 C++ Code (classes) XTypes Schema and Data
  • 10. RefleX Example 12/15/2017 11 class ShapeType { std::string color_; int x_, y_, shapesize_; public: ShapeType() {} ShapeType(const std::string & color, int x, int y, int shapesize) : color_(color), x_(x), y_(y), shapesize_(shapesize) {} std::string & color(); int & x(); int & y(); int & shapesize(); }; #include "reflex.h" REFLEX_ADAPT_STRUCT( ShapeType, (std::string, color(), KEY) (int, x()) (int, y()) (int, shapesize())) Uses boost Fusion (duh!)
  • 11. A property-test in RefleX 12/15/2017 12 template <class T> void test_roundtrip_property(const T & in) { T out; reflex::TypeManager<T> tm; // create Xtypes schema reflex::SafeDynamicData<T> safedd = tm.create_dynamicdata(in); // create Xtypes data reflex::read_dynamicdata(out, safedd); assert(in == out); // must be true for all T } What is T? What is in?
  • 12. Property-based Testing • Complementary to traditional example-based testing • Specify post-conditions that must hold no matter what • Encourages the programmer to think harder about the code • More declarative • Need data generators to produce inputs • Need type generators to produce input types • Free reproducers! – Good property-based testing frameworks shrink inputs to minimal automatically • Famous – Haskell’s QuickCheck – Scala’s ScalaTest 12/15/2017 13
  • 14. Random Integer Generator 12/15/2017 15 • The simplest data generator size_t seed = time(nullptr); srandom(seed); size_t rand() { return random(); } • Alternatively size_t seed = std::chrono::system_clock::now().time_since_epoch().count(); size_t rand() { static std::mt19937 mt(seed); return mt(); }
  • 15. Fundamental Data Generators 12/15/2017 16 • A bool generator bool bool_gen() { return rand() % 2; } • An uppercase character generator char uppercase_gen() // A=65, Z=90 return static_cast<char>(‘A’ + rand() % 26)) }
  • 16. Data Generators 12/15/2017 17 • A range generator – Generates any number in the range (inclusive) int range_gen(int lo, int hi) return lo + rand() % (hi – lo + 1); } • Inconvenient because args must be passed every time
  • 17. Closure as generator 12/15/2017 18 • A stateful range generator – Generates a random number in the given range auto make_range_gen(int lo, int hi) return [lo, hi]() { return lo + rand() % (hi – lo + 1); } } auto r = range_gen(20, 25); std::cout << r(); // one of 20, 21, 22, 23, 24, 25
  • 18. Closure as generator 12/15/2017 19 • The oneof generator template <class T> auto make_oneof_gen(std::initializer_list<T> list) { return [options = std::vector<T>(list)]() { return *(options.begin() + rand() % options.size()); }; } auto days = { “Sun”, “Mon”, “Tue”, “Wed”, “Thu”, “Fri”, “Sat” } auto gen = make_oneof_gen(days); std::cout << gen(); // one of Sun, Mon, Tue, Wed, Thu, Fri, Sat
  • 19. Closure vs Object • Is function/closure a sufficient abstraction for any generator? []() { return blah; } • Answer depends upon your language – No. In C++ 12/15/2017 20
  • 20. 12/15/2017 21 “Closures are poor man's objects; Objects are poor man's closure” -- The venerable master Qc NaSource Google images
  • 21. The Generator Class Template 12/15/2017 22 template <class T, class GenFunc> struct Gen : private GenFunc { using value_type = T; explicit Gen(GenFunc func) : GenFunc(std::move(func)) { } T generate() { return GenFunc::operator()(); } // ... };
  • 22. Creating Gen<T> from lambdas template <class GenFunc> auto make_gen_from(GenFunc&& func) { return Gen<decltype(func()), GenFunc>(std::forward<GenFunc>(func)); } template <class Integer> auto make_range_gen(Integer lo, Integer hi) { return make_gen_from([lo, hi]() { return static_cast<Integer>(lo + rand() % (hi - lo)); }); } 12/15/2017 23
  • 23. The Real Power of Generators: Composition • make_gen_from is low level • Better—Producing complex generators from one or more simpler Generators 12/15/2017 24 Generator map reduce concat where zip_with concat_map take scan
  • 24. The Generator Class Template 12/15/2017 25 template <class T, class GenFunc> struct Gen : private GenFunc { using value_type = T; explicit Gen(GenFunc func) : GenFunc(std::move(func)) { } T generate() { return GenFunc::operator()(); } auto map(...) const; auto zip_with(...) const; auto concat(...) const; auto take(...) const;auto concat_map(...) const; auto reduce(...) const; auto where(...) const; auto scan(...) const; };
  • 25. Mapping over a generator 12/15/2017 26 vector<string> days = { “Sun”, “Mon”, “Tue”, “Wed”, “Thu”, “Fri”, “Sat” }; auto range_gen = gen::make_range_gen(0,6); // random numbers in range 0..6 auto day_gen = range_gen.map([&](int i) { return days[i]; }); // random days in range “Sun” to “Sat” while(true) std::cout << day_gen.generate(); // random days in range “Sun” to “Sat” Gen<int>  Gen<string> f(int  string) std::function<string(int)>
  • 26. 12/15/2017 27 Generator is a You can over it.
  • 27. Functor Laws • Composition Law gen.map(f).map(g) == gen.map(g o f) 12/15/2017 28 auto DAY_gen = range_gen .map([&](int i) { return days[i]; }); .map([](const string & str) { return std::toupper(str, std::locale()); }); auto DAY_gen = range_gen.map([&](int i) { return std::to_upper(days[i], std::locale()); });
  • 28. Functor Laws • Identity Law gen.map(a -> a) == gen 12/15/2017 29 auto gen2 == gen.map([](auto a) { return a; }); • Both gen and gen2 will generate the same data – Their identities are different but they are still the same
  • 29. Implementing map template <class T> template <class Func> auto Gen<T>::map(Func&& func) const & { return make_gen_from( [self = *this, // copy func = std::forward<Func>(func)]() mutable { return func(self.generate()); }); } 12/15/2017 30 auto Gen<T>::map(Func&& func) && { return make_gen_from( [self = std::move(*this), // move func = std::forward<Func>(func)]() mutable { return func(self.generate()); }); }
  • 31. Monoid Laws • Identity Law M o id = id o M = M • Binary operation o = append • Appending to identity (either way) must yield the same generator 12/15/2017 32 auto identity = gen::make_empty_gen<int>(); gen::make_inorder_gen({ 1, 2, 3}).append(identity) == identity.append(gen::make_inorder_gen({ 1, 2, 3});
  • 32. Monoid Laws • Associative Law (f o g) o h = f o (g o h) • Binary operation o = append • Order of operation does not matter. (The order of operands does) – Not to be confused with commutative property where the order of operands does not matter 12/15/2017 33 auto f = gen::make_inorder_gen({ 1, 2}); auto g = gen::make_inorder_gen({ 3, 4}); auto h = gen::make_inorder_gen({ 5, 6}); (f.append(g)).append(h) == f.append(g.append(h));
  • 33. Creating Identity Generator make_empty_gen template <class T> auto make_empty_gen() { return make_gen_from([]() { throw std::out_of_range("empty generator!"); return std::declval<T>(); }); } 12/15/2017 34
  • 34. Gen::append 12/15/2017 35 template <class UGen> auto append(UGen&& ugen) const { return make_gen_from( [tgen = *this, ugen = std::forward<UGen>(ugen), tdone = false, udone = false]() mutable { if(!tdone) { try { return tgen.generate(); } catch(std::out_of_range &) { tdone = true; } } if(!udone) { try { return ugen.generate(); } catch(std::out_of_range &) { udone = true; } } throw std::out_of_range( "concat: both generators done!"); }); }
  • 35. Zipping Generators 12/15/2017 36 auto x_gen = gen::make_stepper_gen(0,100); auto y_gen = gen::make_stepper_gen(0,200,2); auto point_gen = x_gen.zip_with([](int x, int y) return std::make_pair(x, y); }, y_gen); for(auto _: { 1,2,3 }) std::cout << point_gen.generate(); // {0,0}, {1,2}, {3,4} end zip_with is a generator of arbitrary struct/tuple values
  • 36. Implementing zip_with template <class T> template <class Zipper, class... GenList> auto Gen<T>::zip_with(Zipper&& func, GenList&&... genlist) const { return make_gen_from( [self = *this, genlist..., func = std::forward<Zipper>(func)]() mutable { return func(self.generate(), genlist.generate()...); }); } 12/15/2017 37
  • 38. Dependent Generators (concat_map) auto triangle_gen = gen::make_inorder_gen({1,2,3,4,5,4,3,2,1}) .concat_map([](int i) { std::cout << "n"; return gen::make_stepper_gen(1, i); }); try { while(true) std::cout << triangle_gen.generate(); } catch(std::out_of_range &) { } 12/15/2017 39 1 12 123 1234 12345 1234 123 12 1
  • 39. Monad Laws auto f = [](int i) { return gen::make_stepper_gen(1, i); }; auto g = [](int i) { return gen::make_stepper_gen(i, 1, -1); }; auto M = gen::make_single_gen(300); // left identity M.concat_map(f) == f(300); // right identity M == M.concat_map([](int i) { return gen::make_single_gen(i); }); // associativity M.concat_map(f).concat_map(g) == M.concat_map([f,g](int i) mutable { return f(i).concat_map(g); })); 12/15/2017 40
  • 40. Monad’s “return” is make_single_gen 12/15/2017 41 template <class T> auto make_single_gen(T&& t) { return make_gen_from([t = std::forward<T>(t), done = false]() mutable { if(!done) { done = true; return t; } else throw std::out_of_range("single generator completed!"); }); }
  • 41. Monad’s “bind” is Gen::concat_map • See generator.h 12/15/2017 42
  • 42. 12/15/2017 43 The Mathematics of the Generator API
  • 43. Generators • General design principal – Create a language to solve a problem – API is the language – Reuse parsing/compilation of the host language (duh!) • The “language” of Generators – Primitive values are basic generators – Complex values are composite generators – All APIs result in some generator • map, zip_with, concat_map, reduce, etc. – I.e., generators form an algebra 12/15/2017 44
  • 44. Algebra A first-class, lawful abstraction + Compositional* API 12/15/2017 45 *Composition based on mathematical concepts
  • 45. 12/15/2017 46 What Math Concepts? • Algebraic Structures from Category Theory –Monoid –Functor –Monad –Applicative • Where to begin? –Haskell –But innocent should start with Scala perhaps
  • 46. Back to the property-test in RefleX 12/15/2017 47 template <class T> void test_roundtrip_property(const T & in) { T out; reflex::TypeManager<T> tm; reflex::SafeDynamicData<T> safedd = tm.create_dynamicdata(in); reflex::read_dynamicdata(out, safedd); assert(in == out); } What is T? What is in?
  • 47. 12/15/2017 48 if we can generate we can generate
  • 48. Random Numbers at Compile-time #include <stdio.h> enum test { Foo = RANDOM }; int main(void) { enum test foo = Foo; printf("foo = %dn", foo); return 0; } 12/15/2017 49 $ gcc –DRANDOM=$RANDOM main.c –o main $ ./main foo = 17695
  • 49. Random Numbers at Compile-time enum test { Foo = RANDOM, Bar = LFSR(Foo) }; int main(void) { enum test foo = Foo; enum test bar = Bar; printf("foo = %d, bar = %dn", foo, bar); } 12/15/2017 50 constexpr int LFSR_bit(int prev) { return (((prev >> 0) ^ (prev >> 2) ^ (prev >> 3) ^ (prev >> 5)) & 1); } constexpr int LFSR(int prev) { return ((prev >> 1) | (LFSR_bit(prev) << 15)); } $ gcc –DRANDOM=$RANDOM main.c –o main $ ./main foo = 17695, bar = 41615
  • 50. Linear Feedback Shift Register (LFSR) • Simple random number generator • 4 bit Fibonacci LFSR • Feedback polynomial = X4 + X3 + 1 • Taps 4 and 3 12/15/2017 51Image source: wikipedia
  • 51. Linear Feedback Shift Register (LFSR) • A 16 bit feedback polynomial – X16 + X14 + X13 + X11 + 1 • Taps: 16, 14, 13, and 11 12/15/2017 52Image source: wikipedia
  • 52. Random Type Generation at Compile-Time template <int I> struct TypeMap; template <> struct TypeMap<0> { typedef int type; }; template <> struct TypeMap<1> { typedef char type; }; template <> struct TypeMap<2> { typedef float type; }; template <> struct TypeMap<3> { typedef double type; }; 12/15/2017 53
  • 53. Random Type Generation at Compile-Time #include <boost/core/demangle.hpp> template <int seed> struct RandomTuple { typedef typename TypeMap<LFSR(seed) % 4>::type First; typedef typename TypeMap<LFSR(LFSR(seed)) % 4>::type Second; typedef typename TypeMap<LFSR(LFSR(LFSR(seed))) % 4>::type Third; typedef std::tuple<First, Second, Third> type; }; 12/15/2017 54 $ g++ –DRANDOM=$RANDOM main.cpp –o main $ ./main foo = 11660, bar = 5830 tuple = std::tuple<float, double, char> int main(void) { auto tuple = RandomTuple<RANDOM>::type(); printf("tuple = %s", boost::core::demangle(typeid(tuple).name()).c_str()); } Live code
  • 54. Tuples all the way down… • Nested type generation using recursive TypeMap • Classic template meta-programming • See type_generator.h 12/15/2017 56
  • 55. Type Generators Demystified • Random seed as command line preprocess argument • Compile-time random numbers using LFSR constexpr • C++ meta-programming for type synthesis • std::string generator for type names and member names • RefleX to map types to typecode and dynamic data • Source: https://github.com/sutambe/cpp-generators 12/15/2017 57
  • 56. RefleX Property-test Type Generator • “Good” Numbers – 31415 (3 nested structs) – 32415 (51 nested structs) – 2626 (12 nested structs) – 10295 (15 nested structs) – 21525 (41 nested structs) – 7937 ( 5 nested structs) – ... • “Bad” Numbers – 2152 (test seg-faults) sizeof(tuple) > 2750 KB! 12/15/2017 58 Github: https://github.com/rticommunity/rticonnextdds-reflex/blob/develop/test/generator

Editor's Notes

  1. Learn the most fundamental design principal in C++ libraries such as ranges, RxCpp and more
  2. Incompressible strings of every length exis!