3 ms·
I think I can understand what you mean about worrying about the lack of emphasis of functional programming in Julia, in the sense that it certainly isn't emphas
by gajomi 13y ago
I think I can understand what you mean about worrying about the lack of emphasis of functional programming in Julia, in the sense that it certainly isn't emphasized explicitly, but I wonder if your concern is more specific than that? In Julia functions are first class objects and can dispatch on subtypes of Function. There are several immutable types available. There seems to be a convention (at least within the standard library) of adding ! postfix to indicate function as having side effects. You have projects like JUMP (https://jump.readthedocs.org/en/latest/jump.html https://jump.readthedocs.org/en/latest/jump.html), which explicit revolve around declarative programming DSLs. All these things together suggest to me that Julia is supportive of functional programming. But I am only slowly wading into Julia, so I am mostly speaking from a theoretical perspective. Perhaps you can clue me in?
- nextos 13y agoWell, my comment stems from a very superficial overview of the language and some libraries. Perhaps I'm wrong. But I haven't seen any heavy usage of high-order functions or lazy data structures, and this worries me. I don't just want a fast MATLAB replacement. I want a fully-fledged multi-paradigm programming language.
- StefanKarpinski 13y agoYou're right that there isn't a particularly strong emphasis on lazy data structures or higher-order programming in Julia's base library. They are, however, both well supported and higher-order functions in particular are used in many places; Julia uses Ruby-style do blocks all over the place, and a lot of macros desugar to functional constructs. However, Julia's primary paradigm is multiple dispatch. For more details on that, you can check out this presentation I gave at Strange Loop this year: http://nbviewer.ipython.org/gist/StefanKarpinski/b8fe9dbb36c1427b9f22 http://nbviewer.ipython.org/gist/StefanKarpinski/b8fe9dbb36c... Functional style isn't something to embrace for its own sake. Lazy data structures, in particular, while elegant, require a very sophisticated compiler in order to have even remotely decent performance. Even with a sufficiently clever compiler, the performance characteristics of the resulting code tend to be extremely opaque and difficult to reason about. That said, sometimes it's a nice way to express things and it's quite possible to implement lazy data structures in Julia: see, for example, the Lazy [1] and LazySequences [2] packages. [1] https://github.com/one-more-minute/Lazy.jl https://github.com/one-more-minute/Lazy.jl [2] https://github.com/dcjones/LazySequences.jl https://github.com/dcjones/LazySequences.jl