SERVING THE QUANTITATIVE FINANCE COMMUNITY

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

I LOVE FORTRAN

January 24th, 2015, 2:45 pm

Testing CODE::BLOCKS so I thought I would try Black Scholes in FORTRAN (my last FORTRAN program was 1985). What a culture shock.
Last edited by Cuchulainn on January 23rd, 2015, 11:00 pm, edited 1 time in total.
http://www.datasimfinancial.com
http://www.datasim.nl

Every Time We Teach a Child Something, We Keep Him from Inventing It Himself
Jean Piaget
 
User avatar
tthrift
Posts: 48
Joined: May 13th, 2014, 9:22 pm

I LOVE FORTRAN

January 29th, 2015, 5:21 am

In the 70s fortran required me to write nested do loops to combine elements from arrays.Using today's fortran you don't have to use loops?To add the elements you can just write C=A+BAre fortran's array notation extensions generally useful.I know it's an old (and possibly boring) language.But I am a bit surprised that fortran is not talked about (used?) more in the quant community.It's good you brought it up.For pure number crunching and hard core numeric simulation would you expect c++ or fortran to be superior?It seems like Fortran (or apl, t, j) run on an array processor, medium grained parallel machine cluster, etc., would be quite common at big firms.Maybe it is (or was) and just isn't talked about?PSIf Julia matures a bit, it may be expressive enough and fast enough for fleshing out ideas.And if it's ability to seamlessly call fortran and c works well, speed should not be an issue for production code.Well that's just daydreaming about Julia.
 
User avatar
Polter
Posts: 2526
Joined: April 29th, 2008, 4:55 pm

I LOVE FORTRAN

January 29th, 2015, 12:12 pm

https://github.com/jesusfv/Comparison-P ... guages.pdf // Julia did pretty well -- it remains to be seen whether the sufficient ecosystem development will follow.Regardless of performance, the issue is you often need more than pure numerics:- interoperability (e.g., Excel; and, in general, FFIs to work with APIs in other programming languages),- visualization (graphics, etc.),- input/output (in 21st century this involves networking libraries; db libs won't hurt, either).Even if you do solely "pure number crunching and hard core numeric simulation" eventually you want to share/communicate your results.It could be an Excel spreadsheet, perhaps an interactive website -- possibly adding a bunch of portable mobile applications later on. All of that is not (much of) a problem for C++ (which, incidentally, could definitely still benefit from further improvements in this area).However, AFAIK Fortran doesn't really do the whole "software ecosystem" thing -- and the remaining community doesn't appear to show any interest in changing this state of affairs.This affects popularity (and community size, networking effects, etc).This is important -- in programming you often need several programming languages ("the right for the right job").Interactive environments which excel (no pun intended) when prototyping the models / working with data -- like, say, R -- are at least as important as the "fast" compiled languages for numerics.And there's a reason there's an active and popular Rcpp package -- while RFortran hasn't seen an update since 2011.Even the traditional domain of Fortran in the past -- government projects / national labs -- has changed (and has been changing for a while now):- Lawrence Livermore National Laboratory, DOE: CERN: http://en.wikipedia.org/wiki/CERN_Program_Library- DOE: http://www.energymanagertoday.com/doe-c ... 0105459/As for performance, think numerical linear algebra (quite common in applications): To my understanding BLAS and LAPACK are still considered the gold standard in the Fortran number-crunching community.Thing is, best commercial implementations of these (say, Intel MKL) are easily outperformed by free & open-source C++ code (which are also easier to use):- http://eigen.tuxfamily.org/index.php?ti ... LAPACK.3F- http://code.google.com/p/blaze-lib/wiki/BenchmarksTL;DR: If you have higher ease of use, popularity, performance (without having to pay extra for it), and interoperability -- what do you need Fortran for?
Last edited by Polter on January 28th, 2015, 11:00 pm, edited 1 time in total.
 
User avatar
tthrift
Posts: 48
Joined: May 13th, 2014, 9:22 pm

I LOVE FORTRAN

January 30th, 2015, 12:48 am

Great response! Thanks for taking the time.
 
User avatar
Cuchulainn
Topic Author
Posts: 61483
Joined: July 16th, 2004, 7:38 am
Location: Amsterdam
Contact:

I LOVE FORTRAN

January 30th, 2015, 9:18 am

