Questions tagged [julia]

The Julia programming language is fast, expressive and dynamic. By aggressively targeting technical computing it has become a robust general purpose language. It addresses the two-language problem by combining the ease of use of high-level languages such as R and Python with the performance of C and Fortran.

Filter by
Sorted by
Tagged with
202 votes
2 answers
33k views

What is a "symbol" in Julia?

Specifically: I am trying to use Julia's DataFrames package, specifically the readtable() function with the names option, but that requires a vector of symbols. what is a symbol? why would they ...
Mageek's user avatar
  • 4,741
164 votes
8 answers
19k views

Linking R and Julia?

Julia looks very promising for fast and syntax-sane computation (e.g. here), but I suspect it will not be anywhere near R in terms of overall statistics workflow for some time yet. So I'd like to use ...
Ari B. Friedman's user avatar
105 votes
3 answers
13k views

Is Julia dynamically typed?

A lot of blogs, and the manual itself, say that Julia is dynamically typed. But from my reading of the manual, it sounds to me more like it is statically typed with type inference, like F#. Is Julia ...
Frames Catherine White's user avatar
101 votes
2 answers
12k views

How to make user defined function descriptions ("docstrings") available to julia REPL?

How can user defined functions (say f) have meaningful printouts when inspected via the REPL using ?for help(f) For example imagine I write the following funciton function f(x::Float64, y::Float64) ...
spencerlyon2's user avatar
  • 9,496
95 votes
7 answers
125k views

Running Julia .jl files

I'm new to julia and just finished my first program. I wrote the code in julia-studio and have been testing it within that program. It gives me all of the correct output, but the shell separates the ...
user1748681's user avatar
  • 1,127
90 votes
1 answer
2k views

How can I dispatch on traits relating two types, where the second type that co-satisfies the trait is uniquely determined by the first?

Say I have a Julia trait that relates to two types: one type is a sort of "base" type that may satisfy a sort of partial trait, and the other is an associated type that is uniquely ...
Philip's user avatar
  • 7,253
85 votes
3 answers
30k views

What is the difference between `using` and `import` in Julia when building a module?

Question: What is the difference between using and import in Julia when I'm building my own module? My guess based on reading the docs: using is used to bring another module into the name-space of ...
Colin T Bowers's user avatar
82 votes
2 answers
9k views

Speeding up Julia's poorly written R examples

The Julia examples to compare performance against R seem particularly convoluted. https://github.com/JuliaLang/julia/blob/master/test/perf/perf.R What is the fastest performance you can eke out of ...
Ari B. Friedman's user avatar
73 votes
2 answers
14k views

In Julia, why is @printf a macro instead of a function?

In Julia, the syntax to print a formatted string is as follows: @printf("Hello %d\n", 5) Why is @printf a macro instead of a function? Is it so that it can accept a varying number of arguments?
Ben Hamner's user avatar
  • 4,585
73 votes
5 answers
18k views

Get a list of current variables in Julia Lang

I am new to Julia Lang. I am coming from the background of Matlab. In Matlab, when pressing whos command I will get all variables in the current scope; and also, I can store them in another variable ...
vinu k n's user avatar
  • 861
69 votes
2 answers
16k views

Julia compiles the script every time?

Julia language compiles the script every time, can't we compile binaries with julia instead? I tried a small helloworld script with println function it took 2 to 3 seconds for julia to show the output!...
pahnin's user avatar
  • 5,377
69 votes
6 answers
21k views

How do I reload a module in an active Julia session after an edit?

2018 Update: Be sure to check all the responses, as the answer to this question has changed multiple times over the years. At the time of this update, the Revise.jl answer is probably the best ...
Colin T Bowers's user avatar
68 votes
7 answers
67k views

How to upgrade Julia to a new release?

I'm using v"0.3.8" on Windows. I found from http://julialang.org/downloads/ Current Release (v0.3.9) I know I could download the prebuild version and install again. Is there a way to ...
Nick's user avatar
  • 8,451
66 votes
8 answers
40k views

Julia: OOP or not

I'm working on Juno with Julia. I don't know if Julia supports OOP or not. For example, is there something like class or struct of c++? How to declare it with members such as a data or a function?
Yves's user avatar
  • 11.7k
62 votes
7 answers
37k views

How to import custom module in julia

I have a module I wrote here: # Hello.jl module Hello function foo return 1 end end and # Main.jl using Hello foo() When I run the Main module: $ julia ./Main.jl I get this error:...
dopatraman's user avatar
  • 13.4k
61 votes
5 answers
26k views

Access command line arguments in Julia

When I type in $ julia myprog.jl foo bar baz Where in my code can I go to access the strings "foo", "bar", "baz" ? I'm looking for the Python equivalent of sys.argv
MRocklin's user avatar
  • 55.8k
