Skip to main content
10 of 11
Viral and Stefan were not MIT students. Also updated syntax highlighting and capitalized "STDOUT."
Alex A.
  • 24.7k
  • 5
  • 38
  • 119

2012 - Julia

###Language History

Julia was developed in 2012 by Jeff Bezanson, Stefan Karpinski, and Viral Shah while Jeff was a student at the Massachussets Institute of Technology (MIT), advised by professor Alan Edelman. They were motivated by a desire for a programming language that was open source, fast, and dynamic (among many other things) while maintaining ease of use in a variety of applications. The product was Julia, a fresh approach to high performance scientific computing.

###"Hello, World!" Variant

println("Julia was made in 2012!")

Printing to STDOUT in Julia is quite simple!

###ASCII Art N

function asciin(n)
    # Create an nxn matrix of spaces
    m = fill(" ", (n, n))

    # Fill the first and last columns with "N"
    m[:,1] = m[:,n] = "N"

    # Fill the diagonal elements with "N"
    setindex!(m, "N", diagind(m))

    # Print each row of the matrix as a joined string
    for i = 1:n
        println(join(m[i,:]))
    end
end

The code is indented for readability, but Julia imposes no restrictions on whitespace.

###GCD

function g(a, b)
    b == 0 ? a : g(b, a % b)
end

The last thing listed in the function is implicitly returned.

Alex A.
  • 24.7k
  • 5
  • 38
  • 119