Programming
正交(orthogonal)
operations change just one thing without affecting others.
编程中。正交指互相独立,不可替代,并且可以任意组合。
耦合(Coupling)
the degree of interdependence between software modules.
模块间的独立性。
内聚(Cohesion)
the degree to which the elements inside a module belong together.
模块是否向着某一统一目的而组合在一起。
原语(Primitives)
https://en.wikipedia.org/wiki/Language_primitive
In computing, language primitives are the simplest elements available in a programming language. A primitive is the smallest ‘unit of processing’ available to a programmer of a given machine, or can be an atomic element of an expression) in a language.
程序语言处理最小单元
GUI & TUI & CLI
GUI Graphic User Interface: 图形用户界面。为命令提供的带窗口和下拉菜单的用户界面
TUI Terminal User Interface/Text User Interface: 终端用户界面/ 文本用户界面。适用于 ASCII 终端的带窗口和下拉菜单的基于字符的显示。TUI 使用键盘导航(不支持鼠标)。
CLI(CLUI) Command Line (User) Interface: 命令行(用户)界面。在命令行提示符处输入的或由脚本执行的文本格式的命令和选项
Rust
Rust要求表达式返回类型一致,Rust 一切皆表达式;
if else 也是一种表达式,所以 if else 分支返回的类型也就得一致;
Rust 之所以要求函数不能返回多种类型是因为 Rust 在需要在 编译期确定返回值占用的内存大小, 显然不同类型的返回值其内存大小不一定相同.
Scalar Types
- signed integers:
i8
,i16
,i32
,i64
,i128
andisize
(pointer size) - unsigned integers:
u8
,u16
,u32
,u64
,u128
andusize
(pointer size) - floating point:
f32
,f64
char
Unicode scalar values like'a'
,'α'
and'∞'
(4 bytes each)bool
eithertrue
orfalse
- and the unit type
()
, whose only possible value is an empty tuple:()
Despite the value of a unit type being a tuple, it is not considered a compound type because it does not contain multiple values.
Compound Types
- arrays like
[1, 2, 3]
- tuples like
(1, true)
Variables can always be type annotated. Numbers may additionally be annotated via a suffix or by default. Integers default to i32
and floats to f64
. Note that Rust can also infer types from context.