-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve Whitespace #207
Improve Whitespace #207
Conversation
[The disassembly of the current program](https://gist.github.com/0x0dea/f68d381ed844f85fa2bd) clearly indicates that it was generated by a machine, which is, I think, not in the spirit of the project. This patch replaces the existing program with a more idiomatic one which, in addition to being smaller and faster, masquerades as a sequence of assembly instructions while remaining an executable Whitespace program.
Humm, you're using the extended pick/copy instruction "\s\t\s", most interpreters miss that instruction (and it's "leave" friend). In fact I think only the original v0.3 Haskell one does it and that interpreter is horribly slow, fragile and difficult to compile. Perhaps a plain "push/outchar" variant ? The one disassembled below is shorter than yours. BTW: The labels in the original program should probably be interpreted like this ...
New version like this ...
|
I did forget that I suppose it wouldn't be unwise to forego the use of It's largely beside the point, but we must be reading different programs: the one I've proposed contains 23 instructions totaling 168 bytes, whereas the numbers for yours are 29 and 199. |
doh, I forgot you included those "comments". |
I'm no expert on this language, which is the basis for this entire project On Mon, Aug 17, 2015 at 4:39 AM, rdebath notifications@github.com wrote:
|
The current program does use a more diverse collection of the language's instructions, but it does so "unnaturally", in my estimation. There's quite a bit of redundancy, and‒as @rdebath points out‒the labels have been constructed programmatically, making for a rather unsightly program: Contrast that with my proposed program: The comparison isn't particularly authoritative, but I find it rather convincing nonetheless. Given that most of the other examples simply defer to some print routine, I suppose the suggestion to use nothing more than Still, I maintain that demonstrating the rudiments of looping in Whitespace better aligns with the project's intent of providing a "feel" for each language. |
I think that the I would use either the repeated push/outc or the push+loop[pop/out] flavour in a stack language like this. Probably the shorter as speed is likely to be swamped by I/O. So, I agree, the version by @0x0dea or perhaps the "un-golfed" variant without the PICK command. |
Improve Whitespace
The disassembly of the current program clearly indicates that it was generated by a machine, which is, I think, not in the spirit of the project. This patch replaces the existing program with a more idiomatic one which, in addition to being smaller and faster, masquerades as a sequence of assembly instructions while remaining an executable Whitespace program.