r/shittyprogramming • • Mar 19 '14

When you first learn about #define

Post image
510 Upvotes

37 comments sorted by

10

u/504Dug Mar 19 '14

<ooc> What editor is this in? Sublime? I really like that look and feel </ooc>

17

u/reddigineer Mar 19 '14

Komodo

3

u/PublicSealedClass Mar 19 '14

I see what he means though, that font anti-aliasing is pretty damn sexy. Consolas just looks a bit shit when zoomed in Visual Studio...

11

u/shiase Mar 19 '14

try an os that isn't windows

13

u/Randolpho Mar 19 '14

Although your advice is entirely unhelpful, I have to mark points off for not using inflammatory terms like "m$ winblows".

6/10. Mildly successful troll.

8

u/shiase Mar 19 '14

its true, windows font rendering looks like ass

-5

u/[deleted] Mar 19 '14

if you are being serious- I have coded c and c++ on a Linux before, and the IDE experience is so terrible. The best way is to fucking type into a text editor and compile everything manually through a terminal.

Windows is like 1000000 more user friendly for the coder.

8

u/Xenasis Mar 19 '14

GNU/Linux (or other Unix-likes) can very well be more powerful than any IDE with just a well configured text editor. How do you think the GCC was written?

For example, Emacs has M-x compile (and is designed to aid C/C++ development in general), for example, and, like Vim, can be very, very easily set up to use code completion for C/C++. Omnicomplete or YouCompleteMe in Vim are just as powerful as any IDE's completion, arguably more so.

You're right, Windows programs are designed to be easier out of the box - so is Windows. Getting a finely tuned programming environment that you think is 100% tailored to you (and fully understand the workings of) is nigh impossible on Windows - you're stuck with the IDEs given.

Tl;dr - Windows can make things easier in the short run, but it'd be nonsense to deny that you can use a well-configured editor on a Unix-like to be just as powerful if not more-so than any IDE.

1

u/EvilKanoa May 02 '14

That all makes sense. But I'm a high schooler who is happens to be okay at coding that loves to just play around with things. I have used Linux enough to know it's more powerful after you've made it more powerful. Windows is still my favourite OS though. So easy to do stuff, and everything is just ready to go!

3

u/Xenasis May 02 '14

You can't play around with stuff quite as much in Windows though - GNU/Linux is exactly where the hacking (original sense of the word) philosophy began, a bunch of people messing around with stuff for fun.

Though I don't intend to be a dick about this, there's nothing to say GNU/Linux is harder to work with - and most people agree that it's a tonne more user friendly - one only has to look at the installation of programs to see that, and there are distributions like LMDE and Fedora that can have working environments out of the box.

2

u/EvilKanoa May 02 '14

Oh, I could totally use a Linux distro. But I've tried using a few vs my Windows install. I find I'm just more productive on Windows, I know I probably could've configured my stuff more on Linux. But I really don't want to do it too much yet.

If I every got a job in the field, I'd probably switch to Linux. But for the time being I really enjoy Windows the most.

I do have a VM with Ubuntu runing without any UI (SSH in) for anything I can't do on Windows. :P

2

u/Xenasis May 02 '14

Definitely your call - if you're only in high school, it doesn't matter for the most part!

My advice if you want to dabble some time would be to install a GNU/Linux distro some time you have a bit of free time and just... have fun in it - that's what using computers should be about. Don't ever do it if it feels like a chore - it shouldn't be something you have to learn, it should be something you want to do.

The BSD family is also pretty good these days, too. I was pleasantly surprised with FreeBSD when I gave it a shot!

→ More replies (0)

1

u/SnowdensOfYesteryear Mar 19 '14

What's the theme? I want to steal all the colors for my terminal.

59

u/taneth Mar 19 '14

I once encountered a bunch of defines that turned c++ into Delphi, just so a heap of code could be brought over from another project with minimal syntactic changes. It actually worked.

7

u/Delta-62 Mar 24 '14

Would you happen to have a link?

10

u/taneth Mar 24 '14

Not working for that company anymore. But there's something similar somewhere on TheDailyWTF, I think they were trying to turn that one into BASIC.

28

u/[deleted] Mar 19 '14
much program
              very code
         wow

Sorry, I couldn't help making a joke about the "wow" thing.

5

u/green_transistor Mar 19 '14

Just wait till you find out about Lisp macros.

5

u/sfriniks Mar 24 '14

This reminds me of when I first found #define. My friend and I spent a while #define-ing so we could write lolcode and have it compile. It actually worked, too. I wish I still had that header file...

2

u/autowikibot Mar 24 '14

LOLCODE:


LOLCODE is an esoteric programming language inspired by lolspeak, the language expressed in examples of the lolcat Internet meme. The language was created in 2007 by Adam Lindsay, researcher at the Computing Department of Lancaster University.

The language is not clearly defined in terms of operator priorities and correct syntax, but several functioning interpreters and compilers already exist. One interpretation of the language has been proven Turing-complete.


Interesting: Esoteric programming ^language | ^Lolcat | List of Hello world program ^examples | Parrot virtual ^machine

Parent commenter can toggle ^NSFW or ^delete. Will also delete on comment score of -1 or less. | FAQs | ^Mods | Magic ^Words

3

u/danubian1 May 12 '14

Oh. Oh this hurts so much...

2

u/SiOD Mar 19 '14

The original Bourne shell was actually written using macros like these

A rant against flow control macros

2

u/ianbllngr Apr 10 '14

Using this in programming class from now on.

1

u/Dragonfelx Mar 19 '14

This is actually pretty cool. I like the concept of telling a function "bye" to end it.

1

u/coffeedrinkingprole Mar 24 '14

When I was 12 I did this kind of thing with DOS .bat files to make myself feel like a 1337 movie hacker

1

u/Randolpho Mar 19 '14

Lots of esoteric languages are implemented essentially the same way.

-5

u/[deleted] Mar 21 '14

Using a break command is the sign of a poor programmer. I hope that is why it's in this sub.

0

u/[deleted] Mar 19 '14

[deleted]

162

u/kernalphage Mar 19 '14
#ifdef _DEBUG_
#define TRUE (rand() % 9999)

51

u/RenaKunisaki Mar 19 '14
#define if(x) if((x) && (rand() > 700))
#define while if
#define int float
#define stderr stdout
#define sizeof(x) (sizeof(x) + 16)
#define memcpy strncpy
#define malloc(s) malloc((s) - 4)
#undef EACCES
#define EACCES ENOENT

not tested, may not work, use at your own peril.

94

u/[deleted] Mar 19 '14

woah calm down satan

38

u/thungsten Mar 19 '14
 #define struct union
 #define else

12

u/combatdave Mar 19 '14

Had to look up unions. You evil bastard.

3

u/thungsten Mar 19 '14
 #define struct union
 #define else