Programs have 1 input 2 processing and 3 output. Traditionally Fortran was weak in 1 and 2 while excelling at 2 (it was built to manipulate arrays). So it is probably not surprising that it is used less these day. As I mentioned, it is > 35 years since I used Fortran IV and 77 for fluid flow, semiconductors and CAD (the system was written in Fortran then ported to C to run on Sun Sparc stations) and at that time there was no OO Fortran(incidentally, I find OOP for engineering less suitable than Fortran 77 style). I had a quick look at Fortran 95 but it looks klunky IMO and I would personally not like to use it. Typing in that code was a bit of a culture shock;1. First declare, then define variables2. Functions are call-by-reference so no BlackScholes(60,65,..) allowed3. It seems formatting is an issue .. life was easier with punch cardsRegarding numerical/matrix libraries .. AFAIK there is no gold standard C++ library. Fortran has them since the beginning of time. I tried installing Atlas for C++ and it was painful.I think it would be unwise to port 40-year programs for nuclear reactors to C++ just because it is old. And who want to write Fortran?QuoteFor pure number crunching and hard core numeric simulation would you expect c++ or fortran to be superior?Fortran is superior because it has been extensively tested down all the years. And it is faster as well?My wish as *user* is to have a standard C++ interface to LAPACK instead of the umpteen C++ libraries.QuoteTo add the elements you can just write C=A+BAre fortran's array notation extensions generally useful.C = A+B is not trivial in C++. In fairness, that's not the language's condicio sine qua non.Last word goes to Dominic ConnorQuoteQuant C++ is a mix of C written in an ancient Fortran style, various libraries and frameworks that are both new and old and wanton use of exotic new features just to show you can.
Last edited by Cuchulainn on January 29th, 2015, 11:00 pm, edited 1 time in total.
http://www.datasimfinancial.com
http://www.datasim.nl

Every Time We Teach a Child Something, We Keep Him from Inventing It Himself
Jean Piaget
 
User avatar
Cuchulainn
Topic Author
Posts: 61483
Joined: July 16th, 2004, 7:38 am
Location: Amsterdam
Contact:

I LOVE FORTRAN

January 30th, 2015, 9:43 am

MatrixThat's a nice link but one-sided (it focuses on performance). Other quality characteristics are:1 Maturity (# bugs)2 Functionality (e.g. the stuff in Golub/Van Loan).3 Portability (e.g. different hardware)For 2 at least, Eigen > uBLAS as the latter has no numerical linear algebra routines.QuoteArmadillo is a high quality C++ linear algebra library, aiming towards a good balance between speed and ease of use; the syntax (API) is deliberately similar to Matlab
Last edited by Cuchulainn on January 29th, 2015, 11:00 pm, edited 1 time in total.
http://www.datasimfinancial.com
http://www.datasim.nl

Every Time We Teach a Child Something, We Keep Him from Inventing It Himself
Jean Piaget
 
User avatar
Cuchulainn
Topic Author
Posts: 61483
Joined: July 16th, 2004, 7:38 am
Location: Amsterdam
Contact:

I LOVE FORTRAN

January 30th, 2015, 4:18 pm

Here's a good way to compare performance of Fortran versus C++ -> Thomas tridiagonal solver. Now we can compare apples with apples.
Last edited by Cuchulainn on January 29th, 2015, 11:00 pm, edited 1 time in total.
http://www.datasimfinancial.com
http://www.datasim.nl

Every Time We Teach a Child Something, We Keep Him from Inventing It Himself
Jean Piaget
 
User avatar
katastrofa
Posts: 8930
Joined: August 16th, 2007, 5:36 am
Location: Alpha Centauri

I LOVE FORTRAN

February 1st, 2015, 10:21 pm

QuoteOriginally posted by: CuchulainnFortran is superior because it has been extensively tested down all the years. And it is faster as well?The old Fortran had arrays but no actual pointers which guaranteed no aliasing and consequently allowed a more optimised compilation and faster programs. Just like Java is sometimes faster than C++ thanks to allocating new arrays (hence no aliasing). F95 has pointers but they are different from the C++ ones.I also have a warm sentiment for Fortran and consider it optimal for scientific computations, but I would be cautious with trusting its extensive testing: http://stackoverflow.com/questions/1461 ... n-cQuoteMy wish as *user* is to have a standard C++ interface to LAPACK instead of the umpteen C++ libraries.What's wrong with clapack? Or this: http://mathema.tician.de/software/boost ... -bindings/
 
User avatar
Cuchulainn
Topic Author
Posts: 61483
Joined: July 16th, 2004, 7:38 am
Location: Amsterdam
Contact:

I LOVE FORTRAN

February 2nd, 2015, 11:59 am

QuoteOriginally posted by: katastrofaQuoteOriginally posted by: CuchulainnFortran is superior because it has been extensively tested down all the years. And it is faster as well?The old Fortran had arrays but no actual pointers which guaranteed no aliasing and consequently allowed a more optimised compilation and faster programs. Just like Java is sometimes faster than C++ thanks to allocating new arrays (hence no aliasing). F95 has pointers but they are different from the C++ ones.I also have a warm sentiment for Fortran and consider it optimal for scientific computations, but I would be cautious with trusting its extensive testing: http://stackoverflow.com/questions/1461 ... n-cQuoteMy wish as *user* is to have a standard C++ interface to LAPACK instead of the umpteen C++ libraries.What's wrong with clapack? Or this: http://mathema.tician.de/software/boost ... dings/Nice post, thank for posting.I must have a look at clapack. My memories of Fortran are similar to yours as it focuses the mind for algorithmic work in a way that C cannot do. I use uBLAS but not for matrix linear algebra at the moment.
Last edited by Cuchulainn on February 1st, 2015, 11:00 pm, edited 1 time in total.
http://www.datasimfinancial.com
http://www.datasim.nl

