|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
| Thread Tools | Rate Thread | Display Modes |
|
#46
|
|||||
|
|||||
|
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++.
|
|
#47
|
||||
|
||||
|
Re: Why I hate c
Quote:
![]() |
|
#48
|
||||
|
||||
|
Re: Why I hate c
Quote:
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:
) |
|
#49
|
||||
|
||||
|
Re: Why I hate c
Quote:
|
|
#50
|
|||||
|
|||||
|
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);}
|
|
#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? |
|
#52
|
|||
|
|||
|
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. |
|
#53
|
|||||
|
|||||
|
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.
|
|
#54
|
|||||
|
|||||
|
Re: Why I hate c
Quote:
By the way, what does your program do? |
|
#55
|
||||
|
||||
|
Re: Why I hate c
Quote:
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'
};
this is from the first IOCCC competition in 1984 |
|
#56
|
||||
|
||||
|
Re: Why I hate c
Quote:
Wow, that's the crazy. And whoever created that Whitespace language has too much spare time. ![]() ![]() |
|
#57
|
|||||
|
|||||
|
Re: Why I hate c
Ditto on both of those and Deltacoder's
|
|
#58
|
|||
|
|||
|
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
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. |
|
#59
|
|||||
|
|||||
|
Re: Why I hate c
Quote:
|
|
#60
|
||||
|
||||
|
Re: Why I hate c
Quote:
![]() ![]() |
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| I Hate It When... | sanddrag | Chit-Chat | 77 | 25-12-2003 10:57 |
| I hate the BCS and i really ha te KANSAS ST. | Jon Reese | Chit-Chat | 10 | 11-12-2003 12:09 |
| GRRr.... I hate webpages... | XRaVeNX | Chit-Chat | 4 | 15-03-2002 12:28 |
| Why I hate Logic | EnderofDragon | Chit-Chat | 2 | 19-02-2002 21:02 |