O'Reilly logo

Learning Julia by Rahul Lakhanpal, Anshul Joshi

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Expressions and macros

Metaprogramming is fun, and Julia definitely has one of the best metaprogramming features compared with some of its rivals. The initial cues and inspiration have been taken from Lisp, and similarly to Lisp, Julia is written in Julia itself—or in other words, Julia is homoiconic.

To explain how Julia interprets a code, here is a small code snippet:

julia> code = "println(\"hello world \")"
"println(\"hello world \")"

julia> expression = parse(code)
:(println("hello world "))

julia> typeof(expression)
Expr

Here, we have simply passed a normal Julia code println("hello world") as a string to the function parse. This function, in turn, takes this piece of string and converts it into a data type called Expr, which is evident ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required