r/shittyprogramming • • Jan 23 '18

‪The real cause of global warming is Python.‬

Post image
306 Upvotes

32 comments sorted by

105

u/flukus Jan 23 '18

The carbon footprint of slow languages is probably significant, especially when you factor in computer upgrades for slow software.

That said, isn't all the heavy lifting for CV libraries done in C anyway?

59

u/mnbvas Jan 23 '18

Python uses C (and sometimes Fortran, see NumPy) for all heavy lifting.

16

u/kthepropogation Jan 23 '18

* when written correctly

6

u/brokenAmmonite Jan 24 '18
x = np.randn(10000)
for i in range(10000):
   x[i] += 1

10

u/DoorsofPerceptron Jan 23 '18

It's mostly done on GPU, and so it uses CUDA.

4

u/inconspicuous_male Jan 23 '18

I've personally implemented some heavy CV algorithms in python for school and quick projects. Although I assume scipy/numpy uses a C backend. But still, not all of my implementations were easily done in libraries

51

u/[deleted] Jan 23 '18

How many watt-hours would be saved if all programs were written in assembly?

134

u/TCV2 Jan 23 '18

We would need to compare that to the amount of watt-hours used to create the amount of alcohol needed to keep programmers from killing themselves.

20

u/royisabau5 Jan 23 '18

And also the caloric content of the waffles and soylent they’d eat during development, pre-suicide of course

28

u/ILikeLenexa Jan 23 '18 edited Jan 23 '18

C has barely any overhead. In fact, on average, compilers are probably better at writing assembly code than programmers. I'm talking about stuff that would be a nightmare for maintenance, but the compiler automates it. Loop unrolling, strength reduction, common sub expression elimination, register allocation to avoid clobbering variables.

Though perhaps we could have an ASM compiler and double the benefits. Oh, that's actually every C compiler, just use the __asm directive.

14

u/pergnib Jan 23 '18

Though perhaps we could have an ASM compiler and double the benefits. Oh, that's actually every C compiler, just use the __asm directive.

Not that this makes your overall comment wrong but it's definitely not every C compiler; __asm and __asm__ directives are extensions of the C language and are only available on some compilers.

You won't find __asm on GCC nor __asm__ on MSVC, for example.

10

u/ILikeLenexa Jan 23 '18

We'll just use the great and mighty #define

2

u/[deleted] Jan 23 '18

Praise be!

2

u/mr-gaiasoul Jun 09 '18

On average, a skilled ASM dev can reduce the size of his C program and increase its speed by ~25% by creating it directly in ASM compared to C. Source "Randy" something. He wrote this public domain book about CISC x86 ASM programming some 20 years ago or something I think ...

He was referencing several scientific sources in these matters ...

He sounded convincing, and I believed him back then, and still do ...

1

u/ILikeLenexa Jun 09 '18

You can get speed, but not portable speed. The specific set of instructions in your ASM is going to be incorrectly balanced for machines in 15 years. Instead, you should write good C that optimizes well on compilers. Even between manufacturers the relative speed of assembly on the same architecture varies (thus gcc's march flag).

Generally, if you have to beat the compiler, the first step is asking the compiler what it would do at O3.

Gcc has a bit of a high level on doing it: https://gcc.gnu.org/wiki/DontUseInlineAsm

0

u/mr-gaiasoul Jun 09 '18

Instead, you should write good C that optimizes well on compilers

Did you notice how I don't disagree with that ...? ;)

43

u/[deleted] Jan 23 '18

Well bitcoin takes up the same amount of energy as Denmark, bitcoin code is written in c. Python is written in c, so at least Denmark.

6

u/[deleted] Jan 23 '18

Solid reasoning.

20

u/Negatratoron Jan 23 '18

sounds like a good request for r/theydidthemath

5

u/[deleted] Jan 23 '18

Isn't that just an aggregation sub? The actual mathematics is usually done somewhere else.

1

u/_Nexor Jan 23 '18

Torture, much?

31

u/[deleted] Jan 23 '18

What's the carbon footprint of Windows Update?

13

u/BobFloss Jan 23 '18

I've heard it's somewhere over 9000 actually.

1

u/konichiwaaaaaa Mar 03 '18

Green computing is a thing though. But the choice of language has little to do with it.

-13

u/[deleted] Jan 23 '18

GLOBAL WARMING AND MOON LANDING ARE HOAXES

17

u/GNUSSR Jan 23 '18

Apollo 11 used python

7

u/[deleted] Jan 23 '18

No, Python hadn't been invented yet. They used Garter Snake.

4

u/[deleted] Jan 24 '18

bad bot

3

u/[deleted] Jan 24 '18

Are you sure about that? Because I am 100.0% sure that contrarianism is not a bot.


I am a Neural Network being trained to detect spammers | Summon me with !isbot <username> | ^Optout | Feedback: /r/SpamBotDetection | ^GitHub

7

u/[deleted] Jan 24 '18

The hardware may be a little squishier than you're used to, but one machine that's been trained to react instinctively to keywords is no different from another.