Serving the Quantitative Finance Community

 
User avatar
Cuchulainn
Posts: 20254
Joined: July 16th, 2004, 7:38 am
Location: 20, 000

Functional programming

June 26th, 2014, 2:12 pm

QuoteOriginally posted by: outrunQuoteOriginally posted by: CuchulainnQuoteOriginally posted by: outrunand I'm sure there is need for complex<double, long> somewhereand Matrix<complex<double>, complex<long> >complex<Matrix<double>, Matrix<long> >could both be relenant for their different memory layouts.Indeed. The polar form for complex numbers is complex<double, Degree> and in 3d we have curvilinear coordinates Point<T1, T2, T3> e.g. Point<double, Degree, Degree> etc.AlsoPolynomial<Matrix> e.g. Cayley-Hamilton theoremMatrix<Polynomial> aka matrix polynomialsI wonder if anyone has developed efficient data structures for these in C++?Efficient could be defined be in the contect of algorithms that act on them, ... and that could be expressed as performance measures of the algorithms (speed, memory usage, parallel friendly)Time: how long does the algorithm take to complete.Space: how much working memory (typically RAM) is needed by the algorithm. This has two aspects: the amount of memory needed by the code, and the amount of memory needed for the data on which the code operates.
 
User avatar
Traden4Alpha
Posts: 3300
Joined: September 20th, 2002, 8:30 pm

Functional programming

June 26th, 2014, 10:30 pm

QuoteOriginally posted by: CuchulainnQuoteOriginally posted by: outrunQuoteOriginally posted by: CuchulainnQuoteOriginally posted by: outrunand I'm sure there is need for complex<double, long> somewhereand Matrix<complex<double>, complex<long> >complex<Matrix<double>, Matrix<long> >could both be relenant for their different memory layouts.Indeed. The polar form for complex numbers is complex<double, Degree> and in 3d we have curvilinear coordinates Point<T1, T2, T3> e.g. Point<double, Degree, Degree> etc.AlsoPolynomial<Matrix> e.g. Cayley-Hamilton theoremMatrix<Polynomial> aka matrix polynomialsI wonder if anyone has developed efficient data structures for these in C++?Efficient could be defined be in the contect of algorithms that act on them, ... and that could be expressed as performance measures of the algorithms (speed, memory usage, parallel friendly)Time: how long does the algorithm take to complete.Space: how much working memory (typically RAM) is needed by the algorithm. This has two aspects: the amount of memory needed by the code, and the amount of memory needed for the data on which the code operates.What about bandwidth? The Time and Space performance dimensions of the algorithm are linked to the processing speed and memory capacity dimensions of the platform. But the platform also has an intrinsic bandwidth between memory and CPU and different algorithms may call for different levels of utilization of this bandwidth. To a first approximation, the bandwidth requirement of an algorithm is lower-bounded by the space requirement (the algorithm presumably read/writes each data location at least once) and the bandwidth requirement is upper-bounded by the time requirement (an algorithm may spend all of it's time in memory operations). Yet this interval might be quite large and different platforms might have different bandwidth levels (which is especially salient if we employ the algorithm on big data where memory access may be to secondary storage via IP channels).
 
User avatar
exneratunrisk
Posts: 0
Joined: April 20th, 2004, 12:25 pm

Functional programming

July 15th, 2014, 2:41 pm

Performance: if it is designed that way, functional programming really matters - A Comparison of Programming Languages in Economics (a NBER paper). The big difference of 2 Mathematica programming styles.
Last edited by exneratunrisk on July 14th, 2014, 10:00 pm, edited 1 time in total.
 
User avatar
ExSan
Posts: 493
Joined: April 12th, 2003, 10:40 am

Functional programming

July 15th, 2014, 10:07 pm

QuoteOriginally posted by: exneratunriskPerformance: if it is designed that way, functional programming really matters - A Comparison of Programming Languages in Economics (a NBER paper). The big difference of 2 Mathematica programming styles.pp10Quote°our result is that C++ and Fortran still maintain a considerable speed advantagewith respect to all other alternatives°around 10 times faster than Matlab, and around 48 times faster than the Pypy implementation of Python.°We find speed improvements of more than 100 percent between di§erent executables of thesame underlying code (and using equivalent optimization compilation flags)°Our fourth result is that Java imposes a speed penalty of 110 to 169 percent°Julia is also slightly faster than Java and close to 4 times faster than Matlab°Matlab runs between 9 to 11 times slower than the best C++ executable°Python has a mixed performance. In the Pypy implementation, our code runs around 44-45 times slower than in C++°e Numba,code runs only between 1.57 and 1.62 times slower than the best C++ executable°R's performance is poor overall, between 500 to 700 times slower than C++° Mathematica code takes up to 809 times longer than C++.
°°° About ExSan bit.ly/3U5bIdq °°°
 
