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.

Julia is a high-level, high-performance dynamic programming language for technical computing. It addresses the two-language problem by combining the ease of use of languages such as R and Python with the performance of C and Fortran. Julia provides a sophisticated compiler, distributed parallel execution, numerical accuracy, and an extensive mathematical function library. Environments such as Julia for VS Code, Jupyter, and Pluto provide a rich development environment with interactive graphics.

Community-contributed libraries continue to be added at a rapid pace. Programs written in Julia are organized around multiple dispatch - by defining and overloading functions with different combinations of argument types. Part of what makes Julia so expressive is that argument types can be user-defined, and user-defined types live in the same type hierarchy and have the same status as built-in types.

The Julia compiler includes a parser written in Scheme (femtolisp), some compiler passes and the runtime in C, code generation through LLVM using C++, and other compiler passes (type inference, inlining, etc.) as well as much of the Base library in Julia itself. For just-in-time generation of 64-bit or 32-bit optimized machine code the LLVM compiler framework is used.

Julia has foreign function interfaces for C, C++, Python, R, and Java, to name a few. Julia can also be embedded in any other software through its C API. Many of these interfaces are high performance and avoid copying data to the extent possible.

Resources for Julia:

Books

Publications

12250 questions
35
votes
1 answer

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 second case I don't want to have to keep all the lines…
StefanKarpinski
  • 32,404
  • 10
  • 86
  • 111
35
votes
1 answer

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 of type String This may have arisen from a call to…
Mike
  • 619
  • 1
  • 5
  • 13
35
votes
2 answers

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 enter help mode (?), and then look up the type. Is…
Yly
  • 2,150
  • 4
  • 20
  • 33
35
votes
2 answers

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

What is the difference between == and === comparison operators in Julia?
Wajih
  • 619
  • 8
  • 10
35
votes
4 answers

How do you format a string when interpolated in Julia?

In Python 3, I would print_me = "Look at this significant figure formatted number: {:.2f}!".format(floating_point_number) print(print_me) or print_me = f"Look at this significant figure formatted number:…
Joshua Cook
  • 12,495
  • 2
  • 35
  • 31
35
votes
5 answers

How to select elements from array in Julia matching predicate?

Julia appears to have a lot of Matlab like features. I'd like to select from an array using a predicate. In Matlab I can do this like: >> a = 2:7 ; >> a > 4 ans = 0 0 0 1 1 1 >> a(a>4) ans = 5 6 7 I…
Peeter Joot
  • 7,848
  • 7
  • 48
  • 82
35
votes
3 answers

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 slight error, where as 0.4 + 0.1 + 0.1 gave non. What…
vchuravy
  • 1,208
  • 10
  • 22
33
votes
5 answers

Julia: Flattening array of array/tuples

In Julia vec reshapes multidimensional arrays into one-dimension arrays. However it doesn't work for arrays of arrays or arrays of tuples. A part from using array comprehension, is there another way to flatten arrays of arrays/tuples? Or arrays of…
Pigna
  • 2,792
  • 5
  • 29
  • 51
33
votes
1 answer

Checking file existence in Julia

Is there a simple way in Julia to check whether a file in the current working directory exists (something like test = os.path.isfile("foo.txt") in Python or inquire(file = "foo.txt", exist = test) in Fortran)?
Benjamin
  • 690
  • 1
  • 7
  • 14
33
votes
5 answers

Julia request user input from script

How do I request user input from a running script in Julia? In MATLAB, I would do: result = input(prompt) Thanks
ejang
  • 3,982
  • 8
  • 44
  • 70
32
votes
1 answer

What is the difference between fields and properties in Julia?

Julia has the setter functions setproperty! and setfield! and the getter functions getproperty and getfield that operate on structs. What is the difference between properties and fields in Julia? For example, the following seems to indicate that…
Kristoffer Carlsson
  • 2,768
  • 9
  • 16
32
votes
1 answer

How and When to Use @async and @sync in Julia

I have read the documentation for the @async and @sync macros but still cannot figure out how and when to use them, nor can I find many resources or examples for them elsewhere on the internet. My immediate goal is to find a way to set several…
32
votes
1 answer

What's the difference between Array{Bool} and BitArray in Julia and how are they related?

I was writing a function for boolean 2d arrays: function foo(A::Array{Bool,2}) ... end Evaluating and testing it with A = randbool(3,3) foo(A) returns ERROR: 'foo' has no method matching foo(::BitArray{2}) Obviously, randbool() generates a…
reschu
  • 1,095
  • 12
  • 22
32
votes
2 answers

Search for files in a folder

I'm trying parse a lot of text files using Julia, and I want to loop across an array of file names instead of typing out a function call to read each of them individually. So far I have been unable to find a way to search a folder for files matching…
MDe
  • 2,478
  • 3
  • 22
  • 27
31
votes
2 answers

Julia: How to pretty print an array?

a= zeros(4,4) Print a like this > 4×4 Array{Float64,2}: > 0.0 0.0 0.0 0.0 > 0.0 0.0 0.0 0.0 > 0.0 0.0 0.0 0.0 > 0.0 0.0 0.0 0.0 but println(a) prints like this [0.0 0.0 0.0 0.0; 0.0 0.0 0.0 0.0; 0.0 0.0 0.0 0.0; 0.0 0.0 0.0…
xiaodai
  • 14,889
  • 18
  • 76
  • 140