Julia, recommended in this issue, is a high-level, high-performance dynamic language for technical computing.
Julia feature
- Quickly
- Julia was designed for high performance from the start. Julia programs are compiled through LLVM into efficient native code for multiple platforms.
- Dynamic
- Julia is dynamically typed, feels like a scripting language, and has good support for interactive use.
- Reproducible
- The reproducible environment makes it possible to recreate the same Julia environment across platforms every time using pre-built binaries.
- Composable
- Julia uses multiple dispatch as a paradigm that makes it easy to express many object-oriented and functional programming patterns. The lecture on the unreasonable effectiveness of multiple scheduling explains why it works so well.
- General
- Julia provides asynchronous I/O, metaprogramming, debugging, logging, profiling, package manager, and more. Entire applications and microservices can be built in Julia.
- Open source
- Julia is an open source project with over 1,000 contributors. It is provided under the MIT license. The source code is available on GitHub.
Julia Ecosystem
- data visualization and plotting
- data visualization has a complicated history. Drawing software is a trade-off between functionality and simplicity, speed and aesthetics, and static and dynamic interfaces.
- Build, deploy, or embed your code
- Julia makes it possible to build complete applications. Use Dash.jl to write the Web UI or QML.jl and GTK.jl to write the native UI. Extract data from various databases.
- Interact with your data
- The Julia data ecosystem provides DataFrames.jl to process data sets and perform common data operations. Csv.jl is a fast multi-threaded package for reading CSV files and is being integrated with the Arrow ecosystem.
- Scalable machine learning
- The MLJ.jl package provides a unified interface for common machine learning algorithms, including generalized linear models, decision trees, and clustering. Flux.jl and Knet.jl are powerful deep learning packages.
- Rich ecosystem of scientific computing
- Julia was designed to be very good at numerical and scientific calculations.
- Parallel and heterogeneous computing
- Julia is designed for parallelism and provides built-in primitives for parallel computing at every level: instruction level parallelism, multithreading, GPU computing, and distributed computing.
Julia differences
- The core language imposes very little; Julia Base and the standard library are written in Julia itself and include primitive operations such as integer arithmetic.
- Rich type language for constructing and describing objects, optionally for type declaration.
- Ability to define the behavior of a function by assigning multiple combinations across multiple parameter types.
- Automatically generates efficient specialized code for different parameter types.
- Good performance, close to the performance of statically compiled languages such as C.
Julia Getting started
The installation of Julia is simple, whether using pre-compiled binaries or compiling from source.
The easiest way to learn and experiment with Julia is to start an interactive session (also known as the read-eval-print loop or “REPL”) by double-clicking the Julia executable or julia running from the command line:
$ julia
_
_ _ _(_)_ | Documentation: https://docs.julialang.org
(_) | (_) (_) |
_ _ _| |_ __ _ | Type "?" for help, "]?" for Pkg help.
| | | | | | |/ _` | |
| | |_| | | | (_| | | Version 1.7.3 (2022-05-06)
_/ |\__'_|_|_|\__'_| | Official https://julialang.org/ release
|__/ |
julia> 1 + 2
3
julia> ans
3
To exit an interactive session, type CTRL-D (press both Control/^ and d), or type exit(). When running in interactive mode, julia displays a banner and prompts the user for input. Once the user enters a complete expression, such as 1 + 2, and hits Enter, the interactive session evaluates the expression and displays its value. If you enter an expression into an interactive session with a closing semicolon, its value is not displayed. The variable is bound to the value of the last evaluated expression whether or not the ans is displayed. The ans variable is bound only in an interactive session, not when the Julia code is otherwise running.
To evaluate expressions written in the source file file.jl, write include(“file.jl”).
To run the code in the file non-interactively, you can use it as the first argument to the julia command:
$ julia script.jl arg1 arg2...
As the example suggests, the following command line argument julia is interpreted as the program’s command line argument script.jl, passing ARGS in the global constant. The name of the script itself is passed in as global PROGRAM_FILE. Note that the Julia expression is also set when given using ARGS ‘option on the command line (see Help Output below), but will be empty. For example, to print the parameters provided to a script, you would do this: -ejuliaPROGRAM_FILE
$ julia -e 'println(PROGRAM_FILE); for x in ARGS; println(x); end' foo bar
foo
bar
Or you can put this code into a script and run it:
$ echo 'println(PROGRAM_FILE); for x in ARGS; println(x); end' > script.jl
$ julia script.jl foo bar
script.jl
foo
bar
The
separator can be used to separate — command-line arguments for script files from those for Julia:
$ julia --color=yes -O -- script.jl arg1 arg2..
Julia Key points
Julia Base contains a range of functions and macros suitable for performing scientific and numerical calculations, but is also as broad as many general-purpose programming languages. The growing collection of available packages provides additional functionality. Features are grouped by the following themes.
Some general notes:
- To use a Module function, import the Module using import Module, and module.fn (x) uses the function.
- Or, using Module imports all functions that export modules into the current namespace.
- By convention, start with an exclamation point (!) Ending function names modify their arguments. Some functions also have modifications (for example, sort!). And unmodified (sort) versions.
Julia runtime initialization
main()
Start with main()incli/loader_exe.c, call jl_load_repl()in cli/loader_lib.cwhich to load some libraries, The final call is repl_entrypoint()insrc/jlapi.c.
repl_entrypoint() calls libsupport_init() to set up the C library locale and initialize the “ios” library (see ios_init_stdstreams() and Legacy ios.clibrary).
Nextjl_parse_opts() is called to handle command line options. Note that jl_parse_opts() only handles options that affect code generation or early initialization. Other options are handled later by process_options()inbase/client.jl.
jl_parse_opts() Stores command line options in the global jl_options structure.
julia_init()
julia_init()intask.c is called main() and _julia_init()ininit.c.
_julia_init() starts by calling libsupport_init() again (the second time it does nothing).
restore_signals() is called to zero the signal handler mask.
jl_resolve_sysimg_location() Searches for the configuration path of the basic system image. See Building a Julia System Image.
jl_gc_init() Sets up the allocation pool and list for weak references, reserved values, and terminations.
jl_init_frontend() loads and initializes the precompiled femtolisp image containing the scanner/parser.
jl_init_types() Creates a jl_datatype_t type description object for the built-in types defined in. For example, julia.h
Serialization
Serialization.serialize – Function
serialize(stream::IO, value)
Writes any value to the stream in an opaque format so that deserialize. The read-back value will be as identical as possible to the original value. In general, if reading and writing are done by different versions of Julia, or by Julia instances with different system images, this process will not work. The Ptr value is serialized into an all-zero mode (NULL).
First writes an 8-byte identification header to the stream. To avoid writing headers, construct the aSerializer and use it as the first argument, serialize.
—END—
Open Source license: MIT license