Julia (编程语言)

Julia是一种高级通用[13]动态编程语言,它最初是为了满足高性能数值分析计算科学的需要而设计的,不需要解释器,速度快[14][15][16][17],也可用于客户端和服务器的Web用途[18][19]、低级系统编程或用作规约语言[20]

Julia
多范式多重派发过程式函数式元编程多阶段编程
設計者Jeff BezansonAlan EdelmanStefan KarpinskiViral B. Shah
實作者Jeff BezansonStefan KarpinskiViral B. Shah 等[1][2]
2012年2012[3]
穩定版本
1.5.3[4]
( 2020年11月9日2020-11-09
預覽版本
1.6.0-beta1[5]
( 2021年1月8日2021-01-08
實作語言JuliaCC++SchemeLLVM[6]
系统平台x86-64IA-32ARM v8(64位元)CUDAARM (32位元)PowerPC网页浏览器 (JavaScriptWebAssembly)[7]
作業系統macOSWindowsLinuxFreeBSD[8]Android[9]
許可證MIT許可證
文件扩展名.jl
網站JuliaLang.org
啟發語言

Julia设计的独特之处包括,参数多态的类型系统,完全动态语言中的类型,以及它多分派的核心编程范型。它允许并发并行分布式计算,并直接调用CFortran库而不使用粘合代码

Julia拥有垃圾回收机制[21],使用及早求值,包含了用于浮点计算、线性代数随机数生成正则表达式匹配的高效库。有许多库可以使用,其中一些(如用于快速傅里叶变换的库)已经预先捆绑在Julia里[22]

历史

一群拥有各种语言丰富编程经验的Matlab高级用户,对现有的科学计算编程工具感到不满——这些软件对自己专长的领域表现得非常棒,但在其它领域却非常糟糕。他们想要的是一个开源的软件,它要像C语言一般快速而又拥有如同Ruby动态性;要具有Lisp般真正的同像性而又有Matlab般熟悉的数学记号;要像Python般通用、像R般在统计分析上得心应手、像Perl般自然地处理字符串、像Matlab般具有强大的线性代数运算能力、像shell胶水语言的能力,易于学习而又不让真正的黑客感到无聊;还有,它应该是交互式的,同时又是编译型的。[23]

该项目大约于2009年中开始。

功能

主要用于数值计算。

特点

  • 核心语言非常小。标准库用的是Julia语言本身写的
  • 调用许多其它成熟的高性能基础代码。如线性代数随机数生成快速傅里叶变换、字符串处理。
  • 丰富的用于建立或描述对象的类型语法
  • 高性能,接近于静态编译型语言。包括用户自定义类型等
  • 为并行计算和分布式计算而设计
  • 轻量级协程
  • 优雅的可扩展的类型转换/提升
  • 支持Unicode,包括但不限于UTF-8
  • 可直接调用C函数(不需要包装或是借助特殊的API
  • 有类似shell的进程管理能力
  • 有类似Lisp以及其它元编程工具
  • 可與Jupyter notebook 一起使用

示例

生成Mandelbrot集合

function mandel(z)
    c = z
    max = 80
    for n = 1:max
        if abs(z) > 2
            return n-1
        end
        z = z^2 + c
    end
    return max
end

随机矩阵统计

using LinearAlgebra: tr
using Statistics #导入std, mean等函数

function randmatstat(t)
    n = 5
    v = zeros(t)
    w = zeros(t)
    for i = 1:t
        a = randn(n,n)
        b = randn(n,n)
        c = randn(n,n)
        d = randn(n,n)
        P = [a b c d]
        Q = [a b; c d]
        v[i] = tr((P'*P)^4)
        w[i] = tr((Q'*Q)^4)
    end
    std(v)/mean(v), std(w)/mean(w)
end

参见

参考资料

  1. . GitHub. [2020-03-24]. (原始内容存档于2021-01-23).
  2. . GitHub. [2020-03-24]. (原始内容存档于2021-01-23).
  3. . Julia website. February 2012 [2013-02-07]. (原始内容存档于2019-02-19).
  4. . Github.com. 2020-11-09 [2021-01-12]. (原始内容存档于2021-01-23).
  5. . GitHub.com. 2021-01-08 [2021-01-12] (英语).
  6. . Julia. NumFocus project. [9 December 2016]. (原始内容存档于2017-02-21). Julia's Base library, largely written in Julia itself, also integrates mature, best-of-breed open source C and Fortran libraries for ...
  7. Fischer, Keno. . 2019-07-22 [2019-07-25]. (原始内容存档于2020-11-21).
  8. . Julia. [2020-03-24]. (原始内容存档于2021-01-26).
  9. . Github. [2020-03-24]. (原始内容存档于2020-12-27).
  10. . docs.julialang.org. [2018-08-15]. (原始内容存档于2021-01-11) (英语).
  11. . GitHub. [6 December 2016]. (原始内容存档于2020-12-20).
  12. . JuliaCon. [6 December 2016]. (原始内容存档于2021-02-03). He has co-designed the programming language Scheme, which has greatly influenced the design of Julia
  13. (official website). [2018-09-22]. (原始内容存档于2017-02-21). General Purpose [..] Julia lets you write UIs, statically compile your code, or even deploy it on a webserver.
  14. Bryant, Avi. . O'Reilly Strata. 15 October 2012 [2018-09-22]. (原始内容存档于2013-05-24).
  15. Singh, Vicky. . Technotification. 23 August 2015 [2018-09-22]. (原始内容存档于2020-11-09).
  16. Krill, Paul. . InfoWorld. 18 April 2012 [2018-09-22]. (原始内容存档于2014-09-13).
  17. Finley, Klint. . Wired. 3 February 2014 [2018-09-22]. (原始内容存档于2016-12-20).
  18. . Shasi.github.io. [2017-05-31]. (原始内容存档于2016-03-04).
  19. . Node-julia.readme.io. [2017-05-31]. (原始内容存档于2020-10-21).
  20. Moss, Robert. . 26 June 2015 [29 June 2015]. (原始内容存档于2015-07-01). Airborne collision avoidance system
  21. . Groups.google.com. [2017-05-31]. (原始内容存档于2011-01-22).
  22. (now available with using FFTW in current versions; that dependency is one of many moved out of the standard library to a package because it is GPL licensed, and thus is not included in Julia 1.0 by default.) . GitHub. [2018-03-01]. (原始内容存档于2019-02-16) (英语).
  23. . [2012-04-19]. (原始内容存档于2016-01-18).

外部链接

維基教科書中的相關電子:Introducing Julia

This article is issued from Wikipedia. The text is licensed under Creative Commons - Attribution - Sharealike. Additional terms may apply for the media files.