Top 1,000 Features Creators Resources Extensions Blog Explorer CSV Download
GitHub icon

Julia

< >

Julia is an open source programming language created in 2012 by Jeff Bezanson and Alan Edelman and Stefan Karpinski and Viral B. Shah.

#33on PLDB 12Years Old 54kRepos
Download source code:
git clone https://github.com/JuliaLang/julia

Try now: Riju ยท TIO

Julia is a high-level dynamic programming language designed to address the needs of high-performance numerical analysis and computational science, without the typical need of separate compilation to be fast, while also being effective for general-purpose programming, web use or as a specification language. Distinctive aspects of Julia's design include a type system with parametric polymorphism and types in a fully dynamic programming language and multiple dispatch as its core programming paradigm. It allows concurrent, parallel and distributed computing, and direct calling of C and Fortran libraries without glue code. Read more on Wikipedia...


Example from Riju:
println("Hello, world!")
Example from hello-world:
println("Hello World")
# Hello world in Julia println("Hello, World!")
Example from Linguist:
#!/usr/bin/env julia # From https://github.com/JoshCheek/language-sampler-for-fullpath/blob/b766dcdbd249ec63516f491390a75315e78cba95/julia/fullpath help_screen = """ usage: fullpath *[relative-paths] [-c] Prints the fullpath of the paths If no paths are given as args, it will read them from stdin If there is only one path, the trailing newline is omitted The -c flag will copy the results into your pasteboard """ help = false copy = false dir = pwd() paths = [] for arg = ARGS if arg == "-h" || arg == "--help" help = true elseif arg == "-c" || arg == "--copy" copy = true elseif arg != "" push!(paths, arg) end end if help print(help_screen) exit() end function notempty(string) return !isempty(string) end if length(paths) == 0 paths = filter(notempty, map(chomp, readlines())) end function print_paths(stream, paths) if length(paths) == 1 path = paths[1] print(stream, "$dir/$path") else for path = paths println(stream, "$dir/$path") end end end if copy read, write, process = readandwrite(`pbcopy`) print_paths(write, paths) close(write) end print_paths(STDOUT, paths)
Example from Wikipedia:
julia> p(x) = 2x^2 + 1; f(x, y) = 1 + 2p(x)y julia> println("Hello world!", " I'm on cloud ", f(0, 4), " as Julia supports recognizable syntax!") Hello world! I'm on cloud 9 as Julia supports recognizable syntax!
Julia Keywords
begin while if for try return break continue function macro quote let local global const do struct abstract typealias bitstype type immutable module baremodule using import export importall end else catch finally true false

Language features

Feature Supported Token Example
Binary Literals โœ“
# 0b[01]+((_[01]+)+)?
Floats โœ“
# (\d+((_\d+)+)?\.(?!\.)(\d+((_\d+)+)?)?|\.\d+((_\d+)+)?)([eEf][+-]?[0-9]+)?
Hexadecimals โœ“
# 0x[a-fA-F0-9]+((_[a-fA-F0-9]+)+)?
Octals โœ“
# 0o[0-7]+((_[0-7]+)+)?
Conditionals โœ“
Functions โœ“
Constants โœ“
While Loops โœ“
Line Comments โœ“ #
# A comment
Module Pattern โœ“
module MyModule
using Lib

using BigLib: thing1, thing2

import Base.show

export MyType, foo

struct MyType
    x
end

bar(x) = 2x
foo(a::MyType) = bar(a.x) + 1

show(io::IO, a::MyType) = print(io, "MyType $(a.x)")
end
Pipes โœ“
[1,2,3] |> (y -> f(3, y))
Mixins โœ“
# Including the same code in different modules provides mixin-like behavior.
module Normal
include("mycode.jl")
end

module Testing
include("safe_operators.jl")
include("mycode.jl")
end
File Imports โœ“
# Files and file names are mostly unrelated to modules; modules are associated only with module expressions.
# One can have multiple files per module, and multiple modules per file:
using MyModule
using MyModule: x, p
import MyModule
import MyModule.x, MyModule.p
import MyModule: x, p
module Foo
include("file1.jl")
include("file2.jl")
end
Print() Debugging โœ“ println
print("hello world")
Integers โœ“
80766866
Booleans โœ“ true false
Garbage Collection โœ“
MultiLine Comments โœ“ #= =#
#=
A comment.
=#
Comments โœ“
# A comment
Unicode Identifers โœ“
ฮด = 0.00001
Multiple Dispatch โœ“
collide_with(x::Asteroid, y::Asteroid) = ... # deal with asteroid hitting asteroid
collide_with(x::Asteroid, y::Spaceship) = ... # deal with asteroid hitting spaceship
collide_with(x::Spaceship, y::Asteroid) = ... # deal with spaceship hitting asteroid
collide_with(x::Spaceship, y::Spaceship) = ... # deal with spaceship hitting spaceship
Strings โœ“ "
"hello world"
Macros โœ“
# https://jkrumbiegel.com/pages/2021-06-07-macros-for-beginners/
macro show_value(variable)
    quote
        println("The ", $(string(variable)), " you passed is ", $(esc(variable)))
    end
end

@show_value(orange)
@show_value(apple)
Case Insensitive Identifiers X
Semantic Indentation X

View source

- Build the next great programming language ยท About ยท Acknowledgements ยท Part of the World Wide Scroll