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

Pages: 1-

C question

Name: Anonymous 2013-08-03 2:00

How much is void main() saving in CPU cycles compared to int main()?

Name: Anonymous 2013-08-03 2:36

4 bytes not read.

Name: Anonymous 2013-08-03 2:38

>>2
You don't know what the fuck you are talking about.

Name: Anonymous 2013-08-03 3:27

>>3
>being dis easily trolled.

Name: Anonymous 2013-08-03 3:30

>>4
L3 EGGSWIN /G/R0QQQE#F!!FF@@!!xDxD

Name: Anonymous 2013-08-03 5:15

>>1
"return 0" requires "xor eax,eax"

Name: Anonymous 2013-08-03 5:16

>>1
The C language is particularly rich with ways of writing a program that totally hides the original design intent and makes it easy to shoot yourself in the foot:
- Weak-typing: C implicitly converts between floats and integers, despite they being completely different and incompatible objects, while conversion between them incurs high runtime cost. This leads to inefficient code, confusion and complicates semantics. Moreover, C allows passing integer, where pointer is expected, leading to segmentation faults.
- C programmers must write the details of buffer overflow protection into their usage of buffers EVERY TIME they write input buffer code. This means that programmers simply write buffer code with out limit protections, which is expectionally flawed in terms of software design and quality standards. We don't have to imagine how many times this has caused bugs, just look to the number of security breaches and patches with "buffer overflows" as the access point. Null-terminated strings (c-strings) are inefficient and insecure, due to requirement of calculating length every time and inability to correctly handle byte of value 0, so malicious or incorrect user-input could lead to buffer overflow with segfault or unexpected string termination. While malloc always store the size of allocated array, it isn't available to the user, resulting in a waste of 4 to 8 bytes memory and a few CPU cycles per allocation, because user would have to use his own size variable.
- Despite being called "portable assembler", C doesn't expose the some of the common assembler's features, with major deficiency being the absence of non-local gotos, generated gotos and implicit stack constantly getting in the way, so you for example can't implement exceptions or garbage collection using plain C. Moreover, macro-assemblers implement more complex structures, like functions and do-while-loops using macros, while C requires them to be a part of core language. There is also no way to get the size of compiled function or force it to reside at certain memory address, making it impossible to write certain boot-loader and OS code in C. No well defined function/stack ABI means you can't write a garbage collector using plain C. Data alignment and calling-convetion features are very implicit and confusing, while in real assembler they are explicit. The general theme of C-vs-assembly argument is C being both low level and not being low-level enough, while lacking capability for abstraction, macro assemblers have, making C a badly designed half low-level language with no potential for growth - a castrated assembly with infix operators and stack bolted on top.
- Syntax of C, although mimicked by other mainstream languages, has often been criticized. For example, Kernighan and Ritchie themselves say, "C, like any other language, has its blemishes. Some of the operators have the wrong precedence; some parts of the syntax could be better." Some questionable choices of operator precedence, as mentioned by Kernighan and Ritchie, such as == binding more tightly than & and | in expressions like x & 1 == 0, which would need to be written (x & 1) == 0 to be properly evaluated. Moreover, it is easy to mistype == as =, leading to common bugs like "if (Byte = 123)" permeating C code. Ritchie's "declaration reflects use" was proven to be extremely unintuitive and confusing, particularly for function pointers. C inherits dangling else problem from Algol, because C's syntax allows ifs without matching else clause; a good design would be to solve the else problem by forcing ever if to have matching else and introducing `when X then Y` construct for "no-else" ifs, but C doesn't have good design. Finally, a large number of cryptic compound operators, such as +=, -=, *=, ++, ?:, don't make C easier to read or learn.
- Deployment of C software requires especially complicated system of Make, ./configure, Autoconf, Automake and M4 macros (in addition to C preprocessor), with numerous other external tools, like perl, flex and yacc, generating "probes" against compilation environment. Linking process isn't straightforward either, as there is no standard ABI to shared code and even static libraries, especially when C++ kicks in, leading to DLL hell and the like conditions. C code and tools produce programs that are inaccessible to outside world and cannot be inspected during runtime. Once compiled C programs are static, difficult access and upgrade and have horrible ABI, through #include files, instead of robust module system, like the symbol package system of Common Lisp. C preprocessor #include system relies on a myriad of unobvious hacks, like "#ifndef COMMON_H", "#pragma once" and "#line number filename" - combined they wont make language simple or user-friendly.
- In addition,  People are taught to program in C, instead of Lisp, because "industry demands it", so our education is based on the whims of sighted and blinkered industry bosses. More fundamentally, the majority have difficulty dealing with ideas of reflection, meta-programming, homoiconicity, and the like, and it's hard to see the point if you don't understand.

Name: Anonymous 2013-08-03 6:06

>>7
Someone should make one of these kopipes for Symta. Nikita would probably have an aneurysm.

Name: Anonymous 2013-08-03 6:09

:)

Name: Anonymous 2013-08-03 6:10

:)

Name: Anonymous 2013-08-03 6:11

:)

Name: Anonymous 2013-08-03 6:12

>>8
Nobody other than Nikita knows Symta

Name: Anonymous 2013-08-03 6:12

:)

Name: Anonymous 2013-08-03 6:14

>>7

Try to type something original instead of your mall informed and retarded copy pastas.


Deployment of C software requires especially complicated system of Make, ./configure, Autoconf, Automake and M4 macros (in addition to C preprocessor), with numerous other external tools, like perl, flex and yacc, generating "probes" against compilation environment.


This is retarded. Flex (lexical analyzer) and yacc (parser generator) are for creating compilers. It hasn't anything to do with deployment.
You don't have to use make, configure, automake, m4 and other tools for "deployment". You can choose other tools, which are easier to use.



C code and tools produce programs that are inaccessible to outside world and cannot be inspected during runtime. Once compiled C programs are static, difficult access and upgrade and have horrible ABI, through #include files, instead of robust module system, like the symbol package system of Common Lisp.


This is also crap. You can monitor almost everything in a C program. You only need to include the symbols for debugging.
And there is no ABI, because C is used as system programming language, thus accessing a variety of features of completely different kernels, with their own calling conventions, memory addressing etc. It doesn't make sense to say a pointer has to be 32 bits on all systems. It doesn't even make sense to say a pointer points to a memory address.

Name: Anonymous 2013-08-03 6:21

Name: Anonymous 2013-08-03 6:21

>>1
I think they both take the same cycles to declare, on most common architectures that is. All you are saying in void main(), declare my main program with NULL return type. With int you are only assigning it a return type of however the C compiler believes the int should be assigned to in bytes. At the end of the day, it is the compilers job to determine if an additional step needs to be provided for the main() declaration.

Now what you can do is benchmark it with with time(1), to learn if additional cycles are initiated for more opcodes both the compiler failed to optimize, and the architecture failed to simultaneously deliver. GDB and Valgrind are invaluable tools for evaluating performance on your program.

Name: Anonymous 2013-08-03 6:23

>>14
This is retarded. Flex (lexical analyzer) and yacc (parser generator) are for creating compilers. It hasn't anything to do with deployment.
A lot of C/C++ software uses Perl, bison and yacc during build process, because C/C++ cannot provide a library to do robust parsing.

Name: Anonymous 2013-08-03 6:27

>>14
You don't have to use make, configure, automake, m4 and other tools for "deployment". You can choose other tools, which are easier to use.
everyone uses ./configure, so it appears that no better tool is possible for C/C++

Name: Anonymous 2013-08-03 6:30

>>18
Some use Ruby (in addition to Perl) in their C++ builds. http://www.ai3.uni-bayreuth.de/software/Makr/

Name: Anonymous 2013-08-03 6:31

>>17
Liar:
http://en.wikipedia.org/wiki/Comparison_of_parser_generators

If you mean PCRE, now that is something else.

Name: Anonymous 2013-08-03 6:34

:)

Name: Anonymous 2013-08-03 6:37

>>18
everyone uses make(1), so it appears that no better tool is recommended, for many possibilities exists:
https://en.wikipedia.org/wiki/List_of_build_automation_software

>>19
We know, and many more types of DSL and regex for build automation tools.

Name: Anonymous 2013-08-03 6:40

>>22
C/C++ build is a mess. That could be the single reason people go for Haskell.

Name: Anonymous 2013-08-03 6:41

Fixed the copipe for minor errors...

