跳到主要内容

41 篇文档带有标签「language」

查看所有标签

AOP

Go 没有切面语言,横切逻辑只能写成显式包装:HTTP 中间件、高阶函数装饰器、go:generate 代码生成、运行时钩子或服务网格;本页说明链的注册顺序、短路语义与缺失请求 ID、context 丢失、重复注册、生成物漂移四类故障。

AOP

JavaScript 没有 AspectJ 式的编译期织入:装饰器、Proxy、中间件、猴子补丁与运行时插桩各自负责一段横切逻辑,选型的核心是织入时机、执行顺序与不能破坏的不变量。

AOP

Python 的切面实践:装饰器在定义时如何把函数替换成包装,上下文管理器如何保证配对释放,元类与类装饰器如何介入类创建,以及 functools.wraps、叠加顺序与猴子补丁带来的可观测性与一致性代价。

AOP

Rust 没有运行期织入与注解代理,横切逻辑只能用泛型包装器、dyn 包装、宏和 tower 中间件显式组合,代价是单态化膨胀与必须自己维护调用顺序。

Async

Go 没有 async/await,异步由 goroutine、channel 与 context 组合而成;本页说明 errgroup、worker pool、取消与背压的机制,区分异步与并行,并给出 goroutine 泄漏、无缓冲死锁、取消不传播、循环变量捕获四类故障的排查路径。

Async

Java 的异步模型:CompletableFuture 的组合与陷阱、虚拟线程的调度与成本、响应式流的背压,以及执行器、超时与取消的边界。

Async

The event loop and its task queues, Promise states and combinators, async and await sequencing, timers and cancellation, and the worker and backpressure boundaries.

Async

Python 的异步模型:asyncio 事件循环如何调度协程与任务,TaskGroup 如何实现结构化并发,取消、超时与背压的语义边界,to_thread 如何隔离阻塞调用,以及 GIL 之下异步能解决与不能解决什么。

Async

async fn 被编译成惰性的 Future 状态机,执行器轮询、反应器唤醒、Pin 固定地址,取消由 drop 完成;理解这套分工才不会把阻塞调用塞进运行时。

Concept

Go 的设计取舍:少关键字、组合代替继承、显式错误、goroutine 与 GC,以及“简单但可预测”这个目标如何决定语言、运行时和工具链的边界。

Concept

Java 用静态名义类型、JVM 字节码、类加载、JIT 与 GC 组成一套运行时契约,换来跨平台与生态,代价是启动预热和内存占用。

Concept

JavaScript 的心智模型由四件事组成:一个调用栈上的单线程执行、一套运行期才检查的动态类型、一条原型委托链,以及一个由宿主驱动的事件循环;JIT 分层与 ESM/CJS 并存是这套模型的补丁,TypeScript 则在编译期把类型补回来。

Concept

Python 的工程心智模型:动态强类型与鸭子类型如何决定接口,CPython 如何把源码编译成字节码、用引用计数加分代 GC 管理对象,GIL 如何限定并行,以及打包分发为何成为主要成本。

Concept

Rust 用所有权、借用检查与 trait 抽象取代垃圾回收,在编译期证明内存与线程安全,以更陡的学习曲线和更长的编译时间换取确定性的释放时机与接近 C 的运行性能。

Concurrency

GMP 调度与 M:N 复用、goroutine 成本与生命周期、channel 的阻塞与关闭语义、select 与超时、context 取消传播、Mutex/WaitGroup/atomic、happens-before 与数据竞争、worker pool、扇出扇入与泄漏排查、pprof 剖析。

Concurrency

同一个线程上交错推进任务与真正并行是两件不同的事:事件循环的阶段与队列决定执行顺序,Worker、子进程、共享内存与背压决定能否把 CPU 工作搬出主线程。

Concurrency

The GIL, threads, processes and asyncio: which execution model fits which load, how cancellation propagates, and where blocking calls and missing backpressure break a service.

Error

error 接口、哨兵错误与自定义类型、%w 包装链、errors.Is/As/Join、panic 与 recover 的同 goroutine 边界、包设计与 internal/ 的导入约束、导入环、服务错误分类与对外错误码,以及导出标识符和弃用注释的兼容性规则、init 失败只能 panic 的处理。

Error

