Comment On The Secret to Better C

At first, Adam Quinn was a bit confused to see expressions like "repeat until(freq LT testFreq)" in the C application he was maintaining. But after a little bit of digging, he was thrilled to find the secret to "Better C" buried in an appropriately named header file. [expand full text]
« PrevPage 1 | Page 2 | Page 3 | Page 4 | Page 5 | Page 6Next »

Re: The Secret to Better C

2006-02-15 15:00 • by stonguse
Wow. What a waste of time.

Re: The Secret to Better C

2006-02-15 15:00 • by RayMarron
Mmm.... Perly!  However, I can't quite place that "ifnot" language feature.  What's that from?

Re: The Secret to Better C

2006-02-15 15:01 • by bramster
I never did like those pesky equal signs anyway.

#define CURLY_OPEN_BRACE {


Re: The Secret to Better C

2006-02-15 15:02 • by RanmaChan
Hey, I want to see the whole file!  That is only part of a Better C!  Surely there must be something better than switch statements and structures!


Re: The Secret to Better C

2006-02-15 15:02 • by Manni

Ugh, what a waste. It looks like he's trying to pull in some VB or SQL syntax. That makes sense, because it's so hard to remember ">" should be used for greater-than comparisons. Speaking of which, in a lot of places he replaced an operator (like ">") with a keyword that's longer than the original (now it's "GT").


I say we send him hunting with Dick Cheney.

Re: The Secret to Better C

2006-02-15 15:02 • by mrsticks1982

sweet, let's confuse everyone!!! I like to use BETTER_C++ it's my fav!!!


while we're at it why don't we create BETTER_JAVA and oh, oh BETTER_VISUAL_BASIC, changing it all, talk about job security!!

Re: The Secret to Better C

2006-02-15 15:02 • by Sam

Oh, it's just personal preference.  He didn't like the syntax, so he changed it.  Big deal.


 


 

Re: The Secret to Better C

2006-02-15 15:04 • by mrsticks1982
60264 in reply to 60261
Manni:

Ugh, what a waste. It looks like he's trying to pull in some VB or SQL syntax. That makes sense, because it's so hard to remember ">" should be used for greater-than comparisons. Speaking of which, in a lot of places he replaced an operator (like ">") with a keyword that's longer than the original (now it's "GT").


I say we send him hunting with Dick Cheney.



 


that should be the new punishment for all bad programmers!! Cheap Oil and Better Programmers!!! ahh, a fantasy world ...

Re: The Secret to Better C

2006-02-15 15:06 • by SeekerDarksteel

