5 ms·
I used to really like Julia but over time have heavily moved to the view that my ideal general-purpose programming language would look a lot like Swift, perhaps
by RivieraKid 4y ago
I used to really like Julia but over time have heavily moved to the view that my ideal general-purpose programming language would look a lot like Swift, perhaps with some bits of Julia, e.g. the REPL.
Julia doesn't have a good support for OOP. I don't think FP is the optimal way to solve all possible programming tasks. Usually a mix of both approaches leads to the most simple, maintainable and readable code.
And I'm really not sold on multiple dispatch. In Swift, I would simply implement the join function by adding an extension on `Array<String>`. And the + function would just be, for example, `static func + (left: Vector2D, right: Vector2D) -> Vector2D`. I've never come across a situation where I wished Swift would support multiple dispatch. On the other hand, the fact that Julia doesn't use the object.method() has 2 very clear drawbacks: lack of completion in an IDE and poor readability (example: `object.doSomething(a, b, c).doSomethingElse(a, b, c)` - imagine how would this look in Julia).
- m_nyongesa 4y agoI don't understand what the Julia language offers over for example OCaml, which has a solid type system yet also has a REPL as well as a scientific computing library: https://ocaml.xyz/ https://ocaml.xyz/ https://ocaml.xyz/docs/ https://ocaml.xyz/docs/
- galangalalgol 4y agoPerformance (c-like is stretching it, but not by much) and existing libraries for everything I can imagine.
- dunefox 4y agoUsable strings come to mind.
- galangalalgol 4y agodoSomethingElse( doSomething( object, a, b, c), a, b, c) Not that bad is it? I think I like it better actually, especially if a b and c had variable names that were longer
- RivieraKid 4y agoIt's a lot less readable to me. The dot version exactly matches my thinking - take this object and transform it with parameters a, b, c and then transform the result again. When you have an object that you apply a series of transformations to, it's natural to describe the process in chronological order.
- ssivark 4y ago> implement the join function by adding an extension on `Array<String>`. And the + function would just be, for example, `static func + (left: Vector2D, right: Vector2D) -> Vector2D`. 1. We are talking about a function that takes two values and spits out a third. In what sense are we talking about calling a method (or passing a message) to an object (the first string) to mutate its state? How do we enable a compiler to reason about the side-effects (or lack) of this code? 2. In mathematics "+" is almost always used for a commutative operation on values, so defining it the way you have breaks an (implicit) interface that is not explicitly codified (in part because current languages do not give us a way to codify this). The ability to reason about such properties is crucial if you want the runtime to be able to automatically reorder/parallellize/etc without breaking correctness. 3. While these details are minor annoyances in the case of string concatenation (fairly benign problem), they can become really painful when you are trying to leverage the power of generic programming to compose sophisticated algorithms. A classic poster example for this is when you want to add units or uncertainties/error-bars to your numbers and have all your numerical & plotting code generalize seamlessly -- Julia (for example) performs beautifully, while I don't see how any single dispatch (OOP) language can handle this challenge. More examples in this spirit: complex numbers, autodiff with dual numbers, etc.
- RivieraKid 4y ago1. We're not talking about a method that mutates state because this method doesn't mutate state. We can add a `mutating` keyword to the method (this is in fact implemented for Swift structs, but not classes). 2. I don't get this. What's the difference from Julia? Whether the operation is commutative is defined by the implementation of +, like in Julia, AFAIK. 3. Multiple dispatch seems useful in these cases, although it's a fairly niche area. I don't know how doable would this be just with generic programming / protocols without MD, didn't think too much about it. I vaguely remember that I didn't like that extending code with MD in a way relies on implicit, undefined interfaces.
- ChrisRackauckas 4y ago`object.doSomething(a, b, c, doSomethingElse)`. Less redundancy is usually good?