61 votes
1 answer
10k views

Parallelism in Julia: Native Threading Support

In their arXiv paper, the original authors of Julia mention the following: 2.14 Parallelism. Parallel execution is provided by a message-based multi-processing system implemented in Julia in ...
Amelio Vazquez-Reina's user avatar
60 votes
1 answer
8k views

In what sense are languages like Elixir and Julia homoiconic?

Homoiconicity in Lisp is easy to see: (+ 1 2) is both the function call to + with 1, 2 as arguments, as well as being a list containing +, 1, and 2. It is simultaneously both code and data. In a ...
user2666425's user avatar
  • 1,671
57 votes
1 answer
29k views

None value in Julia

What is the Julia equivalent of the None value in Python? (As shown here in built-in constants.)
haxtar's user avatar
  • 1,962
56 votes
4 answers
29k views

What is the recommended way to iterate a matrix over rows?

Given a matrix m = [10i+j for i=1:3, j=1:4], I can iterate over its rows by slicing the matrix: for i=1:size(m,1) print(m[i,:]) end Is this the only possibility? Is it the recommended way? And ...
Nico's user avatar
  • 1,070
53 votes
2 answers
20k views

Is the Julia language really as fast as it claims?

Following this post I decided to benchmark Julia against GNU Octave and the results were inconsistent with the speed-ups illustrated in julialang.org. I compiled both Julia and GNU Octave with ...
juliohm's user avatar
  • 3,701
53 votes
1 answer
59k views

Generating a random integer in range in Julia

I am migrating from MATLAB to Julia and I am trying to generate a random integer in range 1:n. For n < 21, rand(r[1:n]) works. However for n > 20, for example, rand(r[1:21]), I get this message: ...
user3411759's user avatar
50 votes
4 answers
104k views

Julia: append to an empty vector

