4 ms·
Regarding Haskell specifically, Haskell makes it cumbersome to write code that mutates data structures, which is what you need to efficiently implement many num
by yomritoyj 11y ago
Regarding Haskell specifically, Haskell makes it cumbersome to write code that mutates data structures, which is what you need to efficiently implement many numerical algorithms. But I'm a fan of Haskell's [REPA](https://hackage.haskell.org/package/repa https://hackage.haskell.org/package/repa) which provides multidimensional arrays with complete control over which operations are computed immediately and which are deferred and can be combined later with other operations. This allows many computations to be expressed in a high-level array-oriented way without incurring the cost of creating huge temporaries. C++ template libraries like Eigen can do this, but give much less control to the user on what is deferred.
- codygman 11y ago> Regarding Haskell specifically, Haskell makes it cumbersome to write code that mutates data structures Can you provide some Haskell examples that are cumbersome, then provide an example that isn't in another language of your choice? Also, have you tried using lens for this?
- yomritoyj 11y agoCompare the implementation of a simple numerical program in Haskell https://github.com/jmoy/avb-econ-hs/blob/f6d65af480c99045573fd2f8be23572240d3c9e2/Main.lhs https://github.com/jmoy/avb-econ-hs/blob/f6d65af480c99045573... to that in Julia https://github.com/jesusfv/Comparison-Programming-Languages-Economics/blob/b558946c4c4d22a79478174ed157800ba828859f/RBC_Julia.jl https://github.com/jesusfv/Comparison-Programming-Languages-... Despite the Haskell program using the elegant facilities provided by REPA, the fact that mutable part (the `writePolicy`) has to be written in a different style than the pure parts since it is a monadic action seems cumbersome to me.
- codygman 11y agoI agree that the Julia looks nicer, despite the fact I usually dislike so much nesting. > the fact that mutable part (the `writePolicy`) has to be written in a different style than the pure parts since it is a monadic action seems cumbersome to me. It has to be written differently more because it's using the state monad. You can write monadic actions that resemble pure code, for instance: > replicateM_ (readFile "/etc/issue") ["Ubuntu 15.10 \\n \\l\n\n","Ubuntu 15.10 \\n \\l\n\n","Ubuntu 15.10 \\n \\l\n\n","Ubuntu 15.10 \\n \\l\n\n","Ubuntu 15.10 \\n \\l\n\n","Ubuntu 15.10 \\n \\l\n\n","Ubuntu 15.10 \\n \\l\n\n","Ubuntu 15.10 \\n \\l\n\n","Ubuntu 15.10 \\n \\l\n\n","Ubuntu 15.10 \\n \\l\n\n"]