Awww, I saw the GT, GE, and LTs and thought FORTRAN.  Unfortunately those control structures don't look like they're from FORTRAN.  I was hoping there would finally be a WTF I could share with my co-workers.  :(

Re: The Secret to Better C

2006-02-15 15:06 • by PiV
60267 in reply to 60263
This is not a WTF, this is just someone using syntactical sugar type approach. No big deal. Who really cares?

Re: The Secret to Better C

2006-02-15 15:06 • by stonguse
60268 in reply to 60263
Anonymous:

Oh, it's just personal preference.  He didn't like the syntax, so he changed it.  Big deal.


 


 





Yeah, things are better off when everyone creates their own syntax.

Re: The Secret to Better C

2006-02-15 15:09 • by Angstrom
Reminds me of Bournegol.



http://www.goof.com/pcg/marc/bournegol.html

what if he includes...

2006-02-15 15:09 • by nTony
what if he..
#define pi 3.14159265............................................................

omg....
LOL

Re: The Secret to Better C

2006-02-15 15:10 • by Poultine
60274 in reply to 60263

"It's just personal preference" is something that should be kept at home for your fan fiction website, not for something that another sane human would have to maintain, as the submitter did. Now the maintainer has to re-interpret every "repeat { ... }untilforever" in the code into something that the rest of the C-speaking world understands without depending on kooky precompiler tricks.


The WTF is why a person couldn't handle "<" or "while(1)" in their native format. I can only assume that they got "BETTER_C.h" from someone else; anyone with enough syntactic knowledge to write the header didn't need it in the first place.

Re: The Secret to Better C

2006-02-15 15:10 • by R.Flowers

Yeah, the NE, EQ, etc. are Perly. Then we have MOD, which is VBish.


What's up with 'forever?' Where was he going to use forever{ //do something} ?

Re: The Secret to Better C

2006-02-15 15:13 • by Fregas
Can anyone say..."VB C"?

Re: The Secret to Better C

2006-02-15 15:14 • by Manni
60277 in reply to 60263
One anonymous idiot:
Oh, it's just personal preference.  He didn't like the syntax, so he changed it.  Big deal.

Another anonymous moron:
This is not a WTF, this is just someone using syntactical sugar type approach. No big deal. Who really cares?


I have no doubt that you don't care. You'll start pulling your hair out when you inherit some code like this though.

Re: The Secret to Better C

2006-02-15 15:14 • by uncool

Alex Papadimoulis:
#define forever   while(1)
#define untilbreak forever
#define untilreturn forever


 


why didn't i think of that...

Re: The Secret to Better C

2006-02-15 15:14 • by graywh
He was obviously trying to make C more self-documenting, which we all know is just an excuse for longer keywords that makes the language slower to code.

The real WTF is that he used acronymns (GT, LT, EQ, NEQ, ...) instead of whole words (lessthan, greatherthan, equals, ...).

Re: The Secret to Better C

2006-02-15 15:15 • by Arancaytar
> # define do_nothing
Priceless.

Re: The Secret to Better C

2006-02-15 15:16 • by Jeff S
60281 in reply to 60263
Anonymous:

Oh, it's just personal preference.  He didn't like the syntax, so he changed it.  Big deal.


 


 



Congratulations, Sam, that is actually one of the biggest "WTF" comments we've seen here in a while.   yeah, all he did was CHANGE THE SYNTAX of the language ... no biggie.




Re: The Secret to Better C

2006-02-15 15:18 • by blasterz
60282 in reply to 60258
Um...found this lovely document:

http://www.conman.org/software/amc/docs/html/amc_usersguide.html

Full of lovely linguistic and grammatical WTFs itself to boot. It includes all of the operators listed.

Re: The Secret to Better C

2006-02-15 15:19 • by Jeff S
Stupid VB programmers ... wait a second ... this isn't VB .... what is this?  C !?  how can
that be?  All bad coders write in exclusively in VB, and bad code can only be written in VB!!  What the heck is going on?

Re: The Secret to Better C

2006-02-15 15:19 • by cconroy
60284 in reply to 60268
I say we let him use it if he wants, but only if he renames it to I_am_an_incompetent_dumbass.h.



I've seen worse

2006-02-15 15:21 • by The Bears

The original Bourne shell takes this approach even further.



Look at mac.h. Then look at args.c. Then go wash your brain out with vodka.

Re: The Secret to Better C

2006-02-15 15:22 • by NoName
Kids,

the EQ, LT, GT etc. stuff is good old FORTRAN (sans leading and trailing '.').

And attempts to use the preprocessor to rape C are not new. More than 15 years ago I first saw:

#define BEGIN {
#define END }

and since then I have seen it a hundred times. There are just too many idiot programmers out there.

Re: The Secret to Better C

2006-02-15 15:23 • by wintermyute
Sweet.  This is one of the de-facto obfuscation methods used by entrants to the International Obfuscated C Code Contest

Re: The Secret to Better C

2006-02-15 15:25 • by graywh
60288 in reply to 60287
wintermyute:
Sweet.  This is one of the de-facto obfuscation methods used by entrants to the International Obfuscated C Code Contest


Exactly, but used for the opposite purpose.

Re: The Secret to Better C

2006-02-15 15:25 • by ChiefEngineer
60289 in reply to 60267

May be the guys who will have to keep his code up to date in the future?


I'm sure they WILL care about it...

Re: The Secret to Better C

2006-02-15 15:27 • by anonymous
60290 in reply to 60278
You're sane.

Re: The Secret to Better C

2006-02-15 15:27 • by sammybaby
60291 in reply to 60281
Jeff S:
Anonymous:

Oh, it's just personal preference.  He didn't like the syntax, so he changed it.  Big deal.


 


 




Congratulations, Sam, that is actually one of the biggest "WTF" comments we've seen here in a while.   yeah, all he did was CHANGE THE SYNTAX of the language ... no biggie.





 


I dunno, I'm having a hard time caring about it either. Although lately I've been messing with Ruby a lot, so maybe it's just that some of the resulting constructs are familiar. (Ruby has syntax built in for constructs like button.push unless thesign.says("Please do not push this button again").


 


But dude, seriously. He needed to reserve "forever"... AND untilbreak, AND untilreturn?


And a construct called do_nothing? 


(Incidentally: some of those comparison operators look Perlish, but they're not used appropriately. EQ and == aren't equivalent, for example: one compares strings, the other numeric values.)

Re: The Secret to Better C

2006-02-15 15:27 • by boogieman
Reminds me of my software engineering professor.  He was convinced that C was the worst thing ever conceived.

And yet he said the language would be a hundred times better if we added the following lines to the top of our code:
#define BEGIN {
#define END }

Re: The Secret to Better C

2006-02-15 15:28 • by Maurits
60293 in reply to 60275
R.Flowers:

Yeah, the NE, EQ, etc. are Perly. Then we have MOD, which is VBish.


What's up with 'forever?' Where was he going to use forever{ //do something} ?



excerpt of cruise_missile_guidance_system.c...

pos p = starting_position(), p_old, target = acquire_target();

do {
    p_old = p;
    p = gps_query();
    trajectory t = vector(p_old, p);
    correction c = calculate_course(target, p, t);
    adjust_course(c);
} forever;

Re: The Secret to Better C

2006-02-15 15:30 • by ChiefCrazyTalk
60294 in reply to 60266
SeekerDarksteel:

Awww, I saw the GT, GE, and LTs and thought FORTRAN.  Unfortunately those control structures don't look like they're from FORTRAN.  I was hoping there would finally be a WTF I could share with my co-workers.  :(



 


Looks like a half-FORTRAN, half Pascal hybrid super-language.

Re: The Secret to Better C

2006-02-15 15:30 • by ZeoS
60295 in reply to 60293
#define COMMENT //

Re: The Secret to Better C

2006-02-15 15:30 • by ChiefEngineer
60296 in reply to 60267

Anonymous:
This is not a WTF, this is just someone using syntactical sugar type approach. No big deal. Who really cares?


May be the guys who will have to keep his code up to date in the future?


I'm sure they WILL care about it...

Re: The Secret to Better C

2006-02-15 15:30 • by marvin_rabbit
#define    lAlpha    a
#define    lIndia    I
#define    sComma    ,
#define    sPeriod    .
#define    wBel    believe
#define    wBet    Better_C
#define    wCan    can't
#define    wComp    competitive
#define    wEd    edge
#define    wEn    enable
#define    wGv    give
#define    wGy    guys
#define    wI    is
#define    wImprov    improvements
#define    wjt    just
#define    wkd    kind
#define    wM    me
#define    wNd    need
#define    wO    of
#define    wSea    see
#define    wT    to
#define    wTech    technology
#define    wTh    the
#define    wThs    this
#define    wTht    that
#define    wTng    thing
#define    wU    you
#define    wWl    will

wTht wBet wTech wI wjt wTh wkd wO wTng wTht lIndia wNd wT wGv wM lAlpha wComp wEd sPeriod
lIndia wCan wBel wTht wU wGy wCan wSea wTh wkd wO wImprov wTht wThs wWl wEn sPeriod

Re: The Secret to Better C

2006-02-15 15:31 • by Rank Amateur

He's on the right track. Operators are works of the Devil. Weird, mysterious symbols, like Pagan runes. Must be Satan worshipping.


#define ASSIGN(x,y) (x) = (y)
#define ADD(x,y) (x) + (y)
#define SUBTRACT(x,y) (x) - (y)
#define MULTIPLY(x,y) (x) * (y)
#define DIVIDE(x,y) (x) / (y)
#define INCREMENT(x,y) (x) += (y)
#define INCREMENT1(x) INCREMENT(x,1)
#define POINTEROF(x) &(x)
#define THATPOINTEDBY(x) *(x)
#define MEMBEROF(x,y) (x).(y)
#define STOP ;


ASSIGN(a,MULTIPLY(MEMBEROF(THATPOINTEDBY(b),c),INCREMENT1(d))) STOP


And so much easier to read by the next generation of programmers.


Wait, I forgot:


#define BEGINPARENTHESES (
#define ENDPARENTHESES )
#define SEPARATOR ,


--Rank

Re: The Secret to Better C

2006-02-15 15:33 • by ChiefEngineer
60299 in reply to 60295

ZeoS:
#define COMMENT //


Great!


Should be added:


#define COMMENT_START     /*


#define COMMENT _END        */

Re: The Secret to Better C

2006-02-15 15:36 • by Maurits
60300 in reply to 60298
#define CONCATENATE_LITERAL_STRINGS(x, y) x y

Re: The Secret to Better C

2006-02-15 15:38 • by ChiefCrazyTalk
60301 in reply to 60295

ZeoS:
#define COMMENT //


 


you mean #define REM //

Re: The Secret to Better C

2006-02-15 15:39 • by Stern
Any idea why the board software insists on putting all code on a single line in the RSS feed (except the obvious donkey-cock suckage which comes as a built-in feature)?

Re: The Secret to Better C

2006-02-15 15:39 • by ZeoS
OMG! more defines come to my head

#define macro define
#macro . ;    COMMENT every statement should finish with .

Re: The Secret to Better C

2006-02-15 15:40 • by akrotkov
60304 in reply to 60301
I'm taking a C class right now, can I get the full file so I can force the grading TAs to wash their eyes out with acid?

Re: The Secret to Better C

2006-02-15 15:41 • by graywh
60305 in reply to 60298
Rank Amateur:

He's on the right track. Operators are works of the Devil. Weird, mysterious symbols, like Pagan runes. Must be Satan worshipping.


#define ASSIGN(x,y) (x) = (y)
#define ADD(x,y) (x) + (y)
#define SUBTRACT(x,y) (x) - (y)
#define MULTIPLY(x,y) (x) * (y)
#define DIVIDE(x,y) (x) / (y)
#define INCREMENT(x,y) (x) += (y)
#define INCREMENT1(x) INCREMENT(x,1)
#define POINTEROF(x) &(x)
#define THATPOINTEDBY(x) *(x)
#define MEMBEROF(x,y) (x).(y)
#define STOP ;


ASSIGN(a,MULTIPLY(MEMBEROF(THATPOINTEDBY(b),c),INCREMENT1(d))) STOP


And so much easier to read by the next generation of programmers.


Wait, I forgot:


#define BEGINPARENTHESES (
#define ENDPARENTHESES )
#define SEPARATOR ,


--Rank



Don't you mean

#define (x) PLUS (y)   (x) + (y)
#define (x) TIMES (y)   (x) * (y)
#define (x) MINUS (y)   (x) - (y)
#define (x) DIVIDEDBY (y)   (x) / (y)

I especially appreciate STOP.

Re: The Secret to Better C

2006-02-15 15:41 • by Chris
60306 in reply to 60262
I believe those are called C# and VB.NET.

[dons flame suit]

Re: The Secret to Better C

2006-02-15 15:41 • by ZeoS
60307 in reply to 60303
ZeoS:
OMG! more defines come to my head

#define macro define
#macro . ;    COMMENT every statement should finish with .


I meant

#macro . ;   REM every statement should finish with .

Re: The Secret to Better C

2006-02-15 15:43 • by Chris
60308 in reply to 60262
mrsticks1982:

while we're at it why don't we create BETTER_JAVA and oh, oh BETTER_VISUAL_BASIC, changing it all, talk about job security!!



I believe those are called C# and VB.NET.

Re: The Secret to Better C

2006-02-15 15:47 • by Albatross
60310 in reply to 60276

Anonymous:
Can anyone say..."VB C"?


No, but I can say VB++

Re: The Secret to Better C

2006-02-15 15:48 • by ZeoS
60311 in reply to 60308
The real WTF is that there are people still programing in C
« PrevPage 1 | Page 2 | Page 3 | Page 4 | Page 5 | Page 6Next »

Add Comment