5 ms·
As an upper performance bound for a GC language, I don't think Go will be able to surpass C# (which has stack allocation in the form of structs, ahead of time c
by seanmcdirmid 12y ago
As an upper performance bound for a GC language, I don't think Go will be able to surpass C# (which has stack allocation in the form of structs, ahead of time compilation, and many other goodies). Rust, on the other hand, has more potential as a non GC language, though at the end of the day it might be hard to tell given equivalent applications.
- andrewchambers 12y agoThe upper performance for garbage collected languages (and rust) is potentially higher than C. The reasons are non aliased pointers allow more aggressive optimization, and batched garbage collection plus memory compaction can perform better than regular mallocs. Rust still has these advantages though, time will tell. Does rust have a way to avoid bounds checks on arrays? I suppose that requires unsafe annotations.
- kibwen 12y agoRust essentially never wastes cycles on bounds checking thanks to the design of its iterators. The Servo team tells me that bounds checking has never shown up in any performance profiles.
- captaincrowbar 12y ago"Rust essentially never wastes cycles on bounds checking thanks to the design of its iterators." Can you explain this or point me to the relevant documentation or code please?
- kibwen 12y agoThe documentation on iterators describes the advantages of using iteration rather than direct indexing in a loop: http://doc.rust-lang.org/nightly/book/iterators.html http://doc.rust-lang.org/nightly/book/iterators.html The gist is that an iterator has enough information about the thing that it's iterating over that we, as library authors, can avoid unnecessary bounds checking and just perform unchecked indexing while retaining all the safety. LLVM is also surprisingly good at automatically vectorizing our iterators.
- captaincrowbar 12y agoThanks!
- higherpurpose 12y agoI wonder if after Mozilla writes Servo in Rust 1.x and Google sees how fast Servo is, even compared to its own JS engine, it will also consider writing a new JS engine in Rust 2.x (I assume, by then), as I doubt they'd use Go for that. Same for the whole browsers. Due to the safety features of Rust over C++ we might see both Firefox and Chrome be rewritten in Rust over the next 5 years.
- Ded7xSEoPKYNsDd 12y agoServo isn't a JS engine, it does make use of Firefox' SpiderMonkey, written in C++.
- adamnemecek 12y agoyou might want to check this out http://c2.com/cgi/wiki?SufficientlySmartCompiler http://c2.com/cgi/wiki?SufficientlySmartCompiler
- andrewchambers 12y agoThanks, A good page.
- pcwalton 12y ago> The reasons are non aliased pointers allow more aggressive optimization Rust's type system is all about controlling aliasing. But virtually all garbage collected languages, including Go, have much weaker aliasing guarantees than C does. At least C has "restrict". Granted, if you compile with "-fno-strict-aliasing", a C compiler will have a tougher time of alias analysis, but that isn't strictly C anymore. In any case, alias analysis here has nothing to do with garbage collection and everything to do with type safety. > Does rust have a way to avoid bounds checks on arrays? I suppose that requires unsafe annotations. In most cases using iterators will avoid them.
- gillianseed 12y ago>As an upper performance bound for a GC language, I don't think Go will be able to surpass C# I don't know how well Mono C# compares to Microsoft's version, but looking at: http://benchmarksgame.alioth.debian.org/u64q/benchmark.php?test=all&lang=go&lang2=csharp&data=u64q http://benchmarksgame.alioth.debian.org/u64q/benchmark.php?t... Shows that Go certainly beats Mono #C in these benchmarks (often by a very wide margin). From a technical standpoint I don't see any reason why Go would not be faster than C#, how would 'ahead of time compilation' bring C# a performance benefit over Go ?
- seanmcdirmid 12y agoMono is considered slow in the .net world. Lets hope the new stance on open source makes things better. Go and C# are dealing with similar constraints, there is no language design advantage in go with respect to performance, and the resources applied to implementation are similar.