News for hackers. Stuff that matters.
Re:Julia as a CLI Calculator by leephillips on Friday June 05, 2020 @09:42AM (#23428397)
“OOP” is an anemic special case of the multiple dispatch that Julia provides. So if you don’t know any better you can program in that style using Julia.

“str.parse(Int).abs is more readable” No, but it makes sense if you also think that OOP makes sense.

You can index based on anything you want.

Re:Julia as a CLI Calculator by RivieraKid on Friday June 05, 2020 @10:57AM (#23429281)
No it's not. OOP is regularly used for new projects by experienced programmers. Julia doesn't have interfaces for example.

I know that I can set indexing to be 0-based. Not a good solution.

Re:Julia as a CLI Calculator by socialdemocrat on Friday June 05, 2020 @12:42PM (#23430494)
Most dynamic OOP languages don't have interfaces either, so that is kind of a poor argument. You cannot compare Julia to something like Java.

You got to compare it to Ruby, Python etc.

Also I have no idea what an interface definition would look like in Julia. A function in Julia isn't bound to one specific type like in an OOP language.

Re:Julia as a CLI Calculator by newen on Friday June 05, 2020 @03:16PM (#23432656)
I think interfaces in Julia might go something like

    interface AnimalActions
        function walk(x::Animal) end
        function call(x::Animal, y::Animal) end
        function eat(x::Animal, z::Food) end
    end
    
    struct Dog <: Animal
        name::String
    end
    
    AnimalActions.walk(x::Dog) = true
    AnimalActions.call(x::Dog, y::Animal) = true
    AnimalActions.eat(x::Dog, z::Food) = true
    
    setinterface Dog AnimalActions end
and then I guess using it like

    using AnimalActions
    d = Dog("rufus")
    walk(d)
Re:Julia as a CLI Calculator by dklend122 on Friday June 05, 2020 @05:24PM (#23434161)
The below package implements something like that, but better imo: https://tk3369.github.io/BinaryTraits.jl/dev/
Re:Julia as a CLI Calculator by cbkeller on Friday June 05, 2020 @11:43AM (#23429817)
Regardless of what is a subset of what, I certainly agree with the OP that OOP feels "anemic" in comparison to the dispatch-based paradigm of Julia.

I can't tell you how many times I've seen disparate packages written by different authors with no explicit effort towards interoperability "just work" together in Julia (e.g., [1]), something I have never seen to a comparable degree in any other language.

[1] https://www.youtube.com/watch?v=kc9HwsxE1OY