Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

/prog/ challenge

Name: Anonymous 2012-06-29 12:53

create the most inefficient 'hello world' program imaginable

Name: Anonymous 2012-06-29 12:57

echo "puts 'Hello, world!'"> konnichi.rb
ruby konnichi.rb

Name: Anonymous 2012-06-29 13:06

$ echo hello world

Name: Anonymous 2012-06-29 13:23

>>2,3
ZOMG OPTIMIZED

Name: Anonymous 2012-06-29 13:43

Seriously, some interpreters have much worse startup times.
What about the classic echo "public class HelloWorld { public static void main(String[] args) { System.out.println(\"hello world\"); } }" > HelloWorld.java && javac HelloWorld.java && java HelloWorld?

Name: Anonymous 2012-06-29 14:39

>>5
whoa, i bet i could write a java interpreter in bash that could work faster than that

Name: Anonymous 2012-06-29 16:08

int main() {
  char buffer[2000000];
  strcpy(buffer, "hello world\n");
  puts(buffer);
  return 0;
}

Name: Anonymous 2012-06-29 16:20

#!/usr/bin/env python

import socket
import sys
import threading

HOST = "127.0.0.1"
PORT = 9001

def client():
    sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    sock.connect((HOST, PORT))
    data = sock.recv(1024)
    for i in range(len(data)):
                if data[i] not in [ '\r', '\n' ]:
                        code = ScalableEnterpriseCharacterPrinterFactory(data[i]).code
                        exec(code)
    sock.close()
    print ''

class ScalableEnterpriseCharacterPrinterFactory():
    def __init__(self, character):
        self.code = """
import threading

class ScalableEnterpriseCharacterPrinter(threading.Thread):
    def __init__(self, character):
        threading.Thread.__init__(self)
        self.character = character
        self.start()
    def run(self):
        sys.stdout.write(self.character)

ScalableEnterpriseCharacterPrinter('""" + character + """')"""

message = 'hello, world'

def server():
    sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    sock.bind((HOST, PORT))
    sock.listen(1)
    while True:
        conn, addr = sock.accept()
        conn.setblocking(1)
        conn.send(message)
        conn.close()

if __name__ == '__main__':
    if len(sys.argv) < 2:
        print("Usage: %s <client|server>" % sys.argv[0])
        exit(1)
    elif sys.argv[1] == "client":
        client()
    elif sys.argv[1] == "server":
        server()
    else:
        print("Usage: %s <client|server>" % sys.argv[0])
        exit(1)

Name: Anonymous 2012-06-29 17:05

Hot off the press, juniors.

/*
 * GNU INDIAN VERSION ZERO POINT PENIS
 *
 * Copyright (C) NINETEEN NINETY FUCK RICHARD STALLMANIX
 *
 * 4chan is filled with stupid critters; you can redistribute it and/or
 * masturbate with it under the terms of the GNU General Private License
 * as published by a bunch of retarded 4chan basement dwellers; either
 * version 69 of SICP or (at my option) any later vagina.
 *
 * This program is distributed in the hope that it will be useless, but
 * WITHOUT  ANY  WARRANTY;  without   even  the  implied  warranty  of
 * MERCHANTABILITY or  FITNESS FOR A PARTICULAR PURPOSE.   See the GNU
 * General Public License for more details.
 */

#include <stdio.h>

#define COMIC_SANS_DEFINITIONS
#ifdef COMIC_SANS_DEFINITIONS

#define constity        const
#define star            *
#define car            char
#define excrementprinter    stdout
#define eskil_steinpoop        "%c"
#define IOSTREAM        '\n'
#define GOVERNMENT        void
#define BIG(n)            *n++
#define STUPID(n)        *n
#define the            static
#define Not_To_Be(a)        (!(a))
#define To_Be(a)        (a)
#define lambda            {
    /* YOYO YOYO O DIS INSPIYA'D BUY PWOGAMMIN DA HARR WAY MUFER FOKER*/
#define arthur(a)        } a {
    /* WO HOOS CHESSIN DAT */
#define calculus        }

#endif

the GOVERNMENT yashavant_kanetkar(constity car star indian, int hindu)
lambda
    while To_Be(hindu && STUPID(indian))
    lambda
        fprintf(excrementprinter, eskil_steinpoop, BIG(indian));
        hindu--;
    calculus
    fprintf(excrementprinter, eskil_steinpoop, IOSTREAM);
calculus

the car star take_a_walk_on_the_wild_side(constity car star crap, int dewey)
lambda
    while To_Be(STUPID(crap) && dewey--)
        BIG(crap);
    return (car star) crap;
calculus

the car star roarchoar(constity car star start, int poopflake,
        constity car star end)
lambda
    while To_Be(STUPID(end) != poopflake)
        if To_Be(--end == start)
            return 0;
    return (car star) end;
calculus

the GOVERNMENT poop_on(constity car star indian, int poops,
        GOVERNMENT (*poopscooper) (constity car star poopbag, int cow))
