8 ms·
Can we use it along with emscripten to compile fortran programs to js?
by neurostimulant 9y ago
Can we use it along with emscripten to compile fortran programs to js?
- walshemj 9y agoWhy would you want to do that ?
- mtanski 9y agolegacy numeric applications / routines?
- zakk 9y agoExcept for some obscure edge case, it wouldn't really be a great idea to run them on a JS vm... FORTRAN code still in use is computation-heavy stuff for use cases where speed makes a big difference, the performance hit of a VM wouldn't be acceptable.
- sanxiyn 9y agoWell, for example, we could run 1980-era climate model written in Fortran on desktop web browser; it would run with reasonable speed.
- SomeStupidPoint 9y agoAh modern technology: using 1000x faster hardware to run 30 year old code at the same speed, but in a browser!
- pjmlp 9y agoThat is what I think every time I see WebGL demos that most of the time remind me of Voodoo or Amiga demos, but hey it is on the browser!
- mtanski 9y agoYou have accelerated graphics on any modern browser, on any OS, on any CPU architecture. I'll rag on JS as much as the next person but you have to admit 1) that's a pretty big feat 2) it's not an apples to apples comparison.
- pjmlp 9y agoThis is not true, because I have a couple of devices with pefectly fine working OpenGL ES 3.x GPUs where the browsers either don't support any form of WebGL or the FPS are a single digit number. Really, the 2nd coming of VRML.
- shepardrtc 9y agoThirty years ago it would have been run on supercomputers.
- zakk 9y agoThat's what I would define as a "some obscure edge case", see my comment above.
- monocasa 9y agoThe thing is that pretty much all Fortran is "some obscure edge case". Otherwise it'd be written in something that's not Fortran. Another example, I know the guy who maintains NIST's fluid properties solver (back in the day he worked at a subcontractor for NASA characterizing superfluids in fuel tanks). It's ancient Fortran compiled to a windows .dll and wrapped in VB in an excel file. It's super battle tested (being used for nearly 30 years), and it'd be awesome to be exposed in the browser.
- zakk 9y agoI use quite frequently LAPACK (http://www.netlib.org/lapack/ http://www.netlib.org/lapack/) which I would hardly define as "edge case".
- disgruntledphd2 9y agoEveryone who does any stats uses LAPACK, it's just that most of them aren't aware of it.
- jabl 9y agoThere is a lot of battle-tested Fortran out there. If you're for one reason or another in a situation where you have to deploy to the web platform and you need some numerical algorithms, I can imagine it could make sense to pick some routines from netlib instead of reinventing the wheel.
- goatlover 9y agoWhy not keep the numerical code on the sever?
- jabl 9y agoHmm, I guess it depends on the application whether that's a good idea or not. Or rather, before flang + emscripten/wasm/whatever, there was no reasonable way to run Fortran in a browser; now there is. Application developers can then choose whatever is most important for their application. Disclaimer: my web dev experience predates the "modern web" with SPA's, fast javascript runtimes, html5 etc.
- goatlover 9y agoNever thought I'd live to see the day people would be talking about compiling fortran to javascript to run in a web browser. Just mind blowing.
- kardos 9y agoIf you can run the processing on the client side, then you can scale up much, much easier and provide whatever service much cheaper, or even free. Eg, you can provision fewer servers, no need to build a processing queue or load balancing setup, if the input is provided by the client then you use less bandwidth by avoiding a round trip on that, etc.
- goatlover 9y agoNot sure it makes sense for computationally expensive code to be running in the user's browser.
- anentropic 9y agoIt would be useful if you specifically wanted to run it in JS environment, rather than for the speed Seems like most numeric/math code have some Fortran libraries underneath. It'd be handy to have a route to just compile them to JS rather than having to write from scratch
- goatlover 9y agoThis was a serious question? Oh geez. What kind of world has the web wrought?
- zakk 9y ago...and then your Javascript code will run on node.js, and the instance will be Dockerized for ease of deployment to a VPS. How many layers of abstractions are there?
- curtis 9y agoIt's turtles all the way down.
- AstralStorm 9y agoAnd they all live in a VM anyway.
- boromi 9y agoand also nginx reverse proxy m8, with apache compiling instances to be deployed automatically to scale using latest gcc7 with 03 optimization for robustness against DDOS
- walshemj 9y agoYes as some one who used to hack Fortran for a living I was having a hard time to find a use case for converting Fortran to js
- marmaduke 9y agoSo that you can demo your numerical algorithm in a web page because it's the only way 99% of people would ever notice your work?
- coldtea 9y agoAs if the target demographic actually wants to see web demos of numerical algorithms?
- dagw 9y agoI am very much the target demographic and I can definitely see a use. If nothing else an interactive web demo would make a great teaching tool.
- marmaduke 9y agoYes indeed. Perhaps you are not the target demographic, but there are a lot of algorithms which can be interactive and have a visualization for example http://journals.plos.org/plosone/article?id=10.1371/journal.pone.0143015 http://journals.plos.org/plosone/article?id=10.1371/journal....
- JustSomeNobody 9y agoBecause 90% of HN only knows JavaScript so everything must in some way involve it.
- e12e 9y agoTo reap the performance benefits of v8 and wasm for your numerical fortran routines? /S
- cat199 9y agothe matrix.
- pletnes 9y agoI've heard a horror story of someone doing signal processing in node.js. It'd be nice to use a well tested Fortran FFT routine - there aren't many .js libs for doing numerics AFAIK (disclaimer: not a js programmer)
- walshemj 9y agoExactly at my first job we brought our FFT routines in from NAG https://www.nag.co.uk/ https://www.nag.co.uk/
- neurostimulant 9y agoThere are many useful computational model written in fortran that would be absolutely useful if they can be run in a browser, simply because telling the user to compile them on their own is impossible unless they're familiar the toolkit themselves. For example, it would be incredibly useful if you can run various US EPA's dispersion models right in your browser. https://www3.epa.gov/scram001/dispersion_prefrec.htm https://www3.epa.gov/scram001/dispersion_prefrec.htm
- nonsince 9y agoThis is the most Hacker News comment I have seen in years and I love it
- genericpseudo 9y agoMe of fifteen years ago would love this for lab classes on, e.g., classical molecular dynamics. The computational load of these simulations is, in modern terms, not large, so Emscripten-compiled simulations would be plenty fast enough, and deployment of web pages in a computer-lab environment (or for people working from their dorms!) is way easier than the alternatives. So there are real, non-trivial applications. You wouldn't want to be running ABINIT or whatever in your web browser, but GROMACS on some small system? Not unreasonable.
- infinite8s 9y agoFor classroom study - wouldn't straight javascript suffice for basic classical molecular dynamics? That approach would also make it much easier for students to play around with different update algorithms, temperature control, etc.
- genericpseudo 9y agoThat would involve a) writing yourself an engine and that's actual work b) that engine not being one which is used in real research So "it depends" – for introductory teaching yes, for training researchers less so.
- goatlover 9y agoTeachers can utilize Jupyter notebooks today.
- luthaf 9y agoYep, I will definitively try to compile my Rust MD code to emscripten and give it a look! There are quite a few JS molecules visualizers, so the outcome can be pretty nice for teaching.
- waldir 9y agoNot just JavaScript: https://mohd-akram.github.io/languages/?source=LLVM%20IR https://mohd-akram.github.io/languages/?source=LLVM%20IR
- waldir 9y agoIn fact, Flang has now been added: https://mohd-akram.github.io/languages/?source=Fortran https://mohd-akram.github.io/languages/?source=Fortran
- s-macke 9y agoI asked the same question two years ago on another LLVM Fortran project. https://news.ycombinator.com/item?id=10574243 https://news.ycombinator.com/item?id=10574243
- jabl 9y agoThis is the same LLVM Fortran project as discussed two years ago in the thread you linked. Two years ago was just an announcement, now they are publishing some open source code (which might or might not actually work, for some definition of "work", I haven't tried it). So the backstory is that Nvidia bought PGI, a company which produced a C/C++/Fortran compiler suite which was moderately commonly used in HPC. Then they took the Fortran frontend from the PGI suite and bolted it to LLVM and open sourced it as flang.
- hackcasual 9y agoProbably. The biggest stumbling block will be inline assembly.
- CoC_CRUSHER 9y agoInline assembly isn't that common in Fortran.
- acomjean 9y agoFunny.... but: In a past job we had some ada code in our codebase that was just awful looking. It was machine translated from fortran to ada. From what I could tell, it was just a few files that were translated and then fixed up and checked in before they gave up on that conversion project. we nicknamed such code "ada-tran" Thus the I feel the new translated code should be called "Forscript"
- kbenson 9y agoTo my understanding, Emscripten thankfully does not attempt to keep the JS sane for humamn consumption at all. It's basically a higher level assembly language that targets a browser. What Emscripten does is more compiling to JS, not translating to it. > we nicknamed such code "ada-tran" If Fortran -> Ada is ada-tran, then wouldn't Fortran -> Javascript be Javascran? :)
- microcolonel 9y agoIt better not be Forscript.
- leeoniya 9y agoTranscript?