Hacker News new | ask | show | jobs
by forkandwait 2672 days ago
I did a 5000 line dissertation project in Octave after rejecting Julia. Reason : I had derived the math in linear algebra including Kronecker products; the math mapped to Octave pretty directly, but Julia requred me to translate all the Kronecker products to loops —yuck! kron(A, B) would become 12 lines of weird indices and for loops. On the listserv I was told that Julia was great because it didn't require vectorization for performance, but I only wanted vectorization for graceful expression.

Plus I got annoyed with extra weird syntax, but I can't remember the specifics.

Basically, Julia required more lines and characters and wasn't as close to the math.

Aside:I think Matlab / Octave is a lot like SQL and Tcl: lots of haters, unfashionable, but usually the most elegant solution .

5 comments

Surprises me. Julia can usually stay much closer to mathematical notation than, say, Python or C++.

You can even use nice Unicode notation such as A ⊗ B ⊗ C.

So, `kron` is actually provided by the standard library [1], are you saying that this kronecker product didn't do the job?

[1] search in this file: https://github.com/JuliaLang/julia/blob/master/stdlib/Linear...

It was 5 years ago, maybe it's better now.

I wasn't comparing Julia to python or c+, but to Matlab octave.

Thanks for that clarification. 5 years is a lot of evolution for a language that was roughly 2 years old when you used it! Might warrant a revaluation, or at least always state the timeline along with your opinions :-)
As notation for array based algorithms, Octave/Matlab is vastly better than anything else I've found. Some guy did PRML in Matlab, others have done it in Python. The Matlab version is like reading a book; clear, concise, correct.

https://github.com/locklin/PRMLT

IMO for most people, for array based algos, Matlab hits the "notation as thought" Iverson saying in a way that APL didn't quite make it.

For such things, Julia is often very close to Matlab indeed, or at least it can be used that way.

You could translate most of those files line-for-line, with quite a few lines identical or trivially changed (bracket shape, or max -> maximum). This is often a useful thing to do, get a transliterated version running, and then re-write bits of it more idiomatically, while checking that the output is identical.

I'd be happy to look at the output of such an exercise. If I were transcribing it, it would either be to J or C. Julia doesn't solve any problems for me.
Julia has had a kron function in Base since at least 0.5.
I haven't dipped into Julia's macro side, but I wonder how much work it would be to just create macros to create syntactic sugar that maps infix Kronecker products to the Kronecker function.

There are so many Julia packages that do similar stuff that I imagine it can't be all that hard for people who have become fluent with the macro system.

Why metaprogram? Just define an operator using the built in kron function. Example:

const ⊗ = kron

A = rand(5,5)

B = rand(3,3)

A ⊗ B

Tada! I'm not sure how MATLAB/Octave's kron(A,B) looks more like math than A⊗B, but everyone can have their own opinion.

Oh. For the benefit of others reading this comment thread, this is why that works: https://docs.julialang.org/en/v1/manual/variables/#Allowed-V...

This is the second time I've learned about time-saving functionality related to infix that I didn't know about. (The previous was the symbol for integer division, which had been left out of the documentation until version 0.7). In this second case, interpretation of Unicode symbols as infix operators should be better surfaced in Julia documentation and tutorials - it's a really useful feature.

`kron` is in the standard library, at least in the first stable version of the language https://docs.julialang.org/en/v1/stdlib/LinearAlgebra/index....