Hello World: Stuck

Writing "Hello, World!" without writing any code at all?

·

1 min read

Let's start off the series with Stuck, a language where an empty file will output "Hello, World!"

Code


That's it, no code. An empty file in Stuck will print "Hello, World!".

How Does This Work?

We can take a look at the Github repository for Stuck and check out the source code.

In the stuck.py file, we can check out the main function:

def main():
    if len(sys.argv) < 2:
        while True:
            prog = raw_input("stuck > ")
            if prog == 'plugin':
                r=import_modules('plugins')
                for k in r:
                    print '%s - Version %s - By %s\n   %s'%(r[k].NAME, r[k].VERSION, r[k].CREATOR, r[k].DESCR)
            elif prog == '':
                print 'Hello, World!'
            else:
                process(prog, stack=[], t=0, nest=0)
    else:
        if sys.argv[1].split('.')[-1] == 'stk':
            f = open(sys.argv[1], 'r')
            prog = f.read()
            if prog == 'plugin':
                r=import_modules('plugins')
                for k in r:
                    print '%s - Version %s - By %s\n   %s'%(r[k].NAME, r[k].VERSION, r[k].CREATOR, r[k].DESCR)
            elif prog == '':
                print 'Hello, World!'
            else:
                process(prog, stack=[], t=0, nest=0)
        else:
            print 'Usage: python',__file__.split('/')[-1],'program.stk'

Do you see it?

elif prog == '':
           print 'Hello, World!'

The Stuck interpreter will print "Hello, World!" when the file is empty.

Conclusion

Esolangs are fun and help solidify an understanding of computers and programming. Stay tuned for the next language!