SERVING THE QUANTITATIVE FINANCE COMMUNITY

 
User avatar
Cuchulainn
Posts: 60246
Joined: July 16th, 2004, 7:38 am
Location: Amsterdam
Contact:

C++ Modules

June 7th, 2016, 7:54 pm

QuoteC++17 is targeted for a release in March 2017, but some of the proposed work, such as modules and the new concurrency work, will likely slip into C++20.
 
User avatar
katastrofa
Posts: 8368
Joined: August 16th, 2007, 5:36 am
Location: Alpha Centauri

Re: C++ Modules

May 1st, 2017, 4:15 pm

Quote
Originally posted by: Cuchulainn
Quote
Originally posted by: katastrofa
Quote
Originally posted by: katastrofa
How do the modules differ from static/dynamic libraries?I'm sorry if this question is stupid, but this is actually of practical interest to me.I currently pack pieces of my code into libraries to send them to my clients, who shouldn't see my code. The downsides are known. Are modules a better solution?
a
On Windows, at least you can use 1. LIB filles2. dlls (in C)
Which type do you give to clients?
DLLs are probably better and satisfy your requirements. I suppose you want to call them from Excel?
In .NET things are soooh much easier.IMO C dlls an LIBs are an approximation to modules,  
The downsides are known
What are those?

I use simple DLL libraries with External interface using stateless functional API.
The problems with this solution are caused by different implementations of STL by different compilers, different binary versions of STL containers depending on the compilation options, etc. Of course I can provide all necessary classes to communicate with the EI, but it makes things much less straighforward and it feels somewhat uncanny.
a
Still no modules. Seeing where it's going, I'm starting to doubt they will add them at all.
 
User avatar
Cuchulainn
Posts: 60246
Joined: July 16th, 2004, 7:38 am
Location: Amsterdam
Contact:

Re: C++ Modules

May 2nd, 2017, 11:14 am

Quote
Originally posted by: Cuchulainn
Quote
Originally posted by: katastrofa


On Windows, at least you can use 1. LIB filles2. dlls (in C)
Which type do you give to clients?
DLLs are probably better and satisfy your requirements. I suppose you want to call them from Excel?
In .NET things are soooh much easier.IMO C dlls an LIBs are an approximation to modules,  



What are those?

I use simple DLL libraries with External interface using stateless functional API.
The problems with this solution are caused by different implementations of STL by different compilers, different binary versions of STL containers depending on the compilation options, etc. Of course I can provide all necessary classes to communicate with the EI, but it makes things much less straighforward and it feels somewhat uncanny.
a
Still no modules. Seeing where it's going, I'm starting to doubt they will add them at all.
It is a difficult feature to implement I suppose. Microsoft tried something similar with COM (good technology) some time ago. Here is the vision at the time

http://www.drdobbs.com/architecture-and ... /184409407

It means that component -based programming in C++ is a long way off. C# is a good benchmark to show how to do it IMO.
It's little things that seem to be getting attention, such as the piddly std::clamp. I know for a fact that many committee manhours were committed to this Boost Algorithm function. Waste of human resources.

Pity.
 
User avatar
Cuchulainn
Posts: 60246
Joined: July 16th, 2004, 7:38 am
Location: Amsterdam
Contact:

Re: C++ Modules

June 21st, 2017, 7:29 am

This overview of Scala is interesting and relevant. esp 4.1 and 9. 

https://www.scala-lang.org/docu/files/ScalaOverview.pdf

Assembling ready-made components to create applications is still not there. Is grammar-pattern programming the cause?
 
User avatar
outrun
Posts: 4573
Joined: April 29th, 2016, 1:40 pm

Re: C++ Modules

June 21st, 2017, 8:56 am

It has been solved many times with package managers: Linux, python, R, node.js all make it very easy to install, upgrade, remove packages, handle version dependencies. It's a joy for developers, makes you very productive and in control.

The main issue is that C++ is conservative and focussing on the core language features, not on repository of 3rd party libraries. 

Linux, python, R, node.js all supply a repository infrastructure. The libraries in there don't all need to be high quality, that choice is left to the user. But if you want to setup an official repository for C++ libraries, who would be the owner / in control? Boost tried to offer such a repository but is very rigid, curated and monolithic. Boost tried to only accept libraries that potentially end up in the C++ standard. If someones writes a webserver for boost then it needs to be the "one and only" webserver. In other languages you'll have 12 webserver libraries, 2 of which end up being the most popular choice by users. Boost also has a serious issue with supporting libraries where the maintainer has abandoned it, they can't kill those because of its monolithic setup. A user driven organic evolving repository seems to work best.
 
User avatar
Cuchulainn
Posts: 60246
Joined: July 16th, 2004, 7:38 am
Location: Amsterdam
Contact:

Re: C++ Modules

June 21st, 2017, 9:31 am

Good points. 
 
User avatar
outrun
Posts: 4573
Joined: April 29th, 2016, 1:40 pm

Re: C++ Modules

June 21st, 2017, 9:57 am

Good points. 
Thanks! It's more of a rant that a balanced opinion. C++ is the only relevant language that managed to get away with the  98 to 11 dark ages. In those 13 years the internet took off, multi-core machines became the standard, we saw a shifts in OSes, ..but C++ did nothing. No cross-OS uniform file system tools, no network tools, no threads,.. completely useless. The only way C++ was still usable in that period was because of boost.
 
