|
| 1 | +Julia v1.8 Release Notes |
| 2 | +======================== |
| 3 | + |
| 4 | +New language features |
| 5 | +--------------------- |
| 6 | + |
| 7 | +* Mutable struct fields may now be annotated as `const` to prevent changing them after construction, |
| 8 | + providing for greater clarity and optimization ability of these objects ([#43305]). |
| 9 | +* Type annotations can now be added to global variables to make accessing them type stable ([#43671]). |
| 10 | +* Empty n-dimensional arrays can now be created using multiple semicolons inside square brackets, |
| 11 | + e.g. `[;;;]` creates a 0×0×0 `Array` ([#41618]). |
| 12 | +* `try`-blocks can now optionally have an `else`-block which is executed right after the main body only if |
| 13 | + no errors were thrown ([#42211]). |
| 14 | +* `@inline` and `@noinline` annotations can now be placed within a function body ([#41312]). |
| 15 | +* `@inline` and `@noinline` annotations can now be applied to a function call site or block |
| 16 | + to enforce the involved function calls to be (or not to be) inlined ([#41312]). |
| 17 | +* `∀`, `∃`, and `∄` are now allowed as identifier characters ([#42314]). |
| 18 | +* Support for Unicode 14.0.0 ([#43443]). |
| 19 | +* `Module(:name, false, false)` can be used to create a `module` that contains no names |
| 20 | + (it does not import `Base` or `Core` and does not contain a reference to itself) ([#40110, #42154]). |
| 21 | + |
| 22 | +Language changes |
| 23 | +---------------- |
| 24 | + |
| 25 | +* Newly-created Task objects (`@spawn`, `@async`, etc.) now adopt the world age for methods from their parent |
| 26 | + Task upon creation, instead of using the global latest world at start. This is done to enable inference to |
| 27 | + eventually optimize these calls. Places that wish for the old behavior may use `Base.invokelatest` ([#41449]). |
| 28 | +* Unbalanced Unicode bidirectional formatting directives are now disallowed within strings and comments, |
| 29 | + to mitigate the ["trojan source"](https://www.trojansource.codes) vulnerability ([#42918]). |
| 30 | +* `Base.ifelse` is now defined as a generic function rather than a builtin one, allowing packages to |
| 31 | + extend its definition ([#37343]). |
| 32 | +* Every assignment to a global variable now first goes through a call to `convert(Any, x)` (or `convert(T, x)` |
| 33 | + respectively if a type `T` has been declared for the global). This means great care should be taken |
| 34 | + to ensure the invariant `convert(Any, x) === x` always holds, as this change could otherwise lead to |
| 35 | + unexpected behavior ([#43671]). |
| 36 | +* Builtin functions are now a bit more like generic functions, and can be enumerated with `methods` ([#43865]). |
| 37 | + |
| 38 | +Compiler/Runtime improvements |
| 39 | +----------------------------- |
| 40 | + |
| 41 | +* Bootstrapping time has been improved by about 25% ([#41794]). |
| 42 | +* The LLVM-based compiler has been separated from the run-time library into a new library, |
| 43 | + `libjulia-codegen`. It is loaded by default, so normal usage should see no changes. |
| 44 | + In deployments that do not need the compiler (e.g. system images where all needed code |
| 45 | + is precompiled), this library (and its LLVM dependency) can simply be excluded ([#41936]). |
| 46 | +* Conditional type constraints can now be forwarded interprocedurally (i.e. propagated from caller to callee) ([#42529]). |
| 47 | +* Julia-level SROA (Scalar Replacement of Aggregates) has been improved: allowing elimination of |
| 48 | + `getfield` calls with constant global fields ([#42355]), enabling elimination of mutable structs with |
| 49 | + uninitialized fields ([#43208]), improving performance ([#43232]), and handling more nested `getfield` |
| 50 | + calls ([#43239]). |
| 51 | +* Abstract call sites can now be inlined or statically resolved as long as the call site has a single |
| 52 | + matching method ([#43113]). |
| 53 | +* Inference now tracks various effects such as side-effectful-ness and nothrow-ness on a per-specialization basis. |
| 54 | + Code heavily dependent on constant propagation should see significant compile-time performance improvements and |
| 55 | + certain cases (e.g. calls to uninlinable functions that are nevertheless effect free) should see runtime performance |
| 56 | + improvements. Effects may be overwritten manually with the `@Base.assume_effects` macro ([#43852]). |
| 57 | + |
| 58 | +Command-line option changes |
| 59 | +--------------------------- |
| 60 | + |
| 61 | +* The default behavior of observing `@inbounds` declarations is now an option via `auto` in `--check-bounds=yes|no|auto` ([#41551]). |
| 62 | +* New option `--strip-metadata` to remove docstrings, source location information, and local |
| 63 | + variable names when building a system image ([#42513]). |
| 64 | +* New option `--strip-ir` to remove the compiler's IR (intermediate representation) of source |
| 65 | + code when building a system image. The resulting image will only work if `--compile=all` is |
| 66 | + used, or if all needed code is precompiled ([#42925]). |
| 67 | +* When the program file is `-` the code to be executed is read from standard in ([#43191]). |
| 68 | + |
| 69 | +Multi-threading changes |
| 70 | +----------------------- |
| 71 | + |
| 72 | +* `Threads.@threads` now defaults to a new `:dynamic` schedule option which is similar to the previous behavior except |
| 73 | + that iterations will be scheduled dynamically to available worker threads rather than pinned to each thread. This |
| 74 | + behavior is more composable with (possibly nested) `@spawn` and `@threads` loops ([#43919], [#44136]). |
| 75 | + |
| 76 | +Build system changes |
| 77 | +-------------------- |
| 78 | + |
| 79 | + |
| 80 | +New library functions |
| 81 | +--------------------- |
| 82 | + |
| 83 | +* New function `eachsplit(str)` for iteratively performing `split(str)` ([#39245]). |
| 84 | +* New function `allequal(itr)` for testing if all elements in an iterator are equal ([#43354]). |
| 85 | +* `hardlink(src, dst)` can be used to create hard links ([#41639]). |
| 86 | +* `setcpuaffinity(cmd, cpus)` can be used to set CPU affinity of sub-processes ([#42469]). |
| 87 | +* `diskstat(path=pwd())` can be used to return statistics about the disk ([#42248]). |
| 88 | +* New `@showtime` macro to show both the line being evaluated and the `@time` report ([#42431]). |
| 89 | +* The `LazyString` and the `lazy"str"` macro were added to support delayed construction of error messages in error paths ([#33711]). |
| 90 | + |
| 91 | +New library features |
| 92 | +-------------------- |
| 93 | + |
| 94 | +* `@time` and `@timev` now take an optional description to allow annotating the source of time reports, |
| 95 | + e.g. `@time "Evaluating foo" foo()` ([#42431]). |
| 96 | +* `range` accepts either `stop` or `length` as a sole keyword argument ([#39241]). |
| 97 | +* `precision` and `setprecision` now accept a `base` keyword argument ([#42428]). |
| 98 | +* TCP socket objects now expose `closewrite` functionality and support half-open mode usage ([#40783]). |
| 99 | +* `extrema` now accepts an `init` keyword argument ([#36265], [#43604]). |
| 100 | +* `Iterators.countfrom` now accepts any type that defines `+` ([#37747]). |
| 101 | + |
| 102 | +Standard library changes |
| 103 | +------------------------ |
| 104 | + |
| 105 | +* Keys with value `nothing` are now removed from the environment in `addenv` ([#43271]). |
| 106 | +* `Iterators.reverse` (and hence `last`) now supports `eachline` iterators ([#42225]). |
| 107 | +* The `length` function on certain ranges of certain element types no longer checks for integer |
| 108 | + overflow in most cases. The new function `checked_length` is now available, which will try to use checked |
| 109 | + arithmetic to error if the result may be wrapping. Or use a package such as SaferIntegers.jl when |
| 110 | + constructing the range ([#40382]). |
| 111 | +* Intersect returns a result with the eltype of the type-promoted eltypes of the two inputs ([#41769]). |
| 112 | +* Iterating an `Iterators.Reverse` now falls back on reversing the eachindex iterator, if possible ([#43110]). |
| 113 | + |
| 114 | +#### InteractiveUtils |
| 115 | + |
| 116 | +* New macro `@time_imports` for reporting any time spent importing packages and their dependencies ([#41612]). |
| 117 | + |
| 118 | +#### LinearAlgebra |
| 119 | + |
| 120 | +* The BLAS submodule now supports the level-2 BLAS subroutine `spr!` ([#42830]). |
| 121 | +* `cholesky[!]` now supports `LinearAlgebra.PivotingStrategy` (singleton type) values |
| 122 | + as its optional `pivot` argument: the default is `cholesky(A, NoPivot())` (vs. |
| 123 | + `cholesky(A, RowMaximum())`); the former `Val{true/false}`-based calls are deprecated ([#41640]). |
| 124 | +* The standard library `LinearAlgebra.jl` is now completely independent of `SparseArrays.jl`, |
| 125 | + both in terms of the source code as well as unit testing ([#43127]). As a consequence, |
| 126 | + sparse arrays are no longer (silently) returned by methods from `LinearAlgebra` applied |
| 127 | + to `Base` or `LinearAlgebra` objects. Specifically, this results in the following breaking |
| 128 | + changes: |
| 129 | + * Concatenations involving special "sparse" matrices (`*diagonal`) now return dense matrices; |
| 130 | + As a consequence, the `D1` and `D2` fields of `SVD` objects, constructed upon `getproperty` |
| 131 | + calls are now dense matrices. |
| 132 | + * 3-arg `similar(::SpecialSparseMatrix, ::Type, ::Dims)` returns a dense zero matrix. |
| 133 | + As a consequence, products of bi-, tri- and symmetric tridiagonal matrices with each |
| 134 | + other result in dense output. Moreover, constructing 3-arg similar matrices of special |
| 135 | + "sparse" matrices of (nonstatic) matrices now fails for the lack of `zero(::Type{Matrix{T}})`. |
| 136 | + |
| 137 | +#### Printf |
| 138 | + |
| 139 | +* Now uses `textwidth` for formatting `%s` and `%c` widths ([#41085]). |
| 140 | + |
| 141 | +#### Profile |
| 142 | + |
| 143 | +* CPU profiling now records sample metadata including thread and task. `Profile.print()` has a new `groupby` kwarg that allows |
| 144 | + grouping by thread, task, or nested thread/task, task/thread, and `threads` and `tasks` kwargs to allow filtering. |
| 145 | + Further, percent utilization is now reported as a total or per-thread, based on whether the thread is idle or not at |
| 146 | + each sample. `Profile.fetch()` includes the new metadata by default. For backwards compatibility with external |
| 147 | + profiling data consumers, it can be excluded by passing `include_meta=false` ([#41742]). |
| 148 | +* The new `Profile.Allocs` module allows memory allocations to be profiled. The stack trace, type, and size of each |
| 149 | + allocation is recorded, and a `sample_rate` argument allows a tunable amount of allocations to be skipped, |
| 150 | + reducing performance overhead ([#42768]). |
| 151 | +* A fixed duration cpu profile can now be triggered by the user during running tasks without `Profile` being loaded |
| 152 | + first and the report will show during execution. On MacOS & FreeBSD press `ctrl-t` or raise a `SIGINFO`. |
| 153 | + For other platforms raise a `SIGUSR1` i.e. `% kill -USR1 $julia_pid`. Not currently available on windows ([#43179]). |
| 154 | + |
| 155 | +#### REPL |
| 156 | + |
| 157 | +* `RadioMenu` now supports optional `keybindings` to directly select options ([#41576]). |
| 158 | +* ` ?(x, y` followed by TAB displays all methods that can be called |
| 159 | + with arguments `x, y, ...`. (The space at the beginning prevents entering help-mode.) |
| 160 | + `MyModule.?(x, y` limits the search to `MyModule`. TAB requires that at least one |
| 161 | + argument have a type more specific than `Any`; use SHIFT-TAB instead of TAB |
| 162 | + to allow any compatible methods ([#38791]). |
| 163 | +* New `err` global variable in `Main` set when an expression throws an exception, akin to `ans`. Typing `err` reprints |
| 164 | + the exception information ([#40642]). |
| 165 | + |
| 166 | +#### SparseArrays |
| 167 | + |
| 168 | +* The code for SparseArrays has been moved from the Julia repo to the external |
| 169 | + repo at https://github.com/JuliaSparse/SparseArrays.jl. This is only a code |
| 170 | + movement and does not impact any usage ([#43813]). |
| 171 | +* New sparse concatenation functions `sparse_hcat`, `sparse_vcat`, and `sparse_hvcat` return |
| 172 | + `SparseMatrixCSC` output independent from the types of the input arguments. They make |
| 173 | + concatenation behavior available, in which the presence of some special "sparse" matrix |
| 174 | + argument resulted in sparse output by multiple dispatch. This is no longer possible after |
| 175 | + making `LinearAlgebra.jl` independent from `SparseArrays.jl` ([#43127]). |
| 176 | + |
| 177 | +#### Logging |
| 178 | + |
| 179 | +* The standard log levels `BelowMinLevel`, `Debug`, `Info`, `Warn`, `Error`, |
| 180 | + and `AboveMaxLevel` are now exported from the Logging stdlib ([#40980]). |
| 181 | + |
| 182 | +#### Unicode |
| 183 | + |
| 184 | +* Added function `isequal_normalized` to check for Unicode equivalence without |
| 185 | + explicitly constructing normalized strings ([#42493]). |
| 186 | +* The `Unicode.normalize` function now accepts a `chartransform` keyword that can |
| 187 | + be used to supply custom character mappings, and a `Unicode.julia_chartransform` |
| 188 | + function is provided to reproduce the mapping used in identifier normalization |
| 189 | + by the Julia parser ([#42561]). |
| 190 | + |
| 191 | +#### Test |
| 192 | + |
| 193 | +* `@test_throws "some message" triggers_error()` can now be used to check whether the displayed error text |
| 194 | + contains "some message" regardless of the specific exception type. |
| 195 | + Regular expressions, lists of strings, and matching functions are also supported ([#41888]). |
| 196 | +* `@testset foo()` can now be used to create a test set from a given function. The name of the test set |
| 197 | + is the name of the called function. The called function can contain `@test` and other `@testset` |
| 198 | + definitions, including to other function calls, while recording all intermediate test results ([#42518]). |
| 199 | +* `TestLogger` and `LogRecord` are now exported from the Test stdlib ([#44080]). |
| 200 | + |
| 201 | +Deprecated or removed |
| 202 | +--------------------- |
| 203 | + |
| 204 | + |
| 205 | +External dependencies |
| 206 | +--------------------- |
| 207 | + |
| 208 | + |
| 209 | +Tooling Improvements |
| 210 | +--------------------- |
| 211 | + |
| 212 | +* `GC.enable_logging(true)` can be used to log each garbage collection, with the |
| 213 | + time it took and the amount of memory that was collected ([#43511]). |
| 214 | + |
| 215 | +<!--- generated by NEWS-update.jl: --> |
| 216 | +[#33711]: https://github.com/JuliaLang/julia/issues/33711 |
| 217 | +[#36265]: https://github.com/JuliaLang/julia/issues/36265 |
| 218 | +[#37343]: https://github.com/JuliaLang/julia/issues/37343 |
| 219 | +[#37747]: https://github.com/JuliaLang/julia/issues/37747 |
| 220 | +[#38791]: https://github.com/JuliaLang/julia/issues/38791 |
| 221 | +[#39241]: https://github.com/JuliaLang/julia/issues/39241 |
| 222 | +[#39245]: https://github.com/JuliaLang/julia/issues/39245 |
| 223 | +[#40382]: https://github.com/JuliaLang/julia/issues/40382 |
| 224 | +[#40642]: https://github.com/JuliaLang/julia/issues/40642 |
| 225 | +[#40783]: https://github.com/JuliaLang/julia/issues/40783 |
| 226 | +[#40980]: https://github.com/JuliaLang/julia/issues/40980 |
| 227 | +[#41085]: https://github.com/JuliaLang/julia/issues/41085 |
| 228 | +[#41312]: https://github.com/JuliaLang/julia/issues/41312 |
| 229 | +[#41449]: https://github.com/JuliaLang/julia/issues/41449 |
| 230 | +[#41551]: https://github.com/JuliaLang/julia/issues/41551 |
| 231 | +[#41576]: https://github.com/JuliaLang/julia/issues/41576 |
| 232 | +[#41612]: https://github.com/JuliaLang/julia/issues/41612 |
| 233 | +[#41618]: https://github.com/JuliaLang/julia/issues/41618 |
| 234 | +[#41639]: https://github.com/JuliaLang/julia/issues/41639 |
| 235 | +[#41640]: https://github.com/JuliaLang/julia/issues/41640 |
| 236 | +[#41742]: https://github.com/JuliaLang/julia/issues/41742 |
| 237 | +[#41769]: https://github.com/JuliaLang/julia/issues/41769 |
| 238 | +[#41794]: https://github.com/JuliaLang/julia/issues/41794 |
| 239 | +[#41888]: https://github.com/JuliaLang/julia/issues/41888 |
| 240 | +[#41936]: https://github.com/JuliaLang/julia/issues/41936 |
| 241 | +[#42211]: https://github.com/JuliaLang/julia/issues/42211 |
| 242 | +[#42225]: https://github.com/JuliaLang/julia/issues/42225 |
| 243 | +[#42248]: https://github.com/JuliaLang/julia/issues/42248 |
| 244 | +[#42314]: https://github.com/JuliaLang/julia/issues/42314 |
| 245 | +[#42355]: https://github.com/JuliaLang/julia/issues/42355 |
| 246 | +[#42428]: https://github.com/JuliaLang/julia/issues/42428 |
| 247 | +[#42431]: https://github.com/JuliaLang/julia/issues/42431 |
| 248 | +[#42469]: https://github.com/JuliaLang/julia/issues/42469 |
| 249 | +[#42493]: https://github.com/JuliaLang/julia/issues/42493 |
| 250 | +[#42513]: https://github.com/JuliaLang/julia/issues/42513 |
| 251 | +[#42518]: https://github.com/JuliaLang/julia/issues/42518 |
| 252 | +[#42529]: https://github.com/JuliaLang/julia/issues/42529 |
| 253 | +[#42561]: https://github.com/JuliaLang/julia/issues/42561 |
| 254 | +[#42768]: https://github.com/JuliaLang/julia/issues/42768 |
| 255 | +[#42830]: https://github.com/JuliaLang/julia/issues/42830 |
| 256 | +[#42918]: https://github.com/JuliaLang/julia/issues/42918 |
| 257 | +[#42925]: https://github.com/JuliaLang/julia/issues/42925 |
| 258 | +[#43110]: https://github.com/JuliaLang/julia/issues/43110 |
| 259 | +[#43113]: https://github.com/JuliaLang/julia/issues/43113 |
| 260 | +[#43127]: https://github.com/JuliaLang/julia/issues/43127 |
| 261 | +[#43179]: https://github.com/JuliaLang/julia/issues/43179 |
| 262 | +[#43191]: https://github.com/JuliaLang/julia/issues/43191 |
| 263 | +[#43208]: https://github.com/JuliaLang/julia/issues/43208 |
| 264 | +[#43232]: https://github.com/JuliaLang/julia/issues/43232 |
| 265 | +[#43239]: https://github.com/JuliaLang/julia/issues/43239 |
| 266 | +[#43271]: https://github.com/JuliaLang/julia/issues/43271 |
| 267 | +[#43305]: https://github.com/JuliaLang/julia/issues/43305 |
| 268 | +[#43354]: https://github.com/JuliaLang/julia/issues/43354 |
| 269 | +[#43443]: https://github.com/JuliaLang/julia/issues/43443 |
| 270 | +[#43511]: https://github.com/JuliaLang/julia/issues/43511 |
| 271 | +[#43604]: https://github.com/JuliaLang/julia/issues/43604 |
| 272 | +[#43671]: https://github.com/JuliaLang/julia/issues/43671 |
| 273 | +[#43813]: https://github.com/JuliaLang/julia/issues/43813 |
| 274 | +[#43852]: https://github.com/JuliaLang/julia/issues/43852 |
| 275 | +[#43865]: https://github.com/JuliaLang/julia/issues/43865 |
| 276 | +[#43919]: https://github.com/JuliaLang/julia/issues/43919 |
| 277 | +[#44080]: https://github.com/JuliaLang/julia/issues/44080 |
| 278 | +[#44136]: https://github.com/JuliaLang/julia/issues/44136 |
| 279 | + |
1 | 280 | Julia v1.7 Release Notes
|
2 | 281 | ========================
|
3 | 282 |
|
|
0 commit comments