127

oOo, 1569 1515 bytes Had to be done. Try it here. Golfed: ...


59

Brain-Flak Classic, 1271 1247 1239 bytes <>(()){<>((([][][][][])<(((({}){})(({})({}))[])({}(({})({}({})({}{}(<>)))))[])>{()<{}>}{})<{{}}{}>())}{}<>(<(({()(((<>))<>)}{}{<({}(([][][])((({})({}))[]{})){})>((){[]<({}{})((){[]<({}{}<>((({})({})){}{}){})(<>)>}{}){{}{}<>(<(...


48

Python 2 (No STDIN) Thanks to Skulpt, it has become very easy to write a Python interpreter. function out(text) { var output = document.getElementById("output"); output.innerHTML = output.innerHTML + text; } function builtinRead(x) { if(Sk.builtinFiles === undefined || Sk.builtinFiles["files"][x] === undefined) throw "File not found: '...


39

brainfuck, 843 691 bytes Edit: decided to revisit this and found a surprising number of ways to golf off bytes >>>,[>++++[-<-------->]<-[>+<<]>[----------[>]>[<+<+>>>>]<<<-[>]>[<+<+>>>>]<<<-[>]>[<+<+>>>>]<<<-[>]>[<-&...


33

Befunge-93 Edit: I reworked the entire GUI now. I'm much happier with it. Some kind of breakpoint feature would be cool, but it's probably too much for this. Open Points I will probably revisit: Allow an infinite board Displaying the stack when stepping through the program would be neat Since I just implemented this interpreter for this challenge it's not ...


33

TI-BASIC 'cause who doesn't like TI-Basic? I wanted to contribute to this, so I picked a language that is (in my humble opinion) slightly more complicated than, say, Deadfish, but within my control. I know a lot about my calculator, so I picked this. I don't however, have any background experience with JavaScript/CSS/HTML. This was my first program. That ...


31

Mathematica 200 198 188 171 168 Spaces added for clarity: f[i_, b_, h_, j_, r_, n_] := (a = h; p = j; s = k = {}; t = Flatten; (Switch[#, 6, s = {a, p, s}, 8, {a, p, s} = s, _C, k = {k, Line@{p, p += {Cos@a, Sin@a}}}]; If[# < 9, a += I^# b ]) & /@ t@Nest[# /. r &, i, n]; Graphics@t@k) Where: i : Initial state; ...


31

05AB1E, 5 bytes vy.V, Try it online! Explanation This challenge fit 05AB1E like a glove :) vy # for each instruction in the program .V # execute as 05AB1E code , # print


26

Binary Lambda Calculus 112 The program shown in the hex dump below 00000000 44 51 a1 01 84 55 d5 02 b7 70 30 22 ff 32 f0 00 |DQ...U...p0".2..| 00000010 bf f9 85 7f 5e e1 6f 95 7f 7d ee c0 e5 54 68 00 |....^.o..}...Th.| 00000020 58 55 fd fb e0 45 57 fd eb fb f0 b6 f0 2f d6 07 |XU...EW....../..| 00000030 e1 6f 73 d7 f1 14 bc c0 0b ff 2e 1f a1 6f ...


26

Brainfuck Here's a basic BF interpreter. There's no debugger though, but has a couple of customisation options. const NUM_CELLS = 30000; const ITERS_PER_SEC = 100000; const TIMEOUT_MILLISECS = 5000; const ERROR_BRACKET = "Mismatched brackets"; const ERROR_TIMEOUT = "Timeout"; const ERROR_INTERRUPT = "Interrupted by user"; var code, input, wrap, ...


26

Python 3, 421 414 410 404 388 395 401 bytes Golfed: import sys,re v,i,c,g,L={},0,[re.sub('( ?)[^9]+','\\1',l).rstrip().split(' ')for l in open(sys.argv[1])],lambda i:v.get(i,int(i)//9),len while-1<i<L(c): d=c[i];l=L(d);e,*f=d;i+=1 if l>1: x,*y=f if e:w=list(map(g,f));v[e]=sum(w[::2])-sum(w[1::2]) elif l==2:j=input();v[x]=int(j)if L(x)%2 ...


24

Binary Lambda Calculus, 232 bits (29 bytes) 0101000110100000000101011000000000011110000101111110011110000101110011110000001111000010110110111001111100001111100001011110100111010010110011100001101100001011111000011111000011100110111101111100111101110110000110010001101000011010 See http://en.wikipedia.org/wiki/Binary_lambda_calculus#Lambda_encoding for ...


22

Binary Lambda Calculus 186 The program shown in the hex dump below 00000000 18 18 18 18 18 18 44 45 1a 10 18 18 45 7f fb cf |......DE....E...| 00000010 f0 b9 fe 00 78 7f 0b 6f cf f8 7f c0 0b 9f de 7e |....x..o.......~| 00000020 f2 cf e1 b0 bf e1 ff 0e 6f 79 ff d3 40 f3 a4 46 |........oy..@..F| 00000030 87 34 0a a8 d0 80 2b 0b ff 78 16 ff fe 16 ...


21

Marbelous* This interpreter is probably filled with bugs; if you find any, please let me know. This supports all features of Marbelous except #include. There is also an option for using a cylindrical board (marbles shoved off the sides of the board reappear on the other side). The interpreter also comes with many boards present in the examples in the repo ...


21

Unicorn (ES6), 5934 5278 bytes Under the custom encoding, this is 5278 bytes (1 byte per char); but with UTF-8, it would 4 bytes per char (though only 1 for a space), or 20869 total. (too many Unicorns and Goats to reasonably display here) Instead, here's a pastebin. This Unicorn code transpiles to this JS snippet: s=>eval(s.replace(/\S+ ?/g,c=>...


21

Python 3, 43 bytes lambda s:re.sub("00|11","",s)[-1] import re Try it online! The function takes a single string as input, where the first character is the initial state and the rest of the string represents the commands. This solution can be easily ported to other languages that have better support for regular expressions. The difficult part is to ...


20

Python 3, 69 68 bytes -1 byte thanks to @WheatWizard i=0 for c in input(): i+=c==';' if'#'==c:print(end=chr(i%127));i=0 Try it online!


20

*, 0 bytes Since * has no way of reading input, the default rules allow specifying that the input must be given by concatenating it onto the program. (... I think. There's an "at least twice as many upvotes as downvotes" condition that I don't have the rep to verify).


19

Jelly, 3 bytes y@/ Input is a single list: the accumulator, followed by the pairs. Try it online! How it works The y atom performs transliteration; [a,b]yc replaces a with b, so it returns b if a=c and c if a≠c. y@/ folds/reduces the input by y with swapped arguments, performing one transliteration per pair.


18

Retina 0.8.2, 386 391 386 bytes Code contains unprintable NUL (0x00) characters. It's also not super golfed yet, because it's already really slow, and if I golf it more, I don't know how long it'd take to finish. Appears to time out on the prime-finding sample. There may be bugs in the online interpreter or in my program (leading new lines don't show in ...


17

DogeScript The 99 bottles of beer program: many amaze 99 time such scare bottles-of-beer such scream on-the-wall many despair 13 time such fail take-one-down-pass-it-around wow so amaze so scare so scream so despair! so amaze so scare so despair! much amaze so fail so despair! so amaze so scare so scream so despair! so despair! very amaze wow ...


17

JavaScript (sample answer) Interpreting JavaScript using JavaScript is somewhat useless, but this shows what your interpreter snippets should roughly behave like. Here is the bare bones version, intended for quick use in other posts: BEGIN_CODE // Put JavaScript code here // it may be on multiple lines END_CODE_BEGIN_INPUT Put input here it may ...


17

Python 3, 770 bytes This is a REPL on stdin/stdout. Expects every line to be a full statement or empty. eval is used to shorten the implementation, but is otherwise not necessary for logic. import re,sys;S=re.sub P=lambda l:eval(S("([A-Z0-9][A-Z0-9 ]*)",r"' '.join('\1'.strip().split())",S("NIL","()",S("\)",",)",l)))) d={"QUOTE":'(v,L[1])[1]',"EQ":'[(),"T"][...


17

JavaScript (ES6), 76 82 80 bytes s=>s.replace(/./g,c=>c=='#'?String.fromCharCode(a%(a=127)):(a+=(c==';'),''),a=0) Demo let f = s=>s.replace(/./g,c=>c=='#'?String.fromCharCode(a%(a=127)):(a+=(c==';'),''),a=0) console.log(JSON.stringify(f(";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;#;;;;;;;;;;;;;;;;;;;;;;;;;...


16

APL (Dyalog) (326 - 8 = 318) Paste it in an editor window and call H. Input is taken from the keyboard. H ⎕←'Source code contains invalid characters'/⍨~∧/'HhQq9+'∊⍨V←⍞ B←' of beer' W←' on the wall' L←⎕TC[2] Z←{k←' bottle','s'/⍨⍵≠1⋄⍵<0:'99',k⋄⍵=0:'No',k⋄k,⍨⍕⍵} {⍵∊'Hh':⎕←'Hello, world!' ⍵∊'Qq':⎕←V ⍵∊'9':{⎕←G,K,(G←Z⍵),B,L,(⊃'Go to the store and buy some ...


16

Common Lisp, 1180 857 837 836 bytes I know this is not going to win, but I had fun golfing this one. I managed to remove 343 bytes, which is more than two 99 interpreters written in CJam. Also, quite amusingly, the more I try to compress it, the more I am persuaded that for Common Lisp, it is shorter to compile the code than to try interpreting it on ...


16

CJam, 157 bytes {:I;_N" 9"+--N/:P:,$W=){1a*Ab}%:V;{PT):T(=:LS%_{LS#\:,_,({(\{V=}%@{V-1@{2$*+0@-\}*\;t:V;}{:|T@V=9*?:T;}?}{~\{_V=\1&!{128%c}*o}{VIW):W=it:V;}?}?}R?Tg)TP,<*}g} Try it online: I/O Test G11G10G9G8G7G6G5G4G3G2G1G 99 bottles of beer (this code is too long to fit in a URL, so copy the code and paste it into the interpreter manually) ...


16

C (gcc), 1381 1338 1255 1073 bytes Huge improvement thanks to ceilingcat and Rogem. #include<stdio.h> C*F="%02hhx ";m[256],p,a,x,z,n,c,e;g;*I(){R++p+m;}*A(){R*I()+m;}*X(){R*I()+m+x;}C*Q(){W(printf,m[g],1)exit(a);}C*(*L[])()={I,Q,A,Q,X,Q,Q,Q};l(C*i){R 254/p?*i=*L[m[p]&7]():*Q();}s(i){R 254/p?*L[m[p]&7]()=i:*Q();}q(){p>254?Q():++p;}C*y(){p+=...


15

Brainfuck (with basic debugger) I saw the brainfuck answer and thought: you know what would be awesome? If I could pretend I understand what brainfuck code is doing. And hence I made a basic brainfuck interpreter and debugger. The debugger is SLOW, but it works pretty well, albeit I havent implemented breakpoints as of now (on the todo list). Note: the ...


Only top voted, non community-wiki answers of a minimum length are eligible