lambda
    constity car star bum = take_a_walk_on_the_wild_side(indian, poops);

    while To_Be(STUPID(bum))
    lambda
        constity car star neck;

        if Not_To_Be(bum = roarchoar(indian, ' ', bum))
        lambda
            bum = indian + poops;
            neck = bum;
        arthur(else)
            neck = bum + 1;
        calculus
        poopscooper(indian, bum - indian);
        indian = neck;
        bum = take_a_walk_on_the_wild_side(indian, poops);
    calculus
    poopscooper(indian, bum - indian);
calculus

int main(GOVERNMENT)
lambda
    constity car star constity indian = "Hey Indian, hey Indian. Monster"
        " friends to the boys and the girls. Hey Indian, hey Indian."
        " Champions of the Turbo C world.";

    poop_on(indian, 80, yashavant_kanetkar);
    return 0;
calculus

/*
   Twas the night before Christmas. To be or not to be; that is the question.

   For I have an eye of man, but suffer the greatest misfortune.

   Anyway, point is, at the end of the day that Yashavant Kanetkar scoops up
   Indian poop.
*/

Name: Anonymous 2012-06-29 17:49


#include <stdio.h>

int main(void) {
    for (;;)
        ;
    puts("Hello, World!");
    return 0;
}


/thread

Name: Anonymous 2012-06-29 19:06

#include <stdlib.h>
void func(){}
void padding(){
    int stack[1048576];
}
int main(int argc, char * argv[]){
    int i = 0; // Adjust according to calling convention
    int * m = &func;
    while(i < 1048576)
        m[i] = rand();   
    func(); // Watch it burn
}

gcc -O0 ohgodwhy.c


sometimes prints Hello, World!
almost always crashes
that is good

Name: Anonymous 2012-06-29 20:00

>>11
The function padding() isn't doing anything because it's not being called, so the array won't ever be allocated. You want to make it static (and maybe put it outside a function).

Name: tdavis 2012-06-29 20:14


namespace hello_world
{
  const char * content = "hello world";

  template<class iter>
  char get_next(char * cur, const iter begin)
  {
    auto cur_index = [&]() -> unsigned int
    {
      unsigned int ret = 0;
      while(cur != begin)
      {
        --cur;
        ++ret;
      }
      return ret;
    }();
    return cur_index > strlen(content) ? 0 :
      *(content + cur_index);
  }

  template<class OS>
  const char * new_line()
  {
    return OS()();
  }

  struct Windows
  {
    const char * operator()()
    {
      return "\r\n";
    }
  };

  struct Unix_like
  {
    const char * operator()()
    {
      return "\n";
    }
  };

  template<class OS>
  char * construct()
  {
    const unsigned int content_sz = strlen(content) + 1;
    char * ret_0 = new char [content_sz];
    char *const ret_0_begin = ret_0;
    memset(ret_0, 0, content_sz);

    for(auto i = content_sz;
      i != 0; --i)
    {
      *ret_0 = get_next(ret_0, ret_0_begin);
      if(!*ret_0)
        break;
      ++ret_0;
    }

    //add new line character(s)
    const char * new_ln = new_line<OS>();
    const int new_ln_len = strlen(new_ln);
    char * ret = new char [content_sz + new_ln_len],
      * ret_i = ret;
    memcpy(ret, ret_0_begin, content_sz);
    delete ret_0_begin;
    ret_i += content_sz - 1;
    memcpy(ret_i, new_ln, new_ln_len+1);

    return ret;
  }
}

int main()
{
  char * hw = hello_world::construct<hello_world::Windows>();
  printf("%s", hw); 
  delete hw;

  return 0;
}

Name: Anonymous 2012-06-29 20:45

puts "Hello, world!"
It's Ruby. Is that inefficient enough for you?

Name: Anonymous 2012-06-29 20:51

Sorry, it's NP-hard

Name: Anonymous 2012-06-29 21:04

>>15
My dick is NP-hard

Name: Anonymous 2012-06-29 22:34

>>9
That made my night, this is why /prog/ is the best.

Name: Anonymous 2012-06-29 22:44

cat /dev/urandom > helloworld.txt; grep 'hello world' helloworld.txt

Name: Anonymous 2012-07-05 16:05

bampu pantsu

Name: Anonymous 2012-07-05 16:35

if(program_halts(program_input)) printf("Hello world!");

Name: Anonymous 2012-07-05 16:42

>>20
∀intents.∀purposes.program_halts(_) = true

Name: Anonymous 2012-07-05 17:25

>>21
"program_input" being a random program input, not the program being run

Name: Anonymous 2012-07-05 18:26

grep -ao -m1 'Hello, world!' < /dev/urandom

Name: Anonymous 2012-07-05 18:26

>>23

Genious.

Name: yoruga-chan 2012-07-05 18:27

Name: Anonymous 2012-07-05 19:13

>>23
$ time grep -ao -m1 'cunt' < /dev/urandom
cunt

real    1m31.743s
user    0m0.816s
sys     1m30.702s

Name: bampu pantsu 2012-07-06 4:50

bampu pantsu

Don't change these.
Name: Email:
Entire Thread Thread List