{"id":19653270,"url":"https://github.com/florianmichael/brainfuck4j","last_synced_at":"2025-12-28T20:48:04.776Z","repository":{"id":185160467,"uuid":"658885130","full_name":"FlorianMichael/Brainfuck4J","owner":"FlorianMichael","description":"Fast Java interpreter for Brainfuck language with optimizations, memory management and multi dialect support","archived":false,"fork":false,"pushed_at":"2025-02-25T17:45:21.000Z","size":250,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-02-25T18:39:14.166Z","etag":null,"topics":["brainfuck","brainfuck-executor","java","ook","script","troll","trollscript","wrapper"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/FlorianMichael.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"FlorianMichael","custom":["https://florianmichael.de/donate"]}},"created_at":"2023-06-26T17:32:21.000Z","updated_at":"2025-02-25T17:45:25.000Z","dependencies_parsed_at":"2024-03-23T12:33:17.100Z","dependency_job_id":"5653014b-f40a-40c1-b1cb-e921c7f8b13d","html_url":"https://github.com/FlorianMichael/Brainfuck4J","commit_stats":null,"previous_names":["florianmichael/brainfuck4j"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FlorianMichael%2FBrainfuck4J","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FlorianMichael%2FBrainfuck4J/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FlorianMichael%2FBrainfuck4J/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FlorianMichael%2FBrainfuck4J/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/FlorianMichael","download_url":"https://codeload.github.com/FlorianMichael/Brainfuck4J/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240961629,"owners_count":19885368,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["brainfuck","brainfuck-executor","java","ook","script","troll","trollscript","wrapper"],"created_at":"2024-11-11T15:13:44.525Z","updated_at":"2025-12-28T20:48:04.760Z","avatar_url":"https://github.com/FlorianMichael.png","language":"Java","funding_links":["https://github.com/sponsors/FlorianMichael","https://florianmichael.de/donate"],"categories":[],"sub_categories":[],"readme":"# Brainfuck4J\nFast Java interpreter for Brainfuck language with optimizations, memory management and multi dialect support\n\n## What is Brainfuck?\nBrainfuck is an esoteric programming language created in 1993 by Urban Müller. \u003cbr\u003e\nNotable for its extreme minimalism, the language consists of only eight simple commands, a data pointer and an instruction pointer. While it is fully Turing complete, it is not intended for practical use, but to challenge and amuse programmers. Brainfuck requires one to break commands into microscopic steps.\n\nLearn more about Brainfuck [here](https://en.wikipedia.org/wiki/Brainfuck)\n\n## Contact\nIf you encounter any issues, please report them on the [issue tracker](https://github.com/FlorianMichael/Brainfuck4J/issues).  \nIf you just want to talk or need help with Brainfuck4J feel free to join my [Discord](https://florianmichael.de/discord).\n\n## Features\n- Fast interpreter with multiple dialects\n- Dialect converter\n- Swing-based GUI\n- Executable JAR with command line interface\n- Optimizations (clear loops, pre-calculating loop points, instruction batching)\n\n## Usage\n\n### CLI \u0026 GUI\n\nIf you run the packaged JAR directly, you get both CLI and GUI entry points:\n\n```bash\njava -jar Brainfuck4J-\u003cversion\u003e.jar            # GUI (Brainfuck Studio)\njava -jar Brainfuck4J-\u003cversion\u003e.jar run ...    # CLI\n```\n\n![GUI](/.github/media/gui.png)\n\nWhen using the Gradle project directly you can run:\n\n```bash\n./gradlew run                                  # GUI (no args)\n./gradlew run --args=\"run program.bf\"          # CLI\n```\n\n#### CLI commands\n\n![CLI](/.github/media/cli.png)\n\nExamples:\n\n```bash\n# Run a Brainfuck file with defaults (BRAINFUCK dialect, INTEGER memory, 30000 cells)\njava -jar Brainfuck4J-\u003cversion\u003e.jar run hello.bf\n\n# Run with explicit dialect and memory settings\njava -jar Brainfuck4J-\u003cversion\u003e.jar run hello.bf --dialect BRAINFUCK --memory INTEGER --size 60000\n\n# Convert between dialects\njava -jar Brainfuck4J-\u003cversion\u003e.jar convert input.bf output.troll --from BRAINFUCK --to TROLLSCRIPT\n\n# List supported dialects and memory types\njava -jar Brainfuck4J-\u003cversion\u003e.jar list dialects\njava -jar Brainfuck4J-\u003cversion\u003e.jar list memories\n```\n\n### Library\n\n### Gradle/Maven\n\nTo use Brainfuck4J with Gradle/Maven you can\nuse [the Maven Central repository](https://mvnrepository.com/artifact/de.florianmichael/Brainfuck4J)\nor [my own repository](https://maven.florianmichael.de/#/releases/de/florianmichael/Brainfuck4J).  \nYou can also find instructions how to implement it into your build script there.\n\n### Jar File\n\nIf you just want the latest jar file you can download it\nfrom [my build server](https://build.florianmichael.de/job/Brainfuck4J), [GitHub Actions](https://github.com/FlorianMichael/Brainfuck4J/actions)\nor use the [releases tab](https://github.com/FlorianMichael/Brainfuck4J/releases).\n\n### Examples\n\n#### Dialects\n\nFor accessing multiple dialects, the `DialectType` and `Dialect` classes can be used to convert between dialects or define your own:\n\n```java\nimport de.florianmichael.brainfuck4j.dialect.Dialect;\nimport de.florianmichael.brainfuck4j.dialect.DialectType;\n\n// Convert a Brainfuck program to TrollScript\nfinal String trollScript = DialectType.BRAINFUCK.convert(\n        \"\u003e++++++[\u003c++++++\u003e-]\u003c.\",\n        DialectType.TROLLSCRIPT\n);\n\n// Create a custom Brainfuck-like dialect\nfinal Dialect customDialect = new Dialect(\n        \"\u003e\", // increment pointer\n        \"\u003c\", // decrement pointer\n        \"+\", // increment cell\n        \"-\", // decrement cell\n        \"[\", // loop start\n        \"]\", // loop end\n        \",\", // input\n        \".\"  // output\n);\n```\n\n#### Execute Brainfuck code (library API)\n\nThe main entry point is the singleton `Brainfuck4J.INSTANCE`. You supply input/output streams, a memory implementation and the (optionally pre-converted) program:\n\n```java\nimport de.florianmichael.brainfuck4j.Brainfuck4J;\nimport de.florianmichael.brainfuck4j.dialect.DialectType;\nimport de.florianmichael.brainfuck4j.memory.AbstractMemory;\nimport de.florianmichael.brainfuck4j.memory.MemoryType;\nimport de.florianmichael.brainfuck4j.instruction.Instruction;\n\nimport java.io.ByteArrayInputStream;\nimport java.io.ByteArrayOutputStream;\nimport java.io.InputStream;\nimport java.io.PrintStream;\nimport java.nio.charset.StandardCharsets;\nimport java.util.List;\n\n// Original program in an arbitrary dialect\nfinal String source = \"\u003e++++++[\u003c++++++\u003e-]\u003c.\";\nfinal DialectType dialect = DialectType.BRAINFUCK;\n\n// Normalize to pure Brainfuck if needed\nString program = source;\nif (dialect != DialectType.BRAINFUCK) {\n    program = dialect.convert(source, DialectType.BRAINFUCK);\n}\n\n// Optional input for the Brainfuck program\nfinal byte[] inputBytes = new byte[0];\nfinal InputStream in = new ByteArrayInputStream(inputBytes);\n\n// Capture the output in memory (you can also pass System.out)\nfinal ByteArrayOutputStream outBuffer = new ByteArrayOutputStream();\nfinal PrintStream out = new PrintStream(outBuffer, true, StandardCharsets.UTF_8);\n\n// Choose memory type and size\nfinal MemoryType memoryType = MemoryType.INTEGER; // or BYTE, SHORT, ...\nfinal int memorySize = 30000;\nfinal AbstractMemory memory = memoryType.create(memorySize);\n\n// Run the program and get the optimized instruction list\nfinal List\u003cInstruction\u003e instructions = Brainfuck4J.INSTANCE.run(in, out, memory, program);\n\n// Read output as string\nfinal String output = outBuffer.toString(StandardCharsets.UTF_8);\nSystem.out.println(\"Program output: \" + output);\nSystem.out.println(\"Instructions executed: \" + instructions.size());\n```\n\n#### Internals and classes\n\n- `Brainfuck4J.INSTANCE.run(...)` performs parsing, optimizations and execution.\n- `Instruction` and `InstructionType` describe the optimized instruction stream.\n- `MemoryType` and `AbstractMemory` implement the memory model (byte/short/int, size, bounds checking).\n- `DialectType` and `Dialect` handle multi-dialect support and conversion.\n\nAll undocumented methods and classes are considered internal implementation details and may change.\n\n## Credits and sources\nThis program / software was developed with the help of the following resources:\n- http://calmerthanyouare.org/2015/01/07/optimizing-brainfuck.html\n- http://www.hevanet.com/cristofd/brainfuck/qdb.c\n- http://www.hevanet.com/cristofd/brainfuck/\n- http://www.clifford.at/bfcpu/\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fflorianmichael%2Fbrainfuck4j","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fflorianmichael%2Fbrainfuck4j","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fflorianmichael%2Fbrainfuck4j/lists"}