Erik Engheim
2 min readNov 15, 2020

--

Hehehe this thing about code organization must be some hangup you Java guys have. The rest of us have been putting classes in whatever files we wanted for a long time and been very happy with that.

In my opinion the Java approach is what creates a mess. You want each file fairly manageable.

That means you can get a better overview by putting a number of small and related classes in one file.

And in opposite manner you can split a large class across multiple files.

E.g. in Objective-C and Swift you often put class extensions in separate files.

In Julia I am happy I don't have to care about the object-oriented thinking at all. I can group related functionality for many different types in one file. In my opinion Java just typically creates an OOP straightjacket on you which hinders you from having organization that makes sense for your particular code project.

And don't get me started on the crazy deep nesting in Java. Nope in that case I go with the Zen of Python.

If you like this Kotlin type of error handling then you should like how Zig does it. Zig has quite an elegant error handling system.

Kotlin is very similar to how Swift deals with errors I think, but I would say it is cleaner in Swift because you don't have errors and monads. You only have monads for dealing with errors.

Julia is a bit of a mix. You can actually deal with error situations in a bit similar way as Julia also bans null pointers and you need to use either types. However Julia supports exceptions.

An advantage of Julia over languages like Java is that numbers are first class objects, so numbers are actually part of an elaborate type hierarchy. E.g. Int32 has Signed as supertype, which has Integer as supertype Real, which has supertype Number. Thus you can have Maybe and Missing types for numbers and there in no big performance hit.

In fact despite a far more abstract number system, Julia handlily beats Java on number crunching.

--

--

Erik Engheim
Erik Engheim

Written by Erik Engheim

Geek dad, living in Oslo, Norway with passion for UX, Julia programming, science, teaching, reading and writing.

Responses (1)