The C language is particularly rich with ways of writing a program that totally hides the original design intent and makes it easy to shoot yourself in the foot:
- Weak-typing: C implicitly converts between floats and integers, despite they being completely different and incompatible objects, while conversion between them incurs high runtime cost. This leads to inefficient code, confusion and complicates semantics. Moreover, C allows passing integer, where pointer is expected, leading to segmentation faults.
- C programmers must write the details of buffer overflow protection into their usage of buffers EVERY TIME they write input buffer code. This means that programmers simply write buffer code with out limit protections, which is expectionally flawed in terms of software design and quality standards. We don't have to imagine how many times this has caused bugs, just look to the number of security breaches and patches with "buffer overflows" as the access point. Null-terminated strings (c-strings) are inefficient and insecure, due to requirement of calculating length every time and inability to correctly handle byte of value 0, so malicious or incorrect user-input could lead to buffer overflow with segfault or unexpected string termination. While malloc always store the size of allocated array, it isn't available to the user, resulting in a waste of 4 to 8 bytes memory and a few CPU cycles per allocation, because user would have to use his own size variable.
- Despite being called "portable assembler", C doesn't expose the some of the common assembler's features, with major deficiency being the absence of non-local gotos, generated gotos and implicit stack constantly getting in the way, so you for example can't implement exceptions or garbage collection using plain C. Moreover, macro-assemblers implement more complex structures, like functions and do-while-loops using macros, while C requires them to be a part of core language. There is also no way to get the size of compiled function or force it to reside at certain memory address, making it impossible to write certain boot-loader and OS code in C. No well defined function/stack ABI means you can't write a garbage collector using plain C. Data alignment and calling-convetion features are very implicit and confusing, while in real assembler they are explicit. The general theme of C-vs-assembly argument is C being both low level and not being low-level enough, while lacking capability for abstraction, macro assemblers have, making C a badly designed half low-level language with no potential for growth - a castrated assembly with infix operators and stack bolted on top.
- Syntax of C, although mimicked by other mainstream languages, has often been criticized. For example, Kernighan and Ritchie themselves say, "C, like any other language, has its blemishes. Some of the operators have the wrong precedence; some parts of the syntax could be better." Some questionable choices of operator precedence, as mentioned by Kernighan and Ritchie, such as == binding more tightly than & and | in expressions like x & 1 == 0, which would need to be written (x & 1) == 0 to be properly evaluated. Moreover, it is easy to mistype == as =, leading to common bugs like "if (Byte = 123)" permeating C code. Ritchie's "declaration reflects use" idea was proven to be extremely unintuitive and confusing, particularly for function pointers. C inherits dangling else problem from Algol, because C's syntax allows ifs without matching else clause; a good design would be to solve the else problem by forcing every if to have matching else and introducing `when X then Y` construct for "no-else" conditionals, but C doesn't have good design. Finally, a large number of cryptic compound operators, such as +=, -=, *=, ++, ?:, don't make C easier to read or learn.
- Deployment of C software requires especially complicated system of Make, ./configure, Autoconf, Automake and M4 macros (in addition to C preprocessor), with numerous other external tools, like perl, flex and yacc, generating "probes" against compilation environment. Linking process isn't straightforward either, as there is no standard ABI to shared code and even static libraries, especially when C++ kicks in, leading to DLL hell and the like conditions. C code and tools produce programs that are inaccessible to outside world and cannot be inspected during runtime. Once compiled C programs are static, difficult access and upgrade and have horrible ABI, through #include files, instead of robust module system, like the symbol package system of Common Lisp. C preprocessor #include system relies on a myriad of unobvious hacks, like "#ifndef COMMON_H", "#pragma once" and "#line number filename" - combined they wont make language simple or user-friendly.
- In addition,  People are taught to program in C, instead of Lisp, because "industry demands it", so our education is based on the whims of short-sighted and blinkered industry bosses. More fundamentally, the majority have difficulty dealing with ideas of reflection, meta-programming, homoiconicity, and the like, and it's hard to see the point if you don't understand.

Name: Anonymous 2013-08-03 6:44

:)

Name: >>22, clip failure 2013-08-03 6:44

everyone uses make(1), so it appears that no better tool is recommended, for many possibilities exists:
http://en.wikipedia.org/wiki/Comparison_of_parser_generators

>>19
We know, and many more types of DSL and regex for build automation tools:
https://en.wikipedia.org/wiki/List_of_build_automation_software

>>22
Keep using Alex then.

Name: >>26 2013-08-03 6:48

ignore that post, brain is having a race hazard.

Name: Anonymous 2013-08-03 6:58

>>24
 1986 was the year that someone discovered C-bashing as a national sport. It gained popularity mostly among programmers who were just learning C and couldn't wait to write something clever about it, mainly about how much trouble it was giving them. Couldn't be them. Must be C. It's fashionable not to like something that's so popular. I never liked Johnny Cash all that much. In January of 1986, we had "Inefficient C," (get it?) telling us how slow and big C programs are. And in June, we got "What's Wrong With C," telling us more of the same, and suggesting that C programmers do it for the glory of being in on something esoteric. Yeah, and your mama, too.

Name: Anonymous 2013-08-03 7:32

>>28
I have written a lot of code in both Python and C and must say each has its merits. Its upto the programmer to not only choose the language and tools but also to use it wisely.

I get a kick out of all those people's comments about how crappy 'C' is to program with. In case it has not been obvious both Python and Ruby (and many others) are themselves written in 'C'. You may not be programming with pointers but your objects are converted and handled that way.

A good programmer will always manage to find the best language for the project and write good code. A bad programmer will try to find excuses by blaming the programming language he/she chose in the first place.

-Dino

Name: Anonymous 2013-08-03 8:05

I don't even use functions, man.
I just use macros.
Gotta save dem CPU cycles you know.
Also manually unrolled loops 4lyfe

Name: Anonymous 2013-08-03 8:05

The swearing will continue until code quality improves.

Name: Anonymous 2013-08-03 8:09

>>30
What macro replaces main function?

Name: Anonymous 2013-08-03 8:10

>>32
I mean other than main.
Pretty sure main is completely unavoidable.

Name: Anonymous 2013-08-03 8:56

Name: Anonymous 2013-08-03 9:03

>>32
assemlly with external symbol main

Name: Anonymous 2013-08-03 9:28

>>34
Exactly! Assembly is so much superior to C/C++!

Name: Anonymous 2013-08-03 9:29

>>36
hey which book do you recommend to learn asm?

Name: Anonymous 2013-08-03 10:58

:)

Name: Anonymous 2013-08-03 11:02

>>37
Structure and Interpretation of Child Pornography

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