4 ms·
In my opinion, Julia is much better for numeric performance than C or Fortran. Real macros mean that you don't have to use a janky preprocessor (or a separate p
by adgjlsfhk1 5y ago
In my opinion, Julia is much better for numeric performance than C or Fortran. Real macros mean that you don't have to use a janky preprocessor (or a separate programming language) to generate optimal code, and multiple dispatch means you don't need to give your functions awful names (looking at you cgbtrf) and instead can just name them for what they do.
(Also, Julia gives you easy automatic differentiation and gpuification)
- klodolph 5y agoThe awful names are from a six-character limit somewhere. I'm curious why you would want multiple dispatch. Seems to me like either longer names or single dispatch would be enough. In "cgbtrf", the first three letters just tell you what kind of matrix are the input... "cgb" being a complex-valued band matrix. That leaves you only three letters to say what the function does.
- adgjlsfhk1 5y agowith multiple dispatch, this function would just be lu. Multiple dispatch means that all the functions that add things can just be called +, and all the ones that compute lu factorizations can be lu, and which specific version gets called is all handled by the type system. If I call lu on a complex banded matrix, it will dispatch to the method optimized for that without me having to care about what that is. This makes writing generic code much easier because you don't have to write a separate copy of your function for each new datatype you want to support.
- pjmlp 5y agoSo like Fortran generics.
- adgjlsfhk1 5y agoNot really, Fortran is inching it's way towards generics, but doesn't actually have them in a usable form yet.
- pjmlp 5y agoParameterized derived types seem good enough for what Fortran is used for.
- adgjlsfhk1 5y agoThey are powerful enough to express functions that only depend on one argument, but how would you use them to encode the types of both arguments for matrix multiplication?
- pjmlp 5y agoLike this? https://www.pgroup.com/blogs/posts/f03-oop-part3.htm https://www.pgroup.com/blogs/posts/f03-oop-part3.htm
- adgjlsfhk1 5y agoThat gets you some of the way there, but isn't powerful enough to handle things like orthogonal*banded or really any situation where all the types aren't planned out in advance.
- gnufx 5y agoI don't remember if it exists for LAPACK, but there's a generic BLAS interface with ifort/MKL. It's just a pity it was never (quasi-)standardized. (The trivial example is Fortran intrinsics.) I was happily using CLOS-like systems long before Julia, though. Does Julia actually beat SBCL, for instance, on such things?
- adgjlsfhk1 5y agoJulia has been heavily inspired by Lisp (especially Dylan and scheme). In my experience, Julia is easier to use for numeric computing.
- TheRealKing 5y agoJulia currently has specific weaknesses that make it unsuitable for a large category of problems that a language like Fortran (or C) has handled seamlessly for decades.
- cazador69 5y agoDo you have any specific example? I am truly interested. One of the things I don't like so much about Julia is its community, always preaching Julia is a better language than X, Y, and Z all together. It would be nice to have some concrete examples.
- adgjlsfhk1 5y agoThe obvious one is any time you need a statically compiled binary. There's work on that, but for now at least, that's a definite shortcoming.
- TheRealKing 5y agoCan you elaborate further, with an example, how this is different from static polymorphism? I don't fully understand your argument where you say "it will dispatch to the method optimized for that" and then "you don't have to write a separate copy of your function for each new datatype". The two do not seem consistent with each other.
- klodolph 5y agoThat sounds like single dispatch to me. Maybe I'm missing something.
- pjmlp 5y agoEventually, note that you should compare it against latest ISO Fortran standard per commercial compilers, not what gfortran is capable of.
- sampo 5y ago> multiple dispatch means you don't need to give your functions awful names (looking at you cgbtrf) and instead can just name them for what they do. Fortran has ad-hoc polymorphism, and 63 characters maximum length for names. These should be enough to keep the user happy in this use case. (The programmer still needs to write separate code for each version of input types.)