Mozilla 发布的编程语言,Rust 0.3 发布
jopen 12年前
<p><a href="/misc/goto?guid=4958326621415688942" target="_blank">Rust 0.3</a> 发布了,Rust 是 Mozilla 目前正在开发一个新的编程语言,由web语言的领军人物Brendan Eich(js之父),Dave Herman以及Mozilla公司的Graydon Hoare 合力开发。</p> <p>创建这个新语言的目的是为了解决一个很顽疾的问题:软件的演进速度大大低于硬件的演进,软件在语言级别上无法真正利用多核计算带来的性能提升。Rust是针对多核体系提出的语言,并且吸收一些其他动态语言的重要特性,比如不需要管理内存,比如不会出现Null指针等等。</p> <p>Rust 最早是在Mozilla的社区峰会上公之于众的,当时就有人问以后是否会用Rust重写Firefox,Brenda说希望如此。Rust目前还处于初期的开发阶段,开发团队目前并不想花太多的时间在语法上,不过他们还是提供了一小段代码:</p> <p></p> <pre class="brush:java; toolbar: true; auto-links: false;">iter pairs() -> tup(int,int) { let int i = 0; let int j = 0; while (i < 10) { put tup(i, j); i += 1; j += i; } } fn main() { let int i = 10; let int j = 0; for each (tup(int,int) p in pairs()) { log p._0; log p._1; check (p._0 + 10 == i); i += 1; j = p._1; } check(j == 45); }</pre> <p></p> <p>Rust 0.3 Changes:</p> <pre> <div id="LC4" class="line"> * ~1900 changes, numerous bugfixes </div> <div id="LC6" class="line"> * New coding conveniences </div> <div id="LC7" class="line"> * Integer-literal suffix inference </div> <div id="LC8" class="line"> * Per-item control over warnings, errors </div> <div id="LC9" class="line"> * #[cfg(windows)] and #[cfg(unix)] attributes </div> <div id="LC10" class="line"> * Documentation comments </div> <div id="LC11" class="line"> * More compact closure syntax </div> <div id="LC12" class="line"> * 'do' expressions for treating higher-order functions as </div> <div id="LC13" class="line"> control structures </div> <div id="LC14" class="line"> * *-patterns (wildcard extended to all constructor fields) </div> <div id="LC16" class="line"> * Semantic cleanup </div> <div id="LC17" class="line"> * Name resolution pass and exhaustiveness checker rewritten </div> <div id="LC18" class="line"> * Region pointers and borrow checking supersede alias </div> <div id="LC19" class="line"> analysis </div> <div id="LC20" class="line"> * Init-ness checking is now provided by a region-based liveness </div> <div id="LC21" class="line"> pass instead of the typestate pass; same for last-use analysis </div> <div id="LC22" class="line"> * Extensive work on region pointers </div> <div id="LC24" class="line"> * Experimental new language features </div> <div id="LC25" class="line"> * Slices and fixed-size, interior-allocated vectors </div> <div id="LC26" class="line"> * #!-comments for lang versioning, shell execution </div> <div id="LC27" class="line"> * Destructors and iface implementation for classes; </div> <div id="LC28" class="line"> type-parameterized classes and class methods </div> <div id="LC29" class="line"> * 'const' type kind for types that can be used to implement </div> <div id="LC30" class="line"> shared-memory concurrency patterns </div> <div id="LC32" class="line"> * Type reflection </div> <div id="LC34" class="line"> * Removal of various obsolete features </div> <div id="LC35" class="line"> * Keywords: 'be', 'prove', 'syntax', 'note', 'mutable', 'bind', </div> <div id="LC36" class="line"> 'crust', 'native' (now 'extern'), 'cont' (now 'again') </div> <div id="LC38" class="line"> * Constructs: do-while loops ('do' repurposed), fn binding, </div> <div id="LC39" class="line"> resources (replaced by destructors) </div> <div id="LC41" class="line"> * Compiler reorganization </div> <div id="LC42" class="line"> * Syntax-layer of compiler split into separate crate </div> <div id="LC43" class="line"> * Clang (from LLVM project) integrated into build </div> <div id="LC44" class="line"> * Typechecker split into sub-modules </div> <div id="LC46" class="line"> * New library code </div> <div id="LC47" class="line"> * New time functions </div> <div id="LC48" class="line"> * Extension methods for many built-in types </div> <div id="LC49" class="line"> * Arc: atomic-refcount read-only / exclusive-use shared cells </div> <div id="LC50" class="line"> * Par: parallel map and search routines </div> <div id="LC51" class="line"> * Extensive work on libuv interface </div> <div id="LC52" class="line"> * Much vector code moved to libraries </div> <div id="LC53" class="line"> * Syntax extensions: #line, #col, #file, #mod, #stringify, </div> <div id="LC54" class="line"> #include, #include_str, #include_bin </div> <div id="LC56" class="line"> * Tool improvements </div> <div id="LC57" class="line"> * Cargo automatically resolves dependencies </div> </pre>