Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-4041-

The Myth of Speed

Name: Anonymous 2009-12-08 12:21

Why everyone thinks C is the fastest thing evar?

Name: Anonymous 2009-12-08 12:32

I don't think anybody thinks that. Obviously writing code in assembly is the way to achieving most performance, but that isn't portable. C is almost portable assembly, thus it's one of the faster languages.

Most C code can be compiled fairly straightforwardly to ASM, and the performance is somewhat predictable. C also has many limitations when it comes to how well you can abstract, and it lacks powerful metaprogramming features.

Name: Anonymous 2009-12-08 12:32

no exceptions

Name: Anonymous 2009-12-08 13:35

>>2
Most C code can be compiled fairly straightforwardly to ASM
you seem confused. maybe you shoulnt program at all.

Name: Anonymous 2009-12-08 13:39

>>4
MAYBE YOU SHOULD MY ANUS

Name: Anonymous 2009-12-08 13:54

>>2
Homework: write a compiler for harvard architecture microcontrollers

Name: Anonymous 2009-12-08 13:57

>>6
I just wrote an assembler for one. Do you love me now, daddy?

Name: Anonymous 2009-12-08 14:24

>>7
Is that you, /prog/snake?

Name: Anonymous 2009-12-08 14:26

>>2
It depends on the architecture.  A lot of times code written in C is faster than code written in ASM.

Name: Anonymous 2009-12-08 14:37

>>9
Not really, it's impossible to make the best compiler (NP-hard,...), and C compiles to platform specific code(ASM), so you can always improve upon the generated code or write better code yourself. It's another question how well can a human compiler take advantage of the CPU architecture(for example: compilers tend to be smarter when it comes to scheduling), but it's common to be able to do better than the "sufficiently decent compiler". Wether there's any point in humans wasting their time doing that is another question...

Name: Anonymous 2009-12-08 14:40

>>10
Go back to programming "Hello World" in your basement if you actually think you can hand code better ASM than a compiler for any real program.

Name: Anonymous 2009-12-08 14:43

>>11
I never inspect my compiler's output

Name: Anonymous 2009-12-08 14:44

>>12
I use Microsoft's compiler so I do have to.

Name: Anonymous 2009-12-08 15:34

13
Now you have two problems.

Name: Anonymous 2009-12-08 16:29

>>14
He's probably got 99 problems.

Name: Anonymous 2009-12-08 16:46

I can't believe people seriously think that compilers generate decent code.

Go compile x264 or libavcodec or whatever with ASM disabled and see if you can even approach half of the speed you had before.

Even intrinsics suck aplenty (usually ~30% slower than proper ASM, can be 5% if you're lucky or 50% if you're not) and they only require the compiler to solve the "easy" problems (register allocation and maybe scheduling if your CPU is too sucky).

Of course it's not really viable to write everything in ASM, but the notion that a shitty compiler (that is: all of them) can even approach any assembler programmer worth his salt is alien for anybody with experience.

When I'm debugging stuff I'm still amazed at the limitations of modern compilers. They even let trough stuff that a simple peephole optimizer would catch, specially GCC.

Name: Anonymous 2009-12-08 16:46

>>15
But my compiler ain't one.

Name: Anonymous 2009-12-08 16:47

>>15
While I do agree with you, the 'two problems' meme is part of the /prog/scape.

Name: Anonymous 2009-12-08 16:49

>>17
Using MickeySoft is a waste of a perfectly good computer. You certainly do have over nine thousand problems.

Name: Anonymous 2009-12-08 16:57

>>19
Keep compiling with your GCC.

LOL

Name: Anonymous 2009-12-08 16:58

>>18
/prog/::Meme<"two problems"> m;

Name: Anonymous 2009-12-08 17:36

>>17
hit(&me)

Name: Anonymous 2009-12-08 17:39

>>22
If you're having Linux problems, I feel bad for you neckbeard.

Name: Anonymous 2009-12-08 19:14

>>10
a "perfect compiler" solves the halting problem, so you're quite correct.
>>11
Mike Pall can.

Name: Anonymous 2009-12-08 19:18

writing a medium sized program in ASM:
    20,000 hours, 100% speed, portability 10%
writing a medium sized program in C:
    1000 hours, 80% speed, portability 50-100% depending
writing a medium sized program in JAVA:
    20 hours, 30% speed, portability 100%

Name: Anonymous 2009-12-08 19:25

>>23
The year is 94 and in my comp is Forth
And in my TCP ports is the mothafuckin law
I got two choices, y'all, shut down the comp or
Counter-DOS the devil put the bandwidth to the floor

Name: Anonymous 2009-12-08 19:40

>>25
Making up figures on /prog/:
  0.01 hours, 5% speed, portability 50%

Name: Anonymous 2009-12-08 19:52