I would like to create an empty vector and append to it an array in Julia. How do I do that? x = Vector{Float64} append!(x, rand(10)) results in `append!` has no method matching append!(::Type{...
Anarcho-Chossid's user avatar
49 votes
4 answers
38k views

How to install Julia in an anaconda environment?

One of the main features of Anaconda is that it is language agnostic as stated in their blog: You can create environments of any binary dependency tree (different versions of Python, R, Julia, ...
r_31415's user avatar
  • 8,772
48 votes
4 answers
24k views

julia create an empty dataframe and append rows to it

I am trying out the Julia DataFrames module. I am interested in it so I can use it to plot simple simulations in Gadfly. I want to be able to iteratively add rows to the dataframe and I want to ...
cantdutchthis's user avatar
47 votes
5 answers
72k views

Concatenating arrays in Julia

If the two Int arrays are, a = [1;2;3] and b = [4;5;6], how do we concatenate the two arrays in both the dimensions? The expected outputs are, julia> out1 6-element Array{Int64,1}: 1 2 3 4 5 ...
Abhijith's user avatar
  • 1,168
46 votes
1 answer
18k views

What does an exclamation mark mean after the name of a function?

I saw a function like this function operator!(c::Matrix, out::Matrix) ...... end What does ! mean here?
Fazeleh's user avatar
  • 1,018
45 votes
2 answers
3k views

What's the point of firstindex in Julia?

From documentation it says firstindex() finds the first index of a collection. Why not just use 1? What could be the case when it's not 1?
Alex Craft's user avatar
  • 13.7k
44 votes
6 answers
20k views

Determine version of a specific package

How can I get the version number for a specific package? The obvious way is to get the dictionary with all installed packages, and then filter for the one of interest: pkgs = Pkg.installed(); pkgs["...
Julian's user avatar
  • 1,271
43 votes
3 answers
30k views

how to find version number of Julia? Is there a ver() command?

I installed Julia studio 0.4.4, and found it does not support multi-line comments #=...=# so I wanted to find what version of Julia it is running. In Matlab one types the command ver which not only ...
Steve H's user avatar
  • 879
43 votes
7 answers
80k views

Convert float to int in Julia Lang

Is there a way to convert a floating number to int in Julia? I'm trying to convert a floating point number to a fixed precision number with the decimal part represented as 8bit integer. In order to do ...
JJTO's user avatar
  • 847
43 votes
2 answers
14k views

Julia (Julia-lang) Performance Compared to Fortran and Python

I adapted a simple program to compute and plot the movement vortices of to Julia to test the language, I also wrote it in Python for no particular reason. (Disclaimer: 1. Every performance comparison ...
SColvin's user avatar
  • 11.7k
42 votes
4 answers
41k views

How to make a GUI in Julia?

I'm new at programming in Julia and I need to create a GUI. I've been looking for information and I can't find anything useful. I tried to search information in the Julia official web page, but it ...
Daniel Hernandez's user avatar
40 votes
2 answers
3k views

How to write "good" Julia code when dealing with multiple types and arrays (multiple dispatch)

OP UPDATE: Note that in the latest version of Julia (v0.5), the idiomatic approach to answering this question is to just define mysquare(x::Number) = x^2. The vectorised case is covered using ...
Colin T Bowers's user avatar
39 votes
1 answer
9k views

What is the difference between @code_native, @code_typed and @code_llvm in Julia?

While going through julia, I wanted to have a functionality similar to python's dis module. Going through over the net, I found out that the Julia community have worked over this issue and given ...
Rahul's user avatar
  • 2,580
39 votes
3 answers
25k views

Julia DataFrame: remove column by name

The DataFrame type in Julia allows you to access it as an array, so it is possible to remove columns via indexing: df = df[:,[1:2,4:end]] # remove column 3 The problem with this approach is that I ...
Mageek's user avatar
  • 4,741
39 votes
6 answers
40k views

How does one clear or remove a global in julia?

Is there any syntax that does something similar to MATLAB's "clear" i.e. if I have a global variable "a". How do I get rid of it? How do I do the analog of clear a
Mateo's user avatar
  • 1,494
39 votes
3 answers
11k views

Does a Python-like virtualenv exist in Julia?

Is there a Python-like virtualenv environment simulator for Julia where one can do development in a local, virtual environment?
Dawny33's user avatar
  • 10.6k
39 votes
1 answer
6k views

What on earth is an inner constructor?

TL;DR: what's the accurate definition of inner constructors? In Julia-v0.6+, is it right to say "any constructor that can be called with the signature typename{...}(...)(note the {} part) is an inner ...
Gnimuc's user avatar
  • 8,138
38 votes
2 answers
5k views

Why is operating on Float64 faster than Float16?

I wonder why operating on Float64 values is faster than operating on Float16: julia> rnd64 = rand(Float64, 1000); julia> rnd16 = rand(Float16, 1000); julia> @benchmark rnd64.^2 ...
Shayan's user avatar
  • 5,213
38 votes
4 answers
5k views

Julia: How to copy data to another processor in Julia

How do you move data from one processor to another in julia? Say I have an array a = [1:10] Or some other data structure. What is the proper way to put it on all other available processors so that ...
bdeonovic's user avatar
  • 4,130
38 votes
3 answers
44k views

Julia: Convert numeric string to float or int

I am trying to write numeric data pulled from a database into a Float64[]. The original data is in ::ASCIIString format, so trying to push it to the array gives the following error: julia> push!(a,...
peter-b's user avatar
  • 4,083
38 votes
3 answers
20k views

set the random seed in julia generator of random numbers

I would like to do a couple of checkings using the random generator for normal distributed numbers in julia. So what I would like is to obtain the same sequence of pseudo-random numbers. Actually, I ...
user2820579's user avatar
  • 3,291
37 votes
2 answers
10k views

What is the difference between "==" and "===" comparison operators in Julia?

What is the difference between == and === comparison operators in Julia?
Wajih's user avatar
  • 639
37 votes
2 answers
3k views

I have a high-performant function written in Julia, how can I use it from Python?

I have a found a Julia function that nicely does the job I need. How can I quickly integrate it to be able to call it from Python? Suppose the function is f(x,y) = 2x.+y What is the best and most ...
Przemyslaw Szufel's user avatar
36 votes
2 answers
26k views

How to get fields of a Julia object

Given a Julia object of composite type, how can one determine its fields? I know one solution if you're working in the REPL: First you figure out the type of the object via a call to typeof, then ...
Yly's user avatar
  • 2,190
36 votes
3 answers
5k views

Floating point math in different programming languages

I know that floating point math can be ugly at best but I am wondering if somebody can explain the following quirk. In most of the programing languages I tested the addition of 0.4 to 0.2 gave a ...
vchuravy's user avatar
  • 1,218
36 votes
1 answer
14k views

How to read a file line by line in Julia?

How do I open a text file and read it line by line? There are two different cases I'm interested in answers for: Get all the lines in an array at once. Process each line one at a time. For the ...
StefanKarpinski's user avatar
36 votes
2 answers
10k views

How do I select a random item from a weighted array in Julia?

Consider two 1-dim arrays, one with items to select from and one containing the probabilities of drawing the item of the other list. items = ["a", 2, 5, "h", "hello", 3] weights = [0.1, 0.1, 0.2, 0.2,...
Remi.b's user avatar
  • 17.4k
36 votes
1 answer
28k views

Converting integer to string in Julia

I want to convert an integer to a string in Julia. When I try: a = 9500 b = convert(String,a) I get the error: ERROR: LoadError: MethodError: Cannot `convert` an object of type Int64 to an object ...
Mike's user avatar
  • 629

1
2 3 4 5
247