User avatar
exneratunrisk
Posts: 0
Joined: April 20th, 2004, 12:25 pm

Functional programming

July 16th, 2014, 8:28 am

QuoteOriginally posted by: ExSanQuoteOriginally posted by: exneratunriskPerformance: if it is designed that way, functional programming really matters - A Comparison of Programming Languages in Economics (a NBER paper). The big difference of 2 Mathematica programming styles.pp10Quote°our result is that C++ and Fortran still maintain a considerable speed advantagewith respect to all other alternatives°around 10 times faster than Matlab, and around 48 times faster than the Pypy implementation of Python.°We find speed improvements of more than 100 percent between di§erent executables of thesame underlying code (and using equivalent optimization compilation flags)°Our fourth result is that Java imposes a speed penalty of 110 to 169 percent°Julia is also slightly faster than Java and close to 4 times faster than Matlab°Matlab runs between 9 to 11 times slower than the best C++ executable°Python has a mixed performance. In the Pypy implementation, our code runs around 44-45 times slower than in C++°e Numba,code runs only between 1.57 and 1.62 times slower than the best C++ executable°R's performance is poor overall, between 500 to 700 times slower than C++° Mathematica code takes up to 809 times longer than C++.The art of programming: 809 times or 4 time (with functional ?...). That has to do with the implementation of a uniform functional expression layer that is used by the Mathematica Kernel (Wolfram Engine).
Last edited by exneratunrisk on July 16th, 2014, 10:00 pm, edited 1 time in total.
 
User avatar
Cuchulainn
Posts: 20254
Joined: July 16th, 2004, 7:38 am
Location: 20, 000

Re: Functional programming

March 25th, 2023, 9:38 pm

VivienB: well, some do, some don't.In particular, compile-time generic programming (with the binding & dispatch performed statically but general enough so as to allow for compile-time laziness) is not as common.Let's take Template Haskell as an example: http://www.haskell.org/haskellwiki/Temp ... askellThis is closely associated with type classes,[/b] for which, again, while comparable features are widespread, things are rather more interesting as far as the compile-time variant is concerned.Also relevant in this context:- Multi-parameter type classes- (Indexed) Type familiesI'm wondering, how many other FP languages implement comparable features?// I think GP is far more than "generics" implemented by some programming languages. In particular, I find run-time attempts at the implementation particularly limited and generally uninteresting.From the PLT (programming language theory) point of view, Harper (2014) provides an interesting way to look at it (succinct if you're coming from an FP background):QuoteThe generic extension of a type operator is an example of the concept of a functor in category theory (MacLane, 1998). Generic programming is essentially functorial programming, exploiting the functorial action of polynomial type operators (Hinze and Jeuring, 2003).If you're curious / would like more information, take a look at Chapter 13 (Generic Programming), which is the source of the quote:Harper (2014) "Practical Foundations for Programming Languages" Second Editionhttp://www.cs.cmu.edu/~rwh/plbook/book.pdf
Yes, by George!
Haskell Type classes are the omphalos of C++20 Concepts.
Got it, QED

Why did you guys keep the rest of us in the dark for so long?

// HaskellThis is closely associated with type classes
 
User avatar
Cuchulainn
Posts: 20254
Joined: July 16th, 2004, 7:38 am
Location: 20, 000

Re: Functional programming

March 26th, 2023, 3:15 pm

how so?
Attachments
Test101Concepts.pdf
(89.15 KiB) Downloaded 69 times
 
User avatar
jasonbell
Posts: 60
Joined: May 6th, 2022, 4:16 pm
Location: Limavady, NI, UK
Contact:

Re: Functional programming

November 14th, 2023, 10:19 am

Did anyone mention anything about Clojure? Haskell was always a step too far for me. With Clojure, which I used professionally but not in finance, it had everything I wanted plus it would interop into existing java libraries. 
Twitter: @jasonbelldata
Author of Machine Learning: Hands on for Developers and Technical Professionals (Wiley).
 
User avatar
Cuchulainn
Posts: 20254
Joined: July 16th, 2004, 7:38 am
Location: 20, 000

Re: Functional programming

November 14th, 2023, 12:22 pm

FP has its uses. It is older than OOP but has never caught on. It is niche.
The dominant paradigms are Procedural (Modular), OOP and copy-paste-hacking-greatballsofmud.
The big ones Python, C/C++, Java, C#, VB.

See also

viewtopic.php?f=10&t=36774&p=248487&hilit=Hello#p248487

https://www.tiobe.com/tiobe-index/