Hacker News new | ask | show | jobs
by FridgeSeal 2851 days ago
I’ll have a stab at answering this, someone who knows better can correct me.

Dynamic with optional typing. General consensus is that it has a pretty great type system. Union types, language level implementation of high performance missing types. Garbage collected. JIT compiled using LLVM backend; entire language is written in itself, so the compiler doesn’t have any “black boxes”, I.e. it can optimise everything. Great multiple dispatch system. Imperative technically I guess? But feels like it’s lifted a bunch of good ideas from various functional and domain specific languages.

Anything I missed?

3 comments

It's strongly typed. At the code level, it's dynamic, but you can strictly type your functions. For the types of workloads julia is best at (computational, batch) if you get a type error panic mid-computation, you've done something wrong, and it should be rare.

JIT is better described as "extremely lazy ahead of time compilation" (not my words). Except for globally-scoped commands, e.g. REPL (I think?) code is always going to be compiled before it is run.

Some examples of fantastic things I've done with julia:

1) wrote a drop-in replacement to IEEE floating point and evaluated numerical performance in operations like FFT, linear algebra, machine learning... I only had to write the basic operations + - * /, and a few algebraic functions like one(T). Everything else (matrix mult, linear solving, complex numbers) came for free.

2) wrote a Galois field type and ran experiments on Reed-Solomon erasure coding. Didn't have to rewrite the linear solver \ function. The builtin one worked just fine - well, in version 0.5 I had to patch it, but it worked great in 0.6 and beyond.

3) wrote a DSL that would "write verilog for me". I could pass an integer type and validate easily that the wires had the result I expected, then use the multiple dispatch on a "semantic type" which was a wrapper on String, which literally generated verilog instead of doing operations on numbers. Then I used verilator (an open source verilog -> C transpiler) to dynamically generate the verilog into a .so file, upload it back to julia, and then run full set of unit tests against both. This suite took me a week to write.

User defined types are __no__ different than "native" types.

You are talking to the llvm compiler, sure you are talking in Julia most of the time, but if you happen to want to talk in C or FORTRAN or ASM in the middle of your high level script, just do. No marshalling of I/O or data structure impedance it all compiles the same.

Exactly. Typing choices are a key part of what makes Julia interesting. And user types are first-class.
So can I define custom operations in llvm ir?
You can write custom code in llvm IR.[0] I must leave it to you to tell me if you can use it as an operator. My guess is yes, but I will not be getting to play any time soon.

[0]https://docs.julialang.org/en/stable/base/c/#Core.Intrinsics...

Actually, aside from the llvm back end, the parser is in lisp. Not really a black box though.

Though I guess you are talking about libraries?