|
| 1 | +Julia v1.12 Release Notes |
| 2 | +======================== |
| 3 | + |
| 4 | +New language features |
| 5 | +--------------------- |
| 6 | + |
| 7 | +* New option `--trim` creates smaller binaries by removing code that was not proven to be reachable from |
| 8 | + entry points. Entry points can be marked using `Base.Experimental.entrypoint` ([#55047]). |
| 9 | +* A new keyword argument `usings::Bool` has been added to `names`, returning all names visible |
| 10 | + via `using` ([#54609]). |
| 11 | +* The `@atomic` macro family now supports reference assignment syntax, e.g. `@atomic :monotonic v[3] += 4`, |
| 12 | + which modifies `v[3]` atomically with monotonic ordering semantics ([#54707]). |
| 13 | + The supported syntax allows |
| 14 | + * atomic fetch (`x = @atomic v[3]`), |
| 15 | + * atomic set (`@atomic v[3] = 4`), |
| 16 | + * atomic modify (`@atomic v[3] += 2`), |
| 17 | + * atomic set once (`@atomiconce v[3] = 2`), |
| 18 | + * atomic swap (`x = @atomicswap v[3] = 2`), and |
| 19 | + * atomic replace (`x = @atomicreplace v[3] 2=>5`). |
| 20 | +* New option `--task-metrics=yes` to enable the collection of per-task timing information, |
| 21 | + which can also be enabled/disabled at runtime with `Base.Experimental.task_metrics(::Bool)` ([#56320]). |
| 22 | + The available metrics are: |
| 23 | + * actual running time for the task (`Base.Experimental.task_running_time_ns`), and |
| 24 | + * wall-time for the task (`Base.Experimental.task_wall_time_ns`). |
| 25 | +* Support for Unicode 16 ([#56925]). |
| 26 | +* `Threads.@spawn` now takes a `:samepool` argument to specify the same threadpool as the caller. |
| 27 | + `Threads.@spawn :samepool foo()` which is shorthand for `Threads.@spawn Threads.threadpool() foo()` ([#57109]). |
| 28 | + |
| 29 | +Language changes |
| 30 | +---------------- |
| 31 | + |
| 32 | +* Julia now defaults to 1 "interactive" thread, in addition to the 1 default "worker" thread. i.e. `-t1,1`. |
| 33 | + This means in default configuration the main task and repl (when in interactive mode), which both run on |
| 34 | + thread 1, now run within the `interactive` threadpool. The libuv IO loop also runs on thread 1, |
| 35 | + helping efficient utilization of the worker threadpool used by `Threads.@spawn`. Pass `0` to disable the |
| 36 | + interactive thread i.e. `-t1,0` or `JULIA_NUM_THREADS=1,0`, or `-tauto,0` etc. The zero is explicitly |
| 37 | + required to disable it, `-t2` will set the equivalent of `-t2,1` ([#57087]). |
| 38 | +* When a method is replaced with an exactly equivalent one, the old method is not deleted. Instead, the |
| 39 | + new method takes priority and becomes more specific than the old method. Thus if the new method is deleted |
| 40 | + later, the old method will resume operating. This can be useful in mocking frameworks (as in SparseArrays, |
| 41 | + Pluto, and Mocking, among others), as they do not need to explicitly restore the old method. |
| 42 | + At this time, inference and compilation must be repeated in this situation, but we may eventually be |
| 43 | + able to re-use the old results ([#53415]). |
| 44 | +* Macro expansion will no longer eagerly recurse into `Expr(:toplevel)` expressions returned from macros. |
| 45 | + Instead, macro expansion of `:toplevel` expressions will be delayed until evaluation time. This allows a |
| 46 | + later expression within a given `:toplevel` expression to make use of macros defined earlier in the same |
| 47 | + `:toplevel` expression ([#53515]). |
| 48 | +* Trivial infinite loops (like `while true; end`) are no longer undefined behavior. Infinite loops that |
| 49 | + do things (e.g. have side effects or sleep) were never and are still not undefined behavior ([#52999]). |
| 50 | +* It is now an error to mark a binding as both `public` and `export`ed ([#53664]). |
| 51 | +* Errors during `getfield` now raise a new `FieldError` exception type instead of the generic |
| 52 | + `ErrorException` ([#54504]). |
| 53 | + |
| 54 | +Compiler/Runtime improvements |
| 55 | +----------------------------- |
| 56 | + |
| 57 | +* Generated LLVM IR now uses pointer types instead of passing pointers as integers. |
| 58 | + This affects `llvmcall`: Inline LLVM IR should be updated to use `i8*` or `ptr` instead of |
| 59 | + `i32` or `i64`, and remove unneeded `ptrtoint`/`inttoptr` conversions. For compatibility, |
| 60 | + IR with integer pointers is still supported, but generates a deprecation warning ([#53687]). |
| 61 | + |
| 62 | +Command-line option changes |
| 63 | +--------------------------- |
| 64 | + |
| 65 | +* The `-m/--module` flag can be passed to run the `main` function inside a package with a set of arguments. |
| 66 | + This `main` function should be declared using `@main` to indicate that it is an entry point ([#52103]). |
| 67 | +* Enabling or disabling color text in Julia can now be controlled with the |
| 68 | + [`NO_COLOR`](https://no-color.org/) or [`FORCE_COLOR`](https://force-color.org/) environment |
| 69 | + variables. These variables are also honored by Julia's build system ([#53742], [#56346]). |
| 70 | +* `--project=@temp` starts Julia with a temporary environment ([#51149]). |
| 71 | +* New `--trace-compile-timing` option to report how long each method reported by `--trace-compile` took |
| 72 | + to compile, in ms ([#54662]). |
| 73 | +* `--trace-compile` now prints recompiled methods in yellow or with a trailing comment if color is not |
| 74 | + supported ([#55763]). |
| 75 | +* New `--trace-dispatch` option to report methods that are dynamically dispatched ([#55848]). |
| 76 | + |
| 77 | +Multi-threading changes |
| 78 | +----------------------- |
| 79 | + |
| 80 | +* New types are defined to handle the pattern of code that must run once per process, called |
| 81 | + a `OncePerProcess{T}` type, which allows defining a function that should be run exactly once |
| 82 | + the first time it is called, and then always return the same result value of type `T` |
| 83 | + every subsequent time afterwards. There are also `OncePerThread{T}` and `OncePerTask{T}` types for |
| 84 | + similar usage with threads or tasks ([#55793]). |
| 85 | + |
| 86 | +Build system changes |
| 87 | +-------------------- |
| 88 | + |
| 89 | +* There are new `Makefile`s to build Julia and LLVM using the Binary Optimization and Layout Tool (BOLT). |
| 90 | + See `contrib/bolt` and `contrib/pgo-lto-bolt` ([#54107]). |
| 91 | + |
| 92 | +New library functions |
| 93 | +--------------------- |
| 94 | + |
| 95 | +* `logrange(start, stop; length)` makes a range of constant ratio, instead of constant step ([#39071]). |
| 96 | +* The new `isfull(c::Channel)` function can be used to check if `put!(c, some_value)` will block ([#53159]). |
| 97 | +* `waitany(tasks; throw=false)` and `waitall(tasks; failfast=false, throw=false)` which wait for multiple tasks |
| 98 | + at once ([#53341]). |
| 99 | +* `uuid7()` creates an RFC 9652 compliant UUID with version 7 ([#54834]). |
| 100 | +* `insertdims(array; dims)` inserts singleton dimensions into an array --- the inverse operation of |
| 101 | + `dropdims` ([#45793]). |
| 102 | +* A new `Fix` type generalizes `Fix1/Fix2` for fixing a single argument ([#54653]). |
| 103 | +* `Sys.detectwsl()` tests whether Julia is running inside WSL at runtime ([#57069]). |
| 104 | + |
| 105 | +New library features |
| 106 | +-------------------- |
| 107 | + |
| 108 | +* `escape_string` takes additional keyword arguments `ascii=true` (to escape all non-ASCII characters) and |
| 109 | + `fullhex=true` (to require full 4/8-digit hex numbers for u/U escapes, e.g. for C compatibility) ([#55099]). |
| 110 | +* `tempname` can now take a suffix string to allow the file name to include a suffix and include that suffix in |
| 111 | + the uniquing checking ([#53474]). |
| 112 | +* `RegexMatch` objects can now be used to construct `NamedTuple`s and `Dict`s ([#50988]). |
| 113 | +* `Lockable` is now exported ([#54595]). |
| 114 | +* `Base.require_one_based_indexing` and `Base.has_offset_axes` are now public ([#56196]). |
| 115 | +* New `ltruncate`, `rtruncate` and `ctruncate` functions for truncating strings to text width, accounting for |
| 116 | + char widths ([#55351]). |
| 117 | +* `isless` (and thus `cmp`, sorting, etc.) is now supported for zero-dimensional `AbstractArray`s ([#55772]). |
| 118 | +* `invoke` now supports passing a `Method` instead of a type signature ([#56692]). |
| 119 | +* `invoke` now supports passing a `CodeInstance` instead of a type, which can enable certain compiler plugin |
| 120 | + workflows ([#56660]). |
| 121 | +* `Timer(f, ...)` will now match the stickiness of the parent task when creating timer tasks, which can be |
| 122 | + overridden by the new `spawn` keyword argument. This avoids the issue where sticky tasks (i.e. `@async`) |
| 123 | + make their parent sticky ([#56745]). |
| 124 | +* `Timer` now has readable `timeout` and `interval` properties, and a more descriptive `show` method ([#57081]). |
| 125 | +* `sort` now supports `NTuple`s ([#54494]). |
| 126 | +* `map!(f, A)` now stores the results in `A`, like `map!(f, A, A)` or `A .= f.(A)` ([#40632]). |
| 127 | + |
| 128 | +Standard library changes |
| 129 | +------------------------ |
| 130 | + |
| 131 | +* `gcdx(0, 0)` now returns `(0, 0, 0)` instead of `(0, 1, 0)` ([#40989]). |
| 132 | +* `fd` returns a `RawFD` instead of an `Int` ([#55080]). |
| 133 | + |
| 134 | +#### JuliaSyntaxHighlighting |
| 135 | + |
| 136 | +* A new standard library for applying syntax highlighting to Julia code, this uses `JuliaSyntax` and |
| 137 | + `StyledStrings` to implement a `highlight` function that creates an `AnnotatedString` with syntax highlighting |
| 138 | + applied ([#51810]). |
| 139 | + |
| 140 | +#### LinearAlgebra |
| 141 | + |
| 142 | +* `rank` can now take a `QRPivoted` matrix to allow rank estimation via QR factorization ([#54283]). |
| 143 | +* Added keyword argument `alg` to `eigen`, `eigen!`, `eigvals` and `eigvals!` for self-adjoint matrix types |
| 144 | + (i.e., the type union `RealHermSymComplexHerm`) that allows one to switch between different eigendecomposition |
| 145 | + algorithms ([#49355]). |
| 146 | +* Added a generic version of the (unblocked) pivoted Cholesky decomposition (callable via |
| 147 | + `cholesky[!](A, RowMaximum())`) ([#54619]). |
| 148 | +* The number of default BLAS threads now respects process affinity, instead of using the total number of logical |
| 149 | + threads available on the system ([#55574]). |
| 150 | +* A new function `zeroslike` is added that generates the zero elements for matrix-valued banded matrices. |
| 151 | + Custom array types may specialize this function to return an appropriate result ([#55252]). |
| 152 | +* The matrix multiplication `A * B` calls `matprod_dest(A, B, T::Type)` to generate the destination. |
| 153 | + This function is now public ([#55537]). |
| 154 | +* The function `haszero(T::Type)` is used to check if a type `T` has a unique zero element defined as `zero(T)`. |
| 155 | + This is now public ([#56223]). |
| 156 | +* A new function `diagview` is added that returns a view into a specific band of an `AbstractMatrix` ([#56175]). |
| 157 | + |
| 158 | +#### Profile |
| 159 | + |
| 160 | +* `Profile.take_heap_snapshot` takes a new keyword argument, `redact_data::Bool`, which is `true` by default. |
| 161 | + When set, the contents of Julia objects are not emitted in the heap snapshot. This currently only applies to |
| 162 | + strings ([#55326]). |
| 163 | +* `Profile.print()` now colors Base/Core/Package modules similarly to how they are in stacktraces. |
| 164 | + Also paths, even if truncated, are now clickable in terminals that support URI links |
| 165 | + to take you to the specified `JULIA_EDITOR` for the given file & line number ([#55335]). |
| 166 | + |
| 167 | +#### REPL |
| 168 | + |
| 169 | +* Using the new `usings=true` feature of the `names()` function, REPL completions can now |
| 170 | + complete names visible via `using` ([#54610]). |
| 171 | +* REPL completions can now complete input lines like `[import|using] Mod: xxx|` e.g. |
| 172 | + complete `using Base.Experimental: @op` to `using Base.Experimental: @opaque` ([#54719]). |
| 173 | +* The REPL will now warn if it detects a name is being accessed via a module which does not define it (nor has |
| 174 | + a submodule which defines it), and for which the name is not public in that module. For example, `map` is |
| 175 | + defined in Base, and executing `LinearAlgebra.map` in the REPL will now issue a warning the first time it |
| 176 | + occurs ([#54872]). |
| 177 | +* When the result of a REPL input is printed, the output is now truncated to 20 KiB. |
| 178 | + This does not affect manual calls to `show`, `print`, etc. ([#53959]). |
| 179 | +* Backslash completions now print the respective glyph or emoji next to each matching backslash shortcode ([#54800]). |
| 180 | + |
| 181 | +#### Test |
| 182 | + |
| 183 | +* A failing `DefaultTestSet` now prints to screen the random number generator (RNG) of the failed test, to help |
| 184 | + reproducing a stochastic failure which only depends on the state of the RNG. |
| 185 | + It is also possible seed a test set by passing the `rng` keyword argument to `@testset`: |
| 186 | + ```julia |
| 187 | + using Test, Random |
| 188 | + @testset rng=Xoshiro(0x2e026445595ed28e, 0x07bb81ac4c54926d, 0x83d7d70843e8bad6, 0xdbef927d150af80b, 0xdbf91ddf2534f850) begin |
| 189 | + @test rand() == 0.559472630416976 |
| 190 | + end |
| 191 | + ``` |
| 192 | + |
| 193 | +#### InteractiveUtils |
| 194 | + |
| 195 | +* New macros `@trace_compile` and `@trace_dispatch` for running an expression with |
| 196 | + `--trace-compile=stderr --trace-compile-timing` and `--trace-dispatch=stderr` respectively enabled ([#55915]). |
| 197 | + |
| 198 | +External dependencies |
| 199 | +--------------------- |
| 200 | + |
| 201 | +* The terminal info database, `terminfo`, is now vendored by default, providing a better |
| 202 | + REPL user experience when `terminfo` is not available on the system. Julia can be built |
| 203 | + without vendoring the database using the Makefile option `WITH_TERMINFO=0` ([#55411]). |
| 204 | + |
| 205 | +Tooling Improvements |
| 206 | +-------------------- |
| 207 | + |
| 208 | +* A wall-time profiler is now available for users who need a sampling profiler that captures tasks regardless |
| 209 | + of their scheduling or running state. This type of profiler enables profiling of I/O-heavy tasks and helps |
| 210 | + detect areas of heavy contention in the system ([#55889]). |
| 211 | + |
| 212 | +<!--- generated by NEWS-update.jl: --> |
| 213 | +[#39071]: https://github.com/JuliaLang/julia/issues/39071 |
| 214 | +[#40632]: https://github.com/JuliaLang/julia/issues/40632 |
| 215 | +[#40989]: https://github.com/JuliaLang/julia/issues/40989 |
| 216 | +[#45793]: https://github.com/JuliaLang/julia/issues/45793 |
| 217 | +[#49355]: https://github.com/JuliaLang/julia/issues/49355 |
| 218 | +[#50988]: https://github.com/JuliaLang/julia/issues/50988 |
| 219 | +[#51149]: https://github.com/JuliaLang/julia/issues/51149 |
| 220 | +[#51810]: https://github.com/JuliaLang/julia/issues/51810 |
| 221 | +[#52103]: https://github.com/JuliaLang/julia/issues/52103 |
| 222 | +[#52999]: https://github.com/JuliaLang/julia/issues/52999 |
| 223 | +[#53159]: https://github.com/JuliaLang/julia/issues/53159 |
| 224 | +[#53341]: https://github.com/JuliaLang/julia/issues/53341 |
| 225 | +[#53415]: https://github.com/JuliaLang/julia/issues/53415 |
| 226 | +[#53474]: https://github.com/JuliaLang/julia/issues/53474 |
| 227 | +[#53515]: https://github.com/JuliaLang/julia/issues/53515 |
| 228 | +[#53664]: https://github.com/JuliaLang/julia/issues/53664 |
| 229 | +[#53687]: https://github.com/JuliaLang/julia/issues/53687 |
| 230 | +[#53742]: https://github.com/JuliaLang/julia/issues/53742 |
| 231 | +[#53959]: https://github.com/JuliaLang/julia/issues/53959 |
| 232 | +[#54107]: https://github.com/JuliaLang/julia/issues/54107 |
| 233 | +[#54283]: https://github.com/JuliaLang/julia/issues/54283 |
| 234 | +[#54494]: https://github.com/JuliaLang/julia/issues/54494 |
| 235 | +[#54504]: https://github.com/JuliaLang/julia/issues/54504 |
| 236 | +[#54595]: https://github.com/JuliaLang/julia/issues/54595 |
| 237 | +[#54609]: https://github.com/JuliaLang/julia/issues/54609 |
| 238 | +[#54610]: https://github.com/JuliaLang/julia/issues/54610 |
| 239 | +[#54619]: https://github.com/JuliaLang/julia/issues/54619 |
| 240 | +[#54653]: https://github.com/JuliaLang/julia/issues/54653 |
| 241 | +[#54662]: https://github.com/JuliaLang/julia/issues/54662 |
| 242 | +[#54707]: https://github.com/JuliaLang/julia/issues/54707 |
| 243 | +[#54719]: https://github.com/JuliaLang/julia/issues/54719 |
| 244 | +[#54800]: https://github.com/JuliaLang/julia/issues/54800 |
| 245 | +[#54834]: https://github.com/JuliaLang/julia/issues/54834 |
| 246 | +[#54872]: https://github.com/JuliaLang/julia/issues/54872 |
| 247 | +[#55047]: https://github.com/JuliaLang/julia/issues/55047 |
| 248 | +[#55080]: https://github.com/JuliaLang/julia/issues/55080 |
| 249 | +[#55099]: https://github.com/JuliaLang/julia/issues/55099 |
| 250 | +[#55252]: https://github.com/JuliaLang/julia/issues/55252 |
| 251 | +[#55326]: https://github.com/JuliaLang/julia/issues/55326 |
| 252 | +[#55335]: https://github.com/JuliaLang/julia/issues/55335 |
| 253 | +[#55351]: https://github.com/JuliaLang/julia/issues/55351 |
| 254 | +[#55411]: https://github.com/JuliaLang/julia/issues/55411 |
| 255 | +[#55537]: https://github.com/JuliaLang/julia/issues/55537 |
| 256 | +[#55574]: https://github.com/JuliaLang/julia/issues/55574 |
| 257 | +[#55763]: https://github.com/JuliaLang/julia/issues/55763 |
| 258 | +[#55772]: https://github.com/JuliaLang/julia/issues/55772 |
| 259 | +[#55793]: https://github.com/JuliaLang/julia/issues/55793 |
| 260 | +[#55848]: https://github.com/JuliaLang/julia/issues/55848 |
| 261 | +[#55889]: https://github.com/JuliaLang/julia/issues/55889 |
| 262 | +[#55915]: https://github.com/JuliaLang/julia/issues/55915 |
| 263 | +[#56175]: https://github.com/JuliaLang/julia/issues/56175 |
| 264 | +[#56196]: https://github.com/JuliaLang/julia/issues/56196 |
| 265 | +[#56223]: https://github.com/JuliaLang/julia/issues/56223 |
| 266 | +[#56320]: https://github.com/JuliaLang/julia/issues/56320 |
| 267 | +[#56346]: https://github.com/JuliaLang/julia/issues/56346 |
| 268 | +[#56660]: https://github.com/JuliaLang/julia/issues/56660 |
| 269 | +[#56692]: https://github.com/JuliaLang/julia/issues/56692 |
| 270 | +[#56745]: https://github.com/JuliaLang/julia/issues/56745 |
| 271 | +[#56925]: https://github.com/JuliaLang/julia/issues/56925 |
| 272 | +[#57069]: https://github.com/JuliaLang/julia/issues/57069 |
| 273 | +[#57081]: https://github.com/JuliaLang/julia/issues/57081 |
| 274 | +[#57087]: https://github.com/JuliaLang/julia/issues/57087 |
| 275 | +[#57109]: https://github.com/JuliaLang/julia/issues/57109 |
| 276 | + |
1 | 277 | Julia v1.11 Release Notes
|
2 | 278 | ========================
|
3 | 279 |
|
|
0 commit comments