{"id":6696,"date":"2020-11-13T19:53:55","date_gmt":"2020-11-13T18:53:55","guid":{"rendered":"https:\/\/walkingrandomly.com\/?p=6696"},"modified":"2020-11-13T19:53:55","modified_gmt":"2020-11-13T18:53:55","slug":"no-fortran-no-data-science-in-r-and-python","status":"publish","type":"post","link":"https:\/\/walkingrandomly.com\/?p=6696","title":{"rendered":"No Fortran?  No data science in R and Python!"},"content":{"rendered":"<p>Earlier this week Apple announced their new, Arm-based &#8216;Apple Silicon&#8217; machines to the world in <a href=\"https:\/\/www.youtube.com\/watch?v=5AwdkGKmZ0I\">a slick marketing event<\/a> that had many of us reaching for our credit cards. Simultaneously, <a href=\"https:\/\/www.nag.com\/\">The Numerical Algorithms Group<\/a>\u00a0announced that they had ported their Fortran Compiler to the new platform. At the time of writing this is the only Fortran compiler publicly available for Apple Silicon although that will likely change soon as open source Fortran compilers get updated.<\/p>\n<blockquote class=\"twitter-tweet\">\n<p dir=\"ltr\" lang=\"en\">Fortran on your Mac! <a href=\"https:\/\/twitter.com\/NAGTalk?ref_src=twsrc%5Etfw\">@NAGTalk<\/a> announce the first Fortran Compiler for Apple Silicon Macs ahead of <a href=\"https:\/\/twitter.com\/Apple?ref_src=twsrc%5Etfw\">@Apple<\/a> event <a href=\"https:\/\/twitter.com\/hashtag\/OneMoreThing?src=hash&amp;ref_src=twsrc%5Etfw\">#OneMoreThing<\/a> \u2013 learn more <a href=\"https:\/\/t.co\/pcCuTs2vET\">https:\/\/t.co\/pcCuTs2vET<\/a> <a href=\"https:\/\/twitter.com\/hashtag\/AppleEvent?src=hash&amp;ref_src=twsrc%5Etfw\">#AppleEvent<\/a> <a href=\"https:\/\/twitter.com\/hashtag\/Apple?src=hash&amp;ref_src=twsrc%5Etfw\">#Apple<\/a> <a href=\"https:\/\/twitter.com\/hashtag\/AppleSiliconMacs?src=hash&amp;ref_src=twsrc%5Etfw\">#AppleSiliconMacs<\/a> <a href=\"https:\/\/twitter.com\/hashtag\/Fortran?src=hash&amp;ref_src=twsrc%5Etfw\">#Fortran<\/a> <a href=\"https:\/\/twitter.com\/hashtag\/Compiler?src=hash&amp;ref_src=twsrc%5Etfw\">#Compiler<\/a> <a href=\"https:\/\/twitter.com\/hashtag\/SC20?src=hash&amp;ref_src=twsrc%5Etfw\">#SC20<\/a> <a href=\"https:\/\/twitter.com\/Arm?ref_src=twsrc%5Etfw\">@Arm<\/a> <a href=\"https:\/\/t.co\/d03WsGVrUN\">pic.twitter.com\/d03WsGVrUN<\/a><\/p>\n<p>\u2014 NAG (@NAGTalk) <a href=\"https:\/\/twitter.com\/NAGTalk\/status\/1326138070043865088?ref_src=twsrc%5Etfw\">November 10, 2020<\/a><\/p><\/blockquote>\n<p><script async src=\"https:\/\/platform.twitter.com\/widgets.js\" charset=\"utf-8\"><\/script><\/p>\n<p><strong>Fortran? OK Boomer!<\/strong><\/p>\n<p>At over 60 years old, <a href=\"https:\/\/en.wikipedia.org\/wiki\/Fortran#:~:text=Fortran%20(%2F%CB%88f%C9%94%CB%90rt,numeric%20computation%20and%20scientific%20computing.\">Fortran<\/a> is one of the oldest programming languages that continues to be actively developed and used (The latest language specification is Fortran 2018). Routinely mocked by software engineers as old-skool (including me who, <a href=\"http:\/\/walkingrandomly.com\/?p=1397\">over a decade ago<\/a>, suggested that it shouldn&#8217;t be taught to undergraduates), Fortran is the language that everyone overlooks as they spend their days sipping flat-whites in Starbucks while hacking away in MATLAB, R or Python on shiny Macbook Airs.<\/p>\n<p>It can come as quite a shock, therefore, to discover that much of our favourite data science tools simply cannot work natively on any system that doesn&#8217;t have a Fortran compiler!<\/p>\n<p><strong>It&#8217;s Fortran all the way down<\/strong><\/p>\n<p>Much of the numerical functionality we routinely use today was developed decades ago and released in Fortran. More modern systems, such as R, make direct use of a lot of this code because it is highly performant and, perhaps more importantly, has been battle tested in production for decades.\u00a0 Numerical computing is hard (<a href=\"https:\/\/walkingrandomly.com\/?p=6633\">even when all of your instincts suggest otherwise<\/a>) and when someone demonstrably does it right, it makes good sense to reuse rather than reinvent.<\/p>\n<p>As a result, with no Fortran, there&#8217;s no R.<\/p>\n<p><a href=\"https:\/\/walkingrandomly.com\/wp-content\/uploads\/2020\/11\/R_fortran.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-large wp-image-6697\" src=\"https:\/\/walkingrandomly.com\/wp-content\/uploads\/2020\/11\/R_fortran-924x1024.png\" alt=\"R_fortran\" width=\"462\" height=\"512\" srcset=\"https:\/\/walkingrandomly.com\/wp-content\/uploads\/2020\/11\/R_fortran-924x1024.png 924w, https:\/\/walkingrandomly.com\/wp-content\/uploads\/2020\/11\/R_fortran-271x300.png 271w, https:\/\/walkingrandomly.com\/wp-content\/uploads\/2020\/11\/R_fortran-768x851.png 768w, https:\/\/walkingrandomly.com\/wp-content\/uploads\/2020\/11\/R_fortran.png 1190w\" sizes=\"auto, (max-width: 462px) 100vw, 462px\" \/><\/a><\/p>\n<p>The Python crowd don&#8217;t get away with it either.\u00a0 Here are the <a href=\"https:\/\/github.com\/scipy\/scipy\">GitHub stats for Scipy<\/a> as of today<\/p>\n<p><a href=\"https:\/\/walkingrandomly.com\/wp-content\/uploads\/2020\/11\/scipi_fortran.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-6698\" src=\"https:\/\/walkingrandomly.com\/wp-content\/uploads\/2020\/11\/scipi_fortran.png\" alt=\"scipi_fortran\" width=\"371\" height=\"175\" \/><\/a><\/p>\n<p>Of course, no Scipy means you also can&#8217;t have anything that <a href=\"https:\/\/libraries.io\/pypi\/scipy\/dependents\">depends on Scipy<\/a> including things like Keras or Scikit-learn.\u00a0 Also, if you want good performance for linear algebra operations (Which underpins a huge number of data science and ML algorithms) then you&#8217;ll need a good <a href=\"https:\/\/en.wikipedia.org\/wiki\/Basic_Linear_Algebra_Subprograms\">BLAS implementation<\/a>.\u00a0 Many projects use <a href=\"https:\/\/github.com\/xianyi\/OpenBLAS\">OpenBLAS<\/a>\u00a0(It&#8217;s a popular option in Numpy for example) which&#8230;you guessed it&#8230;is almost 49% Fortran.<\/p>\n<p><strong>Emulation for now<\/strong><\/p>\n<p>NAG&#8217;s Fortran compiler is excellent (it <a href=\"https:\/\/www.fortran.uk\/fortran-compiler-comparisons\/intellinux-fortran-compiler-diagnostic-capabilities\/\">routinely tops independent charts for its checking and Fortran standards compliance<\/a> for example) but it is commercial.\u00a0 \u00a0The community needs and will demand\u00a0open source (or at least free) Fortran compilers if data scientists are ever going to realise the full potential of Apple&#8217;s new hardware and I have no doubt that these are on the way.\u00a0 Other major silicon providers (e.g. Intel, AMD, NEC and NVIDIA\/PGI) have their own Fortran compiler that co-exist with the open ones.\u00a0 Perhaps Apple should join the club (I suggest they talk to NAG!).<\/p>\n<p>Until this is resolved, most of us will be relying on the Rosetta2 emulation&#8230;which, thankfully, <a href=\"https:\/\/developer.r-project.org\/Blog\/public\/2020\/11\/02\/will-r-work-on-apple-silicon\/\">is apparently pretty good<\/a>!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Earlier this week Apple announced their new, Arm-based &#8216;Apple Silicon&#8217; machines to the world in a slick marketing event that had many of us reaching for our credit cards. Simultaneously, The Numerical Algorithms Group\u00a0announced that they had ported their Fortran Compiler to the new platform. At the time of writing this is the only Fortran [&hellip;]<\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[34],"tags":[],"class_list":["post-6696","post","type-post","status-publish","format-standard","hentry","category-fortran"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/p3swhs-1K0","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/walkingrandomly.com\/index.php?rest_route=\/wp\/v2\/posts\/6696","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/walkingrandomly.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/walkingrandomly.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/walkingrandomly.com\/index.php?rest_route=\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/walkingrandomly.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=6696"}],"version-history":[{"count":3,"href":"https:\/\/walkingrandomly.com\/index.php?rest_route=\/wp\/v2\/posts\/6696\/revisions"}],"predecessor-version":[{"id":6701,"href":"https:\/\/walkingrandomly.com\/index.php?rest_route=\/wp\/v2\/posts\/6696\/revisions\/6701"}],"wp:attachment":[{"href":"https:\/\/walkingrandomly.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=6696"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/walkingrandomly.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=6696"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/walkingrandomly.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=6696"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}