Scratch is dumb

From Esolang
Jump to navigation Jump to search

Scratch is dumb is a trivial brainfuck substitution made by User:None1, it is made to response to the person who invented the esolang Esolang Simply Created To Annoy People Who Dislike Scratch, who wants to annoy people who dislike scratch. This esolang will tell you that Scratch IS useless and even dumb! Even dumber than brainfuck! Because Scratch has no ASCII table and no control characters (That means you cannot say mutiline text in Scratch)

Introduction

This is a brainfuck-equivalent esolang, instead of brainfuck's command, you use the unprintable characters 0x00 to 0x07, that means all Scratch is dumb programs are binaries.

Why this esolang tells you that Scratch is dumb

Because this esolang uses unprintable characters which you cannot type and print in Scratch, but a proper language like brainfuck can print it easily.

Convert to brainfuck

Here is a Scratch is dumb to brainfuck table.

Scratch is dumb (hex)     brainfuck
00                       +
01                       -
02                       ,
03                       .
04                       <
05                       >
06                       [
07                       ]

Example Programs

The programs here are in hex dump.

Cat Program

00 06 02 03 07

Hello World

00 00 00 00 00 00 00 00 06 05 
00 00 00 00 06 05 00 00 05 00 
00 00 05 00 00 00 05 00 04 04 
04 04 01 07 05 00 05 00 05 01 
05 05 00 06 04 07 04 01 07 05 
05 03 05 01 01 01 03 00 00 00 
00 00 00 00 03 03 00 00 00 03 
05 05 03 04 01 03 04 03 00 00 
00 03 01 01 01 01 01 01 03 01 
01 01 01 01 01 01 01 03 05 05 
00 03 05 00 00 03 

brainfuck Interpreter

Because dbfi is not public domain, this program is moved here.

Turing completeness

Scratch is dumb programs are binaries but it is still Turing complete because brainfuck is.

P.S.: I dislike Scratch very much, I think Scratch isn't even capable of being an esolang (nor is it capable of being a non-esoteric programming language)!

Interpreter

Python

import sys
def run(code):
    s1=[]
    s2=[]
    matches={}
    tape=[0]*1000000
    for i,j in enumerate(code):
        if j==6:
            s1.append(i)
        if j==7:
            m=s1.pop()
            matches[m]=i
            matches[i]=m
    cp=0
    p=0
    while cp<len(code):
        if code[cp]==0:
            tape[p]=(tape[p]+1)%256
        if code[cp]==1:
            tape[p]=(tape[p]-1)%256
        if code[cp]==2:
            tape[p]=ord(sys.stdin.read(1))%256
        if code[cp]==3:
            print(chr(tape[p]),end='')
        if code[cp]==4:
            p-=1
        if code[cp]==5:
            p+=1
        if code[cp]==6:
            if not tape[p]:
                cp=matches[cp]
        if code[cp]==7:
            if tape[p]:
                cp=matches[cp]
        cp+=1
with open(sys.argv[1],'rb') as f:
    run(f.read())

Scratch