Skip to content

Instantly share code, notes, and snippets.

@minitech
Created July 1, 2012 17:14
Show Gist options
  • Save minitech/3028999 to your computer and use it in GitHub Desktop.
Save minitech/3028999 to your computer and use it in GitHub Desktop.
Fake Ruby
// This C is pretending to be Ruby.
// Yeah, I know the ifs aren't quite right. Oh well.
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#define puts );printf("%s\n",
#define gets _gets()
#define if );if(
#define then ){noop(
#define else );}else{noop(
#define end );}noop(
void noop() {}
char *_gets() {
char *r = malloc(81);
fgets(r, 80, stdin);
return r; // YAY memory leaks
}
main(){noop(
/* Insert your Ruby code here! */
puts "Hello, world!"
if 0 == 0 then
puts "The universe still works."
else
puts "Weird stuff is happening!"
end
if "hello" == "hello" then
puts "GCC has some pretty awesome compiler optimizations."
end
if 5 < 4 then
puts "Ooookay, then."
else
puts "Yeah!"
end
puts gets
/* All right, stop now. */
);return 0;}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment