5 ms·
I like Julia (mostly because of multiple dispatch). The only thing that's lacking is an industry strength Garbage Collector, something that can be found in the
by odipar 6y ago
I like Julia (mostly because of multiple dispatch). The only thing that's lacking is an industry strength Garbage Collector, something that can be found in the JVM.
I know that you shouldn't produce garbage, but I happen to like immutable data structures and those work better with optimised GCs.
- newswasboring 6y agoI didn't even know julia GC had issues. Care to elaborate?
- StefanKarpinski 6y agoIt doesn’t, it just doesn’t have a $100B GC like Java does. Rather than spending that kind of money trying to compensate for a language design that generates massive amounts of garbage (ie Java), Julia takes the approach of making it easier to avoid generating garbage in the first place, eg by using immutable structures that can be stack allocated and having nice APIs for modifying pre-allocated data structures in place.
- leephillips 6y agoOuch.
- StefanKarpinski 6y agoI mean I’m not trying to hate on Java — pointer-heavy programming was all the rage when it was designed, and GC was a hot research topic, so there was good reason to be optimistic about that approach. But it turns out that it’s very hard to make up for generating tons of garbage and pointer-heavy programming hasn’t aged well given the way hardware has evolved (pointers are large and indirection is expensive).
- leephillips 6y agoHating on Java seems perfectly reasonable to me.
- odipar 6y agoso are you for GC or against GC? In other posts you actually argue that GCs help you reduce complexity because manual memory management is too much of a hassle. May be immutable is not the correct term - persistent data structures is what I like support for: that is my use-case. I think you can have efficient persistent data structures without a GC, but that requires fast reference counting and in turn, that requires a lot of work to be competitive with the JVM. I also understand that my use-case is not Julia's focus. That's perfectly fine.
- ChrisRackauckas 6y agoThat's a major oversimplification. GC is good for ease of use and safety of a high level language. GC is never as performant as not requiring heap allocations at all. Julia has a GC, but also provides a lot of tools to avoid needing the GC in high performance computations. This combination gives ease of use and performance. Java sacrifices some performance for having this "one paradigm" of all objects, and then heavily invested in the GC, but in many cases like writing a BLAS it still just will not give performance exactly matching a highly tuned code, where as in Julia for example you can write really fast BLAS codes like Octavian.jl. Julia is multi-paradigm in a way that is purposely designed for how these features compose. I think it's important to appreciate that design choice, in both its pros and cons.
- odipar 6y agoI like your response, and yes, it was a major oversimplification and I'm sorry for that. Indeed, it is always about design choices and trade-offs. I can see why BLAS code is important and why Julia is an optimal choice for computation heavy problems.
- StefanKarpinski 6y agoI don't know that the object model is why writing a BLAS in Java doesn't make sense. After all they special case `float` and `double` as primitives, which bifurcates the whole type system and is its own whole issue, but means that you can store them efficiently inline. I'm actually not sure what stops someone from writing a BLAS in Java except that it would be hard and there's no point.
- odipar 6y agoI don't think you can allocate immutable data structures on the stack. I've never seen a 10 million entry immutable set on the stack but I could be wrong.
- StefanKarpinski 6y agoObviously a 10-million-element array doesn't get stack allocated. But if individual objects of some type are immutable, then they can be stack allocated, or maybe not allocated at all (kept in registers). Edit: reading your other post, it seems like you may mean persistent data structures, a la Clojure, rather than immutable structures, which are quite different. The former would indeed always be heap-allocated (it's necessary since they are quite pointer-heavy). Immutable structures, on the other hand are detached from any particular location in memory. Moreover, if the elements in an array are mutable, eg Java objects, then each one needs to be individually heap allocated with a vtable pointer and the array has to be an array of pointers to those individually allocated objects. For pointer-sized objects (say an object that has a single pointer-sized field), that takes 3x memory to store x objects, so that's already brutal, but worse is that since the objects are all individually allocated, the GC needs to look at every single one, and freeing the space is a fragmentation nightmare. If the objects are immutable (and the type is final; btw all concrete types are final in Julia), then you can store them inline with no overhead and GC can deal with them a single big block. Btw, I had to vouch for you to undead your posts in order to reply. Looks like you got downvoted a bunch.
- adgjlsfhk1 6y agoThe biggest struggle Julia's GC has is that in multi-threaded workloads, it sometimes isn't aggressive enough to reclaim memory leading to OOM.
- StefanKarpinski 6y agoThis is very legit issue that the compiler team has their eye on and plans to work on.
- adgjlsfhk1 6y agofyi, I'm oscardssmith on most other channels.
- StefanKarpinski 6y agoHi, Oscar! Nice user name :P
- adgjlsfhk1 6y agoIt's my backup username discovered when I was 10 or so, and I wanted something that wasn't my name and would be available everywhere.
- eigenspace 6y agoJulia's garbage collector is quite good. > I know that you shouldn't produce garbage, but I happen to like immutable data structures and those work better with optimised GCs. If you use immutable data-structures in julia, you're rather unlikely to end up with any heap allocations at all. Unlike Java, Julia is very capable of stack allocating user defined types.
- dan-robertson 6y agoI think that’s true for small structs made of floats but not true for something like an immutable lisp-style linked list.
- DNF2 6y agoNot just floats, and I'm not sure they have to be that small. All sorts of structs containing bitstypes/value types can be stack allocated. In fact, even some structs with pointers to heap-allocated memory can be stack-allocated (such as array views.) I don't know about linked lists, though.
- superdimwit 6y agoA low-latency GC would also be great. But again, the JVM only has that due to many millions of dollars spent over decades.