Every Time We Teach a Child Something, We Keep Him from Inventing It Himself
Jean Piaget
 
User avatar
rmax
Posts: 6080
Joined: December 8th, 2005, 9:31 am

I LOVE FORTRAN

February 3rd, 2015, 11:26 am

Quoteit focuses the mind for algorithmic work in a way that C cannot do. Sapir?Whorf hypothesis in action...
 
User avatar
Cuchulainn
Topic Author
Posts: 61483
Joined: July 16th, 2004, 7:38 am
Location: Amsterdam
Contact:

I LOVE FORTRAN

February 3rd, 2015, 12:03 pm

QuoteOriginally posted by: rmaxQuoteit focuses the mind for algorithmic work in a way that C cannot do. Sapir?Whorf hypothesis in action...Bingo! Can Programming Be Liberated from the vonNeumann Style? A Functional Style and ItsAlgebra of ProgramsJohn BackusIBM Research Laboratory, San JoseCan C++ be liberated?
Last edited by Cuchulainn on February 2nd, 2015, 11:00 pm, edited 1 time in total.
http://www.datasimfinancial.com
http://www.datasim.nl

Every Time We Teach a Child Something, We Keep Him from Inventing It Himself
Jean Piaget
 
User avatar
rmax
Posts: 6080
Joined: December 8th, 2005, 9:31 am

I LOVE FORTRAN

February 3rd, 2015, 12:56 pm

Thanks for the reference. It is speeding its way to a printer now so that I can read it and make notes. However we have been down this path before you and I!!!5GL have their past behind them - Cuch 2009This is exactly the kind of approach I was advocating in a 5 GL - although to be fair I did not expound on it much in the subsequent posts.Can C++ be liberated? No. It is something that is fundamental. Similar to evolution. At somepoint a spider evolved to have 8 legs - it is going to take a lot of evolution to get it down to six through a species jump where as adding a poison fangs is less of a structural change.I think that the current coding regime is bad and probably a paradigm shift will come when you look at the plethora of languages out there at the moment.
 
User avatar
Traden4Alpha
Posts: 23951
Joined: September 20th, 2002, 8:30 pm

I LOVE FORTRAN

February 3rd, 2015, 12:57 pm

QuoteOriginally posted by: CuchulainnQuoteOriginally posted by: rmaxQuoteit focuses the mind for algorithmic work in a way that C cannot do. Sapir?Whorf hypothesis in action...Bingo! Can Programming Be Liberated from the vonNeumann Style? A Functional Style and ItsAlgebra of ProgramsJohn BackusIBM Research Laboratory, San JoseCan C++ be liberated?Maybe, maybe not. If the core grammar and atoms of C++ are best suited to a certain style of programming, then trying to change that style will create a dissonant and more confusing language in which the elements of the language become modal (e.g., a line of code could be procedural or functional).The cleanest language of a given type would be designed from the ground up to most naturally represent it's style of programming.
 
User avatar
Cuchulainn
Topic Author
Posts: 61483
Joined: July 16th, 2004, 7:38 am
Location: Amsterdam
Contact:

I LOVE FORTRAN

February 3rd, 2015, 2:07 pm

QuoteOriginally posted by: Traden4AlphaQuoteOriginally posted by: CuchulainnQuoteOriginally posted by: rmaxQuoteit focuses the mind for algorithmic work in a way that C cannot do. Sapir?Whorf hypothesis in action...Bingo! Can Programming Be Liberated from the vonNeumann Style? A Functional Style and ItsAlgebra of ProgramsJohn BackusIBM Research Laboratory, San JoseCan C++ be liberated?Maybe, maybe not. If the core grammar and atoms of C++ are best suited to a certain style of programming, then trying to change that style will create a dissonant and more confusing language in which the elements of the language become modal (e.g., a line of code could be procedural or functional).The cleanest language of a given type would be designed from the ground up to most naturally represent it's style of programming.C++ is a general systems language that was originally called "C with classes". A spin-off was that it is a "better C".Quote If the core grammar and atoms of C++ are best suited to a certain style of programmingAnd that style(s) is?
Last edited by Cuchulainn on February 2nd, 2015, 11:00 pm, edited 1 time in total.
http://www.datasimfinancial.com
http://www.datasim.nl

Every Time We Teach a Child Something, We Keep Him from Inventing It Himself
Jean Piaget
 
User avatar
Traden4Alpha
Posts: 23951
Joined: September 20th, 2002, 8:30 pm

I LOVE FORTRAN

February 3rd, 2015, 2:10 pm

QuoteOriginally posted by: CuchulainnQuoteOriginally posted by: Traden4AlphaIf the core grammar and atoms of C++ are best suited to a certain style of programmingAnd that style(s) is?"Complicated"
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