Serving the Quantitative Finance Community

 
User avatar
outrun
Posts: 4573
Joined: January 1st, 1970, 12:00 am

Re: C++ Modules

June 22nd, 2017, 11:20 am

that's the point, it can't be done in C++.
* 300-1000 lines of code is too much for 10 days
* 1000 lines is not enough for this task if you decide to do it in C++.
 
User avatar
Cuchulainn
Posts: 20253
Joined: July 16th, 2004, 7:38 am
Location: 20, 000

Re: C++ Modules

June 22nd, 2017, 1:09 pm

that's the point, it can't be done in C++.
* 300-1000 lines of code is too much for 10 days
* 1000 lines is not enough for this task if you decide to do it in C++.
Indeed. You buy the package from IBM.

Again, who supports this 2-day effort?
 
User avatar
outrun
Posts: 4573
Joined: January 1st, 1970, 12:00 am

Re: C++ Modules

June 22nd, 2017, 1:31 pm

What do you mean "buy the package"? That's evading the premises in this discussion that software has to be developed with some specs and with some budget.
So... if we go back at the project description: how much work would it be in C++? What's your guess? And why would is be so much more than e.g. python? (to answer both you need to study the requirement I wrote down, what does it take, what tools would you use)
 
User avatar
Alan
Posts: 2958
Joined: December 19th, 2001, 4:01 am
Location: California
Contact:

Re: C++ Modules

June 22nd, 2017, 3:10 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.
I finally upgraded to Mathematica 11 -- and started playing around with their neural net stuff. It's pretty amazing IMO. One of their learning examples is using the cifar-10 dataset to do exactly this kind of project. As long as you have an Nvidia video card, it can use the GPU to do the training, so no need to pass this project to a server. Local training on my *very old* desktop with my *very old* video card should take about an hour for that accuracy, probably 5-10 or minutes or less with a modern desktop. (Well, I am really just guessing based upon successfully running one of their examples). Once trained, the 100ms response rate should be immediate. It's only a half-dozen lines of code: here  

 To invoke the GPU, the NetTrain line in the linked example is just changed to:
