Things I Find ‘Just Neat’ About The Julia Programming Language

2025/02/24

Marge Simpson holding an object and saying “I just think they’re neat”
Marge Simpson holding an object and saying “I just think they’re neat”

I have been learning the Julia programming language recently and I wanted to take a bit of time to just show some things that I found neat about the language. I may update this over time as I learn more!

I really recommend the book Practical Julia by Lee Phillips, at least one of these examples came from there.

Neat Stuff

# export MY_ENV_VARIABLE=1234

my_var = ENV["MY_ENV_VARIABLE"]
print(my_var)

## 1234
a = [1,2,3,4]
print(a[end])

# 4
w = 2
print(2w)

# 4
print(1//2 + 1//3)

# 5//6

print(1//2 + 1//2)

# 1//1

print(1//2 + 0.5)

# 1.0
m = [11 12 13 14; 15 16 17 18; 19 20 21 22;]

m[2, [2, 3]]

# 16 17 -- Vector

m[[1, 2], [3, 4]]

# 13 14
# 17 18 -- Matrix
m = [2, 4, 6]

function double(x)
  return 2x
end

double.(m)

# 4, 8, 12