==========================
New language features
---------------------
* Function call overloading: for arbitrary objects `x` (not of type
`Function`), `x(...)` is transformed into `call(x, ...)`, and `call`
can be overloaded as desired. Constructors are now a special case of
this mechanism, which allows e.g. constructors for abstract types.
`T(...)` falls back to `convert(T, x)`, so all `convert` methods implicitly
define a constructor ([8712], [2403]).
* Unicode version 8 is now supported for identifiers etcetera ([7917], [12031]).
* Type parameters now permit any `isbits` type, not just `Int` and `Bool` ([6081]).
* Keyword argument names can be computed, using syntax such as `f(; symbol => val)` ([7704]).
* The syntax `generated function` enables generation of specialized methods based on
argument types. At compile time, the function is called with its arguments bound to their
types instead of to their values. The function then returns an expression forming the
body of the function to be called at run time ([7311]).
* [Documentation system](https://docs.julialang.org/en/v1/manual/documentation/)
for functions, methods, types and macros in packages and user code ([8791]).
* The syntax `function foo end` can be used to introduce a generic function without
yet adding any methods ([8283]).
* Incremental precompilation of modules: call `VERSION >= v"0.4.0-dev+6521" && __precompile__()` at the top of a
module file to automatically precompile it when it is imported ([12491]), or manually
run `Base.compilecache(modulename)`. The resulting precompiled `.ji` file is saved in
`~/.julia/lib/v0.4` ([8745]).
* See manual section on `Module initialization and precompilation` (under `Modules`) for
details and errata. In particular, to be safely precompilable a module may need an
`__init__` function to separate code that must be executed at runtime rather than precompile
time. Modules that are *not* precompilable should call `__precompile__(false)`.
* The precompiled `.ji` file includes a list of dependencies (modules and files that
were imported/included at precompile-time), and the module is automatically recompiled
upon `import` when any of its dependencies have changed. Explicit dependencies
on other files can be declared with `include_dependency(path)` ([12458]).
* New option `--output-incremental={yes|no}` added to invoke the equivalent of `Base.compilecache`
from the command line.
* The syntax `new{parameters...}(...)` can be used in constructors to specify parameters for
the type to be constructed ([8135]).
* `++` is now parsed as an infix operator, but does not yet have a default definition ([11030], [11686]).
* Support for inter-task communication using `Channels` ([12264]).
See https://docs.julialang.org/en/v1/manual/parallel-computing/#Channels-1 for details.
* `RemoteRef`s now point to remote channels. The remote channels can be of length greater than 1.
Default continues to be of length 1 ([12385]).
See https://docs.julialang.org/en/v1/manual/parallel-computing/#Remote-References-and-AbstractChannels-1 for details.
* `__LINE__` special macro now available to reflect invocation source line number ([12727]).
Language changes
----------------
* Tuple types are now written as `Tuple{A, B}` instead of as `(A, B)`.
Tuples of bits types are inlined into structs and arrays, like other
immutable types.
`...` now does splatting inside parentheses, instead of constructing a
variadic tuple type ([10380]).
Variadic tuple types are written as `Tuple{Vararg{T}}`.
* Using `[x,y]` to concatenate arrays is deprecated, and in the future will
construct a vector of `x` and `y` instead ([3737], [2488], [8599]).
* Significant improvements to `ccall` and `cfunction`
* As a safer alternative to creating pointers (`Ptr`), the managed reference type
`Ref` has been added. A `Ref` points to the data contained by a value in an
abstract sense, and in a way that is GC-safe. For example, `Ref(2)` points to
a storage location that contains the integer `2`, and `Ref(array,3)` points
to the third element of an array. A `Ref` can be automatically converted to a
native pointer when passed to a `ccall`.
* When passing a by-reference argument to `ccall`, you can declare
the argument type to be `Ref{T}` instead of `Ptr{T}`, and just
pass `x` instead of `&x`.
* `ccall` is now lowered to call `unsafe_convert(T, cconvert(T, x))` on each
argument. `cconvert` falls back to `convert`, but can be used to convert an
argument to an arbitrarily-different representation more suitable for passing
to C. `unsafe_convert` then handles conversions to `Ptr`.
* `ccall` and `cfunction` now support correctly passing and returning structs,
following the platform ABI (assuming the C types are mirrored accurately in Julia).
* `cfunction` arguments of struct-like Julia types are now passed by value.
If `Ref{T}` is used as a `cfunction` argument type, it will look up the
method applicable to `T`, but pass the argument by reference (as Julia functions
usually do). However, this should only be used for objects allocated by Julia
and for `isbits` types.
* `convert(Ptr,x)` is deprecated for most types, replaced by
`unsafe_convert`. You can still `convert` between pointer types,
and between pointers and `Int` or `UInt`.
* Module `__init__` methods no longer swallow thrown exceptions; they now
throw an `InitError` wrapping the thrown exception ([12576]).
* Unsigned `BigInt` literal syntax has been removed ([11105]).
Unsigned literals larger than `UInt128` now throw a syntax error.
* `error(::Exception)` and `error(::Type{Exception})` have been deprecated
in favor of using an explicit `throw` ([9690]).
* `Uint` etcetera are renamed to `UInt` ([8905]).
* `String` is renamed to `AbstractString` ([8872]).
* `FloatingPoint` is renamed to `AbstractFloat` ([12162]).
* `None` is deprecated; use `Union{}` instead ([8423]).
* `Nothing` (the type of `nothing`) is renamed to `Void` ([8423]).
* Arrays can be constructed with the syntax `Array{T}(m,n)` ([3214], [10075]).
* `Dict` literal syntax `[a=>b,c=>d]` is replaced by `Dict(a=>b,c=>d)`,
`{a=>b}` is replaced by `Dict{Any,Any}(a=>b)`, and
`(K=>V)[...]` is replaced by `Dict{K,V}(...)`.
The new syntax has many advantages: all of its components are first-class,
it generalizes to other types of containers, it is easier to guess how to
specify key and value types, and the syntaxes for empty and pre-populated
dicts are synchronized. As part of this change, `=>` is parsed as a normal
operator, and `Base` defines it to construct `Pair` objects ([6739]).
* `Char` is no longer a subtype of `Integer` ([8816]).
Char now supports a more limited set of operations with `Integer` types:
* comparison / equality
* `Char` + `Int` = `Char`
* `Char` - `Char` = `Int`
* `round` rounds to the nearest integer using the default rounding mode,
which is ties-to-even by default ([8750]).
* A custom triple-quoted string like `x"""..."""` no longer invokes an `x_mstr`
macro. Instead, the string is first unindented and then `x_str` is invoked,
as if the string had been single-quoted ([10228]).
* Colons (`:`) within indexing expressions are no longer lowered to the range
`1:end`. Instead, the `:` identifier is passed directly. Custom array types
that implement `getindex` or `setindex!` methods must also extend those
methods to support arguments of type `Colon` ([10331]).
* Unions of types should now be written with curly braces instead of parentheses, i.e.
`Union{Type1, Type2}` instead of `Union(Type1, Type2)` ([11432]).
* The keyword `local` is no longer allowed in global scope. Use `let` instead of
`begin` to create a new scope from the top level ([7234], [10472]).
* Triple-quoted strings no longer treat tabs as 8 spaces. Instead, the
longest common prefix of spaces and tabs is removed.
* `global x` in a nested scope is now a syntax error if `x` is local
to the enclosing scope ([7264]/[11985]).
* The default `importall Base.Operators` is deprecated, and relying on it
will give a warning ([8113]).
* `remotecall_fetch` and `fetch` now rethrow any uncaught remote exception locally as a
`RemoteException`. Previously they would return the remote exception object.
The worker pid, remote exception and remote backtrace are available in the
thrown `RemoteException`.
* If any of the enclosed async operations in a `sync` block throw exceptions, they
are now collected in a `CompositeException` and the `CompositeException` thrown.
Command line option changes
---------------------------
* The `-i` option now forces the REPL to run after loading the specified script (if any) ([11347]).
* New option `--handle-signals={yes|no}` to disable Julia's signal handlers.
* The `--depwarn={yes|no|error}` option enables/disables syntax and method deprecation warnings,
or turns them into errors ([9294]).
* Some command line options are slated for deprecation / removal
- `-f, --no-startup` Don't load ~/.juliarc (deprecated, use --startup-file=no)
- `-F` Load ~/.juliarc (deprecated, use --startup-file=yes)`
- `-P, --post-boot <expr>` Evaluate <expr>, but don't disable interactive mode (deprecated, use -i -e instead)
- `--no-history-file` Don't load history file (deprecated, use --history-file=no)
Compiler/Runtime improvements
-----------------------------
* Functions may be annotated with metadata (`:meta` expressions) to be used by the compiler ([8297]).
* `inline` before a function definition forces the compiler to inline the function ([8297]).
* Loads from heap-allocated immutables are hoisted out of loops in more cases ([8867]).
* Accessing fields that are always initialized no longer produces undefined checks ([8827]).
* New generational garbage collector which greatly reduces GC overhead for many common workloads ([5227]).
Library improvements
--------------------
* Build with USE_GPL_LIBS=0 to exclude all GPL libraries and code ([10870]).
* Linear algebra
* The `LinAlg` module is now exported.
* `sparse(A)` now takes any `AbstractMatrix` A as an argument ([10031]).
* Factorization API is now type-stable; functions dispatch on `Val{false}` or `Val{true}` instead of a boolean value ([9575]).
* Added generic Cholesky factorization, and the Cholesky factorization is now parametrized by the matrix type ([7236]).
* Sparse `cholfact` and `ldltfact` functions now accept a `perm` keyword
for user-provided permutations and a `shift` keyword to factorize
a shifted matrix ([10844]).
* New `svds` function for the sparse truncated SVD ([9425]).
* `Symmetric` and `Hermitian` immutables are now parametrized by the matrix type ([7992]).
* New `ordschur` and `ordschur!` functions for sorting a Schur factorization by the eigenvalues ([8467],[9701]).
* `Givens` type doesn't have a size anymore and is no longer a subtype of `AbstractMatrix` ([8660]).
* Large speedup in sparse `\` and splitting of Cholesky and LDLᵀ factorizations into `cholfact` and `ldltfact` ([10117]).
* Add sparse least squares to `\` by adding `qrfact` for sparse matrices based on the SPQR library ([10180]).
* Split `Triangular` type into `UpperTriangular`, `LowerTriangular`, `UnitUpperTriagular` and `UnitLowerTriangular` ([9779])
* OpenBLAS 64-bit (ILP64) interface is now compiled with a `64_` suffix ([8734]) to avoid conflicts with external libraries using a 32-bit BLAS ([4923]).
* New `vecdot` function, analogous to `vecnorm`, for Euclidean inner products over any iterable container ([11067]).
* `p = plan_fft(x)` and similar functions now return a `Base.DFT.Plan` object, rather
than an anonymous function. Calling it via `p(x)` is deprecated in favor of
`p * x` or `p \ x` (for the inverse), and it can also be used with `A_mul_B!`
to employ pre-allocated output arrays ([12087]).
* `LU{T,Tridiagonal{T}}` now supports extraction of `L`, `U`, `p`, and `P` factors ([12137]).
* Allocations in sparse matrix factorizations are now tracked by Julia's garbage collector ([12034]).
* Strings
* NUL-terminated strings should now be passed to C via the new `Cstring` type, not `Ptr{UInt8}` or `Ptr{Cchar}`,
in order to check whether the string is free of NUL characters (which would cause silent truncation in C).
The analogous type `Cwstring` should be used for NUL-terminated `wchar_t*` strings ([10994]).
* `graphemes(s)` returns an iterator over grapheme substrings of `s` ([9261]).
* Character predicates such as `islower()`, `isspace()`, etc. use
utf8proc to provide uniform cross-platform behavior and
up-to-date, locale-independent support for Unicode standards
([5939]).
* `reverseind` function to convert indices in reversed strings (e.g. from
reversed regex searches) to indices in the original string ([9249]).
* `charwidth(c)` and `strwidth(s)` now return up-to-date cross-platform
results (via utf8proc) ([10659]): Julia now likes pizza ([3721]), but some terminals still don't.
* `is_valid_char(c)`, (now `isvalid(Char,c)` ([11241])), now correctly handles Unicode "non-characters", which are valid Unicode codepoints ([11171]).
* Backreferences in replacement strings in calls to `replace` with a `Regex` pattern are now supported ([11849]).
Use the `s` string prefix to indicate a replacement string contains a backreference. For example, `replace("ab", r"(.)(.)", s"\2\1")` yields "ba".
* Capture groups in regular expressions can now be named using PCRE syntax, `(?P<group_name>...)`. Capture group matches can be accessed by name by indexing a `Match` object with the name of the group ([11566]).
* `countlines()` now counts all lines, not just non-empty ([11947]).
* Array and AbstractArray improvements
* New multidimensional iterators and index types for efficient iteration over `AbstractArray`s. Array iteration should generally be written as `for i in eachindex(A) ... end` rather than `for i = 1:length(A) ... end` ([8432]).
* New implementation of SubArrays with substantial performance and functionality improvements ([8501]).
* AbstractArray subtypes only need to implement `size` and `getindex`
for scalar indices to support indexing; all other indexing behaviors
(including logical indexing, ranges of indices, vectors, colons, etc.) are
implemented in default fallbacks. Similarly, they only need to implement
scalar `setindex!` to support all forms of indexed assignment ([10525]).
* AbstractArrays that do not extend `similar` now return an `Array` by
default ([10525]).
* Data structures
* New `sortperm!` function for pre-allocated index arrays ([8792]).
* Switch from `O(N)` to `O(log N)` algorithm for `dequeue!(pq, key)`
with `PriorityQueue`. This provides major speedups for large
queues ([8011]).
* `PriorityQueue` now includes the order type among its
parameters, `PriorityQueue{KeyType,ValueType,OrderType}`. An
empty queue can be constructed as `pq =
PriorityQueue(KeyType,ValueType)`, if you intend to use the
default `Forward` order, or `pq = PriorityQueue(KeyType,
ValueType, OrderType)` otherwise ([8011]).
* Efficient `mean` and `median` for ranges ([8089]).
* `deepcopy` recurses through immutable types and makes copies of their mutable fields ([8560]).
* `copy(a::DArray)` will now make a copy of a `DArray` ([9745]).
* New types
* Enums are now supported through the `enum EnumName EnumValue1
EnumValue2` syntax. Enum member values also support arbitrary
value assignment by the `enum EnumName EnumValue1=1
EnumValue2=10 EnumValue3=20` syntax ([10168]).
* New `Dates` module for calendar dates and other time-interval calculations ([7654]).
* New `Nullable` type for missing data ([8152]).
* A new `Val{T}` type allows one to dispatch on bits-type values ([9452]).
* `linspace` now returns a `LinSpace` object which lazily computes linear interpolation of values between the start and stop values. It "lifts" endpoints which are approximately rational in the same manner as the `colon` operator.
* Arithmetic
* `convert` now checks for overflow when truncating integers or converting between
signed and unsigned ([5413]).
* Arithmetic is type-preserving for more types; e.g. `(x::Int8) + (y::Int8)` now
yields an `Int8` ([3759]).
* Reductions (e.g. `reduce`, `sum`) widen small types (integers smaller than `Int`, and `Float16`).
* Added optional rounding argument to floating-point constructors ([8845]).
* Equality (`==`) and inequality (`<`/`<=`) comparisons are now correct
across all numeric types ([9133], [9198]).
* Rational arithmetic throws errors on overflow ([8672]).
* Optional `log` and `log1p` functions implemented in pure Julia (experimental) ([10008]).
* The `MathConst` type has been renamed `Irrational` ([11922]).
* `isapprox` now has simpler and more sensible default tolerances ([12393]), supports arrays, and has synonyms `≈` ([U+2248](https://www.fileformat.info/info/unicode/char/2248/index.htm), LaTeX `\approx`) and `≉` ([U+2249](https://www.fileformat.info/info/unicode/char/2249/index.htm), LaTeX `\napprox`) for `isapprox` and `!isapprox`, respectively ([#12472]).
* Numbers
* `primes` is now faster and has been extended to generate the primes in a user defined closed interval ([12025]).
* The function `primesmask` which generates a prime sieve for a user defined closed interval is now exported ([12025]).
* Random numbers
* Streamlined random number generation APIs [8246].
The default `rand` no longer uses global state in the underlying C library,
dSFMT, making it closer to being thread-safe ([8399], [8832]).
All APIs can now take an `AbstractRNG` argument ([8854], [9065]). The seed argument to `srand` is now optional ([8320], [8854]).
The APIs accepting a range argument are extended to accept an arbitrary
`AbstractArray` ([9049]).
Passing a range of `BigInt` to `rand` or `rand!` is now supported ([9122]).
There are speed improvements across the board ([8808], [8941], [8958], [9083]).
* Significantly faster `randn` ([9126], [9132]).
* The `randexp` and `randexp!` functions are exported ([9144]).
* File
* Added function `readlink` which returns the value of a symbolic link "path" ([10714]).
* Added function `ismount` which checks if a directory is a mount point ([11279]).
* The `cp` function now accepts keyword arguments `remove_destination` and `follow_symlinks` ([10888]).
* The `mv` function now accepts keyword argument `remove_destination` ([11145]).
* `Pipe()` creates a bidirectional I/O object that can be passed to `spawn` or `pipeline`
for redirecting process streams ([12739]).
* Other improvements
* You can now tab-complete emoji via their [short names](http://www.emoji-cheat-sheet.com/), using `\:name:<tab>` ([#10709]).
* `gc_enable` subsumes `gc_disable`, and also returns the previous GC state.
* `assert`, `assert` now throws an `AssertionError` exception type ([9734]).
* `simd` now rejects invalid control flow (`goto` / break / continue) in the inner loop body at compile time ([8624]).
* The `machinefile` now supports a host count ([7616]).
* `code_native` now outputs branch labels ([8897]).
* Added `recvfrom` to get source address of UDP packets ([9418]).
* `ClusterManager` performance improvements ([9309]) and support for changing transports([9434]).
* Added `Base.get_process_title` / `Base.set_process_title` ([9957]).
* `readavailable` now returns a byte vector instead of a string.
* New `lock` and `unlock` functions, operating on `ReentrantLock`, to lock a stream during
concurrent writes from multiple tasks ([10679]).
* `code_llvm` now outputs stripped IR without debug info or other attached metadata.
Use `code_llvm_raw` for the unstripped output ([10747]).
* New `withenv(var=>val, ...) do ... end` function to temporarily
modify environment variables ([10914]).
* New function `relpath` returns a relative filepath to path either from the current
directory or from an optional start directory ([10893]).
* `mktemp` and `mktempdir` now take an optional argument to set which
directory the temporary file or directory is created in.
* New garbage collector tracked memory allocator functions: `jl_malloc`, `jl_calloc`,
`jl_realloc`, and `jl_free` with libc API ([[12034]]).
* `mktempdir` and `mktemp` now have variants that take a function as its
first argument for automated clean-up ([[9017]]).
Deprecated or removed
---------------------
* several syntax whitespace insensitivities have been deprecated ([11891]).
julia
function call
f (x)
getindex
x [17]
rand(2) [1]
function definition
f (x) = x^2
function foo (x)
x^2
end
* indexing with `Real`s that are not subtypes of `Integer` (`Rational`, `AbstractFloat`, etc.) has been deprecated ([10458]).
* `push!(A)` has been deprecated, use `append!` instead of splatting arguments to `push!` ([10400]).
* `names` for composite datatypes has been deprecated and
renamed to `fieldnames` ([10332]).
* `DArray` functionality has been removed from `Base` and is now a
standalone package under the JuliaParallel umbrella organization ([10333]).
* The `Graphics` module has been removed from `Base` and is now a
standalone package ([10150], [9862]).
* The `Woodbury` special matrix type has been removed from `LinAlg` ([10024]).
* `median` and `median!` no longer accept a `checknan` keyword argument ([8605]).
* `inf` and `nan` are now deprecated in favor of `T(Inf)` and `T(NaN)`, respectively ([8776]).
* `oftype(T::Type, x)` is deprecated in favor of `convert(T,x)` (or `T(x)`).
* `{...}` syntax is deprecated in favor of `Any[...]` ([8578]).
* `itrunc`, `ifloor`, `iceil` and `iround` are deprecated in favour of
`trunc{T<:Integer}(T,x)`, `floor{T<:Integer}(T,x)`, etc.. `trunc` is now
always bound-checked;`Base.unsafe_trunc` provides the old unchecked `itrunc`
behaviour ([9133]).
* `squeeze` now requires that passed dimension(s) are an `Int` or tuple of `Int`s;
calling `squeeze` with an arbitrary iterator is deprecated ([9271]).
Additionally, passed dimensions must be unique and correspond to extant
dimensions of the input array.
* `randbool` is deprecated. Use `rand(Bool)` to produce a random boolean value, and
`bitrand` to produce a random BitArray ([9105], [9569]).
* `beginswith` is renamed to `startswith` ([9578]).
* `null` is renamed to `nullspace` ([9714]).
* The operators `|>`, `.>`, `>>`, and `.>>` as used for process I/O redirection
are replaced with the `pipeline` function ([5349], [12739]).
* `flipud(A)` and `fliplr(A)` have been deprecated in favor of `flipdim(A, 1)` and
`flipdim(A, 2)`, respectively ([10446]).
* Numeric conversion functions whose names are lower-case versions of type
names have been removed. To convert a scalar, use the type name, e.g.
`Int32(x)`. To convert an array to a different element type, use
`Array{T}(x)`, `map(T,x)`, or `round(T,x)`. To parse a string as an integer
or floating-point number, use `parse` ([1470], [6211]).
* Low-level functions from the C library and dynamic linker have been moved to
modules `Libc` and `Libdl`, respectively ([10328]).
* The functions `parseint`, `parsefloat`, `float32_isvalid`,
`float64_isvalid`, and the string-argument `BigInt` and `BigFloat` have
been replaced by `parse` and `tryparse` with a type argument. The string
macro `big"xx"` can be used to construct `BigInt` and `BigFloat` literals
([3631], [5704], [9487], [10543], [10955]).
* the `--int-literals` compiler option is no longer accepted ([9597]).
* Instead of `linrange`, use `linspace` ([9666]).
* The functions `is_valid_char`, `is_valid_ascii`, `is_valid_utf8`, `is_valid_utf16`, and
`is_valid_utf32` have been replaced by generic `isvalid` methods.
The single argument form `isvalid(value)` can now be used for values of type `Char`, `ASCIIString`,
`UTF8String`, `UTF16String` and `UTF32String`.
The two argument form `isvalid(type, value)` can be used with the above types, with values
of type `Vector{UInt8}`, `Vector{UInt16}`, `Vector{UInt32}`, and `Vector{Char}` ([11241]).
* Instead of `utf32(64,123,...)` use `utf32(UInt32[64,123,...])` ([11379]).
* `start_timer` and `stop_timer` are replaced by `Timer` and `close`.
* The following internal julia C functions have been renamed, in order to prevent
potential naming conflicts with C libraries: ([11741])
* `gc_wb*` -> `jl_gc_wb*`
* `gc_queue_root` -> `jl_gc_queue_root`
* `allocobj` -> `jl_gc_allocobj`
* `alloc_[0-3]w` -> `jl_gc_alloc_*w`
* `diff_gc_total_bytes` -> `jl_gc_diff_total_bytes`
* `sync_gc_total_bytes` -> `jl_gc_sync_total_bytes`
* `require(::AbstractString)` and `reload` (see news about addition of `compile`).
* `cartesianmap` is deprecated in favor of iterating over a `CartesianRange`