An introduction to the Julia language, part 1
lwn.net
lwn.net
http://news.mit.edu/2018/mit-developed-julia-programming-lan...
But above all it’s the community that takes the cake. So many hard algorithms that I would have a hard time doing from scratch are implemented in Julia.
However, it could have a lot of potential here. It is a fully homoiconic language with real macros, so it could be a very good fit for symbolic math, just as Maxima is built in Common Lisp.
It would be great if there was a real effort towards that. Mathematica is still really the only game in town.
Since Maxima runs on top of Common Lisp, could it run on a JVM-based Common Lisp, and exchange objects with Clojure?
Could the CLASP project, CL on the LLVM, lead to a Julia-Maxima bridge?
Any other integration ideas from the Common Lisp folks?
>It's surprising to me that there isn't a good way to call Maxima from either Python/R/Julia or even a non-CL lisp.
There's Sage, which integrates Scipy/Numpy, Maxima, and some other things. However, I personally find Maxima to be pretty awful to use, and even it is nowhere close to Mathematica in functionality at this point. Mathematica itself is horrible to use (although extemely capable), so I'd love an open source, good alternative.
Trying to use Mathematica like Python/Matlab is setting yourself up for failure. It took me a few months of getting frustrated with Mathematica till I suddenly "got" it [1]. But once I understood that it's programming model revolves around pattern matching and string replacement, things just clicked and it was very easy to write Mathematica code after that.
[1] Coincidentally, I was reading a little bit about functional programming when Mathematica finally started making sense. In particular, IIRC, I was looking at "Learn You a Haskell" for fun, unrelated to Mathematica, which was for work.
I'm no expert, but I've been forced to use it on a few occasions, and I've hated every minute of it. I'm fairly fluent in several of languages in different paradigms, but the frustration I experience with Mathematica is worse than any of them.
Well it helps that it's a lot easier to implement stuff from scratch in Julia than pretty much any other language.
Does anyone here happen to know why the decision was made to not allow “normal” classes in Julia? I know you can define your own types to get some of the functionality but sometimes in numerical computing with matlab or python it really makes sense for me to pack functionality into a class.
I know in matlab using classes causes a performance hit but I always thought that wasn’t because the feature was bolted on afterwards. Is there something I’m missing here?
Why? Where you would ordinarily write
class Foo {
int x;
int my_method() { ... }
}
can't you just equivalently write type Foo
x::Int
end
my_method(foo::Foo) = begin ... end
?(https://groups.google.com/forum/#!searchin/julia-users/objec...)
To answer the next-level question of "why multiple dispatch?"... Multiple dispatch is a generalization of single dispatch and leads to much more composable, extensible systems, largely by providing a simple, intuitive and efficient solution to the somewhat esoteric-sounding “Expression Problem” [2]. Even though the problem sounds obscure, it has profound practical consequences and most of the stumbling blocks to writing reusable, composable code in both object oriented and functional languages boil down to it being hard to either extend existing operations to new types or to define new operations on existing types. Julia does both so easily that it’s easy to forget that it’s a problem in other languages. Multiple dispatch is also a particularly good fit for numerical programming problems where it often makes little sense for a specialized operation to "belong" only to its first argument. For example, `x + y` doesn't belong to `x` any more than it does to `y`.
Creating a whole class just to neatly carry around a few related values always felt like a very “heavy” solution.
Is my memory faulty? If not, have these concerns been addressed?
From my perspective at least, the julia test suite is quite comprehensive (if something passes the test suite, I'm generally happy to put it on master and have people use it). We're also lucky that there is so much open source julia code available, which we can use as essentially one giant regression test. We used that heavily in the lead up to 1.0 to make sure that there weren't any surprise bugs waiting for people.
Edit: missed one, natively compiled or VM based.
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?
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.
[0]https://docs.julialang.org/en/stable/base/c/#Core.Intrinsics...
Though I guess you are talking about libraries?
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.
- It is functional (including lisp-like macro programming) but has a strict type system along with multiple dispatch, which effectively allows for OOP constructs.
- It allows for dynamic typing but since it is JIT compiled using LLVM, you can specify static types for variables and thus take advantage of lots of smart optimisation.
- There is garbage collection but also the ability to get right in there and reach into pointers and memory-allocation manually.
It's truly a pleasure to work with once you appreciate what's possible.
* A lot of packages are incompatible with the latest versions of Julia. Though because it has stabilized, this is likely to stop being an issue soon.
* There isn’t any major organization that has adopted it yet, which may impact its long term success in contrast to other new languages like go swift rust etc that have a major sponsor. Garbage collector makes it unsuitable for certain real time uses, which is unfortunate given its otherwise predictable performance characteristics.
* Although there are web frameworks for it, I’m not sure whether they are mature enough for production use.
* Personal pet peeve: no infix operator for integer division. I haven’t looked recently whether there is a package for this. I should probably make my own if not.
(To be clear, I really love the Julia language, and use it quite a bit in personal projects - I'm just hoping that it gets strong adoption, since adoption is what drives the development of miscellaneous libraries and packages).
Sure there is
julia> 10 ÷ 3
3
type as``` 10 \div<tab> 3 ```
in any decent julia-capable environment (REPL, editors, notebooks, etc)
Why not allow a/b + c/d = (a.d + c.b)/(b.d)? It's what happens when I get my pen and paper out in the real world (along with my tongue sticking out and much perspiration and perhaps a few doodles.) Why does Julia use / to cause one of those weird repeated decimal expansion things to appear but // is needed to keep things pure?
Yes I am partially taking the piss but I'm also interested into the design decision into why // is needed to avoid a type conversion. I note that 1/2 = 0.5 was also a design decision.
https://lwn.net/SubscriberLink/763626/f2990348ebd06167/
Please consider subscribing, so they can pay me and other authors for more articles.
I'm pretty sure I can find a tutorial somewhere else.