User avatar
Cuchulainn
Posts: 60246
Joined: July 16th, 2004, 7:38 am
Location: Amsterdam
Contact:

Re: C++ Modules

June 21st, 2017, 12:23 pm

I miss a number of things:

1. Assemblies (self-aware dlls, not them C dlls).
2. A real interface specification.
3. Mixin,.

Stillm for number-crunching I don't see any alternative.
 
User avatar
outrun
Posts: 4573
Joined: April 29th, 2016, 1:40 pm

Re: C++ Modules

June 21st, 2017, 12:44 pm

I think it's the other way around: you need to spend ages implementing C++ optimised routines for number-crunching because C++ doens't provide good algorithms and optimised libraries out of the box.

Here is a list of tools I can use in python in the next hour, and C++ has a hard time with:
* highly optimized linear algebra engine that uses smart algorithms and optimized for you cpu. In C++ you need to get Atlas or some Blas up and running. In python it's part of numpy
* Use automatic differentiation, have a dozen of pre-build gradient descent algorithms (e.g. things like ADAM stochastic gradient descent )
* run it on the GPU 

What's interesting is that most of those backend-libraries used in Python are of course written in C/C++. However, Python people can use them very easily, C++ people need ages to install things.

So for that problem my initial guess would be: don't do it in C++, do it in python (or else Matlab, R)?
 
User avatar
Cuchulainn
Posts: 60246
Joined: July 16th, 2004, 7:38 am
Location: Amsterdam
Contact:

Re: C++ Modules

June 21st, 2017, 8:06 pm

So for that problem my initial guess would be: don't do it in C++, do it in python (or else Matlab, R)?
As they say; "it depends".

* highly optimized linear algebra engine that uses smart algorithms and optimized for you cpu. In C++ you need to get Atlas or some Blas up and running. In python it's part of numpy

DD yeah, no matrices in  C++. BTW Atlas install is a disaster.
For FDM just write a Thomas solver and be done with it. Or use Eigen. 


* Use automatic differentiation, have a dozen of pre-build gradient descent algorithms (e.g. things like ADAM stochastic gradient descent )

DD AAD is a niche area.

* run it on the GPU 
DD multicore C++ like PPL and TBB are good.
 
User avatar
Cuchulainn
Posts: 60246
Joined: July 16th, 2004, 7:38 am
Location: Amsterdam
Contact:

Re: C++ Modules

June 21st, 2017, 8:09 pm

python
I don't like it. Just like I don't like Java and Pascal. 

How many production systems use Python? C++ will be here forever.
 
User avatar
outrun
Posts: 4573
Joined: April 29th, 2016, 1:40 pm

Re: C++ Modules

June 21st, 2017, 8:35 pm

I like it, I don't like Java either, but I do like Javascript, especially some of the frameworks for building webbased rich user interaces like React that talk to an API.

Python runs in a lot of production systems, it's a Borg language -extremely good at assimilating good science libraries-, and it's expressive. .. and I like the fact that it's interpreted instead of compiled.
 
User avatar
Cuchulainn
Posts: 60246
Joined: July 16th, 2004, 7:38 am
Location: Amsterdam
Contact:

Re: C++ Modules

June 21st, 2017, 8:43 pm

I've heard that inside many Python programs there's a C++ inside trying to get out.

Does Python pay the bills?
 
User avatar
outrun
Posts: 4573
Joined: April 29th, 2016, 1:40 pm

Re: C++ Modules

June 21st, 2017, 9:59 pm

I think this is a typical interesting freelancer project:

Write a client application that uploads a photo to a server using a rest api over https. The server application does a simple "gender analysis" on te uploaded photo: {male, female, don't know}, and send the analysis results back in JSON. The server needs to do it in 100ms and have a 80% accuracy rate.

The software development budget is 10 days.

In C++ I see many many problems:
* how do you capture and store a photo?
* how do you send the photo to the server across a https socket? Don't forget to check the certificate.
* how does the server application capture the photo?
* how will te server do computer vision / AI and find the gender?
* how can you do move that to the GPU so that it performs within the specs?
* how do you serialize the response to JSON? (this one is easy!)
* how do you send the response back to the client?

And with a 10 days budget, you probably only get to write about 300-1000 lines of code?

In python this is easy. It takes just 2 days, the other 8 days of budget you use to take a mini vacation to Bora Bora.
 
User avatar
Cuchulainn
Posts: 60246
Joined: July 16th, 2004, 7:38 am
Location: Amsterdam
Contact:

Re: C++ Modules

June 22nd, 2017, 11:08 am

Is it not better to let your company buy the software for this?

BTW who supports that undocumented code that took 2 days to write? You will need 2 X 8 days to document. And is there a maintainance programmer to support the software product?

Golden rule on estimation; real estimate = THREE X developer estimate (due to incomplete recall).


And with a 10 days budget, you probably only get to write about 300-1000 lines of code?
That's a lot of code. Normally developers write 5 lines of real code per day. Then it has to be tested. 

//
A random search shows there's lots of stuff

http://www.c-sharpcorner.com/article/a- ... g-c-sharp/

Seems everyone is doing it. 
Last edited by Cuchulainn on June 22nd, 2017, 11:29 am, edited 2 times in total.
ABOUT WILMOTT

PW by JB

Wilmott.com has been "Serving the Quantitative Finance Community" since 2001. Continued...


Twitter LinkedIn Instagram

JOBS BOARD

JOBS BOARD

Looking for a quant job, risk, algo trading,...? Browse jobs here...


GZIP: On