0.为什么选择学习Julia
开源免费
性能好
自定义类型与内置类型同样高效、紧凑
为并行和分布式计算而设计
像 Shell 一样强大的管理其他进程的能力
可以直接调用C语言的函数,无需API
高效支持 Unicode, 包括且不只 UTF-8
1.变量
1.1可用变量名
变量名必须以字母(a-z 或 A-Z),下划线,或一个 Unicode 编码指针中指向比 00A0 更大的指针子集开始
首位之后的字符也包括 !和数字(0-9 和其他字符 Nd/No ),以及其他 Unicode 编码指针
关键字不能作为变量名
注意: 1.可以使用Unicode字符作为变量名 2.Julia允许重新定义build-in的常数和函数
- However, this is obviously not recommended to avoid potential confusion
julia> δ = 0.000011.0e-5julia> 안녕하세요 = "Hello""Hello"julia> piπ = 3.1415926535897...julia> pi = 3WARNING: imported binding for pi overwritten in module Main3julia> pi3julia> sqrt(100)10.0julia> sqrt = 4WARNING: imported binding for sqrt overwritten in module Main4
1.2命名规范
Names of variables are in lower case.
- 变量名使用小写字母
Word separation can be indicated by underscores (
'_'), but use of underscores is discouraged unless the name would be hard to read otherwise.- 单词间使用下划线 (‘_’``) 分隔,但不鼓励
Names of
Types andModules begin with a capital letter and word separation is shown with upper camel case instead of underscores.- 类型名首字母大写, 单词间使用驼峰式
Names of
functions andmacros are in lower case, without underscore.- 函数名和宏名使用小写字母, 不使用下划线分隔单词.
Functions that write to their arguments have names that end in
!. These are sometimes called “mutating” or “in-place” functions because they are intended to produce changes in their arguments after the function is called, not just return a value.- 修改参数的函数结尾使用 !``. 这样的函数被称为 mutating functions 或 in-place functions
