Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Programming (http://www.chiefdelphi.com/forums/forumdisplay.php?f=51)
-   -   Why I hate c (http://www.chiefdelphi.com/forums/showthread.php?t=26085)

Astronouth7303 10-03-2004 15:17

Re: Why I hate c
 
Plus, if you go into PC programming, there's a lot of C++ around. Plus, lets face it, pretty much only assembler is harder than C/C++.

Mike Soukup 10-03-2004 16:00

Re: Why I hate c
 
Quote:

Originally Posted by Joe Johnson
You could code your robot before you actually had a robot in stead of what we have now which is the mechanical system gets done in 5.9 weeks, the wiring gets done in .09 weeks and the programmers have .01 weeks to make it all behave.

There are a lot of things that are unfair about the FIRST competition, but the stress that we tend to put on the coders is among the unfairest burdens we put on people in this FIRST game.

Thanks for the quote Joe, I'm certainly going to send this to Raul :)

mtrawls 10-03-2004 16:08

Re: Why I hate c
 
Quote:

Originally Posted by Joe Johnson
the mechanical system gets done in 5.9 weeks, the wiring gets done in .09 weeks and the programmers have .01 weeks to make it all behave.


Wow! So it's not just me ... sounds like it would be cool to learn about, but I'm a little weary about letting some computer output a program for me!

Quote:

Beauty is in the eye of the beholder. So, apparently, is ugly.
Program something in Perl, then come back to me about "ugly"! Seriously, if you do it right, C can be pretty elegant ... and thinking like a compiler is a good way to reduce the bugs in your code, anyway (so it's not necessarily a bad thing). Anyway, make a page long perl regexp and *then* start talking about C (you might change your mind ;))

deltacoder1020 17-03-2004 10:43

Re: Why I hate c
 
Quote:

Originally Posted by mtrawls
Wow! So it's not just me ... sounds like it would be cool to learn about, but I'm a little weary about letting some computer output a program for me!



Program something in Perl, then come back to me about "ugly"! Seriously, if you do it right, C can be pretty elegant ... and thinking like a compiler is a good way to reduce the bugs in your code, anyway (so it's not necessarily a bad thing). Anyway, make a page long perl regexp and *then* start talking about C (you might change your mind ;))

Quite simply, if you're going to program a machine, you should be prepared to program for it, not at it. There will always be a tradeoff between ease-of-use and power, and C does a fairly good job of balancing the two.

gnormhurst 18-03-2004 16:29

Re: Why I hate c
 
I had to toss this in. It's my favorite bit of obfuscated C -- a program written to be incomprehensible. (I didn't write it -- I don't know who did.) I guess what's "bad" about C is that it lets you write code like this. But this code is masterfully written by someone who knows the language very well -- maybe a little too well.

This will compile and run on a command line, printing a message. It looks scary, but it's harmless. The output will astound you. Here's a hint: Merry Christmas!

/Norm
Code:

#include <stdio.h>
main(t,_,a)
char
*
a;
{
        return!
0<t?
t<3?
main(-79,-13,a+
main(-87,1-_,
main(-86, 0, a+1 )
+a)):
1,
t<_?
main(t+1, _, a )
:3,
main ( -94, -27+t, a )
&&t == 2 ?_
<13 ?
main ( 2, _+1, "%s %d %d\n" )
:9:16:
t<0?
t<-72?
main( _, t,
"@n'+,#'/*{}w+/w#cdnr/+,{}r/*de}+,/*{*+,/w{%+,/w#q#n+,/#{l,+,/n{n+,/+#n+,/#;\
#q#n+,/+k#;*+,/'r :'d*'3,}{w+K w'K:'+}e#';dq#'l q#'+d'K#!/+k#;\
q#'r}eKK#}w'r}eKK{nl]'/#;#q#n'){)#}w'){){nl]'/+#n';d}rw' i;# ){nl]!/n{n#'; \
r{#w'r nc{nl]'/#{l,+'K {rw' iK{;[{nl]'/w#q#\
\
n'wk nw' iwk{KK{nl]!/w{%'l##w#' i; :{nl]'/*{q#'ld;r'}{nlwb!/*de}'c ;;\
{nl'-{}rw]'/+,}##'*}#nc,',#nw]'/+kd'+e}+;\
#'rdq#w! nr'/ ') }+}{rl#'{n' ')# }'+}##(!!/")
:
t<-50?
_==*a ?
putchar(31[a]):
main(-65,_,a+1)
:
main((*a == '/') + t, _, a + 1 )
:
0<t?
main ( 2, 2 , "%s")
:*a=='/'||
main(0,
main(-61,*a, "!ek;dc i@bK'(q)-[w]*%n+r3#l,{}:\nuwloca-O;m .vpbks,fxntdCeghiry")
,a+1);}


meatmanek 18-03-2004 16:51

Re: Why I hate c
 
Cryptic code can be acceptable if:

1. You are the only person who will ever look at the code, and you are used to seeing this kind of cryptic code.
2. You know the people looking at your code (teammates, coworkers, etc) can understand it.
3. You need process and memory-optimized code, because you are working on a system with a relatively slow processor and relatively small memory (The RC, for example).

Remember, though, you should _ALWAYS_ comment your code, especially if it is cryptic. What if your grandmother (who I'm assuming doesn't know C) wanted to read and understand your code?

meatmanek 18-03-2004 17:00

Re: Why I hate c
 
If you really want to see some obfuscated C code, there's actually a contest for it. http://www.ioccc.org/ - The International Obfuscated C Code Contest.

Winning entries can be found at http://www1.us.ioccc.org/years.html

If you want a language that is very easy to program in and makes sense, check out Ruby at http://www.ruby-lang.org
For example, to run a command 3 times in C, you would do this:

for (int i=3; i<=0; i--) {
command();
}

In Ruby, it would look something like this:

3.times { command }

Ruby is also loosely-typed, meaning you don't have to worry about the size of the variable that's holding your data, the interpreter will determine that for you.

Note that you can't use Ruby on the robot, this is just for hobbyist programmers.

gnormhurst 18-03-2004 18:20

Re: Why I hate c
 
Thanks for that pointer to IOCCC -- I think that's where that bit of code came from, many years ago.

And now I'm reminded of another language, "whitespace,", wherein all code is composed entirely of three characters: space, newline, and tab.

Here's a example bit of code:

Code:

This is a comment.
         

                             
 
       
                             
       
           
           
                           
                 
                                     

 
                           

                             
 





                                                                                       
         
       

                                                                                                                                                                                                   
 
                         
 
                                                                                                                                                                                                                                                                                                                                                                       
       
           
         
 
                                                                                                                                                                                                 

                                                                                                                                                                                                                                                                                                                                                                 
 

 


       

                                                                                                                                   
 
 
       
                                 
                     
                 
                                                                                                                                                                                                                                                                                                       
 

         
         
 
                                                                                                                                 

                                                                                                                                                                                                                                                                                                 
 

         
             
               
       

                                                                                                                                                                                                                                                                                         
                   
                           
       
         
 
       


End of code example.

Maybe next year FIRST will specify whitespace as the language we use.

Astronouth7303 18-03-2004 19:45

Re: Why I hate c
 
Quote:

Originally Posted by gnormhurst
Thanks for that pointer to IOCCC -- I think that's where that bit of code came from, many years ago.

And now I'm reminded of another language, "whitespace,", wherein all code is composed entirely of three characters: space, newline, and tab.

Here's a example bit of code:

...

Maybe next year FIRST will specify whitespace as the language we use.

**** the guy who makes that decission.

By the way, what does your program do?

deltacoder1020 18-03-2004 23:37

Re: Why I hate c
 
Quote:

Originally Posted by gnormhurst
Thanks for that pointer to IOCCC -- I think that's where that bit of code came from, many years ago.

best bit of IOCCC code ever... only runs on certain machines, though:

Code:

short main[] = {
        277, 04735, -4129, 25, 0, 477, 1019, 0xbef, 0, 12800,
        -113, 21119, 0x52d7, -1006, -7151, 0, 0x4bc, 020004,
        14880, 10541, 2056, 04010, 4548, 3044, -6716, 0x9,
        4407, 6, 5568, 1, -30460, 0, 0x9, 5570, 512, -30419,
        0x7e82, 0760, 6, 0, 4, 02400, 15, 0, 4, 1280, 4, 0,
        4, 0, 0, 0, 0x8, 0, 4, 0, ',', 0, 12, 0, 4, 0, '#',
        0, 020, 0, 4, 0, 30, 0, 026, 0, 0x6176, 120, 25712,
        'p', 072163, 'r', 29303, 29801, 'e'
};

see the hint file here
this is from the first IOCCC competition in 1984

Ryan M. 19-03-2004 08:45

Re: Why I hate c
 
Quote:

Originally Posted by gnormhurst
I had to toss this in. It's my favorite bit of obfuscated C -- a program written to be incomprehensible. (I didn't write it -- I don't know who did.) I guess what's "bad" about C is that it lets you write code like this. But this code is masterfully written by someone who knows the language very well -- maybe a little too well.

This will compile and run on a command line, printing a message. It looks scary, but it's harmless. The output will astound you. Here's a hint: Merry Christmas!

/Norm
...

There is absolutly no way that should compile. :) Wow, that's the crazy. And whoever created that Whitespace language has too much spare time. :):)

Astronouth7303 19-03-2004 18:41

Re: Why I hate c
 
Ditto on both of those and Deltacoder's

meatmanek 20-03-2004 01:43

Re: Why I hate c
 
If you really want to see a pointless language, check out Befunge(http://kotisivu.mtv3.fi/quux/befunge.html); they call it a '2 dimensional, lower than assembly' language. Scary thought. Here's a bit of code:

Code:

>1+>:~::"0"-:v>$:v>>21p    :0#v_1-::::6g:" "-!88+*+v
p  +v_:#`0 #<_|_ " |-+77:+1g12_!v!-"!":+0-"0"+gg12\<
6v 3>#$"9"-:v#<|_/ >$11g3+:6g4v->88+*+:"9"`:"0"+85*v
\| p#_!:`"#0_ ^"|" vp3p04+1:g0<^+2g11p+1g12\-*+55p1<
^< ^6+1p11:\_!-6#<^>1+:6g:84*#^-#4 _$$40g:"+"\:"|"v
                        v59:+1p3+1\g6p12:<1:p2p3\<
                        >*\2p:21g1+:11g-#^_$$31p70p11gv
2x                  v06:g22p124 p42 -\p22+1:g04p00::-3-<
3x                  >p80p >22g::3g:" "-!88#v+#*<
4x                  v g42_^#!:-1p22+1pg12\+<>+90p650p11v
5x                  >:23p 3g60g:1+60p21ggv  ^77p08p06:<g
6x                  ^+1g32_v#!:- _v#-" ":<vg12\+*+88!<-2
7x                      # >0`!#v_22g:1+22p  :3g:" "-^++ >v
8x                      !  >$$>#_      >    22g00g1^: 0g
9x                        v_v#`0_v#:-gg12g06 gg05 :    < 51
 vp*469"$"`-1g13:$_v#! -* 48 :g <_v>60g1+60p1+:70g-  #^_^+
v_>$>:#,_@>      #\    $^$ >50g1  +50p50g90g-1-  !#v_^  5
">v>50p:!#^_50g:vv6 8-6g05<      #                  < !p0<
0:2^+1\-1\p1\"0"<>* +22g1-1p!#v_ :50g1-g>  80g:1+80p21g1+pv
"+1^g22:: <  v_ #` #g13g2$#2!#<^  #    ^_v#-" ":g-1g05: +1<
\1g >64*-#^_$| >$  60g21g2+p          v >$$80p22g>1-::60p:21v
 p2 ^p12:+2g12p 08p06:\-<v06gg09 :<$#  >#    #<  ^vg+1g12\gg<
 +>+g"0"-!#v_:22g\- 00g\^>g21gg-:!#^_0`90g\-90p^    >:" "-!#v_v
 ^2g12\" ":<$!_^#!-+88-gg12-1g06 :+"0"<  p080_v#<`0+1:-g08-  <
>:#-1g #2\  #<    >1-:31g-"."\#|_\:< ^++55p081< ^10    :$$<JJ

... Yep, that's code. I swear. Don't ask me how it works, I'm as clueless as you are. Apparently that divides two numbers.

Also, Assembly is by far not the lowest language. Many programmers (decades ago) have programmed by punching holes in punch cards, using direct binary values, and even wiring vaccuum tubes together to perform a specific task.

Astronouth7303 20-03-2004 10:02

Re: Why I hate c
 
Quote:

Originally Posted by meatmanek
...
Also, Assembly is by far not the lowest language. Many programmers (decades ago) have programmed by punching holes in punch cards, using direct binary values, and even wiring vaccuum tubes together to perform a specific task.

The latter isn't programming. In order to program, it has to be programmable.

Ryan M. 20-03-2004 12:37

Re: Why I hate c
 
Quote:

Originally Posted by Astronouth7303
The latter isn't programming. In order to program, it has to be programmable.

I agree to some extent. That really isn't programming any more than revising an electrial circuit is. When you see someone substitute one circuit board for another, you don't think, "Wow, that's great programming." :):)


All times are GMT -5. The time now is 00:14.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi