7 ms·
Because you can build things like: * A faster grep ( https://github.com/BurntSushi/ripgrep https://github.com/BurntSushi/ripgrep ) * A GPU accelerated termina
by l1ambda 9y ago
Because you can build things like:
* A faster grep ( https://github.com/BurntSushi/ripgrep https://github.com/BurntSushi/ripgrep )
* A GPU accelerated terminal emulator ( https://github.com/jwilm/alacritty https://github.com/jwilm/alacritty )
* A web browser ( https://servo.org/ https://servo.org/ )
* A containerization system ( https://github.com/tailhook/vagga https://github.com/tailhook/vagga )
* An operating system ( https://github.com/redox-os/ https://github.com/redox-os/ )
* An extremely fast text editor ( https://github.com/google/xi-editor https://github.com/google/xi-editor )
And be faster and safer than C/C++.
- hacker_9 9y agoJust like with Javascript, everything must be rebuilt again!..
- drzaiusapelord 9y agoExcept Rust has incredible memory safety, without cumbersome and slow GC, and runs close to C++ speeds, unlike the heavy, wasteful, and slow frameworks you mention like Electron or HTML5. Rust is a modern C/C++ replacement, or at least tries to be. That's no mean feat.
- mseri 9y agoPlus alacritty looks great and is much faster and lighter than most other terminal emulators, ripgrep is a great replacement for grep and can be a serious improvement when you are searching through millions of lines on thousands of giant files. To mention just the two of them...
- bpicolo 9y agoI only use ripgrep these days.
- Spiritus 9y agoAlacritty is full of render issues and missing features. It's fast because it barely does anything, and doesn't even do it correct. Just check the ever growing laundry list of issues it has on Github. With that said, it's a very interesting project. Especially with regards to its rendering engine.
- wulfklaue 9y agoExcept that there are other languages like Go, Crystal, D, Nim that all offer memory safety ( thanks to there GC ), with a light GC ( like reference counting ). And based upon the same benchmarks that Rust in participates, they are close or even faster at times, with close or better memory usage. https://github.com/kostya/benchmarks https://github.com/kostya/benchmarks
- bnolsen 9y agoGCs are nondeterministic amongst other issues. Baking one into the core of a systems language likely isn't a good idea.
- pjmlp 9y agoIt worked out alright for Algol 68RS, Mesa/Cedar, Modula-2+, Modula-3, Oberon, Oberon-2, Active Oberon, Component Pascal, Sing#, System C#. Those systems failed market adoption mostly due to politics and company acquisitions than technical hurdles.
- adrianN 9y agoSome applications are easier without a GC. Embedded work comes to mind. Realtime guarantees for systems with GC are also somewhat tricky (though not impossible to achieve).
- pjmlp 9y agoTrue, but just because a systems language has a GC doesn't mean one has to use it everywhere, it is the only mechanism to allocate memory or that it has to run all the time. Modula-3 is a good example of how to support all scenarios required by a systems programming language with GC, unfortunately Compaq buying DEC followed by HP buying Compaq, killed all the work the SRC group was doing. For embedded work check the Oberon compilers sold by Astrobe for ARM Cortex-M3, Cortex-M4 and Cortex-M7, as well as, Xilinx FPGA Systems.
- rurban 9y ago
- rurban 9y agoI hope you do realize that a good GC is usually faster then refcounting, and comparing it to slow GC's does not prove anything. For fairness you need to compare Rust to D or Pony or SBCL, which are also close to C++ (even faster), plus added concurrency safety or memory safety, which can be circumvented in Rust.
- adwn 9y ago> I hope you do realize that a good GC is usually faster then refcounting, and comparing it to slow GC's does not prove anything. In idiomatic Rust code, you typically have very few reference increments/decrements, making it faster and more efficient than both, GC and traditional RC-based approaches. The reasons for this are that objects are often allocated on the stack, passed by reference (a safe pointer), and directly integrated into a larger structure, requiring fewer heap allocations and very few – if any – refcounted objects. In Rust, unlike C or C++, you can do this safely and ergonomically because Rust enforces clear and well-defined ownership semantics.
- rurban 9y agoI do know rust, their RC problems, their unsafe problems, their concurrency and locking problems and their type system problems. What is problematic is that the rust community does not care about it and still repeats wrong sentences all over. (Besides downvoting, but this just shows how much they don't care to learn)
- steveklabnik 9y agoYou haven't actually demonstrated any problems, just repeated that they exist. Unsubstantiated criticism usually gets downvoted on HN, Rust or not.
- adwn 9y ago> I do know rust, their RC problems, their unsafe problems, their concurrency and locking problems and their type system problems. Please elaborate. In particular, what RC and concurrency problems?
- freyr 9y agoYeah, hard to imagine that things can improve over time!
- baq 9y agotry ripgrep, it'll blow your socks off.
- majewsky 9y agoWhat makes ripgrep fast (AFAIK) is mainly using mmap() instead of open()/read() to read files, and relying on Rust's regex library that compiles regexes to DFAs which can run in linear time. Those are things that you can do just as well in C. To witness, https://github.com/ggreer/the_silver_searcher https://github.com/ggreer/the_silver_searcher (aka "ag") is about as fast as ripgrep, but written in C. This is not to say that Rust does not have benefits. But the benefit is not "speed", but "speed plus security".
- bpicolo 9y agoHere's a much more thorough post on why it's fast. mmap is only a small part of it (a bunch of the grep implementations mmap) http://blog.burntsushi.net/ripgrep/ http://blog.burntsushi.net/ripgrep/
- j1f4 9y agoThat's a great blog post. The `linux_literal` section is particularly interesting re: mmap.
- joshuata 9y agoRipgrep only uses mmap() when it is searching very few files. For anything beyond that it uses intermediate buffers.
- pcwalton 9y agoI switched from ag to rg a while ago. The speed benefits are noticeable.
- burntsushi 9y ago> Those are things that you can do just as well in C. [..] But the benefit is not "speed", but "speed plus security". But nobody said otherwise? I don't understand your point. Speed + safety is indeed precisely the point. I would implore you to do your own comparative analysis by looking at the types of bugs reported for these search tools. (I can't do this for you. If I could, I would.) > What makes ripgrep fast (AFAIK) is mainly using mmap() instead of open()/read() to read files, I think you're confused. This is what the author of the silver searcher has claimed for a long time, but with ripgrep, it's actually precisely the opposite. When searching a large directory of files, memory mapping them has so much overhead that reading files into intermediate fixed size buffers is actually faster. Memory maps can occasionally be faster, but only when the size of the file is large enough to overcome the overhead. A code repository has many many small files, so memory maps do worse. (N.B. My context here is Linux. This doesn't necessarily apply to other operating systems.) > and relying on Rust's regex library that compiles regexes to DFAs which can run in linear time. There's no confusion that such things can't be done in C. GNU grep also uses a lazy DFA, for example, and is written in C. The "linear time" aspect doesn't show up too often, and none of my benchmarks[1] actually exploit that. There's a lot more to the story of how ripgrep beats the silver searcher. "About as fast" is fairly accurate in many cases, but to stop there would be pretty sad because you'd miss out on other cool things like: - SIMD for multiple pattern matching - Heuristics for improving usage of memchr - Parallel directory iterator (all safe Rust code) - Fast multiple glob matching In many cases, this can make a big difference. Try searching the MySQL server repository, for example, and you'll find that the silver searcher isn't "about as fast" as ripgrep. (Hint: Take a peek at its .gitignore file.[2] This has nothing to do with memory maps, SIMD or linear time regex engines.) And yes, I could have done all of this in C. But it's likely I would have given up long before I finished. [1] - http://blog.burntsushi.net/ripgrep/ http://blog.burntsushi.net/ripgrep/ [2] - https://github.com/mysql/mysql-server/blob/5.7/.gitignore https://github.com/mysql/mysql-server/blob/5.7/.gitignore
- dronemallone 9y agoIs there a reason why all the above software cannot perform as "fast" or "safe" as Rust when written in other programming languages? After all, every program compiles down to machine code/assembly.
- echelon 9y agoRust is "fast" because it runs close to the bare metal, like C or C++. It doesn't feature garbage collection, many of which stop the world to clear memory. Other non-garbage collected languages (ie those with manual memory management) lack Rust's memory safety semantics and are this subject to segfaults, buffer overflow exploits, etc. Rust is extremely "safe" since it prevents these types of errors at compile time.
- dronemallone 9y agoSo why does C, for example, lack Rust's memory safety semantics? Is it something to do with the design of the language itself? Can Rust predict user input, whereas C cannot?
- proyb2 9y agoNot sure which C compilers you're referring to. If you mean Clang which is also based on LLVM. https://clang.llvm.org/ https://clang.llvm.org/ Clang is a competitor to GCC.
- dronemallone 9y agoI did not mention compilers in my comment. Do you mean that if I use LLVM compile a C program then I get the same assurances as when I compile a Rust program?
- proyb2 9y agoLLVM is a compiler construction, not a compiler. If I understand, no languages offer the same assurances, I remember GodBolt is a nice way to explore how it's compile to assembly code you can compare. https://rust.godbolt.org https://rust.godbolt.org https://gcc.godbolt.org https://gcc.godbolt.org https://go.godbolt.org https://go.godbolt.org
- arunmu 9y agoIts only fair to also write "Also be slower but definitely more safer than C++".
- steveklabnik 9y agoRust should not be slower. If so, it's a bug. Please file them.
- swah 9y agoOfftopic: using symbols make it hard to read for an outsider https://github.com/BurntSushi/ripgrep/blob/master/src/pathutil.rs#L17 https://github.com/BurntSushi/ripgrep/blob/master/src/pathut...
- AsyncAwait 9y agoThese symbols are in fact very important in Rust and reading the book makes their usage very clear. I get that it may be hard to read if you're not familiar with the language, but so is * and & if you're not familiar with them in the context of pointers. Sometimes however, a language feature calls for a special symbol as is the case here. The usage of apostrophes in English also doesn't make much sense for an outsider, but they're very much a necessary part of the language and very easy to use if you're an English speaker. Same applies for Rust.
- dorfsmay 9y agoTo add to that point... I'm a beginner to Rust and this was my exact reaction (Too much complex syntax!!), but one conclusion I have come to since, is that one of the really nice thing languages like Python do, is that they just don't deal with a whole bunch of CS issues (eg: everything is a reference to an object) or are very opinionated about it (ownership/lifetime is bound to scope, no way to extend/change it). By doing this, not only are the language simpler, but they also just need less symbols.