NetTrain[net, trainingData, TargetDevice -> "GPU"];
Actually, this did not work for me the first time, but did after I took the support advice from WRI to upgrade my Nvidia driver.  The effect of this line was to change my predicted training run-time from 36hrs (which I didn't do) to 1hr, which completed nicely. The actual example I ran is this one here
 
User avatar
Cuchulainn
Posts: 20253
Joined: July 16th, 2004, 7:38 am
Location: 20, 000

Re: C++ Modules

June 22nd, 2017, 3:40 pm

What do you mean "buy the package"? That's evading the premises in this discussion that software has to be developed with some specs and with some budget.
So... if we go back at the project description: how much work would it be in C++? What's your guess? And why would is be so much more than e.g. python? (to answer both you need to study the requirement I wrote down, what does it take, what tools would you use)
"buy the package" means buying the complete software system instead of assembling it yourself. Surely someone has a package that satisfy the requirements?

I had a quick look here and it looks like Microsoft Azure is doing this stuff .
https://docs.microsoft.com/en-us/azure/ ... arp#Detect
 
User avatar
Cuchulainn
Posts: 20253
Joined: July 16th, 2004, 7:38 am
Location: 20, 000

Re: C++ Modules

June 22nd, 2017, 3:52 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.
C# is better than C++ I reckon. Looks like it!
https://docs.microsoft.com/en-us/azure/ ... arp#Detect
Detect Faces in Images With Face API Using C#
Use the Face - Detect method to detect faces in an image and return face attributes including:+
  • Face ID: Unique ID used in a number of Face API scenarios.
  • Face Rectangle: The left, top, width, and height indicating the location of the face in the image.
  • Landmarks: An array of 27-point face landmarks pointing to the important positions of face components.
  • Facial attributes including age, gender, smile intensity, head pose, and facial hair.
 
User avatar
outrun
Posts: 4573
Joined: January 1st, 1970, 12:00 am

Re: C++ Modules

June 22nd, 2017, 8:48 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.
I finally upgraded to Mathematica 11 -- and started playing around with their neural net stuff. It's pretty amazing IMO. One of their learning examples is using the cifar-10 dataset to do exactly this kind of project. As long as you have an Nvidia video card, it can use the GPU to do the training, so no need to pass this project to a server. Local training on my *very old* desktop with my *very old* video card should take about an hour for that accuracy, probably 5-10 or minutes or less with a modern desktop. (Well, I am really just guessing based upon successfully running one of their examples). Once trained, the 100ms response rate should be immediate. It's only a half-dozen lines of code: here  

 To invoke the GPU, the NetTrain line in the linked example is just changed to:
NetTrain[net, trainingData, TargetDevice -> "GPU"];
Actually, this did not work for me the first time, but did after I took the support advice from WRI to upgrade my Nvidia driver.  The effect of this line was to change my predicted training run-time from 36hrs (which I didn't do) to 1hr, which completed nicely. The actual example I ran is this one here
Cool! It seems to have a rich set of Machine Learning capabilities and examples!
The auto-encoder are great for curves and surfaces I expect, https://www.wolfram.com/language/11/neu ... athematica it's like a nonlinear PCA, a neural network that learns a low dimensional representation of higher dimensional data. 
 
User avatar
outrun
Posts: 4573
Joined: January 1st, 1970, 12:00 am

Re: C++ Modules

June 22nd, 2017, 9:05 pm

Cuch, yes C# looks already better. I bet is has all the networking stuff in .NET. Throwing money at MS to do the gender analysis for you is of course not what this startup wants! You're better of giving it to Alan so that he can buy a new computer and solve it with Mathematica!
 
User avatar
outrun
Posts: 4573
Joined: January 1st, 1970, 12:00 am

Re: C++ Modules

June 22nd, 2017, 9:10 pm

This is something everyone should do who tries to fit a vol surface, but nobody does it:
https://www.wolfram.com/language/11/neu ... athematica
 
User avatar
Cuchulainn
Posts: 20253
Joined: July 16th, 2004, 7:38 am
Location: 20, 000

Re: C++ Modules

October 31st, 2017, 10:55 am

It feels that C++ modules won't be here anytime soon. Why is it talking so long? But it is possible to create .NET assembly using C++/CL and native C++. 

https://msdn.microsoft.com/en-us/library/x0w2664k.aspx

This is a nice option for C# developers who want to access native C++ functonalty in nice wrappers?
Last edited by Cuchulainn on October 31st, 2017, 10:59 am, edited 1 time in total.
 
User avatar
Cuchulainn
Posts: 20253
Joined: July 16th, 2004, 7:38 am
Location: 20, 000

Re: C++ Modules

October 31st, 2017, 10:56 am

This is something everyone should do who tries to fit a vol surface, but nobody does it:
https://www.wolfram.com/language/11/neu ... athematica
What's that got to do with C++ modules? (the topic of the current thread).
 
User avatar
outrun
Posts: 4573
Joined: January 1st, 1970, 12:00 am

Re: C++ Modules

October 31st, 2017, 12:48 pm

This is something everyone should do who tries to fit a vol surface, but nobody does it:
https://www.wolfram.com/language/11/neu ... athematica
What's that got to do with C++ modules? (the topic of the current thread).
I have no idea, that was a long time ago, and reading back this threat went all over the place.
Why did you dig this up now? 
 
User avatar
Cuchulainn
Posts: 20253
Joined: July 16th, 2004, 7:38 am
Location: 20, 000

Re: C++ Modules

November 4th, 2017, 10:46 am

Back to modules. In .NET we can use

C#
C++/CLI (bilingual)
native C++11

Now, it is possible to mix C++/CLI and C++11 in  a C++ project and load assembles/dlls into main() without having to give away source.  On Windows it is a piece of cake . Of course, linux probably uses Mono (haven't looked into that).

So, we can wrap C++ legacy and call it from C# (don't need IDL-based SWIG). We also can call .NET libraries from C++11.

This dll approach is in all probability better than klunky LIB files; dllls have types and be loaded at run-time.

Anybuddy used this?

http://www.boost.org/doc/libs/1_65_1/do ... t_dll.html
 
User avatar
Cuchulainn
Posts: 20253
Joined: July 16th, 2004, 7:38 am
Location: 20, 000

Re: C++ Modules

September 10th, 2020, 10:50 am

C++20 is now official. To test the tires I am trying the problem here but I can't get it to work

https://en.cppreference.com/w/cpp/language/modules


I get a linker error on hello() under vS 2019 16.7.3

How to resolve?
 
User avatar
ISayMoo
Posts: 2332
Joined: September 30th, 2015, 8:30 pm

Re: C++ Modules

September 11th, 2020, 12:07 am