TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Save the planet Program in C, avoid Python, Perl

91 点作者 gdrift超过 3 年前

31 条评论

wfleming超过 3 年前
I realize this argument is probably tongue-in-cheek, but if we were to take it at face value it would be interesting to factor in energy costs required to feed/house/etc. the programmers for the additional time it would take to implement a given system in C vs python, and how often would the code need to run to make it balance out?
评论 #29271757 未加载
评论 #29272697 未加载
评论 #29271976 未加载
评论 #29271720 未加载
评论 #29272075 未加载
评论 #29271758 未加载
scoofy超过 3 年前
I honestly hate headlines like this. Jokey, tongue-and-cheek takes that effectively treat environmentalism like every little bit counts. It doesn&#x27;t.<p>We are in the midst of a serious crisis, we know the reasonable solutions we should be taking to avoid catastrophe, and we are collectively choosing to ignore them. It should be treated seriously. If we&#x27;re going to joke about it, it should be dark comedy.
Mikeb85超过 3 年前
This would make sense if all computers ever did was mathematical micro-benchmarks.<p>Can you create a web framework in C that has as many features as Rails or Django? And what&#x27;s the power consumption of that?<p>Higher level languages do more stuff. It&#x27;s not like Guido and Matz just woke up one day and were like &quot;fuck your CPU&quot;.<p>Plus, compilation requires a decent amount of power, as shown in those graphs. Does every C&#x2F;C++ project run perfectly with no bugs the first time?
评论 #29272115 未加载
评论 #29274500 未加载
aejnsn超过 3 年前
This comes from an academic who doesn’t support any code. Why would I spend the time as a developer to do manual memory management under the guise of efficiency, when instead I can support twice (arbitrary) as many apps making a computer do it for me? This is a human, whose carbon footprint is terrible compared to a little memory overhead. SMH. Silly articles.
评论 #29272109 未加载
评论 #29272071 未加载
H8crilA超过 3 年前
Please no, a lot more energy and carbon will be wasted undoing the damage done by full stack engineers now suddenly finding out about memory management problems.
whateveracct超过 3 年前
Not sure if this is satire or some light techie ecofascism
评论 #29271660 未加载
评论 #29272031 未加载
neuroscihacker超过 3 年前
I&#x27;ve written about this topic before and I think this is not right. Scroll down to &quot;Environmental Impact&quot;.<p><a href="https:&#x2F;&#x2F;towardsdatascience.com&#x2F;high-performance-code-pays-dividends-ce97768b5fa5" rel="nofollow">https:&#x2F;&#x2F;towardsdatascience.com&#x2F;high-performance-code-pays-di...</a><p>&quot;The climate crisis threatens human civilization on a grand scale and electricity is frequently produced from fossil fuel. Electricity is then consumed by the operation of computer code. Google alone used 12.8 Terrawatt-hours in 2019 according to its 2020 environmental report, more than many countries and more than several US states. It seems intuitive that improving code efficiency should reduce environmental impact. Does it?<p>The answer is not at all clear and must be considered on a system by system basis. The main reason is induced demand.<p>...it will take a centrally coordinated process at both national and international levels that can allocate energy to different industrial and consumer sectors and manage the energy production mix on behalf of the whole of society. Only then we can solve this problem in a rational way that doesn’t depend on luck.<p>In fairness, software companies aren’t power companies, it’s a little ridiculous to expect them to build their own generation. What we can more expect from them is to pay taxes, divest from fossil fuel companies if they hold securities, and hold their total energy consumption under a ceiling set by a regulator while the society changes the energy mix as fast as possible.&quot;
wheelerof4te超过 3 年前
Besides the already mentioned &quot;donate via crypto&quot; red flag, this argument is NULL and void.<p>Different languages were made with a reason, and they solve different problems. Even Python can be efficient when your largest bottleneck is network or disk IO.<p>Nowadays we have Rust, which is slowly catching up to C speed, and sometimes even surpasses it.<p>C is a beautiful language when used in embedded space, where memory allocations are minimal. Once you start throwing mallocs left and right, you lose that simple elegance.
benibela超过 3 年前
I have been saving the planet by writing all my code in Pascal<p>From that paper, only C and Pascal, are optimal for energy and memory usage.<p>And Pascal has memory safe strings with reference counting. C is just too unsafe. 70% of all security issues are caused by C.
评论 #29278307 未加载
megous超过 3 年前
Or just use an ad blocker. It&#x27;s a 0% vs 100% CPU use on some websites.
rodmena超过 3 年前
Oh yes, let&#x27;s reinvent the Erlang&#x2F;OTP in C just to save CPU cycles (I bet that won&#x27;t be the case). Let&#x27;s waste millions of hours of programmers&#x27; life, just to make a point.<p>C or any &quot;so called&quot; efficient languages are wonderful for their use cases. Python or Erlang have other use cases. We have all of those languages for a reason.
评论 #29271934 未加载
Zababa超过 3 年前
The sweet spot seems to be Go, Haskell, Java, Lisp, OCaml and maybe JS.
jancsika超过 3 年前
I always wondered if setting up those Bitcoin rigs in that abandoned warehouse was just a giant waste of energy.<p>Now I have proof it wasn&#x27;t.<p>Thanks, C++.
francisl超过 3 年前
To be more accurate, it needs one variable. - Butt(s) per feature<p>That includes defects,<p>It&#x27;s one of many reasons I like new compiled&#x2F;vm languages like Go, Swift, Nim F#. You got the productivity of python, but near the performance of C. User wins, dev wins and planet wins.
评论 #29273939 未加载
henning超过 3 年前
If you&#x27;re worried about the environment, avoid researching how microprocessors are made with respect to chemicals used for lithography and how much waste water is generated when making a modern microprocessor.
synergy20超过 3 年前
Many script language runs C in its modules, or c++ for that matter.<p>From the best analysis it does seem modern c++ could be the optimal performance&#x2F;energy&#x2F;speed&#x2F;safety choice.<p>And yes I&#x27;m a proud c&#x2F;c++ programmer.
评论 #29271999 未加载
hmrr超过 3 年前
I think they should offset all of these things against the probability that the IDE you have to use has its own ozone hole.<p>That stab is mostly aimed in the direction of C# and Java
yayr超过 3 年前
&gt; As a former software engineer who’s mostly worked with C programming, and to a lesser extent assembler, I know in my heart that those are the two most efficient programming languages since they are so close to the hardware.<p>one could argue, that programming languages that are more close to the mind are more efficient. At least when looking at 2nd to n-th order efficiency effects, not just pure runtime performance.
评论 #29272014 未加载
ac42超过 3 年前
Does this factor in the wetware upkeep during the development cycle? Development in C generally is slower than in most of the other languages.
tomohawk超过 3 年前
I once re-wrote a non-trivial program in ruby that was originally written in C. The performance and scale of the ruby version was considerably better.<p>Could it have been even better in C? Probably, but it was a lot easier to conceptualize and properly choose the architectural features that made the difference using ruby.<p>These days I would have done the rewrite in golang, and had the best of both worlds.
mclightning超过 3 年前
Oh, are we doing this now? I mean, if we are, let&#x27;s get rid of JS&#x2F;TS and move to Rust or something, anything really.
sn9超过 3 年前
I think an argument could be made for writing code in a systems programming language like C or Rust to save energy, but I&#x27;d be much more interested to know what the same choice would be for front-end development.<p>Could we get something as flexible and expressive and ergonomic as React or Vue with the performance of WASM?
Tozen超过 3 年前
This is a bit deceptive, because we could always go back to writing in assembly language. The point of scripting languages are usually to make creating programs easier, requiring fewer lines and time to create. There are different aspects of efficiency that is being overlooked.
anthk超过 3 年前
1) HN shoudn&#x27;t be dependant on JS<p>2) There is a gopher proxy for HN: gopher:&#x2F;&#x2F;gopherddit.com<p>3) Use CLI tools, avoid JS ridden apps. If so, download the video and use mpv offline. Many times less power wasting.
smoldesu超过 3 年前
Perl and Python are scripting languages, their energy savings come from the fact that the programmer is typically the only person who will be running it, so it makes more sense to write something that minimizes screen-on time than it does to micro-optimize an app that hundreds of thousands of people will interact with. It&#x27;s entirely a matter of scale: if you&#x27;re working server-side, I&#x27;d wager you&#x27;re saving quite a bit of energy by not using an IDE that constantly relies on static analysis to make sure you&#x27;re not shooting yourself in the foot.
评论 #29271554 未加载
评论 #29271750 未加载
评论 #29271639 未加载
评论 #29271602 未加载
tehsauce超过 3 年前
This is a very miscalculated take, please avoid.
uncomputation超过 3 年前
How is Go so high? It’s far higher than even Java or Erlang. Is it due to a high CPU usage that compile times in Go are so fast?
评论 #29272027 未加载
评论 #29271935 未加载
mberning超过 3 年前
It’s a bit like saying the world would be better off if we went back to pre industrial revolution practices.
评论 #29271844 未加载
ofou超过 3 年前
Perl is the worst programing in terms of energy usage.
Minor49er超过 3 年前
It seems unusual to have a post that makes an environmentalist statement about computer energy consumption, but then end it by requesting donations via cryptocurrencies which are mined through their enormous consumption of electricity.
评论 #29272023 未加载
评论 #29272050 未加载
评论 #29272290 未加载
alcover超过 3 年前
For the moment, using higher-level languages seems a natural go-to. It&#x27;s comfortable, and energy and hardware are abundant.<p>But this won&#x27;t last. Many energy sources and metals are peaking and I can imagine a day when efficiency will count heavily.
评论 #29272343 未加载