4 ms·
I teach a graduate course in optimization methods for machine learning and engineering [1,2]. Julia is just perfect for teaching numerical algorithms. First, i
by jpfr 6y ago
I teach a graduate course in optimization methods for machine learning and engineering [1,2]. Julia is just perfect for teaching numerical algorithms.
First, it removes the typical numpy syntax boilerplate. Due to its conciseness, Julia has mostly replaced showing pseudo-code on my slides. It can be just as concise / readable; and on top the students immeditaly get the "real thing" they can plug into Jupyter notebooks for the exercises.
Second, you get C-like speed. And that counts for numerical algorithms.
Third, the type system and method dispatch of Julia is very powerful for scientific programming. It allows for composition of ideas in ways I couldn't imagine before seeing it in action. For example, in the optimization course, we develop a mimimalistic implementation of Automatic Differentiation on a single slide. And that can be applied to virtually all Julia functions and combined with code from preexisting Julia libraries.
[1] https://www.youtube.com/playlist?list=PLdkTDauaUnQpzuOCZyUUZc0lxf4-PXNR5 https://www.youtube.com/playlist?list=PLdkTDauaUnQpzuOCZyUUZ...
[2] https://drive.google.com/drive/folders/1WWVWV4vDBIOkjZc6uFY3nfXvpaOUHcfb?usp=sharing https://drive.google.com/drive/folders/1WWVWV4vDBIOkjZc6uFY3...
- awefasdfasdf 6y agoSmall aside. Do you use the beamer package for your slides?
- i_am_proteus 6y agoThis. Julia's combination of human-readable pseudocode-like code and speed makes it perfect for these applications, and seems to be driving adoption.
- mirekrusin 6y agoAlso not seen before degree of code reuse.
- legerdemain 6y agoI'm using Julia (because of the hype) to prototype out some numerical optimization stuff. There is a million functions for reshaping multidimensional arrays. The syntax is uncannily like Matlab: retrieving the last element of an array with `[end]`, indexing into a collection with an array of booleans, element-wise versions of operators prepended with dot, etc. However, I keep running into niggling corner cases that kind of make Julia's promise of a powerful, extensible, yet intuitive type system less convincing. ME: I want to write a custom getproperty() for Tuple! JULIA: No. ME: I want to broadcast over the fields of a NamedTuple! JULIA: Not allowed. ME: I want to get a view, not copy, with `@view M[m:n, r:s]`, but also get the ability to specify a default for out-of-range indices, like `get()` allows. JULIA: I'm afraid I can't let you do that.
- oivey 6y agoFor the last thing, is this what you want? https://github.com/JuliaArrays/PaddedViews.jl https://github.com/JuliaArrays/PaddedViews.jl There may be other packages or methods for doing the other things you want. I’d think that broadcasting over a NamedTuple would iterate over the key => value pairs, but I haven’t tried it.
- legerdemain 6y agoThanks for the good find!
- oivey 6y agoLooks like vectorizing over NamedTuples is explicitly disallowed. Probably you can still vectorize things over the keys and values separately, along with some helper functions, but it is a bit annoying. Looks like the reason was due to questions on whether iteration should be over values or pairs.
- StefanKarpinski 6y agoIndeed, that is precisely the decision that must be made. Neither one is obviously correct. And once a decision is made and goes into a release, it cannot be unmade — we all have to live with it forever.
- yellowcake0 6y agoI would add, Fourth, the ability to effortlessly drop down several layers of abstraction: Pointer types, all packages including Base are written in Julia and can easily be extended or patched on the fly, homoiconicity, seamless integration with BLAS and LAPACK.
- grayclhn 6y ago> Due to its conciseness, Julia has mostly replaced showing pseudo-code on my slides. This benefit is really underappreciated IMO — for a lot of "science" applications, the core part of the program should be readable by people who don't program in the language. In research papers, by people who want to understand the fine details of your algorithm, for example. Julia gets closer to "executable pseudocode" than I would have thought possible.