avatarEmma Boudreau

Summary

The website content discusses five standout features of the Julia programming language, including macros, dispatch, syntactical expressions, metaprogramming, and parallel computing capabilities.

Abstract

The article "Julia’s Most Awesome Features" delves into the Julia programming language's unique and powerful features that set it apart from other languages. It highlights macros, which are well-implemented shortcuts for accessing functions, particularly useful in functional programming. The dispatch system allows for high-performance, type-specific method implementations, enabling universal function usage across different types. Syntactical expressions underpin Julia's code writing methodology, allowing for flexible and dynamic code execution. Metaprogramming in Julia is handled with efficiency, using the Meta.parse() and eval() functions to turn strings into executable code. Lastly, the article praises Julia's robust parallel computing support, noting its extensive GPU support and integration of parallel computing types and functions.

Opinions

  • The author expresses that Julia's macros are not only well-done but also particularly useful for functional programming.
  • Julia's dispatch system is lauded for its ability to handle different types with the same methods, which is seen as an amazing side-effect of the language's design.
  • The author suggests that syntactical expressions are underappreciated, yet they form the backbone of Julia's methodology and offer powerful ways to assert code behavior.
  • Metaprogramming in Julia is considered interesting and efficient, with the language's base being optimized for performance while still including powerful features.
  • The article conveys that Julia's parallel computing is not just a feature but a testament to the impressive work done by Julia Computing, offering unparalleled GPU support and integration.
  • The author's enthusiasm for Julia's features is clear, suggesting that these capabilities make the language versatile and creative for problem-solving.
  • A call to action is presented, inviting readers to share their own favorite Julia features and to consider trying out a recommended AI service for its cost-effectiveness compared to ChatGPT Plus (GPT-4).

Julia’s Most Awesome Features

Five of my favorite features in the Julia programming language.

(julia logo src = http://julialang.org , juliaGPU logo src = https://github.com/JuliaGPU)

Within the bounds of programming languages are programming concepts and paradigms. Many languages take advantage of both their paradigm, as well as interesting generic programming concepts to create features to differentiate themselves from other languages. However, these features are often limited in scope, and sometimes aren’t used frequently enough to even justify being around.

The Julia programming language is an interesting case because unlike most languages, Julia has some killer defining features that make it capable of various different things that you might not expect to go together. Though there is certainly an enormous list of fantastic features that the Julia language utilizes, these are five of those features that I find the most useful and engaging.

№1: Macros

Although macros are certainly not a new concept to programming, their implementation in Julia is rather unique and in my subjective opinion rather well done. Macros are “ shortcuts” that can be used to quickly and effectively access functions, and are incredibly useful when working with functional applications of the Julia language. In Julia, you can define a macro by simply using “ macro.”

macro add(num1,num2)
   num1 + num2 
end

And we can use the macro by adding the @ symbol before the name of the macro. The parameters can be added with white-space, no parenthesis or commas necessary!

№2: Dispatch

If you are familiar with the Julia language and have used it even relatively, chances are you are familiar with Julia’s high-performance dispatch. Using a syntactical expression in Julia, we can create different functions that handle different types with the same methods using parametric polymorphism. To do this, we just use the equal operator.

exampledispatch(x::Int64) = _int(x)
exampledispatch(x::Float64) = _float(x)

An amazing side-effect you might not have noticed about Julia’s dispatch is that all Julia functions can be universally used on any type. Consider this example:

I want to make a type that uses the push function to add data to an array that is contained within a struct.

The push!() function is part of Julia’s Base, and in most other languages we would instead need to write an entirely new identifier specific to our module in order to avoid conflicts. This is especially true with using the standard library included with that language. However, in Julia we can just dispatch push!() to handle our type:

push!(data,x::Type{ihavedatainme}) = _pushdata(data,x)

№3: Syntactical Expressions

Even some Julia programmers might not realize this, but syntactical expressions are responsible for the entire methodology behind how we write Julia code. In essence, using a syntactical expression we can set any expression or variable equal to any expression or variable. This is how dispatch works, as well, as all we are doing is setting a method with specific parameter types equal to a corresponding method.

Aside from dispatch, however, there are several ways that we can use syntactical expressions. For example, we could set a method equal to an expression:

If you’d like to learn more about syntactical expressions, and learn about some cool ways to do them, I have an article all about them here:

№4: Metaprogramming

Julia handles concepts like metaprogramming in a really interesting way. The packages for metaprogramming, and similar concepts are typically segmented while still being included with Julia’s base. This makes Julia’s base take far less time to pre-compile while still being loaded with awesome features. In order to metaprogram in Julia, the two functions you should start with are Meta.parse() and eval(). Eval is contained within the Julia core, and will not need to be imported, whereas Meta is a module contained within Base.

using Base.Meta

The first step to evaluating a meta expression is to parse it. This will turn a regular string into an expression type that eval() is able to handle.

meta_code = "1 + 1"
expression = Meta.parse(meta_code)

№5: Parallel Computing

(src = https://github.com/JuliaGPU)

Okay, I get it… Parallel computing is not necessarily a “ feature,” per se, but what is impressive about Julia’s parallel computing is just how amazing of a job Julia Computing has done with it. Unlike many other languages, Julia comes with a ridiculous amount of GPU support out of the box. The core Julia language supports graphics arrays and processing that you simply cannot get anywhere else. Having parallel computing tightly integrated into Julia with types and functions specifically designed to handle it is far more powerful than in most languages where this is an afterthought. Additionally, Julia has all kinds of neat packages for parallel computing alongside industry standards like CUDA and OpenCL.

Conclusion

The Julia programming language has a whole host of incredible features that definitely make using the language worth-while. With all of the unique ways to approach problems, there is rarely a time where you can’t be creative to get something done in the language. On top of that, Julia comes with all of the advantages that it normally boasts, as well. These are some of my favorites, but I would be interested in knowing what other programmers love in the language, as well. (Leave a comment if you’d like to share!)

Programming
Julia
Computer Science
Gpu
Macro
Recommended from ReadMedium