>>25
Figures are somewhat wrong.
Here's my own figures from my own recollection,
Some archiving program:
- 5 hours + 5 hours spent debugging in Asm
- 4 hours + 3 hours spent debugging in C
- 1.5 hours + ~20 minutes spent debugging in C#
- 45 minutes (debugging time included, each function was tested live after writing) in Lisp.

I'm sure some programmers out there that write perfect code won't need the debugging time, but I'm not a perfect programmer.
Regarding speed, ASM and C performed roughly the same, when C was compiled with high optimization settings. C# was fairly fast as well, but the runtime has some fixed loading time, which makes it slower to run. The Lisp implementation does have its loading time as well, but it's not an issue if you're like me and keep it running all the time. It would be an issue if you loaded it each time. Overall speed was about 3 times slower than the C version.
C code was C89 compatible, and Lisp didn't make use of anything non-standard except for sb-ext:*posix-argv* when ran from the command line, but that's trivial to make de-facto portable.
C# code is portable, except it only runs on Microsoft's .NET and MONO, so it's slightly less portable than C or the Lisp code, but it doesn't matter in practice, as I don't need it running on that many platforms.

Name: Anonymous 2009-12-08 19:52

>>27
you know they're right.
only somebody whose time is worthless would program in ASM willingly

Name: Anonymous 2009-12-08 19:59

>>29
There are some uses. I'm glad those making decoders/encoders(codecs) for various video/audio formats are such speed/optimization freaks. For example, x264 has most of the routines are written in C, then rewritten in ASM for specific platforms. Many other multimedia apps follow the same route. This has resulted in huge speedups in encoding times, which is beneficial to a lot of people. While I know x86 asm myself, I avoid writing ASM unless absolutely necessary or I really need the speedup. It's all about how well one can balance the need for speed and the need for abstraction/portability.

Name: Anonymous 2009-12-08 20:02

>>29
I'm sure all those people that wasted their time writing kernel code in asm, when it could have been written so much faster in python, will be upset to hear that [/sarcasm]

Name: Anonymous 2009-12-08 20:10

>>31
The amount of minimum needed asm code in the kernel and library runtime isn't that huge, but that code is needed for either doing things which are not possible to do portably in the language in which they're implementing the OS/language or things which require very compact/fast code(such as thunks/multi-processing code which is ran very often). It's fair to say that anyone writing an OS or language which natively compiles is going to have to write at least some assembler.

Name: Anonymous 2009-12-08 20:11

>>31
Most kernels that are written after the invention of Python are written in C.

Name: Anonymous 2009-12-08 20:15

I find it funny people actually think that code written in ASM is faster than code written in C.  You can make code written in ASM as fast as code generated by a decent compiler if you want to hack your way through it (manually unrolling loops, etc.), but even if you do that you are going to be roughly the same speed as code generated by a compiler if you are lucky. 

Of course, this is talking about real programs, not the 10 line fibs that most of you saying ASM code is faster than compiled are probably writing.  Also, this is using real-world ASM coders and C compilers.  Yes, there is still reasons to use ASM, and you can write ASM code that is faster than code generated by a compiler, but not programs.

Name: Anonymous 2009-12-08 20:16

>>29
Nobody's time is worth anything. People who program in ASM just like to program in ASM.

Name: Anonymous 2009-12-08 20:21

>>34
My CISC processor has a FIBS intruction :P

Name: Anonymous 2009-12-08 20:40

>>31
kernel code authors generally try to keep ASM to the bare minimum.
99% of kernel code is written in C

Name: Anonymous 2009-12-08 21:01

>>34
Few compilers can actually generate efficient code which takes advantage of the latest and greatest new instructions some CPUs provides(SSE/MMX for x86 as an example), which is why a lot of optimized multimedia code is written in asm.

Name: Anonymous 2009-12-08 21:05

>>38
SSE and MMX are not the best examples there.

Name: Anonymous 2009-12-08 22:31

C is the fastest thing evar.

Name: Anonymous 2009-12-08 22:36

[quote]c is the fastest thing evar.[/quote]

Fixed your capitalization issues.

Name: Anonymous 2009-12-08 22:38

>>41
Same: the heck?  quote is normal BBCode

Name: Anonymous 2009-12-08 22:43

>>41
FIX YOUR BBCODE ISSUES FAGGOT

Name: Anonymous 2009-12-08 22:48

>>41
Learn to quote
Properly
Please!

Name: Anonymous 2009-12-09 0:02

>>44
[q]MAYBE IF YOU TOLD US WHAT THE TAG WAS YOU FAGGOT[/q]

Name: Anonymous 2009-12-09 0:08

>>45
I'll give you a hint: this text board runs a Spanish BBCode parser.

Name: Anonymous 2009-12-09 0:09

>>45
I'll give you a hint: gtfo

Name: Anonymous 2009-12-09 0:10

