MiniStringFuck

MiniStringFuck (or MSF-) is an esoteric programming language with only two commands, operating on one cell.

Hello, World!
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++.+++++++++++++++++++++++++++++.+++++++..+++.+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++.++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++.+++++++++++++++++++++++++++++++++++++++++++++++++++++++.++++++++++++++++++++++++.+++.++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++.++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++.+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++.

Alphabet (uppercase)
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.

Golfing
To golf code you need to input the code to this program that does the job for you.

Implementation
Here is an implementation in Python 2.7.12. """ MiniStringFuck interpreter by Έρικ Κωνσταντόπουλος, © 2001-2015 """
 * 1) coding=utf-8

from sys import argv, stdout
 * 1) Let's import the required modules

code_ = open(argv[1]) code = code_.read
 * 1) Let's get teh code!

del stdin
 * 1) Free some memory! Not required, but I would recommend it.
 * 2) Un-comment the below line to disable memory freeing.
 * 1) """ # Never tamper with this line!

cell0 = 0
 * 1) Initialize the cell

for i in xrange(len(code)): while code[i:i + 256] == '+' * 256: # We don't need 256 +s in a row...        code = code[:i] + code[i + 256:] # ...so we trash them!
 * 1) Code fastener; not really required.
 * 2) Un-comment the line below to disable it, although I recommend to leave it enabled.
 * 1) """ # Please do not remove or un-comment this line!

for i in code: if i == '+':   # + cell0 += 1 # Increments the cell. cell0 %= 256 # There are no ASCII characters over 255, so we wrap. if i == '.':                 #. stdout.write(chr(cell0)) # Outputs the character in the cell.
 * 1) Interpreter

code_.close

Here's an implementation in C# using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.IO;

namespace MiniStringFuck_Interpreter {   class Program {       static void Main(string[] args) {           StreamReader sr = new StreamReader(args[0]); string code = sr.ReadToEnd; code = code.Replace(((char)13).ToString, "");

int cell = 0;

foreach (char c in code) {               if (c == '+') {                   if (cell == 255) {                       cell = 0; }                   else {                       cell++; }               }                else if (c == '.') {                   Console.Write((char)cell); }           }

Console.ReadLine; }   } }

Generator
""" MiniStringFuck generator by Έρικ Κωνσταντόπουλος, © 2006-2013 """
 * 1) coding=utf-8

from sys import stdout, stdin, stderr
 * 1) Module importing

string = stdin.read
 * 1) String getting

del stdin
 * 1) Memory freeing #1
 * 2) """ # Uncomment this line to disable!
 * 1) """ # Never modify line 12.

for i in string: if ord(i) not in range(256): stderr.write('Your string contains non-ASCII characters.') exit
 * 1) String checking (ASCII only)

del stderr
 * 1) Memory freeing #2
 * 2) """ # Uncomment this line to disable!
 * 1) """ # Never modify line 23.

char = 0
 * 1) Character storing

for i in string: while chr(char) != i:       char += 1 char %= 256 stdout.write('+') stdout.write('.')
 * 1) Code generating

Optimizer
""" MiniStringFuck optimizer by Έρικ Κωνσταντόπουλος, © 2001-2004 """
 * 1) coding=utf-8

from sys import argv, stdout, stdin
 * 1) Module imports

file = open(argv[1]) if len(argv) >= 2 else stdin if len(argv) >= 3: out = open(argv[2], 'w') elif file != stdin: out = open(argv[1] + '_cmp', 'w') else: out = stdout del stdout code = file.read
 * 1) Free precious RAM!!

del stdin
 * 1) Memory freeing

for i in xrange(len(code)): while code[i] not in '+.': brtoggle = False if i == len(code) - 1: continue_ = '' brtoggle = True else: continue_ = code[i + 1:] code = code[:i] + continue_ if brtoggle: break if i == len(code) - 1: break
 * 1) Main

code = '.' + code while code[-1] != '.': code = code[:-1] code = code[1:]

while '+' * 256 in code: code = code.replace('+' * 256, '')

out.write(code)
 * 1) File O