3 ms·
Does a shell really exercise the use of data structures? To my mind it seems there's very little state, and all of it in substantially simpler formats than even
by lmm 12y ago
Does a shell really exercise the use of data structures? To my mind it seems there's very little state, and all of it in substantially simpler formats than even e.g. JSON.
- chubot 12y agoYeah, probably not. In any program, if you don't care about performance, you essentially don't need anything more than hashes and arrays (what Python/Perl/Ruby/JS provide). In a shell you don't care about runtime performance because all the cost is in the invoked programs. Ironically you probably care about parsing performance more than execution performance, because parsing happens at startup and can cause latency. You will have a stack since I think shells have some form of scope, but that's pretty much an array.
- sanxiyn 12y ago> In a shell you don't care about runtime performance because all the cost is in the invoked programs. This is not strictly true. In a reasonable shell many commands will be builtin, because invoking processes for, say, echo, is slow.
- chubot 12y agoWhat you said is true, but it doesn't make what I said untrue. It could be that 99% of the statements are executed by shell builtins. But for essentially any shell script I've seen, speeding those up by 10x won't make any difference, because the real work is invoking compilers, linkers, invoking curl, tar, gzip, etc. As well as simple process creation overhead.
- hugofirth 12y agoAgreed - when I play with a language I normally like to building something like a simple Trie implementation to get a feel for the collections library. I guess a shell is a pretty good learning project though, as you can just expand its scope to touch upon most of a language's API surface area as you go: - Want to see how a language handles IO? cd, ls, mkdir and friends will give you a pretty good introduction. - Want to look at the http lib? A simple wget clone.
- JoshTriplett 12y agoRust is supposed to be a language for systems programming, and a shell seems like a good exercise for that.
- lmm 12y agoIs it? I understood it was a language for Mozilla (i.e. with the browser as a core use case) - so for very high-performance applications (those that need so much control of memory management that even Haskell is unacceptable) rather than systems per se. No?
- burntsushi 12y agoSeems like pretty nebulous territory to me (which I think means it's probably not worth splitting hairs over it). In any case, rust-lang.org says in big giant letters: "Rust is a systems programming language ..."
- JoshTriplett 12y agoWriting a browser is very much a systems programming task, including careful memory management, access to numerous platform features, implementation of a high-performance JIT and language runtime...
- lmm 12y agoIt's not really systems programming in the sense that I understand it (or in e.g. the wikipedia article). More to the point, I think a browser involves a lot more manipulation of complex data structures - even the basic DOM is more complex than anything you'd use in a shell - and this is an area in which I expect Rust to shine. So I don't think a shell provides the best opportunity to appreciate Rust's strengths.