>>46
YOU HELPED HIM!!

Name: Anonymous 2009-12-09 6:30

>>46
[cita]YHBMT[/cita]>>46

Name: Anonymous 2009-12-09 15:25

[quote=""]is this it?[/quote]

Name: Anonymous 2009-12-09 15:25

[cita]this?[/cita]

Name: Anonymous 2009-12-09 15:26

[cite]what about this?[/cite]

Name: Anonymous 2009-12-09 15:29

test

Name: Anonymous 2009-12-09 15:48

>>49-53
now learn to use sage

goddamn

Name: Anonymous 2009-12-09 15:57

>>41-42,45,50-52
Jesus fucking Christ, get the fuck out.

Name: Anonymous 2009-12-09 21:01

C is the fastest thing evar.

Name: Anonymous 2009-12-09 21:11

FASTER THAN A SPEEDING BULLET

Name: Anonymous 2009-12-09 22:27

>>56
C is the fastest thing evar.
No, c is the fastest speed evar.

Name: Anonymous 2009-12-09 22:34

>>58
dohohoho

Name: Anonymous 2009-12-09 23:08

My sick CFLAGS will take on your ASSembly cireclejerk anyday. Don't be shy, come up with your best optimizations. Oh wait, you don't have CFLAGS right? More like ASSFAGS right?

Name: Anonymous 2009-12-09 23:24

>>60
CFLAG MY ANUS

Name: Anonymous 2009-12-09 23:47

>>60
http://bugs.gentoo.org/show_bug.cgi?id=104437
CFLAGS="-pipe -O2 -march=athlon-xp -fomit-frame-pointer -ftracer -m32 -mmmx -msse -m3dnow -funroll-loops -fpeel-loops -funswitch-loops -fweb -fgcse-after-reload -fmodulo-sched -fgcse-sm -fgcse-las -ftree-loop-linear -ftree-loop-im -ftree-loop-ivcanon -fivopts -mtune=athlon-xp"

Name: Anonymous 2009-12-10 0:10

I believe this should be a new copypasta:

Aye carumba!  Are you absolutely sure you've got enough CFLAGS in there?  How
about adding -O3 and -ffastmath in there for good measure...?

Seriously, the root of your problems here, is the insane CFLAGS you have set.
Just because a certain flag is recognised by GCC, doesn't mean it's necessarily
a good idea to go playing with it, unless you're familiar with what it does, and
what the consequences are.

Likely, due to the abuse of these flags, your system is most likely messed up
beyond all repair.  (FUBAR, as some of my mates would call it... I'll leave it
to others to derive the definition of that acronym)

Might I suggest, trimming back on the CFLAGS (e.g. I'd recommend "-O2 -pipe
-march=athlon-xp" and leave it at that) and see how that goes.  You may also
need to rebuild glibc and other components of your system -- so it may be easier
to reformat and reload.

The performance gained by CFLAGS on x86 is minimal at best -- largely because
the machines are still basically overclocked 386's at their core.  RISC
architectures (e.g. MIPS) can benefit by compiling to a particular ISA and CPU,
(e.g. throwing in -mips4 on an SGI O2 will get it humming nicely) however, going
beyond that only causes major headaches.

In short though, the only thing gained by lots of CFLAGS is über instability,
horrendous compile errors, and next to no speed gain.Aye carumba!  Are you
absolutely sure you've got enough CFLAGS in there?  How about adding -O3 and
-ffastmath in there for good measure...?

Seriously, the root of your problems here, is the insane CFLAGS you have set.
Just because a certain flag is recognised by GCC, doesn't mean it's necessarily
a good idea to go playing with it, unless you're familiar with what it does, and
what the consequences are.

Likely, due to the abuse of these flags, your system is most likely messed up
beyond all repair.  (FUBAR, as some of my mates would call it... I'll leave it
to others to derive the definition of that acronym)

Might I suggest, trimming back on the CFLAGS (e.g. I'd recommend "-O2 -pipe
-march=athlon-xp" and leave it at that) and see how that goes.  You may also
need to rebuild glibc and other components of your system -- so it may be easier
to reformat and reload.

The performance gained by CFLAGS on x86 is minimal at best -- largely because
the machines are still basically overclocked 386's at their core.  RISC
architectures (e.g. MIPS) can benefit by compiling to a particular ISA and CPU,
(e.g. throwing in -mips4 on an SGI O2 will get it humming nicely) however, going
beyond that only causes major headaches.

In short though, the only thing gained by lots of CFLAGS is über instability,
horrendous compile errors, and next to no speed gain.

Name: Anonymous 2010-12-06 9:51

Back to /b/, ``GNAA Faggot''

Name: Anonymous 2011-01-31 20:34

<-- check em dubz

Don't change these.
Name: Email:
Entire Thread Thread List