5 ms·
Show HN: Print chr$(205.5+rnd(1)) goto 10
JavaScript implementation of the famous `10 print chr$(205.5+rnd(1)) goto 10` one line of BASIC code.
data:text/html,<script>a=()=>{document.write(Math.random()<0.5?'\u2571':'\u2572');document.body.style.cssText="margin:0;padding:0;font-family:monospace;word-break:break-word;font-size:3em;letter-spacing:0;font-stretch:ultra-expanded"};update=()=>{a();window.requestAnimationFrame(update)};update()</script>
Copy and paste the above "link" in your browser.
- andreareina 6y agoBravo. Just ran this, seeing the JIT kick in was a trip. Data URIs: https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/Data_URIs https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_...
- ineiti 6y agoChrome seems to compile before it runs it. Only Firefox takes some lines before it runs it as fast as Chrome. Now I wonder why it takes so long to do the JIT? I always thought that JIT compiles with every execution...
- andreareina 6y agoAs I understand it there's a "baseline" compilation, then after n calls it's specialized according to the types/values seen.
- quickthrower2 6y agoThe result looks like this: ╱╲╱╱╱╲╲╱╲╲╲╱╲╱╲╱╲╲╲╲╱╲╱╲╲╱╲╱╱╲╱╲╱╱╲╱╲╲╲╲╲╱╲╱╲╲╲╲╲╲╲╲╱╲╱╱╱╱╲╲╱╱╲╱╲╲╱╱╱╱╲╱╱╲╲╱╲╱╲╲╱╱╲╱╱╲╱╱╲╱╲╲╲╲╲╱╱╱╱╲╲╲╱╱╲╱╲╲╱╲╱╲╲╲╱╱╱╲╱╱╱╲╱╲╱╱╲╲╲╲╲╲╲╲╱╱╲╲╲╱╲╲╱╱╲╲╲╱╲╲╲╲╱╲╱╲╲╲╲╱╲╱╱╲╱╱╱╲╲╲╲ ╲╱╲╱╲╲╲╱╱╲╱╱╲╱╲╲╱╱╲╱╲╲╱╲╲╱╲╲╲╲╲╲╱╲╱╱╲╱╱╱╱╱╱╲╲╱╱╲╱╱╲╱╱╲╲╲╲╱╱╲╱╱╱╱╱╲╲╱╲╱╲╲╲╱╱╱╱╲╱╲╱╲╱╱╱╱╲╲╲╲╱╱╱╱╱╱╱╲╲╱╲╲╱╱╱╱╱╲╱╲╱╱╱╱╲╲╱╱╱╱╱╱╲╱╲╲╱╲╲╱╱╲╱╲╱╲╱╲╲╱╲╱╱╲╱╲╱╲╲╲╲╲╱╲╲╱╱╲╱╱╲╱╲╱╲╱╲╱╱╲╱ ╱╲╱╱╱╲╲╲╲╱╲╲╱╱╱╱╲╲╲╲╲╲╱╱╲╲╲╲╱╲╲╱╲╱╱╲╱╲╲╲╱╱╱╲╱╱╲╱╲╱╲╱╲╱╲╲╲╱╱╲╱╱╱╱╱╲╱╱╱╲╲╲╱╱╲╱╲╱╲╱╱╲╱╱╱╲╱╱╱╲╲╱╲╱╱╱╲╱╱╲╱╱╲╱╲╱╱╱╱╲╲╲╲╱╲╱╲╲╱╲╱╱╱╲╱╲╱╲╲╲╲╲╱╲╱╱╲╱╲╱╲╲╲╲╱╲╱╱╱╲╲╱╱╲╱╱╲╲╲╲╲╲╲╲╱╱╱╱╲╲╱ ╲╱╲╱╲╲╲╱╲╲╱╲╱╱╲╱╱╲╲╱╱╲╱╱╲╱╱╲╲╱╲╱╱╲╲╱╱╱╱╱╲╲╱╲╲╱╱╱╲╲╲╲╱╱╲╲╱╲╲╱╱╱╱╱╲╱╱╱╲╱╱╱╱╱╲╱╲╲╱╲╱╲╱╲╱╱╱╲╱╲╲╲╱╱╱╲╲╱╱╱╱╲╲╲╱╲╲╲╲╱╲╱╱╱╱╲╱╲╱╱╱╲╱╱╲╱╱╲╱╲╱╱╱╱╲╱╱╲╱╲╱╱╲╱╲╱╱╲╱╲╲╲╱╲╲╲╱╲╱╱╱╲╱╱╲╲╱╲╱╲╲ ╲╲╲╱╱╱╲╲╱╱╱╲╱╲╱╱╱╲╲╱╱╲╲╲╱╱╲╱╱╲╲╲╲╱╲╱╱╲╲╲╲╲╲╱╱╱╱╱╱╲╱╲╲╱╱╲╱╲╲╱╱╲╲╱╱╱╲╱╱╲╱╱╲╱╱╲╱╲╱╱╱╱╲╱╱╱╲╱╱╱╲╱╱╲╱╱╲╱╲╲╱╲╲╲╱╲╲╲╲╱╱╲╱╱╱╲╱╲╲╲╱╲╲╲╱╲╱╱╲╱╲╲╱╱╱╱╱╲╲╱╲╱╲╱╲╱╱╲╱╲╲╲╲╲╱╱╲╱╱╱╱╲╲╲╲╱╲╲╱╲╱ ╲╱╲╲╱╲╲╲╱╱╲╱╲╲╱╱╲╱╲╱╲╲╱╲╲╲╱╲╱╲╱╲╲╲╲╲╱╲╱╲╱╱╱╱╱╱╲╲╱╲╲╱╲╱╱╲╱╱╲╱╱╱╱╲╱╲╱╱╱╲╱╲╲╲╲╱╲╲╱╲╲╱╲╱╱╱╱╲╱╲╲╲╱╱╲╲╱╱╲╲╱╲╲╱╲╱╲╱╱╱╲╲╱╲╱╱╲╲╲╲╱╲╱╱╱╲╲╱╱╱╱╱╲╲╱╱╱╱╱╱╱╱╱╱╲╱╲╲╱╱╲╲╱╱╲╲╱╱╲╱╲╲╱╱╱╱╲╱╲╲╱
- Cyber_squad 6y agoUnderrated comment!
- _nothing 6y agoIn which browsers? This doesn't seem to work for me in Chrome, but maybe it's just me. Works in Firefox and Safari. Edit: Nevermind, I tried again and it did begin to run before the tab closed abruptly. Tried again in an incognito window and it worked, and it also worked in a regular Chrome window with only one tab. Tried to run it in a second tab in that same window and the tab instantly closed again. Anyone know why this might be the case? Second edit: While it doesn't run in regular Chrome windows with multiple tabs, it does run in Incognito windows with multiple tabs. I don't think I have the expertise to dig further though.
- atum47 6y agoI'm using breve these days and it works. It's chromium based
- pkaye 6y agoThere is actually a whole book written about this line of code. A pdf is available on the Open Access tab. https://mitpress.mit.edu/books/10-print-chr2055rnd1-goto-10 https://mitpress.mit.edu/books/10-print-chr2055rnd1-goto-10
- sedatk 6y agoIt works but doesn't scroll automatically like others :) Still a neat idea! I had also written one in Z80 Assembly in 14-bytes for Amstrad CPC computers: https://github.com/ssg/mazecpc https://github.com/ssg/mazecpc
- AlbertoGP 6y agoHere it is with scrolling: data:text/html,<script>a=()=>{document.write(Math.random()<0.5?'\u2571':'\u2572');document.body.style.cssText="margin:0;padding:0;font-family:monospace;word-break:break-word;font-size:3em;letter-spacing:0;font-stretch:ultra-expanded"};update=()=>{a();window.requestAnimationFrame(update);window.scroll(0,window.scrollMaxY)};update()</script>
- syrrim 6y agoAdd 'line-height:1em;' to make it look a bit cooler.
- rkwasny 6y agoUh, why is it so slow?
- m463 6y agodata:text/html,<script>a=()=>{document.write('\u{1F600}');document.body.style.cssText="margin:0;padding:0;font-family:monospace;word-break:break-word;font-size:3em;letter-spacing:0;font-stretch:ultra-expanded"};update=()=>{a();window.requestAnimationFrame(update)};update()</script> or maybe change 1F600 to 1F44D :)
- Cyber_squad 6y agoWoW really cool effect! Love this kind of works!