SERVING THE QUANTITATIVE FINANCE COMMUNITY

  • 1
  • 5
  • 6
  • 7
  • 8
  • 9
  • 15
 
User avatar
Cuchulainn
Posts: 62626
Joined: July 16th, 2004, 7:38 am
Location: Amsterdam
Contact:

C++ quiz --- STL tricks

October 14th, 2013, 9:15 am

QuoteOriginally posted by: katastrofaI know very well what I'm talking about ;-) Tricks in production code make it harder to maintain. Most things which can be achieved by "STL tricks" can be done in a simpler, more readable and easier to debug way, and the performance difference is usually minimal or none.Feel free to post an example of actual production code where the use of an "STL trick" gave a measurable performance gain, or actually made the code more readable.Again, post _your_ counterexamples or hold your peace.
Last edited by Cuchulainn on October 13th, 2013, 10:00 pm, edited 1 time in total.
Step over the gap, not into it. Watch the space between platform and train.
http://www.datasimfinancial.com
http://www.datasim.nl
 
User avatar
Cuchulainn
Posts: 62626
Joined: July 16th, 2004, 7:38 am
Location: Amsterdam
Contact:

C++ quiz --- STL tricks

October 14th, 2013, 9:21 am

QuoteOriginally posted by: outrunYes I agree with that. If I had a team I would move to C++11 asapDon't encourage
Step over the gap, not into it. Watch the space between platform and train.
http://www.datasimfinancial.com
http://www.datasim.nl
 
User avatar
Cuchulainn
Posts: 62626
Joined: July 16th, 2004, 7:38 am
Location: Amsterdam
Contact:

C++ quiz --- STL tricks

October 14th, 2013, 9:36 am

Exercise for the troll:Write an algorithm to find all permutations of {1,2,...,3}.
Step over the gap, not into it. Watch the space between platform and train.
http://www.datasimfinancial.com
http://www.datasim.nl
 
User avatar
Cuchulainn
Posts: 62626
Joined: July 16th, 2004, 7:38 am
Location: Amsterdam
Contact:

C++ quiz --- STL tricks

October 14th, 2013, 3:54 pm

Back on topic.Polter,I am impressed that C++ 11 supports function composition.1. How is this magik realised (the [] or auto or both)? 2. Any performance issue?3. Use for data flow (stateless?)Doing it in bind is less readable.
Last edited by Cuchulainn on October 13th, 2013, 10:00 pm, edited 1 time in total.
Step over the gap, not into it. Watch the space between platform and train.
http://www.datasimfinancial.com
http://www.datasim.nl
 
User avatar
Cuchulainn
Posts: 62626
Joined: July 16th, 2004, 7:38 am
Location: Amsterdam
Contact:

C++ quiz --- STL tricks

October 15th, 2013, 5:27 pm

Now we can use C++ 11 to do data piping with function composition (well-known in maths) and as in F#.Piece of cake.
Last edited by Cuchulainn on October 14th, 2013, 10:00 pm, edited 1 time in total.
Step over the gap, not into it. Watch the space between platform and train.
http://www.datasimfinancial.com
http://www.datasim.nl
 
User avatar
Cuchulainn
Posts: 62626
Joined: July 16th, 2004, 7:38 am
Location: Amsterdam
Contact:

C++ quiz --- STL tricks

January 24th, 2014, 3:43 pm

QuoteIf I was hiring C++ developers, I would quiz them on "STL tricks" and if they passed with flying colours and were proud of their answers, their CVs would go straight to the bin.There are severals reasons for this mindset 1. "Not Invented Here" syndrome. New graduates can suffer from this ailment. They still think CS is blue sky research.2. STL's syntax can be cryptic yes, but effort ... learn another programming paradigm upon which STL is based 3. You have not been immersed in Fortran, NAG, IMSL libraries. aka REUSE.4. If it were a fixed-point project and you were tendering then your tune would change. You would either 1) not get selected or 2) run out of funds very early. 5. You have not understood enough of STL to give a measured opinion "A little knowledge is a dangerous thing". 6. We will be left wth non-standard legacy code to be maintained.If I were your cost control manager I would be very worried. QuoteFeel free to post an example of actual production code where the use of an "STL trick" gave a measurable performance gain, or actually made the code more readable. NDA old bean
Last edited by Cuchulainn on January 23rd, 2014, 11:00 pm, edited 1 time in total.
Step over the gap, not into it. Watch the space between platform and train.
http://www.datasimfinancial.com
http://www.datasim.nl
 
User avatar
Cuchulainn
Posts: 62626
Joined: July 16th, 2004, 7:38 am
Location: Amsterdam
Contact:

C++ quiz --- STL tricks

May 1st, 2014, 6:11 pm

How do you create polymorphic/generic hash functions?
Step over the gap, not into it. Watch the space between platform and train.
http://www.datasimfinancial.com
http://www.datasim.nl
 
User avatar
Polter
Posts: 2526
Joined: April 29th, 2008, 4:55 pm

C++ quiz --- STL tricks

May 1st, 2014, 7:07 pm

Relevant: http://htmlpreview.github.io/?https://g ... ing.html// In particular, see sections "How to get X to use a general purpose hashing algorithm" & "Introducing the Universal hash function!"Discussion: http://comments.gmane.org/gmane.comp.la ... sals/10149
 
User avatar
katastrofa
Posts: 9455
Joined: August 16th, 2007, 5:36 am
Location: Alpha Centauri

C++ quiz --- STL tricks

May 5th, 2014, 10:33 am

QuoteOriginally posted by: CuchulainnExercise for the troll:Write an algorithm to find all permutations of {1,2,...,3}.Using an std function does not qualify as a trick.QuoteOriginally posted by: outrunMaybe some day you get promoted to a position where you can (not) hire people!Actually, he does hire (or not) people. If he couldn't get promoted, he would probably go and start his own consultancy selling our old student-times C++ libs ;-)a
 
User avatar
dd3
Posts: 246
Joined: June 8th, 2010, 9:02 am

C++ quiz --- STL tricks

May 7th, 2014, 9:28 am

Last edited by dd3 on May 6th, 2014, 10:00 pm, edited 1 time in total.
 
User avatar
dd3
Posts: 246
Joined: June 8th, 2010, 9:02 am

C++ quiz --- STL tricks

May 7th, 2014, 9:29 am

Sorry, the thread is backwards
Last edited by dd3 on May 6th, 2014, 10:00 pm, edited 1 time in total.
 
User avatar
Cuchulainn
Posts: 62626
Joined: July 16th, 2004, 7:38 am
Location: Amsterdam
Contact:

C++ quiz --- STL tricks

May 7th, 2014, 5:20 pm

QuoteOriginally posted by: dd3Sorry, the thread is backwardsGood job Wilmott does not have a SWAM policy.
Step over the gap, not into it. Watch the space between platform and train.
http://www.datasimfinancial.com
http://www.datasim.nl
 
User avatar
Cuchulainn
Posts: 62626
Joined: July 16th, 2004, 7:38 am
Location: Amsterdam
Contact:

C++ quiz --- STL tricks

May 27th, 2014, 6:38 pm

Quizstd::vector<double> v = {2.-9,1,12,...,99,...}Find the index corresponding to value 99..And fast (O(1)) // Also for std::list<>
Last edited by Cuchulainn on May 26th, 2014, 10:00 pm, edited 1 time in total.
Step over the gap, not into it. Watch the space between platform and train.
http://www.datasimfinancial.com
http://www.datasim.nl
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