8 ms·
Sustainability with Rust
- sgt 5y agoGetting more intrigued by Rust by the day. Mostly I use Java, Python, JS, some C#. Some golang. But Rust looks like it may actually be a language of the future.
- tialaramex 5y agoIt's a nice language, the first language where having learned it I really wanted to rewrite my existing code in it. If you enjoy learning languages (you listed five) it isn't hard to play around with some Rust and see if you like it, the entry "price" in terms of time and effort is minimal, the tools even by default generate a Hello, World example so you don't have that intro-to-Java moment where there's like eight lines of inexplicable boilerplate to copy from the slides before you can print a word on the screen (what is "Public static void" and what are "String[] args" ?) But it isn't a panacea, all the languages you list are Garbage Collected, so for you Rust would be a crash course in ownership / lifetimes. If you write enough of the languages you mentioned you might have touched on this, a database handle for example might have a distinct lifetime, the IDisposable interface in C# is in this ballpark, you may have some clue. In Rust this gets real immediately for even mundane seeming objects like a String (the mutable string type), and you may find that it's more productive to do work where you're unclear about the object lifetimes in a garbage collected language where it isn't your problem. Or you might find it all makes perfect sense and you wonder why anybody wasted their time with these GC languages. People vary.
- Abishek_Muthian 5y agoThanks for a comprehensive comparison. > you may find that it's more productive to do work where you're unclear about the object lifetimes in a garbage collected language where it isn't your problem. This is exactly why I haven't ventured into Rust yet. But lately I've taken interest in WASM and HW programming. I write in Go-WASM, But have realized that concurrency prowess of Go is irrelevant in WASM as threads are not implemented yet, More over it's a recipe for getting the UI thread blocked. And GC languages are generally a pain on HW with low memory. Is Rust worth the effort for writing WASM? Thereby gaining the necessary skills to apply in HW systems programming?
- deleted 5y ago[deleted]
- aaaaaaaaaaab 5y agoAh yes, we'll save the planet by writing web services in Rust, which serve inefficient, bloated webapps to billions people, with browsers constantly spinning the CPU near thermal shutdown... If you want to save energy, write small software. Small, local, self-contained software. Not everything has to be a webapp. In fact, most things shouldn't.
- Abishek_Muthian 5y ago> Not everything has to be a webapp. In fact, most things shouldn't. And be at the mercy of monopolies.
- sodality2 5y agoWASM is more efficient than JS...
- culi 5y agoI think they were just pointing out that software architecture will usually make a much bigger impact on efficiency and energy usage than language choice A bloated app is wasteful no matter what language its in
- sodality2 5y agoAh, okay, that makes sense :D I agree
- habibur 5y ago> WASM is more efficient than JS... Last time I checked it wasn't. That's a few years back. I would be really happy if it is now.
- Jcampuzano2 5y agoIt highly depends on what the use case is. For most use cases JS is still more performant than WASM unless you're doing a lot of very heavy number crunching which the vast majority of WebApps aren't. Browser vendors have done a ton to make JS fast.
- kennywinker 5y agohttps://en.m.wikipedia.org/wiki/Jevons_paradox https://en.m.wikipedia.org/wiki/Jevons_paradox The more efficient you make it the cheaper it is to use, the cheaper it is to use the more people use it. Efficiency just creates more consumption. You can’t “efficiency” your way out of climate change. Sorry.
- culi 5y agoI see Jevons' effect touted around a lot as if it's a law of nature when in reality it's just a name given an effect observed in very specific instances Even within economics it's treated as a rare market effect and not as a given eventuality
- kennywinker 5y agoIt’s literally just a special case of the idea of price elasticity, a pretty core and uncontroversial idea in economics. For many (but not all) goods - if the price goes up, demand goes down. If the price goes down (due to efficiency improvements) the demand goes up. If overall resource consumption stays the same or increases, then boom: Jevon’s paradox. And experience shows me that’s the norm, not an exception.
- patrec 5y agoHave you heard of computers? Do you consider the development of computing power per Watt vs the total power consumed for computing over the last 70 years as an example of this rare market effect?
- vaylian 5y agoI agree that it's not a law of nature or economics, but it is a trap that we can fall into and that is why we have to be sceptical when we talk about technological solutions. Any efforts that try to make a harmful process less harmful can give a worse end result, because the improved processes will be used more than before because of efficiency gains.
- ReactiveJelly 5y agoSounds like the same story as risk compensation. "If you let people wear seat belts, they'll drive recklessly and die more." I don't believe it for the same reasons. Though I agree that what we actually need for climate change is a seemingly-impossible amount of political coordination. A global pollution tax (not just on CO2) which no country or state can race to the bottom to escape. So many people are categorically "anti-globalist" (I don't know what this means, but that's the sentiment I feel from them) that I have no idea if we can pull it off.
- allisdust 5y agoSo finally the greening of programming languages! Kind of hard to argue with the article's premise. Though all languages aren't equal for all tasks. For example, its hard to use Rust for web projects because the ecosystem isn't mature enough. May be there should be investments into Rust ecosystem from pro-environment groups. PS: that Go memory usage is incredible. Why is it so low when compared with even 'C'.
- scottlamb 5y ago> May be there should be investments into Rust ecosystem from pro-environment groups. Meh, I think they have better ways to spend their limited resources than putting them into something Amazon is also investing in. > PS: that Go memory usage is incredible. Why is it so low when compared with even 'C'. That study has been posted here and a bunch of other places and just isn't that reliable. It's based on The Computer Language Benchmarks Game. Some of the implementations are painstakingly optimized with SIMD and sophisticated algorithms. Some aren’t. It’s benchmarking N different programs written in M languages (where M<N) that satisfy a given challenge, not the same program ported to N languages. Which languages have high-quality implementations might say more about how obsessed a given language’s community is with this particular set of benchmarks and rules than the actual efficiency of the language in question. Take a look at the dramatic difference between Javascript and Typescript. Then realize that Typescript is literally the same language. Basically I think someone wrote slow-solution.ts, then someone else wrote fast-solution.js, and no one bothered to cp fast-solution.js fast-solution.ts. Edit: that said, I do think Rust is genuinely a great language when you need security and efficiency together. And Go is a great language when efficiency is not quite as important as productivity.
- bick_nyers 5y agoI've still not yet seen a proper benchmark of performance across programming languages that properly accounts for the spectrum of implementation ability that a particular engineer might have. If Leetcode published some of its statistics though it might be pretty good
- 5y ago
- zerr 5y agoWhat about the carbon footprint of development time? Or maybe it is no longer an issue due to stagnated salaries and skyrocketed profits?
- nevi-me 5y agoInteresting question, what about it? Would the incremental cost of more people learning the language mean that there'd be less output in the short term, thus offsetting the benefit of "RIIR"? Rust can be a difficult language, but I think that for most common usecases (web), we could reach reasonable proficiency in a few months/years. There's also other interesting aspects like more tooling written in Rust, benefiting some of the existing languages, with a positive benefit to development time. If there are say 1'000'000 CI JS CI jobs running at any time, and compile/transpile times are reduced from say 3 minutes to 30 seconds, would developers be more productive and thus produce more (higher energy) or complete work quicker (less energy)?
- isomel 5y agoThere is also the compilation time. So it depends if the program is meant to be run about as many time as being compiled (during development) Or if the program is compiled once, and run millions of times
- allisdust 5y agoAre there any use cases where its beneficial to compile frequently?
- lostdog 5y ago> Are there any use cases where its beneficial to compile frequently? Writing software? It's very useful to check your work. If can only verify your work slowly, then you will verify less frequently. This means you will work on a large feature but only check at the very end. This can be very inefficient, and checking for mistakes as you write code is much more efficient.
- arriu 5y agoI’m not sure how I feel about the placement of Java and C# with regards to energy efficiency related to golang. I get that they are optimizing JIT compilers and golang is not going to get any better after the compile step but this seems odd nonetheless. Anyone have more insight?
- sirwhinesalot 5y agoYou can't really trust the computer language benchmark's game. Many of the solutions there have code that's as far from idiomatic as possible (nobody would write code like that in real production applications). That said, two things: 1. Go is not particularly efficient as a language and its compiler doesn't optimize much compared to the other "efficient" language compilers (even the JIT ones). 2. These small benchmarks benefit JIT languages quite a bit since the JIT cost is barely noticeable. In large real-world apps constantly running a compiler in the back is not exactly efficient. It'll pay for itself vs interpreted languages, but never against AOT compiled ones.
- throwaway894345 5y ago> Go is not particularly efficient as a language and its compiler doesn't optimize much compared to the other "efficient" language compilers (even the JIT ones). I mean, relative to many other mainstream languages including many of the JIT languages, Go is very efficient, but a lot of that efficiency comes from the language design (e.g., idiomatic value types) such that the compiler and runtime don’t need to be as smart. Agreed that the benchmarks game is a pretty crumby measure of performance, but it typically imposes strange restrictions on Go that prevents it from showing its idiomatic performance (never mind its ceiling). For example, languages with garbage collectors aren’t allowed to preallocate memory for certain benchmarks even though that’s absolutely idiomatic in Go (because Go has value types) so you have languages with GCs optimized for languages where everything is an allocation which perform well and languages like C and Rust which are allowed to preallocate because they don’t have a GC (which is a weird criteria) and then you have Go which appears to be very slow because it’s forced to allocate in a tight loop.
- 5y ago
- mwcampbell 5y agoTangent: > Energy Efficiency in the Cloud I recently moved the infrastructure for one of my company's products, from ~10 smallish EC2 VMs, plus durable storage in RDS, EFS, and S3, to a single dedicated box at OVH with local storage and backups in S3 Glacier and rsync.net. The application stack is the same in both cases. I wonder which is more energy efficient. The OVH box has a 6-core CPU, 32 GB of RAM, two 512 GB SSDs, and two 6 TB hard drives. I suppose AWS, because of their massive scale and use of virtualization, can be more energy-efficient than OVH's comparatively low-capacity dedicated servers; notice how absurdly high the specs are on all of the EC2 bare-metal instances. On the OVH box, I set the Linux CPU frequency governor to "performance", to make sure all requests get the fastest possible response even though the box is ~98% idle. I wonder how much energy that's actually wasting. The main reason for the move was to save money. And yes, since we moved to one box, we decided we could tolerate some reduction in uptime (this is a consumer app). But I wonder what the relative costs would look like if the externalities of having that relatively low-capacity, mostly idle box to ourselves, as opposed to using several small EC2 VMs (also mostly idle), were factored in. Maybe the only really fair answer is for everyone who doesn't actually own and operate their own servers to go all serverless and be nickled and dimed for every little thing. Edit: And FWIW, no, we're not using energy-efficient programming languages at the application layer. Mostly CPython. I guess I could experiment with PyPy, and/or rewrite some of the smaller services in Rust.
- lumost 5y agoIt sounds like you had invested in a high redundancy deployment in AWS, and switched to a single host with a single DB in a colo facility given the background that you could tolerate downtime and the people time to remediate the outage. I'm curious, what made you choose to also move to a colo facility vs. allocating a single ec2 instance to act as a VPS? I'd imagine the costs would have been comparable, and you could still get automated backups/recovery with EBS + snapshots.
- mwcampbell 5y agoFair point. I was just thinking about that myself. One big reason is to avoid being charged for outgoing data transfer; with OVH, that's unmetered, with a gigabit port. Also, the OVH box, with the specs I laid out above, costs ~$150 per month. For roughly that same price on EC2, we could get an m5ad.xlarge on-demand instance, with 2 cores, 16 GB of RAM, and a 150 GB SSD. We'd have to add EBS and/or S3 (non-Glacier) storage on top of that, and as noted above, outgoing data transfer.
- arunc 5y agoIt looks like the research paper indicated in the article isn't fair. D probably fits in the top 5 languages on performance and efficiency, but it's not even in the list of languages studied.
- odiroot 5y agoI really wish D was used more widely by companies. Out of all "new C" propositions, this is the one that appeals to me the most. But it seems a bit counter-productive to commit yourself to it, since it's not gonna help you get a good job.
- throwaway923432 5y ago
- victor106 5y agoI hope someday in the near future AWS Lambda supports Rust as a first class language.
- ncmncm 5y agoAny analysis that seems to show C++ as 34% or 56% less energy efficient than C only demonstrates its own failure. And, any analysis that relies on such results is likewise a failure. We need read no further.
- ttfkam 5y agoIn the first chart in the article, JavaScript has an energy efficiency of 4.45 (impressive) but TypeScript's efficiency is 21.50? Is it transpiling on every run or something? Anyone have some insight on this?