From Esolang
Jump to navigation Jump to search
Paradigm(s) imperative
Designed by User:Mujk
Appeared in 2023
Memory system Cell-based
Dimensions two-dimensional
Computational class Turing complete
Major implementations trainfck
Influenced by brainfuck
File extension(s) .trainf

Trainfck is a minimalistic esoteric programming language with trains.


Trainfck is an esoteric programming language inspired by brainfuck and railways. Trains depart from stations (+) and travel in all directions. There is no limitation on stations and therefore also not on trains.


If there is no way to go the train turns. When two or more trains collide, they crash. The program ends when all trains have crashed. Memory is managed in byte cells, as in brainfuck. All trains use the same byte cells. Because trainfck uses all the brainfuck operators, the language is turning complete.



The pointer points on the third cell. This byte can be increased or decreased now. The cell pointer and the cell value is controlled by the direction where a train passes a station, all other operators are on the rails. Empty cells have always the value 0.


  • + : station

train directions:

  1. up -> cell byte + 1
  2. down -> cell byte - 1
  3. right -> cell pointer goes to next cell
  4. left -> cell pointer goes to last cell
  • - | : rails, the train can only move on rails and operators, or they will turn around
  • ^ > < v  : changes direction at the next possible option (o)
  • ? : ignores the next action if the current cell equals the last cell
  • . prints out the current cell
  • , takes input as value for the current cell
  • o change direction



 > <
   >  <

add one (old longer version)

 |  | <
 |  o^o
 >  > 

add one (new shorter version)