TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Fortran vs Python: The counter-intuitive rise of Python in scientific computing (2020)

89 pointsby zaikunzhangover 1 year ago

23 comments

arc619over 1 year ago
Personally, I think Python&#x27;s success is down to the productivity of its peudocode-like syntax letting you hack prototypes out fast and easy. In turn, that makes building libraries more attractive, and these things build on each other. FORTRAN is very fast but it&#x27;s a less forgiving syntax, especially coming from Python.<p>In that regard, I&#x27;m surprised Nim hasn&#x27;t taken off for scientific computing. It has a similar syntax to Python with good Python iterop (eg Nimpy), but is competitive with FORTRAN in both performance and bit twiddling. I would have thought it&#x27;d be an easier move to Nim than to FORTRAN (or Rust&#x2F;C&#x2F;C++). Does anyone working in SciComp have any input on this - is it just a lack of exposure&#x2F;PR, or something else?
评论 #38892422 未加载
评论 #38892130 未加载
评论 #38892380 未加载
评论 #38892201 未加载
评论 #38895054 未加载
评论 #38892144 未加载
评论 #38892664 未加载
评论 #38896862 未加载
评论 #38893156 未加载
评论 #38892062 未加载
评论 #38892658 未加载
HarHarVeryFunnyover 1 year ago
IMO the popularity of Python has as much, if not a lot more, to do with the available libraries and frameworks as the language itself. The language itself seems more inherently suited as a successor to Perl - as a powerful scripting language, rather than one really suited to large, complex, multi-person projects.<p>What seems to have bootstrapped the success of Python for ML and scientific use was early adoption by people in these communities who were not hard core programmers, and found it easy to get started with. Once SciPy and NumPy were available, and NumPy became used for ML, then the momentum of ML helped further accelerate the adoption of Python.
评论 #38892361 未加载
评论 #38892269 未加载
cjs_acover 1 year ago
Python isn&#x27;t the language of scientific computing, data science, or high-performance computing.<p>Python is a popular user interface for scientific computing, data science or high-performance computing.
评论 #38892399 未加载
评论 #38892434 未加载
评论 #38892706 未加载
pjmlpover 1 year ago
As someone that was at CERN when Python started to be adopted in the early 2000&#x27;s, Python got popular as saner Perl alternative for UNIX scripting, build tools (CMT), and as means to provide a REPL to C++ and Fortran libraries instead of dealing with ROOT.<p>That was all, it could have been Tcl instead.
评论 #38908720 未加载
jraphover 1 year ago
Programming languages are a bit like social networks. There&#x27;s some network effect. People go where other people are. Python is currently where things happen.
tyingqover 1 year ago
I imagine part of it is also that a lot of the code isn&#x27;t the science part. It&#x27;s all the setup, things like parsing data for input or output. Languages like Python and Perl have very rich standard library stuff for massaging strings, data formats, etc.
评论 #38892793 未加载
zwiebackover 1 year ago
I&#x27;m so old that Fortran was actually my first language. Over the years I&#x27;ve seen language bindings to the old Fortran numerical libraries we all rely on but Python&#x2F;numpy is the first wrapper I&#x27;ve actually enjoyed using. It&#x27;s more than a wrapper in that it brings a compact representation of slices and vectors.<p>However, if I didn&#x27;t know how things work underneath I&#x27;d be a little uneasy. You can always profile after the fact but it helps knowing how to avoid inefficient approaches.
zzbn00over 1 year ago
The slowness of Python meant that nobody thought &quot;it&#x27;ll be easier just to write this routine&quot; as opposed to looking to re-use existing (most often compiled) code. And if you are doing science, the less time you spend re-inventing code, the more science you will get done.
npalliover 1 year ago
The date of this discussion (July&#x2F;2020) really caught my eye. Fortran is actually making quite a comeback (to the extent an ancient scientific language can :-). I casually looked at the TIOBE index[1], flawed as it may be, it gives you sense of the trends of the larger languages. To my not-a-surprise, turns out precisely in 2020&#x2F;July Fortran was at it&#x27;s lowest rank on the index since it was tracked from 2001, and has steadily climbed since then. No doubt it is due to vast number of libraries already existing and python is really glue code not something you write the main code in. As someone joked to me, the first rule of python programming in scientific computing is make sure you don&#x27;t have any of your program go through python. You cannot avoid Fortran&#x2F;C++ unless you have very trivial or textbook type code.<p>[1] <a href="https:&#x2F;&#x2F;www.tiobe.com&#x2F;tiobe-index&#x2F;fortran&#x2F;" rel="nofollow">https:&#x2F;&#x2F;www.tiobe.com&#x2F;tiobe-index&#x2F;fortran&#x2F;</a>
评论 #38892551 未加载
gjvcover 1 year ago
Tooling is the thing. To keep older languages popular with people new to the industry (and who never get <i>properly</i> introduced to older tools) it would take someone like JetBrains need to create COBOL and Fortran IDEs. People will always go for shiny and new, like it or not.
评论 #38891992 未加载
评论 #38891682 未加载
andy99over 1 year ago
I wrote a short thing about working with Fortran for AI recently: <a href="https:&#x2F;&#x2F;www.marble.onl&#x2F;posts&#x2F;fortran_llms.html" rel="nofollow">https:&#x2F;&#x2F;www.marble.onl&#x2F;posts&#x2F;fortran_llms.html</a><p>I&#x27;m a big Fortran now for anything fast. If I was doing EDA or any one-of data science stuff I&#x27;d be more likely to use python though (or coreutils and gnuplot depending on the circumstances).
pjs_over 1 year ago
I worked hard to replace LabView and Matlab with Python in the lab when I was a PhD student - about 15 years ago. By far the biggest motivation to do this was to remove the friction and cost of obtaining licenses for proprietary software.
1-6over 1 year ago
I wish Python existed when I was in high school. My school’s compiler wouldn’t remind me that I was missing a semicolon and I would constantly be wasting time looking at syntax rather than grasping bigger concepts.
TrianguloYover 1 year ago
Not sure if it&#x27;s real or not, but on my university I&#x27;m almost sure python is used primarily for being the free alternative to matlab.<p>That, and how easy it is to install and import things.
评论 #38892289 未加载
xondonoover 1 year ago
Python wins because it’s the lowest common denominator.<p>We have a bunch of people programming, most of them scientists. Even if Python is poorly suited for us, it’s pretty much the only thing everyone can work with.
评论 #38893427 未加载
logtempoover 1 year ago
When you look at the &quot;monster&quot; that is ROOT-CERN, which is a C&#x2F;C++ interpreter* with very efficient statistics and plot tools (it can digest tons of data), it is completely logic that Python is a good language for daily lab tasks and analysis. But I&#x27;m not sure if it is really used beyond this daily lab task or intern project where performance is not critical. Big simulations I participated were made in C&#x2F;C++.<p>Nowaday, it seems that at least physics particle community looks enthusiastic regarding Julia development.<p>*: it mimics most of core python features such as no strict typing, data structures that can store different types, on-the-fly coding, graphic interface for representation, no compilation needed.
dadogeover 1 year ago
Python is also a more transferable skill than Fortran.<p>I bet that plays some role too in its popularity in the scientific community, which has many young anxious grad students&#x2F;postdocs looking to ensure they are employable.
评论 #38892152 未加载
PLenzover 1 year ago
This is less the difference between fortran and python and more the difference between run once for an experiment culture and run as part of a pipeline culture.<p>Languages are mostly funglible, coding culutre is not.
LispSporks22over 1 year ago
Like just about any technology in our industry, people use it because it’s popular. Competitive advantage be damned - just use what your competitors use.
zaikunzhangover 1 year ago
Original post at <a href="https:&#x2F;&#x2F;cerfacs.fr&#x2F;coop&#x2F;fortran-vs-python" rel="nofollow">https:&#x2F;&#x2F;cerfacs.fr&#x2F;coop&#x2F;fortran-vs-python</a><p>Contents:<p>- “Python, a slower language”<p>- “more and more”<p>- “time-critical scientific computations”<p>- Is Python ever better suited?<p>- User story : same author, two languages<p>- Speed vs agility<p>- Takeaway
deterministicover 1 year ago
Python is mostly used as an API for interacting with high-performance libraries written in <i>other</i> languages. It is the BASIC of today.
QuadmasterXLIIover 1 year ago
The miracle of python is that it has standard syntax for vectorized code across many packages.<p><pre><code> For i in range(100): mask = lib.abs2(z) &lt; 4 subset = z[mask] subc = c[mask] subcounts = 0 for j in range(100): subcounts = subcounts + lib.abs2 (subset )&lt; 4 subz = subz**2 + subc Z[mask] = subset Counts[mask] += subcounts </code></pre> Was that code using numpy, tensorflow, torch, arrayfire, or some proprietary amd gpu lib? It’s hard to say!<p>Try the same with eigen vs arrayfire in C++ or math.js vs tensorflow.js and you will have to do a hell of a lot more than change the value of lib
评论 #38891896 未加载
评论 #38893285 未加载
ringofchaosover 1 year ago
Python is also recommended in tech community as recommended programming for coding interviews as you need to write less code.