Julia Programming Language 1.8 Release

The release of the programming language Julia 1.8 is available, which combines such qualities as high performance, support for dynamic typing and built-in tools for parallel programming. The syntax of Julia is close to MATLAB, with some elements borrowed from Ruby and Lisp. The string manipulation method is reminiscent of Perl. The project code is distributed under the MIT license.

Key features of the language:

  • High performance: one of the key goals of the project is to achieve performance close to C programs. The Julia compiler is based on the LLVM project and generates efficient native machine code for many target platforms;
  • Support for various programming paradigms, including elements of object-oriented and functional programming. The standard library provides functions for asynchronous I/O, process management, logging, profiling, and package management, among other things;
  • Dynamic typing: The language does not require explicit definition of types for variables, by analogy with scripting programming languages. Supports interactive mode;
  • Optional ability to explicitly specify types;
  • Syntax that is excellent for numerical calculations, scientific calculations, machine learning systems and data visualization. Support for many numeric data types and tools for parallelizing calculations.
  • Ability to directly call functions from C libraries without additional layers.

Major changes in Julia 1.8:

  • New language features
    • The fields of a mutable struct can now be annotated as constants to prevent them from being changed and allow for optimization.
    • Type annotations can be added to global variables.
    • Empty n-dimensional arrays can be created using multiple semicolons inside square brackets, for example "[;;;]" creates an array of 0x0x0.
    • Try blocks can now optionally have an else block that executes right after the main body if no errors were thrown.
    • @inline and @noinline can be placed inside a function body, allowing an anonymous function to be annotated.
    • @inline and @noinline can now be applied to a function in a call site or block to force the inclusion (or not inclusion) of the corresponding function calls.
    • βˆ€, βˆƒ, and βˆ„ are allowed as identifier characters.
    • Added support for the Unicode 14.0.0 specification.
    • the Module(:name, false, false) method can be used to create a module that does not contain names, does not import Base or Core, and does not contain a reference to itself.
  • Language changes
    • Newly created Task objects (@spawn, @async, etc.) now have world_age for methods from the parent Task when they are created to optimize their execution. The previous activation option is available using the Base.invokelatest method.
    • Unicode unbalanced bidirectional formatting directives are now prohibited in strings and comments to avoid injections.
    • Base.ifelse is now defined as a generic function rather than a built-in one, allowing packages to extend its definition.
    • Every assignment to a global variable now first goes through a call to convert(Any, x) or convert(T, x) if the type T was declared for the global variable. Before using global variables, make sure that the invariant convert(Any, x) === x is always true, otherwise it may lead to unexpected behavior.
    • Built-in functions are now similar to generic functions and can be programmatically enumerated using methods.
  • Compiler/Runtime Improvements
    • Boot time reduced by about 25%.
    • The LLVM-based compiler has been separated from the runtime library into a new library, libjulia-codegen. It is loaded by default, so there shouldn't be any changes in normal use. In deployments that don't need a compiler (such as system images that have all the required code precompiled), this library (and its LLVM dependency) can simply be omitted.
    • Conditional type inference is now possible by passing an argument to a method. For example, for Base.ifelse(isa(x, Int), x, 0) returns ::Int even if the type of x is unknown.
    • SROA (Scalar Replacement of Aggregates) improved: excludes getfield calls with constant global fields, excludes mutable structures with uninitialized fields, improves performance and handling of nested getfield calls.
    • Type inference tracks various effectsβ€”side effects and non-dropping. Constant propagation is taken into account, which significantly improves compile-time performance. In some cases, for example, calls to functions that cannot be inlined but do not affect the result will be discarded at runtime. Rules for effects can be overwritten manually using the Base.@assume_effects macro.
    • Precompilation (with explicit precompilation directives or defined workloads) now saves more type-specific code, resulting in faster first run times. Any new method/type combinations required by your package, no matter where those methods were defined, can now be cached in the precompile file if they are called by a method that belongs to your package.
  • Command line parameter changes
    • The default behavior for monitoring @inbounds declarations is now the auto option in "--check-bounds=yes|no|auto".
    • New "--strip-metadata" option to remove docstrings, source location information, and local variable names when creating a system image.
    • New "--strip-ir" option for compiler to remove intermediate representation of source code when compiling a system image. The resulting image will only work if "--compile=all" is used, or if all the required code is pre-compiled.
    • If the "-" character is specified instead of the file name, then the executable code is read from the standard input stream.
  • Multithreading Support Changes
    • Threads.@threads by default uses the new scheduling option :dynamic, which differs from the previous mode in that iterations will be scheduled dynamically across available worker threads rather than being assigned to each thread. This mode allows for better distribution of nested loops with @spawn and @threads.
  • New library functions
    • eachsplit(str) to execute split(str) multiple times.
    • allequal(itr) to check if all elements in an iterator are equal.
    • hardlink(src, dst) can be used to create hard links.
    • setcpuaffinity(cmd, cpus) to match the processor core to the running processes.
    • diskstat(path=pwd()) to get disk statistics.
    • New @showtime macro to display both the string being evaluated and the @time report.
    • LazyString and lazy"str" ​​macro are added to support lazy building of error messages in error paths.
    • Fixed a concurrency issue in Dict and other derived objects such as keys(::Dict), values(::Dict) and Set. Iteration methods can now be called on a dictionary or set, as long as there are no calls that modify the dictionary or set.
    • @time and @timev now have an optional description to allow you to annotate the time reporting source, for example. @time "Evaluating foo" foo().
    • range takes either stop or length as its only keyword argument.
    • precision and setprecision now accept base as a keyword
    • TCP socket objects now provide a closewrite method and support the use of half-open mode.
    • extrema now accepts an init argument.
    • Iterators.countfrom now accepts any type that defines a + method.
    • @time now allocates % of the time spent recompiling methods with changed types.
  • Standard library changes
    • Keys with a value of Nothing are now removed from the environment in addenv.
    • Iterators.reverse (and therefore last) supports eachline.
    • The length function for ranges of certain types no longer checks for integer overflow. A new function, checked_length, is available, which contains bit-carry control logic. If necessary, use SaferIntegers.jl to build the range type.
    • The Iterators.Reverse iterator implements the inversion of eachindex, if possible.
  • Package manager
    • New indicators βŒƒ and βŒ… next to packages in the "pkg>" status that have new versions available. βŒ… indicates that new versions cannot be installed.
    • New outdated::Bool argument to Pkg.status ( --outdated or -o in REPL mode) to show information about previous version packages.
    • New compat::Bool argument to Pkg.status (-compat or -c in REPL mode) to show any [compat] entries in Project.toml.
    • New "pkg>compat" (and Pkg.compat) mode for setting project compatibility entries. Provides an interactive editor via "pkg>compat" or direct entry control via "pkg>Foo 0.4,0.5" which can load current entries via tab completion. That is "pkg> compat Fo ' is automatically padded to 'pkg > Foo 0.4,0.5' so that an existing entry can be edited.
    • Pkg now only tries to download packages from a package server if the server is monitoring the registry that contains the package.
    • Pkg.instantiate will now issue a warning when Project.toml is out of sync with Manifest.toml. It does this based on the hash of the project's deps and compat entries (other fields are ignored) in the manifest when it resolves, so that any change to the Project.toml deps or compat entries can be detected without re-resolution.
    • If "pkg>add" cannot find a package with the given name, it will now suggest packages with similar names that can be added.
    • The version of julia stored in the manifest no longer includes the build number, i.e. master will now be written as 1.9.0-DEV.
    • Aborting the "pkg>" test will now be detected more consistently, and will correctly return to the REPL.
  • InteractiveUtils
    • New @time_imports macro to report time spent importing packages and their dependencies, highlighting compile and recompile time as a percentage of imports.
  • Linear algebra
    • The BLAS submodule now supports the level-2 BLAS functions of spr!.
    • The LinearAlgebra.jl standard library is now completely independent of SparseArrays.jl both in terms of source code and unit testing. As a consequence, sparse arrays are no longer returned (implicitly) by methods from LinearAlgebra applied to Base or LinearAlgebra objects. In particular, this leads to the following breaking changes:
      • Concatenations using special "sparse" matrices (e.g. diagonal) now return dense matrices; As a consequence, the fields D1 and D2 of SVD objects created by getproperty calls are now dense matrices.
      • The similar(::SpecialSparseMatrix, ::Type, ::Dims) method returns a dense null matrix. As a consequence, the products of two-, three-, and symmetric tridiagonal matrices with each other lead to the generation of a dense matrix. Also, building similar three-argument matrices from special "sparse" matrices from (non-static) matrices now fails due to "zero(::Type{Matrix{T}})".
  • printf
    • %s and %c now uses the textwidth argument to format the width.
  • Profile
    • CPU usage profiling now records metadata, including threads and tasks. Profile.print() has a new groupby argument that allows you to group threads, tasks or nested threads/tasks, tasks/threads, as well as threads and tasks arguments to provide filtering. In addition, usage percentage is now reported either as a total or per thread, depending on whether the thread is idle or not in each sample. Profile.fetch() includes the new default metadata. For backward compatibility with external consumers of profiling data, it can be omitted by passing include_meta=false.
    • The new Profile.Allocs module allows you to profile memory allocations. A stack trace is recorded, the type and size of each memory allocation, and the sample_rate argument allows a configurable number of allocations to be skipped, reducing performance overhead.
    • Fixed Duration Processor Profiling can now be run by the user while running tasks without first loading the profile, and the report will be displayed at run time. On MacOS and FreeBSD press ctrl-t or call SIGINFO. For other platforms, enable SIGUSR1, i.e. % kill -USR1 $julia_pid. This is not available on Windows.
  • REPL
    • RadioMenu now supports additional keyboard shortcuts for direct selection of options.
    • The sequence "?(x, y" followed by pressing TAB displays all the methods that can be called with arguments x, y, .... (A space at the beginning prevents you from entering help mode). "MyModule.?(x, y ' restricts the search to 'MyModule'. Pressing TAB requires at least one argument to be of a type more specific than Any. Or use SHIFT-TAB instead of TAB to allow any compatible methods.
    • The new global variable err allows you to get the last exception, similar to the behavior of ans with the last response. Typing err reprints the information about the exception.
  • SparseArrays
    • The SparseArrays code has been moved from the Julia repository to the external SparseArrays.jl repository.
    • The new concatenation functions sparse_hcat, sparse_vcat, and sparse_hvcat return a SparseMatrixCSC type regardless of the input argument types. It became necessary to unify the matrix gluing mechanism after the separation of the LinearAlgebra.jl and SparseArrays.jl code.
  • Logging
    • The standard logging levels BelowMinLevel, Debug, Info, Warn, Error, and AboveMaxLevel are now exported from the standard Logging library.
  • Unicode
    • Added isequal_normalized function to check Unicode equivalence without explicitly building normalized strings.
    • The Unicode.normalize function now accepts the chartransform keyword, which can be used to provide custom character mappings, and a Unicode.julia_chartransform function is provided to reproduce the mapping used when the Julia parser normalizes identifiers.
  • Test
    • '@test_throws "some message" triggers_error()' can now be used to check if the displayed error text contains "some message", regardless of the specific exception type. Regular expressions, lists of strings, and matching functions are also supported.
    • @testset foo() can now be used to create a test set from a given function. The test case name is the name of the function to be called. The called function can contain @test and other @testset definitions, including those for calls to other functions, while recording all intermediate test results.
    • TestLogger and LogRecord are now exported from the Test standard library.
  • Distributed
    • SSHManager now supports csh/tcsh wrapped worker threads via the addprocs() method and the shell=:csh parameter.
  • Other changes
    • GC.enable_logging(true) can be used to log each garbage collection operation with the time and amount of memory collected.

Source: opennet.ru

Add a comment