{"id":13780032,"url":"https://github.com/BenWiederhake/ohno","last_synced_at":"2025-05-11T13:31:20.835Z","repository":{"id":149598494,"uuid":"55165502","full_name":"BenWiederhake/ohno","owner":"BenWiederhake","description":"Interpreter for an esoteric, overly hard language","archived":false,"fork":false,"pushed_at":"2023-01-08T15:48:12.000Z","size":23,"stargazers_count":16,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-11-14T12:22:53.333Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/BenWiederhake.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"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}},"created_at":"2016-03-31T16:21:42.000Z","updated_at":"2024-07-18T18:43:05.000Z","dependencies_parsed_at":"2024-01-17T01:34:07.728Z","dependency_job_id":null,"html_url":"https://github.com/BenWiederhake/ohno","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BenWiederhake%2Fohno","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BenWiederhake%2Fohno/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BenWiederhake%2Fohno/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BenWiederhake%2Fohno/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/BenWiederhake","download_url":"https://codeload.github.com/BenWiederhake/ohno/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225056758,"owners_count":17414202,"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":[],"created_at":"2024-08-03T18:01:11.636Z","updated_at":"2024-11-17T15:30:50.950Z","avatar_url":"https://github.com/BenWiederhake.png","language":"C","funding_links":[],"categories":["C"],"sub_categories":[],"readme":"# ohno - Interpreter for \"ohno\"\n\n\"ohno\" is an esoteric \"programming language\" designed to be cryptographically difficult.\n\n\"ohno\" does not stand for \"overly hard, nonsensical language\"\n\n\n## What.\n\n\"ohno\" is a highly advanced language.  For example, it uses the very\nmodern hashing algorithm Keccak to compile the input into ohno\nbytecode.  Thus, portability is guaranteed, as Keccak has been\nimplemented on lots of platforms so far.  This way, even large programs\ncan be compiled very quickly.\n\nThe generated bytecode is then interpreted essentially as Brainfuck\ninstructions, yet another example of the progressive, highly advanced\nnature of ohno.\n\nSince it uses a secure hashing algorithm to generate the byteode,\ndisassembly of complex programs is as hard as preimage attacks on SHA3.\n\nThe overly difficult nature of ohno makes sure that only the best\nprogrammers with the most advanced hardware can hope to find an ohno\nprogram that does something somewhat useful.\n\nFeel free to use the program `search` with `grep` to search for good\nohno programs.  The `cat` example was found using these tools.\n\n\n## Seriously. What?!\n\nOf course all of this isn't to be taken too seriously.  Obviously ohno\nisn't *truly* compiled, as it uses an interpreter.  But it could be.\nShoot me a PR that compiles ohno into actual assembly, probably using\nLLVM? :D\n\nOhno is intended to rival\n[Malbolge](https://en.wikipedia.org/wiki/Malbolge) in difficulty, as\nnow the \"hashing\"\nisn't some home-made algorithm that may or may not have nice\nproperties, but instead uses industry-grade hashing.\n\n\n## Spec for `.ohno` files\n\nA valid `.ohno`-file needs to:\n- Contain at least 4 bytes\n- Start with 4 bytes, big endian, which is the amount of bytes of the bytecode.\n- The rest is used to seed the hashing function.\n\nThus, nearly all files are ohno programs; albeit they probably don't do\nanything useful.  Especially not if the first byte is not `0x00`.\n\n\n## ohno bytecode\n\nThe ohno bytecode is nibble-based, and technically not even that: only\nthe last three bits of each nibble are considered, and mapped to the\nBrainfuck instructions (in order) `+-{}\u003e\u003c,.`, while ignoring the\nhighest bit.  Note that `{}` is similar to Brainfuck's `[]` but not identical.\n\nAs Brainfuck is underspecified, here's the filled-in details:\n- The tape is infinite in both directions and initialized to 0.\n  Well, as infinite as something can be on a finite machine.\n- The tape can hold values from 0 to 255, inclusively, and will wrap.\n  (Unless you have an optimizing compiler that actually exploits the UB\n  on integer overflow.  In that case, it doesn't wrap, but UB's.)\n- Where `[xxx]` in Brainfuck is equivalent to `while (*tape_ptr) { xxx }` in C,\n  ohno's `{xxx}` behaves like `do { xxx } while (*tape_ptr);` in C.\n  Note that this\n  [probably is](http://cs.stackexchange.com/q/47603)\n  [still Turing-complete](http://cs.stackexchange.com/a/33711).\n- Technically, the `}` only behaves as specified above if there is an\n  appropriate `{` to which it can jump.  Otherwise, the program hangs\n  and never terminates.\n- You can stack at least 4 billion (`2^32 - 1`) brackets.\n- Stack depth at the end of the program is ignored.  Notice that this\n  means that you don't really need to care about balanced brackets, as it\n  will either hang or terminate successfully, but never crash!\n  (Unless you're a weirdo and want to do something useful.)\n- `,` (read) stores the current input *byte* on the tape.  Good luck with\n  doing anything Unicode-related.\n- If `,` (read) encounters the end of `stdin`, then the program terminates\n  with exit code 0.\n\n\n## `cat.ohno`\n\nI believe there is only one somewhat meaningful program that is short\nenough to be discovered by brute force:  `cat -`, or in words:\ncopy stdin to stdout.\n\nThe desired bytecode in Brainfuck should to match this regular expression:\n```\n^\\{,\\.[\u003c\u003e][-\\+]\\}$\n```\nOh god.  Let's try the actual bytecode/nibblecode:\n```\n^[2A][6E][7F][45CD][0189][3B]$\n```\nNot much better.\n\nThis essentially means: \"read and write, then move to a new cell and\nmake sure that it's not zero (otherwise we wouldn't loop back)\".  Since\nthat's only 6 instructions, and fixes only 16 bits, we need on average\n65536 tries to find an ohno program that compiles to this bytecode.\n\nOf course, there's even more general versions.  Can you find a regex\nthat captures all Brainfuck-bytecodes that are equivalent to `cat -`?\n\n(Hint:  No.  At least not if this Brainfuck dialect is Turing-complete,\nbecause then you'd be solving, among other things, the [halting\nproblem](https://en.wikipedia.org/wiki/Halting_problem).  Not only\nthat, you'd solve it with merely a [Finite State\nMachine](https://en.wikipedia.org/wiki/Regular_expression#Expressive_power_and_compactness)!)\n\nSo, after all, `cat.ohno` was computed like this, where `ohno-search.c`\nsays `#define OUTPUT_BYTES (6/2)` (because we want 6 instructions, each\ntaking up half of a byte):\n```\n./search | grep '^[2a][6e][7f][45cd][0189][3b] '\n```\nAs you can see for yourself, there's lots of matches.\n\nLet's measure throughput:\n```\ncat /dev/zero | pv -bartT | ./ohno example/cat/cat.ohno\n```\nWow! This implementation reaches roughly 1 MiB/s on my machine, which is\nincredibly fast for being so shitty.\n\n\n## `spacecat.ohno`\n\nThe previous cat implementation uses a new cell for each character, which is bad™.\n\nChanging `OUTPUT_BYTES` to `(8/2)` in `ohno-search.c` and recompiling\nlet's us do this:\n```\n./search | grep '^[2a][6e][7f][2a][0189][3b][0189][3b] '\n```\n\nWhich finds the included space-efficient cat implementation in a\nreasonable time.  Note that I fixed 22 bits, so this should take (on\naverage) 2 million guesses until something is found.  In fact, the\nfirst such program is found on attempt 1779300.  It seems that\n`./search` is pleasently fast for being written so carelessly.\n\n```\ncat /dev/zero | pv -bartT | ./ohno example/spacecat/spacecat.ohno\n```\nIt seems that this program only achieves 241KiB/s, which is probably\ndue to having to `rewind` each character.  As I'm using `/dev/zero`\nhere, which *always* hits the worst-case, it may be a bit faster on\nreal-life data.\n\n\n## TODO\n\nThe current implementation doesn't seem to be very fast at squeezing\nout several megabytes of ohno bytecode.  Of course, this needs to be\nimproved significantly in order to write literally-large programs that\nrequire gigabytes of bytecode, like MATLAB or AutoCAD.\n\nCalculating `cat.ohno` took only 1 second.  Obviously, that's too\nfast.  Future versions of ohno thus should incorporate some hash\nfunction that is more time-intensive.  `bcrypt` might be the way to go.\nYes, this item is in direct contradiction to the previous point.\n\nAs already mentioned, this is just an interpreter, but a true compiler\nshould be easily possible.  This could seriously improve the execution\ntime for the \"jump back\" instruction!\n\nAre there other interesting ohno programs you can find?  Something that\ndoes something even *slightly* advanced?  Maybe Caesar encoding with\nwraparound?\n\nShoot me a Pull Request! :D\n\n(Or *just* shoot me!  Aargh, the pain from writing this!  Oh god!  Help!)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FBenWiederhake%2Fohno","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FBenWiederhake%2Fohno","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FBenWiederhake%2Fohno/lists"}