Java 的失败处理:受检与非受检异常的契约,try-with-resources 与抑制异常,异常链的因果关系,以及领域错误在边界上的转换。

Error

The Error family, throw and try semantics with cause chains, ESM static linking and live bindings, CJS interop, and the circular-dependency and dual-package failures that follow.

Error

Python 的错误处理:异常对象如何沿栈展开并匹配 handler,try/except/else/finally 与 with 的执行顺序,raise from 如何建立根因链,3.11 的异常组如何聚合并发失败,以及捕获、翻译与清理的边界。

Error

Rust 把失败编码进类型:Result 承载可恢复错误、Option 表示缺失、panic 留给不变量破坏,? 与 From 让错误沿调用链携带上下文向上传播。

Functions

函数作为一等值、多返回值与命名结果、变参打包、闭包捕获与 Go 1.22 的每轮循环变量、defer 的求值顺序与 panic 展开、值接收者复制与指针接收者共享、方法集与接口满足、结构体嵌入与方法提升、方法值绑定接收者的时机、init 的初始化顺序与常见风险、调用求值顺序与 nil 函数调用。

Functions

Functions as first-class values: declaration forms, parameters, lexical scope, hoisting and the temporal dead zone, closures, and the four rules that fix this at call time.

Functions

Argument binding, closures and decorators, generators, context managers, the exception contract, and the gradual type system that documents all of them.

OOP

接口值为什么不是 nil、隐式满足与方法集规则、typed nil 陷阱、类型断言与类型 switch、消费方小接口,以及泛型的类型参数、comparable 与 ~ 近似项、联合约束、实例化与类型推断、接口与泛型的选型边界和装箱成本、约束接口不能作变量类型、类型参数的编译期检查。

OOP

Java 的面向对象:类、接口、记录、枚举与密封层级的取舍,继承与组合的边界,以及分派、equals/hashCode 与脆弱基类的约束。

OOP

Objects as property bags: descriptors, getters, the prototype chain, class syntax, private fields, Symbol keys, and the Proxy and Reflect pair that intercepts every operation.

OOP

Python 的面向对象:类如何由类体执行与元类共同创建,属性查找为何先描述符后实例字典,C3 线性化如何决定 MRO 与 super 的走向,以及 dataclass、Protocol、ABC 与组合在动态分派下的分工与边界。

OOP

Traits as contracts, generics that monomorphize, and Result-based errors that make every failure part of the signature.

Syntax

Go 的语法面:25 个关键字、预声明标识符、字面量与运算符、语句形式,以及自动分号插入和版本边界带来的陷阱。

Syntax

Java 的语法面:50 个关键字、字面量与语句骨架,以及 record、sealed、模式匹配和文本块在 8/11/17/21 上的版本边界。

Syntax

The eight runtime types, the conversion and equality algorithms that connect them, numeric and string precision, and the expression and statement forms that produce them.

Syntax

Python 的语法面:35 个关键字如何划出语句边界,缩进为何是语法而不是风格,推导式、装饰器、海象运算符与 match 各自的求值规则,以及 3.8 / 3.10 / 3.11 / 3.12 的版本门槛。

Syntax

Rust 的语法把声明、模式解构与类型约束写在同一套表达式规则里,用 match 的穷尽性、? 的短路传播和生命周期标注把控制流与借用范围显式化。

Type

Go 的值模型:基本类型与零值、显式转换和类型身份、常量与 iota 的求值、string/byte/rune 的 UTF-8 边界、slice 头的 len/cap、append 扩容与别名、map 的引用语义、struct 对齐填充、指针复制语义、可比较规则,以及逃逸分析如何决定栈或堆。

Type

Nominal typing, generics and erasure, null safety and algebraic data types across Java, Kotlin and Scala.

Type

Arrays, typed arrays, Map, Set and the weak variants, the iterator and generator protocols that unify them, and the traversal forms whose differences decide correctness.

Type

How CPython compiles and executes a module, how names bind to objects, how reference counting and the cyclic GC decide a lifetime, and how protocols decide identity, equality and attribute access.

Types: Generics and Operators

Type parameters and constraints, keyof and indexed access, conditional and mapped types with infer and key remapping, template literal types, and the twenty-two built-in utility types.

Types: Narrowing

Structural typing, the assignability rules behind it, the three escape types, and the eight narrowing forms that turn a runtime check into a static guarantee.