News for hackers. Stuff that matters.
Re:Why physicists still use Fortran by throwaway7645 on Sunday December 18, 2016 @04:09PM (#13207648)
Agreed. I want to write numeric software, but don't want to use Fortran or C++. Rust looked great, but I couldn't find anything in this domain.
Re:Why physicists still use Fortran by bachmeier on Sunday December 18, 2016 @04:37PM (#13207798)
There's a lot of activity for D in this area. For instance, there's a BLAS replacement[1] with good performance. Supporting numerical programming is a priority for Walter and Andrei. There's more work to do, but it is adding enough functionality that it will be a realistic option for those that like the language.

[1] http://blog.mir.dlang.io/glas/benchmark/openblas/2016/09/23/...

Re:Why physicists still use Fortran by m_mueller on Sunday December 18, 2016 @08:47PM (#13208922)
Why don't you want to use Fortran?

If you want to get started, here's my recommendation: Program Kernels only in Modern Fortran, learn about f2py bindings and do the other parts in NumPy. If you use Fortran purely as a number crunching language - no I/O, no setup, no config code etc. - it's pretty sweet actually - IMO there isn't much need for replacing it with something new that has 50 years of compiler work to catch up (which is near impossible anyways).

Re:Why physicists still use Fortran by keldaris on Monday December 19, 2016 @08:12AM (#13211139)
Not the OP, but a computational physicist writing a fairly decent sized codebase for a long term project, just went through the language choice and initial prototyping phase. I have extensively used Julia, Python, MATLAB, C99, C++98/11/14, Fortran and D for work and I believe in picking the right tool for the job.

I chose C++ (writing in a fairly modern style, but not eschewing aliasing-restricted pointers, etc. where beneficial) because it handily beats everything except Fortran for performance and is vastly superior to Fortran in terms of zero-cost abstraction. I'm writing code that's largely portable between CPUs and accelerators (mostly GPUs) and has a lot of interchangeable parts. With C++ I can use templates to achieve compile time polymorphism and genericity, while retaining Fortran level performance on CPUs at the cost of higher code complexity.

The Fortran story on GPUs has also been very disappointing initially, especially for those of us not interested in proprietary compilers, though I understand the situation is improving there. Ultimately, in my experience, while individual strengths of C++ can be reproduced in other languages, there's no other language that does it all. I hope that changes some day (for now, D looks like the most promising alternative to me) as writing C++ is often an exercise in frustration, but that's where we're at.

Re:Why physicists still use Fortran by m_mueller on Monday December 19, 2016 @07:21PM (#13216272)
I'm in a similar situation as you, albeit with a large Fortran codebase that needs to stay - therefore I chose to write a transpiler in python that enables a Fortran codebase to be parallelised on CPU and GPU - see my profile link.
Re:Why physicists still use Fortran by keldaris on Wednesday December 21, 2016 @04:23PM (#13232741)
Hybrid-Fortran looks like an elegant workaround for an ugly problem, kudos for dealing with the storage order as well.

Ultimately, it seems to me the only way to justify using Fortran for scientific computing nowadays (apart from legacy issues, of course) is if you have no intention of ever using accelerators and absolutely must have optimal CPU performance. NVidia and, to a lesser extent, Intel/AMD could have maintained the language advantages Fortran offers in the accelerator space as well, but chose not to, and now you need solutions like this coupled with proprietary compilers just to approach CUDA C / OpenCL performance. Legacy projects will be around for decades, of course, but for new things I think C++ is/will increasingly be the default choice.

Re:Why physicists still use Fortran by goatlover on Sunday December 18, 2016 @04:29PM (#13207764)
Julia has strong numerical and multi-dimensional array support, but it's JIT compiled. However, once a function is JITted, it has comparable performance to Go & Rust.
Re:Why physicists still use Fortran by divbit on Sunday December 18, 2016 @05:13PM (#13208004)
Seconded for Julia. I have been using it for math prototyping and it's recently replaced my old favorites like matlab / python / lua.
Re:Why physicists still use Fortran by luthaf on Sunday December 18, 2016 @08:23PM (#13208813)
Yep, Julia is a very nice language with very good performances. But I abandoned it because it is not (yet?) oriented toward library development, and more usable in exploratory style.

I ran into issues a year ago when trying to organize a library with more than 8000 loc, when the "dump everything into a global namespace" started to be more a hassle and less a nice way to get stuff done. I am waiting for it to stabilize a bit before giving a second try.

Re:Why physicists still use Fortran by photon-torpedo on Sunday December 18, 2016 @11:18PM (#13209484)
Could you elaborate on why you felt the need to "dump everything into the global namespace"? For quite a long time now, you can use modules in Julia to keep things in separate namespaces. With "import MyModule" (instead of "using MyModule") things will not enter the global namespace, but will need to be qualified, like "MyModule.myfunction(...)". I feel this is very much like Python. You could even introduce abbreviations for the modules, using "const mm = MyModule" (admittedly, Python's "import...as" is cleaner).
Re:Why physicists still use Fortran by luthaf on Monday December 19, 2016 @11:17AM (#13212353)
Yes, but `using MyModule` is (was?) the default and preferred way to use a module. Which is equivalent to recommend everyone to do `from module import *` in Python.
Re:Why physicists still use Fortran by dnautics on Sunday December 18, 2016 @05:25PM (#13208079)
I believe the multidimensional arrays are backended by Fortran
Re:Why physicists still use Fortran by 3JPLW on Sunday December 18, 2016 @05:32PM (#13208112)
Not really. They're just written in a way such that the memory layout is compatible with BLAS libraries — which are frequently written in Fortran. So they can be passed directly to functions that happen to have been written in Fortran.
Re:Why physicists still use Fortran by photon-torpedo on Sunday December 18, 2016 @11:29PM (#13209510)
Additionally, invoking BLAS/LAPACK only happens for dense arrays of specific types (single/double precision real/complex numbers). The great thing in Julia is that almost all of the array and linear algebra functionality is implemented completely generically, so that algorithms can be written using these higher-level concepts, and the low-level functionality will (very efficiently) dispatch to BLAS/LAPACK if possible; if not, the generic implementations still allow your algorithm to work for e.g. your user-defined number type.
Re:Why physicists still use Fortran by dnautics on Tuesday December 20, 2016 @02:40PM (#13223226)
haha yeah I guess i should have been more precise with my wording. I'm currently prototyping a custom number system in julia, and obviously, the multidimensional array ops will not be backended in BLAS.
Re:Why physicists still use Fortran by david-given on Sunday December 18, 2016 @06:35PM (#13208394)
Has anyone tried numerical programming in Ada?

I haven't played with Ada arrays much, but I know it supports various different representations (so it can be binary compatible with Fortran column-first arrays and C row-first arrays), it's got nice array slicing semantics, it's got good support for generics which can operate on arbitrary sized arrays.

I don't know whether it has Fortran-like aliasing guarantees, though. You can't take an address of an array element unless the array has been declared to support it, which helps, but I don't know whether you can e.g. pass the same array by mutable reference into a function twice. (It makes sense that this isn't supported, as it's kinda meaningless, but I can't find an actual reference.)

Re:Why physicists still use Fortran by nickpsecurity on Sunday December 18, 2016 @06:43PM (#13208420)
It might have changed in 2005 or 2012 revisions but here is Ada 95's take on that:

http://www.adaic.org/resources/add_content/docs/craft/html/c...

Also check out ParaSail language designed for easy, safe parallel and concurrent programming. It's an Ada variant from Tucker Taft at AdaCore. Might have something interesting on this topic. Might not.

Re:Why physicists still use Fortran by frozenport on Sunday December 18, 2016 @05:22PM (#13208069)
Rust is like C++ but with better syntax for safer sharing of resources. If you don't like C++ you're not going to like Rust.