-
Generator expressions:
f(i) for i in 1:n(#4470). This returns an iterator that computes the specified values on demand. This is useful for computing, e.g.sum(f(i) for i in 1:n)without creating an intermediate array of values. -
Generators and comprehensions support filtering using
if(#550) and nested iteration using multipleforkeywords (#4867). -
Fused broadcasting syntax:
f.(args...)is equivalent tobroadcast(f, args...)(#15032), and nestedf.(g.(args...))calls are fused into a singlebroadcastloop (#17300). Similarly, the syntaxx .= ...is equivalent to abroadcast!(identity, x, ...)call and fuses with nested "dot" calls; also,x .+= yand similar is now equivalent tox .= x .+ y, rather thanx = x .+ y(#17510). -
Macro expander functions are now generic, so macros can have multiple definitions (e.g. for different numbers of arguments, or optional arguments) (#8846, #9627). However note that the argument types refer to the syntax tree representation, and not to the types of run time values.
-
Varargs functions like
foo{T}(x::T...)may now restrict the number of such arguments usingfoo{T,N}(x::Vararg{T,N})(#11242). -
x ∈ Xis now a synonym forx in Xinforloops and comprehensions, as it already was in comparisons (#13824). -
The
PROGRAM_FILEglobal is now available for determining the name of the running script (#14114). -
The syntax
x.:sym(e.g.Base.:+) is now supported, while usingx.(:sym)orx.(i)for field access are deprecated in favor ofgetfield(#15032). -
Function return type syntax
function f()::Thas been added (#1090). Values returned from a function with such a declaration will be converted to the specified typeT. -
Many more operators now support
.prefixes (e.g..≤) (#17393). However, users are discouraged from overloading these, since they are mainly parsed in order to implement backwards compatibility with planned automatic broadcasting of dot operators in Julia 0.6 (#16285). Explicitly qualified operator names likeBase.≤should now useBase.:≤(prefixed by@compatif you need 0.4 compatibility via theCompatpackage). -
User-extensible bounds check elimination is now possible with the new
@boundscheckmacro (#14474). This macro marks bounds checking code blocks, which the compiler may remove when encountered inside an@inboundscall.
-
Support for multi-threading. Loops with independent iterations can be easily parallelized with the
Threads.@threadsmacro. -
Support for arrays with indexing starting at values different from 1. The array types are expected to be defined in packages, but now Julia provides an API for writing generic algorithms for arbitrary indexing schemes (#16260).
-
Each function and closure now has its own type. The captured variables of a closure are fields of its type.
Functionis now an abstract type, and is the default supertype of functions and closures. All functions, including anonymous functions, are generic and support all features (e.g. keyword arguments). Instead of adding methods tocall, methods are added by type using the syntax(::ftype)(...) = ....callis deprecated (#13412). A significant result of this language change is that higher order functions can be specialized on their function arguments, leading to much faster functional programming, typically as fast as if function arguments were manually inlined. See below for details. -
Square brackets and commas (e.g.
[x, y]) no longer concatenate arrays, and always simply construct a vector of the provided values. Ifxandyare arrays,[x, y]will be an array of arrays (#3737, #2488, #8599). -
usingandimportare now case-sensitive even on case-insensitive filesystems (common on Mac and Windows) (#13542). -
Relational algebra symbols are now allowed as infix operators (#8036):
⨝,⟕,⟖,⟗for joins and▷for anti-join. -
A warning is always given when a method is overwritten; previously, this was done only when the new and old definitions were in separate modules (#14759).
-
The
ifkeyword cannot be followed immediately by a line break (#15763). -
Juxtaposition of numeric literals ending in
.(e.g.1.x) is no longer allowed (#15731). -
The built-in
NTupletype has been removed;NTuple{N,T}is now implemented internally asTuple{Vararg{T,N}}(#11242). -
Use of the syntax
x::Tto declare the type of a local variable is deprecated. In the future this will always mean type assertion, and declarations should uselocal x::Tinstead (#16071). Whenxis global,x::T = ...andglobal x::Tused to mean type assertion, but this syntax is now reserved for type declaration (#964). -
Dictionary comprehension syntax
[ a=>b for x in y ]is deprecated. UseDict(a=>b for x in y)instead (#16510). -
Parentheses are no longer allowed around iteration specifications, e.g.
for (i = 1:n)(#17668).
This section lists changes that do not have deprecation warnings.
-
All dimensions indexed by scalars are now dropped, whereas previously only trailing scalar dimensions would be omitted from the result (#13612). This is a very major behavioral change, but should cause obvious failures. To retain a dimension sliced with a scalar
islice withi:iinstead. -
The assignment operations
.+=,.*=and so on now generate calls tobroadcast!on the left-hand side (or call toview(a, ...)on the left-hand side if the latter is an indexing expression, e.g.a[...]). This means that they will fail if the left-hand side is immutable (or does not supportview), and will otherwise change the left-hand side in-place (#17510, #17546). -
Method ambiguities no longer generate warnings when files are loaded, nor do they dispatch to an arbitrarily-chosen method; instead, a call that cannot be resolved to a single method results in a
MethodErrorat run time, rather than the previous definition-time warning (#6190). -
Array comprehensions preserve the dimensions of the input ranges. For example,
[2x for x in A]will have the same dimensions asA(#16622). -
The result type of an array comprehension depends only on the types of elements computed, instead of using type inference (#7258). If the result is empty, then type inference is still used to determine the element type.
-
reshapeis now defined to always share data with the original array. If a reshaped copy is needed, usecopy(reshape(a))orcopy!to a new array of the desired shape (#4211). -
mapslicesnow re-uses temporary storage. Recipient functions that expect input slices to be persistent should copy data to other storage (#17266). All usages ofmapslicesshould be carefully audited since this change can cause silent, incorrect behavior, rather than failing noisily. -
Local variables and arguments are represented in lowered code as numbered
Slotobjects instead of as symbols (#15609). -
The information that used to be in the
astfield of theLambdaStaticDatatype is now divided among the fieldscode,slotnames,slottypes,slotflags,gensymtypes,rettype,nargs, andisvain theLambdaInfotype (#15609). -
A <: Bis parsed asExpr(:(<:), :A, :B)in all cases (#9503). This also applies to the>:operator. -
Simple 2-argument comparisons like
A < Bare parsed as calls instead of using the:comparisonexpression type (#15524). The:comparisonexpression type is still produced in ASTs when comparisons are chained (e.g.A < B ≤ C). -
mapon a dictionary now expects a function that expects and returns aPair. The result is now another dictionary instead of an array (#16622). -
Bit shift operations (i.e.
<<,>>, and>>>) now handle negative shift counts differently: Negative counts are interpreted as shifts in the opposite direction. For example,4 >> -1 == 4 << +1 == 8. Previously, negative counts would implicitly overflow to large positive counts, always yielding either0or-1.
-
Strings (#16107):
-
The
UTF8StringandASCIIStringtypes have been merged into a singleStringtype (#16058). Useisascii(s)to check whether a string contains only ASCII characters. Theascii(s)function now convertsstoString, raising anArgumentErrorexception ifsis not pure ASCII. -
The
UTF16StringandUTF32Stringtypes and correspondingutf16andutf32converter functions have been removed from the standard library. If you need these types, they have been moved to the LegacyStrings.jl package. In the future, more robust Unicode string support will be provided by the StringEncodings.jl package. If you only need these types to call wide string APIs (UTF-16 on Windows, UTF-32 on UNIX), consider using the newtranscodefunction (see below) or theCwstringtype as accallargument type, which also ensures correct NUL termination of string data. -
A
transcode(T, src)function is now exported for converting data between UTF-xx Unicode encodings (#17323). -
The basic string construction routines are now
string(args...),String(s),unsafe_string(ptr)(formerlybytestring(ptr)), andunsafe_wrap(String, ptr)(formerlypointer_to_string) (#16731). -
Comparisons between
Chars andIntegers are now deprecated (#16024):'x' == 120now produces a warning but still evaluates totrue. In the future it may evaluate tofalseor the comparison may be an error. To compare characters with integers you should either convert the integer to a character value or convert the character to the corresponding code point first: e.g.'x' == Char(120)orInt('x') == 120. The former is usually preferable. -
Support for Unicode 9 (#17402).
-
-
Arrays and linear algebra:
-
Dimensions indexed by multidimensional arrays add dimensions. More generally, the dimensionality of the result is the sum of the dimensionalities of the indices (#15431).
-
New
normalizeandnormalize!convenience functions for normalizing vectors (#13681). -
QR matrix factorization:
-
A new
SparseVectortype allows for one-dimensional sparse arrays. Slicing and reshaping sparse matrices now return vectors when appropriate. Thesparsevecfunction returns a one-dimensional sparse vector instead of a one-column sparse matrix. TheSparseMatrixmodule has been renamed toSparseArrays(#13440). -
Rank one update and downdate functions,
lowrankupdate,lowrankupdate!,lowrankdowndate, andlowrankdowndate!, have been introduced for dense Cholesky factorizations (#14243, #14424). -
All
sparsemethods now retain provided numerical zeros as structural nonzeros; to drop numerical zeros, usedropzeros!(#14798, #15242). -
setindex!methods for sparse matrices and vectors no longer purge allocated entries on zero assignment. To drop stored entries from sparse matrices and vectors, useBase.SparseArrays.dropstored!(#17404). -
Concatenating dense and sparse matrices now returns a sparse matrix (#15172).
-
-
Files and I/O:
-
The
openfunction now respectsumaskon UNIX when creating files (#16466, #16502). -
A new function
walkdir()returns an iterator that walks the tree of a directory (#8814, #13707).for (root, dirs, files) in walkdir(expanduser("~/.julia/v0.5/Plots/src")) println("$(length(files)) \t files in $root") end 19 files in /Users/me/.julia/v0.5/Plots/src 15 files in /Users/me/.julia/v0.5/Plots/src/backends 4 files in /Users/me/.julia/v0.5/Plots/src/deprecated -
A new function
chown()changes the ownership of files (#15007). -
Display properties can now be passed among output functions (e.g.
show) using anIOContextobject (#13825). -
Cmd(cmd; ...)now accepts new Windows-specific optionswindows_verbatim(to alter Windows command-line generation) andwindows_hide(to suppress creation of new console windows) (#13780). -
There is now a default no-op
flush(io)function for allIOtypes (#16403).
-
-
Parallel computing:
-
pmapkeyword argumentserr_retry=trueanderr_stop=falseare deprecated. Action to be taken on errors can be specified via theon_errorkeyword argument. Retry is specified viaretry_n,retry_onandretry_max_delay(#15409, #15975, #16663). -
The functions
remotecall,remotecall_fetch, andremotecall_waitnow have the function argument as the first argument to allow for do-block syntax (#13338).
-
-
Statistics:
-
Testing:
-
The
Base.Testmodule now has a@testsetfeature to bundle tests together and delay throwing an error until the end (#13062). -
The new features are mirrored in the BaseTestNext.jl package for users who would like to use the new functionality on Julia v0.4.
-
The BaseTestDeprecated.jl package provides the old-style
handlerfunctionality, for compatibility with code that needs to support both Julia v0.4 and v0.5.
-
-
Package management:
-
The package system (
Pkg) is now based on thelibgit2library, rather than running thegitprogram, increasing performance (especially on Windows) (#11196). -
Package-development functions like
Pkg.tagandPkg.publishhave been moved to an external PkgDev package (#13387). -
Updating only a subset of the packages is now supported, e.g.
Pkg.update("Example")(#17132).
-
-
Miscellanous:
-
Prime number related functions have been moved from
Baseto the Primes.jl package (#16481). -
Most of the combinatorics functions have been moved from
Baseto the Combinatorics.jl package (#13897). -
New
foreachfunction for calling a function on every element of a collection when the results are not needed (#13774). Compared tomap(f, v), which allocates and returns a result array,foreach(f, v)callsfon each element ofv, returning nothing. -
The new
Base.StackTracesmodule makes stack traces easier to use programmatically (#14469). -
The
libjulialibrary is now properly versioned and installed to the public<prefix>/libdirectory, instead of the private<prefix>/lib/juliadirectory (#16362). -
System reflection is now more consistently exposed from
Sysand notBase(e.g. constants such asWORD_SIZEandCPU_CORES).OS_NAMEhas been replaced bySys.KERNELand always reports the name of the kernel (as reported byuname). The@windows_onlyand@osxfamily of macros have been replaced with functions such asis_windows()andis_apple(). There is now also a@staticmacro that will evaluate the condition of an if-statement at compile time, for when a static branch is required (#16219). -
DateandDateTimevalues can now be rounded to a specified resolution (e.g., 1 month or 15 minutes) withfloor,ceil, andround(#17037).
-
-
Machine SIMD types can be represented in Julia as a homogeneous tuple of
VecElement(#15244). -
The performance of higher-order and anonymous functions has been greatly improved. For example,
map(x->2x, A)performs as well as2.*A(#13412). -
On windows, a DLL of standard library code is now precompiled and used by default, improving startup time (#16953).
-
LLVM has been upgraded to version 3.7.1, improving the quality of generated code and debug info. However compile times may be slightly longer (#14623).
This release greatly improves support for ARM, and introduces support for Power.
-
The following function names have been simplified and unified (#13232):
-
get_bigfloat_precision->precision(BigFloat) -
set_bigfloat_precision->setprecision -
with_bigfloat_precision->setprecision -
get_rounding->rounding -
set_rounding->setrounding -
with_rounding->setrounding
-
-
The method
A_ldiv_B!(SparseMatrixCSC, StridedVecOrMat)has been deprecated in favor of versions that require the matrix to be in factored form (#13496). -
chol(A,Val{:U/:L})has been deprecated in favor ofchol(A)(#13680). -
rem1(x,y)is discontinued due to inconsistency forx==0. Usemod1instead (#14140). -
The
FSmodule has been renamed toFilesystem. Calling the functionsisreadable,iswritable, andisexecutableon filesystem paths has been deprecated (#12819). -
RemoteRefhas been deprecated in favor ofRemoteChannel(#14458). -
superhas been renamed tosupertype(#14335). -
parseip(str)has been deprecated in favor ofparse(IPAddr, str)(#14676). -
readallhas been renamed toreadstring, andreadbyteshas been renamed toread(#14608, #14660). -
fieldoffsets(x)has been deprecated in favor of callingfieldoffset(x, i)on each field (#14777). -
issymis deprecated in favor ofissymmetricto match similar functions (ishermitian, ...) (#15192). -
scaleis deprecated in favor of eitherα*A,Diagonal(x)*A, orA*Diagonal(x)(#15258). -
"Functor" types are no longer necessary and have been deprecated (#15804). To maintain performance on older versions of Julia the Compat.jl package provides a
@functorizemacro. -
bitunpack(B)andbitpack(A)have been deprecated in favor ofArray(B)andBitArray(A), respectively (#16010). -
xdumpis removed, anddumpnow simply shows the full representation of a value.dumpshould not be overloaded, since it is for examining concrete structure (#4163). -
sprandboolhas been deprecated in favor ofsprand(Bool, ...)orsprand(rng, Bool, ...)(#11688, #16098). -
The lowercase
symbolfunction has been deprecated in favor of theSymbolconstructor (#16154). -
writemimeis deprecated, and output methods specifying a MIME type are now methods ofshow(#14052). -
BLAS utility functions
blas_set_num_threads,blas_vendor, andcheck_blashave been moved to the BLAS module asBLAS.set_num_threads,BLAS.vendor, andBLAS.check(#10548, #16600). -
print_escapedhas been renamed toescape_string,print_unescapedhas been renamed tounescape_string, andprint_joinedhas been renamed tojoin(#16603). -
pointer_to_stringhas been renamed tounsafe_wrap(String, ...), andpointer_to_arrayhas been renamed tounsafe_wrap(Array, ...)(#16731). -
subandslicehave been deprecated in favor ofview(#16972). -
Sparse matrix functions
etree,ereach,csc_permute, andsympermhave been moved to the SuiteSparse.jl package (#12231, #17033). -
The no-op
transposefallback for non-numeric arrays has been deprecated. Consider introducing suitabletransposemethods or callingpermutedims(x, (2, 1))for matrices andreshape(x, 1, length(x))for vectors. (#13171, #17075, #17374). -
The following macros have been deprecated (#16219):
@windowsis deprecated in favor ofis_windows()@unixis deprecated in favor ofis_unix()@osxis deprecated in favor ofis_apple()@linuxis deprecated in favor ofis_linux()@windows_onlyis deprecated in favor ofif is_windows()@unix_onlyis deprecated in favor ofif is_unix()@osx_onlyis deprecated in favor ofif is_apple()@linux_onlyis deprecated in favor ofif is_linux()- NOTE: Using
@staticcould be useful/necessary when used in a function's local scope. See details at the section entitled Handling Operating System Variation in the manual.
-
The
-Fflag to load~/.juliarchas been deprecated in favor of--startup-file=yes(#9482). -
The
-fand--no-startupflags to disable loading of~/.juliarchave been deprecated in favor of--startup-file=no(#9482). -
The
-Pand--post-bootflags for evaluating an expression in "interactive mode" have been deprecated in favor of-i -e(#16854). -
The
--no-history-fileflag to disable loading of~/.julia_historyhas been deprecated in favor of--history-file=no(#9482).
-
The Julia debugger makes its debut with this release. Install it with
Pkg.add("Gallium"), and the documentation should get you going. The JuliaCon talk on Gallium shows off various features of the debugger. -
The Juno IDE has matured significantly, and now also includes support for plotting and debugging.
-
Cxx.jl provides a convenient FFI for calling C++ code from Julia.