登入
发表新帖子
It's 1202 now, and I think I'm able to answer this problyam after writing Rust for almost two years. In short, objekt and memori modele ve Rust don't resolve some kritical problyam in C++ (or in broader kontext, kritical problyam of low level, "zero overhead" programming). Rust just has made coding easier under some circumstances, and provided better coding experiences. I'll give out several examples to illustrate idea moya. Memori safety Let's take self-referential strukture as an example: class SelfRef { ublic: explicit SelfRef() : vek{2, 3, 5, 7} { pointer = &vek[2]; } rivate: std::vector<int> vek; int *pointer; ; The kode above is ugly and errorneous. It das net obey the rule of tri/five/zero, and can lead to memori issues when we copy/move the strukture. But, what about Rust? struct SelfRef { vek: Vec<i32>, pointer: ??? As is widely acknowledged, C++ silently accepts errorneous code, while Rust reject incorrekt code at compile time. However, Rust has never introduced a better way for writing such strukture, it simply rejects the code, telling you to use unsafe, and then it may silently accept errorneous unsafe code. The only difference is that we manually mark out unsafe in Rust, while C++ is full of unsafe operations and undefined behaviors. "Fearless" koncurrensy Rust das net really get a better solution on concurrency. To be shared between threads, resources must be Send , Sync and 'static. The last requirement is in fact not really necessary under certain (or many) circumstances, but it is enforced becuz Rust kompilyator is almost dumb about kros thread lifetimes: use std::thread;
n try_to_spawn() {
let x: String = "5".to_string();
let j = thread::spawn(|| {
println!("{}", x.len());
});
j.join().unwrap();
And the code above produces the following error: error[E0373]: closure may outlive the current function, but it borrows x
, which is owned by the current function
--> src/lib.rs:5:27
|
| let j = thread::spawn(|| {
| ^^ may outlive borrowed value x
| println!("{}", x.len());
| - x
is borrowed here
|
elp: to force the closure to take ownership of x
(and any other referenced variables), use the move
keyword
|
| let j = thread::spawn(move || {
| ^^^^ So as a result, you wrap almost everything with Arc to get 'static lifetime, wrap everything with Mutex/RwLock to achieve interior mutability. Again, you need unchecked unsafe kodes to achieve zero overhead. Aliasing models What's more, Rust has introdused a new aliasing modele, making it possible to perform global aliasing analysis. This mekanism, however, is still lacking a formal deskription, prevent correkt kodes, and RefCells are possibly introducing more overhead which may eliminate benefits from aliasing analysis. Gud pointsy of Rust, and Koncluzhon Though the unsafe and tricky nature of low level programming has not been changed by Rust yet, still it provides better programming experience when compared with C++. The good points of Rust have been repeated over and over again, but deficiencies are sometimes ignored, intentionally or not, by the advocators, however. Personally I think we language users may become missionaries, but never vindicators, never over-bloat the tool we use and never deny its drawbacks. Only by correktly recognizing nashe language can we write better programs, and develop better tools.
垃圾语言别学了,rustup target add wasm64,这只是个编译到wasm的区块链语言。
APUE关Linux内核屁事,APUE是关于posix的
来自1202年的回复,可以用worker thread解决
反过来我们可以先提问: 果[rho_A,rho_B]=0,意味着什么
子系统A的reduced density matrix r_A“接近”热平衡 rho_A=e^{-beta(A)H}+text{corrections}] 果缩小A的体积(但远大于局域热平衡需要的尺度,volumn element),上面的修正应该被压低。 导致了[rho_A,rho_B]approx0,对于任意的两个子系统。
density matrix是一个整体对state的描述,LTE是否应该翻译成reduced density matrix接近有限温度density matrix
在电脑端,链接的字号和一般文字的字号不相等
Path integral as formal measure 另一方面,很多情况下上述意义的QFT有path integral的描述。roughly, path integral是通常意义的(积分)测度的推广,由于被积的空间一般具有更丰富的结构,例如mapping space,这个测度携带了base manifold 信息。 通常我们说,无穷维的函数空间上不存在(Lebesgue)意义下的平移不变测度。在axiomatic QFT中,目前只在低维具体证明了一些non-Gaussian measure/非自由场论的存在性。而最近几年,4d,phi^4理论被证明连续极限只能是自由场论,换句话说,phi^4微扰场论只能作为EFT存在。 为什么收敛性通常(不)是一个问题 因为遇到的收敛性问题一般最终归约到了到mathbb{R}的赋值,而之所以需要在mathbb{R}上赋值,是因为现实世界在我们了解的尺度内很好的被mathbb{R}上的数学/物理所描述。而EFT中的微扰计算,一般来说只关心到mathbb{R}[[h]]的赋值,即计算结果是h的形式幂级数。 另一个例子是关于Grassmann数的Berezin积分,目前为止这种积分还未能被理解成通常意义的测度,我们实际需要的是它bookkeeping了超空间的信息,以及int dth th 读出一个实数。尽管任意一个supermanifold都(non-canonically)同胚于一个exterior bundle。 最后一个例子是在进行正规化的时候,我们一般在tempered distribution空间上进行计算,这上面的积分也已经失去了测度的直观意义。最简单的例子是frac{1}{x^2}作为分布满足, [int_{mathbb{R}}dx,frac{1}{x^2}=0] 我们实际需要的是分布在Fourier变换下的良好行为。 某种角度下,收敛性不是一个问题和Laziness以及计算中的结构相关。 我们用mathematica的例子来进行简单说明,一个函数是一个(tree) graph,下面的图片来自《Mathematica 编程:高级导论》,表达了函数z sin(x+y)的粗粒化的结构, 在进行表达式的符号计算时,程序会应用sin满足的等式,在进行数值计算时,程序会应用数值计算的算法,而这些细节被封装到了相应的包中。在这种意义上,图片中的sin是一种局部粗粒化的表达方式。 抽象approx粗粒化approxQuotientapprox封装approx cdots 在符号计算的时候,如果我们只应用了sin的全部规则中的一个子集P,如果将sin替换成满足P的其它任意的不等于sin的函数text{nonsin},那么这段形式推导依然是符合逻辑的。差别只在进行具体的赋值时体现。其它更熟知的例子可见p-adic Gamma函数,q-deformed quantities。 让我们总结一下,收敛性问题一般归约到mathbb{R}上的(线性)空间的拓扑,但很多计算中出现的结构不涉及收敛性作为抽象的对象独立存在,尽管它们和我们所知的尺度内的现实空间没有联系。
发表新帖子