6 ms·
Show HN: Particles – the URL contains the whole program code
- reneberlin 4y agoflems.io (lightweight online html, js,css editor) does this also. i was very impressed, when i first encountered this. Everything is encoded in the url to share. https://flems.io/#0=N4IgzgpgNhDGAuEAmIBcIB0ALeBbKIANCAGYCWMYaA2qAHYCGuEamO+RIsA9nYn6wA8WAIwA+ADp0ABNKzQo3aQHduAJyhIAhFMEB6UWM6QYCMryroATKgCsIAL6F6TFugwArKsR58IA9EdnEEZmVgxYMG8uXn54VkcAXQcgA https://flems.io/#0=N4IgzgpgNhDGAuEAmIBcIB0ALeBbKIANCAGYCWMY... cryptpad does the same, i read yesterday. https://cryptpad.fr/ https://cryptpad.fr/
- deleted 4y ago[deleted]
- chkas 4y agoURL parameters starting with # sound interesting, since they are obviously not sent to the server.
- chkas 4y agoI looked it up: "#" is the location.hash and sets the anchor part of a URL. And is probably perfect for client side parameters, which is what I need. Such a discussion on HN is really often very helpful. There was a comment here that unfortunately got deleted again before I could reply that mentioned that.
- cryptonector 4y agoIt's called a "fragment", and it's never sent to the server in HTTP requests. It was originally intended to have an HTML anchor as its value. Like when you click on a section or paragraph and you see the URL in the location bar gets "#<anchor>".
- chkas 4y agoIt now also works with "#" parameter code - which is not sent to the server unnecessarily. https://easylang.online/run/#code=%23%20Pendulum%0A%23%20%0Aang%20%3D%2045%0Acolor%20881%0A%23%20%0Aon%20animate%0A%20%20clear%0A%20%20move%2050%2050%0A%20%20circle%201%0A%20%20x%20%3D%2050%20%2B%2040%20*%20sin%20ang%0A%20%20y%20%3D%2050%20-%2040%20*%20cos%20ang%0A%20%20line%20x%20y%0A%20%20circle%206%0A%20%20vel%20%2B%3D%20sin%20ang%20%2F%207%0A%20%20ang%20%2B%3D%20vel%0A.%0A https://easylang.online/run/#code=%23%20Pendulum%0A%23%20%0A...
- fastball 4y agoPartly this is doable because although RFC 2616 (HTTP/1.1) specifies a max URL length of 2048 bytes, all the major browsers will process URLs which are much longer, with Safari allowing URL strings up to 2GB in size![1] In 2021 probably one of the bigger blockers of giant URLs is CDNs, which impose various limits on URL size. e.g. Cloudflare limits URLs to 16kb. [1] https://github.com/apple/swift-corelibs-foundation/blob/b23dc8e249987442811e9e0097c326d7083784ac/CoreFoundation/URL.subproj/CFURLComponents_URIParser.c#L708 https://github.com/apple/swift-corelibs-foundation/blob/b23d...
- chkas 4y agoAnother demo: https://easylang.online/run/?code=%23%20Mastermind%3Aw90%0A%23%20%0Acol%5B%5D%20%3D%20%5B%20802%20990%20171%20229%20950%20808%20%5D%0Alen%20code%5B%5D%204%0Alen%20guess%5B%5D%204%0A%23%20%0Asubr%20init_vars%0A%20%20row%20%3D%207%0A.%0Afunc%20draw_rate%20r%20black%20white%20.%20.%0A%20%20for%20j%20range%202%0A%20%20%20%20for%20c%20range%202%0A%20%20%20%20%20%20move%20c%20*%203.5%20%2B%2071.5%20r%20*%2011.5%20%2B%2010.4%20%2B%20j%20*%203.5%0A%20%20%20%20%20%20if%20black%20%3E%200%0A%20%20%20%20%20%20%20%20color%20000%0A%20%20%20%20%20%20%20%20circle%201.4%0A%20%20%20%20%20%20%20%20black%20-%3D%201%0A%20%20%20%20%20%20elif%20white%20%3E%200%0A%20%20%20%20%20%20%20%20color%20999%0A%20%20%20%20%20%20%20%20circle%201.4%0A%20%20%20%20%20%20%20%20white%20-%3D%201%0A%20%20%20%20%20%20else%0A%20%20%20%20%20%20%20%20color%20310%0A%20%20%20%20%20%20%20%20circle%200.7%0A%20%20%20%20%20%20.%0A%20%20%20%20.%0A%20%20.%0A.%0Afunc%20show_code%20.%20.%0A%20%20color%20531%0A%20%20move%2022%200%0A%20%20rect%2046%208%0A%20%20for%20i%20range%204%0A%20%20%20%20move%20i%20*%208%20%2B%2028%203%0A%20%20%20%20color%20col%5Bcode%5Bi%5D%5D%0A%20%20%20%20circle%202%0A%20%20.%0A.%0Afunc%20draw_guess%20.%20.%0A%20%20for%20c%20range%204%0A%20%20%20%20move%20c%20*%2012%20%2B%2020%20row%20*%2011.5%20%2B%2012%0A%20%20%20%20color%20col%5Bguess%5Bc%5D%5D%0A%20%20%20%20circle%203.8%0A%20%20.%0A.%0Afunc%20next_row%20.%20.%0A%20%20color%20420%0A%20%20linewidth%2011%0A%20%20move%2017%20row%20*%2011.5%20%2B%2012%0A%20%20line%2060%20row%20*%2011.5%20%2B%2012%0A%20%20call%20draw_guess%0A%20%20move%2073.5%20row%20*%2011.5%20%2B%2012%0A%20%20color%20310%0A%20%20circle%205.0%0A%20%20color%20753%0A%20%20move%2071.5%20row%20*%2011.5%20%2B%208.5%0A%20%20textsize%207%0A%20%20text%20%22%E2%9C%93%22%0A.%0Afunc%20rate%20.%20.%0A%20%20move%2073.5%20row%20*%2011.5%20%2B%2012%0A%20%20color%20531%0A%20%20circle%205.2%0A%20%20c%5B%5D%20%3D%20code%5B%5D%0A%20%20g%5B%5D%20%3D%20guess%5B%5D%0A%20%20for%20i%20range%204%0A%20%20%20%20if%20c%5Bi%5D%20%3D%20g%5Bi%5D%0A%20%20%20%20%20%20black%20%2B%3D%201%0A%20%20%20%20%20%20c%5Bi%5D%20%3D%20-1%0A%20%20%20%20%20%20g%5Bi%5D%20%3D%20-2%0A%20%20%20%20.%0A%20%20.%0A%20%20for%20i%20range%204%0A%20%20%20%20for%20j%20range%204%0A%20%20%20%20%20%20if%20c%5Bi%5D%20%3D%20g%5Bj%5D%0A%20%20%20%20%20%20%20%20white%20%2B%3D%201%0A%20%20%20%20%20%20%20%20c%5Bi%5D%20%3D%20-1%0A%20%20%20%20%20%20%20%20g%5Bj%5D%20%3D%20-2%0A%20%20%20%20%20%20.%0A%20%20%20%20.%0A%20%20.%0A%20%20call%20draw_rate%20row%20black%20white%0A%20%20color%20531%0A%20%20linewidth%2012%0A%20%20move%2017%20row%20*%2011.5%20%2B%2012%0A%20%20line%2060%20row%20*%2011.5%20%2B%2012%0A%20%20call%20draw_guess%0A%20%20row%20-%3D%201%0A%20%20if%20black%20%3D%204%0A%20%20%20%20row%20%3D%20-1%0A%20%20.%0A%20%20if%20row%20%3D%20-1%0A%20%20%20%20call%20show_code%0A%20%20%20%20timer%202%0A%20%20else%0A%20%20%20%20call%20next_row%0A%20%20.%0A.%0Aon%20timer%0A%20%20row%20%3D%20-2%0A.%0Afunc%20new%20.%20.%0A%20%20call%20init_vars%0A%20%20for%20i%20range%204%0A%20%20%20%20code%5Bi%5D%20%3D%20random%206%0A%20%20.%0A%20%20color%20531%0A%20%20move%2010%2010%0A%20%20rect%2070%2080%0A%20%20linewidth%2010%0A%20%20move%205%205%0A%20%20line%205%2095%0A%20%20line%2085%2095%0A%20%20line%2085%205%0A%20%20line%205%205%0A%20%20color%20310%0A%20%20linewidth%207%0A%20%20move%2028%203.5%0A%20%20line%2058%203.5%0A%20%20move%2030%201.5%0A%20%20color%20864%0A%20%20textsize%204%0A%20%20text%20%22Mastermind%22%0A%20%20color%20310%0A%20%20linewidth%200.5%0A%20%20move%2010%2010%0A%20%20line%2010%2096%0A%20%20move%2067%2010%0A%20%20line%2067%2096%0A%20%20move%2080%2010%0A%20%20line%2080%2096%0A%20%20for%20r%20range%208%0A%20%20%20%20for%20c%20range%204%0A%20%20%20%20%20%20move%20c%20*%2012%20%2B%2020%20r%20*%2011.5%20%2B%2012%0A%20%20%20%20%20%20circle%202%0A%20%20%20%20.%0A%20%20%20%20call%20draw_rate%20r%200%200%0A%20%20.%0A%20%20guess%5B0%5D%20%3D%200%0A%20%20guess%5B1%5D%20%3D%200%0A%20%20guess%5B2%5D%20%3D%201%0A%20%20guess%5B3%5D%20%3D%201%0A%20%20call%20next_row%0A.%0Afunc%20do_move%20.%20.%0A%20%20c%20%3D%20(mouse_x%20-%2015)%20div%2012%0A%20%20guess%5Bc%5D%20%3D%20(guess%5Bc%5D%20%2B%201)%20mod%206%0A%20%20call%20draw_guess%0A.%0Aon%20mouse_down%0A%20%20if%20row%20%3D%20-2%0A%20%20%20%20call%20new%0A%20%20elif%20mouse_y%20%3E%20row%20*%2011.5%20%2B%207%20and%20mouse_y%20%3C%20row%20*%2011.5%20%2B%2017%20and%20row%20%3E%3D%200%0A%20%20%20%20if%20mouse_x%20%3E%2015%20and%20mouse_x%20%3C%2061%0A%20%20%20%20%20%20call%20do_move%0A%20%20%20%20elif%20mouse_x%20%3E%2067%20and%20mouse_x%20%3C%2080%0A%20%20%20%20%20%20call%20rate%0A%20%20%20%20.%0A%20%20.%0A.%0Acall%20new%0A https://easylang.online/run/?code=%23%20Mastermind%3Aw90%0A%...
- golf_mike 4y agoWhat am I missing? the URL is just https://easylang.online/run/ https://easylang.online/run/ --edit-- ah its in the link, which then is not visible in the address bar anymore. Got it :)
- jakeogh 4y agoChrome? I see it on webkit/surf no prob.
- memalign 4y agoHere’s a list of example programs: https://easylang.online/run/list.html https://easylang.online/run/list.html Also reminds me of this: https://viz.intelligence.rocks/ https://viz.intelligence.rocks/
- rambambram 4y agoWow, very friendly and welcoming UI/UX that quickly makes me try out stuff. It looks simple but the flow is very polished. Good job! P.S. Do you have more plans for this app? I see there's tutorials on programming.
- chkas 4y agoThanks. The main motivation was to develop a programming language for beginners. The code runner, the web apps, and the various tutorials were created kind of on the side.
- deleted 4y ago[deleted]
- mkoryak 4y agoCool, but why are the variables named like you are trying to conserve memory? I understand `dx` and `dy`, but `thres` and `n_part` ?
- chkas 4y agoFor me the code is more maintainable if the variable names are not too long. (thres = threshold, n_part = number of particles)
- cmp2tio 4y agoHow is this different from Try It Online https://tio.run https://tio.run ?
- chkas 4y agoIt runs in the browser using WASM, not on the server. And it is a beginner-friendly programming language.
- Natfan 4y agoIn case anybody would like to view the source, see below (via PowerShell[0]): $Post = Invoke-WebRequest -URI "https://news.ycombinator.com/item?id=31883209" -UseBasicParsing $Link = $Post.Links.Where{$_.href -like "https://easylang.online/run/?code=*"}.href $EncodedCode = $Link -replace "https://easylang.online/run/\?code=(.+)",'$1' $Code = [Web.HTTPUtility]::URLDecode($EncodedCode) Write-Output $Code [0]: https://github.com/PowerShell/PowerShell https://github.com/PowerShell/PowerShell, note that Windows PowerShell 5.x is installed on most Windows systems by default.
- chkas 4y agoOr you click on "Code" on the web page.
- jansan 4y agoTHe URL is 1548 character long, which is below the "safe" length limit for URLs of 2058 characters. With Internet Explorer gone, URLs of up to 8192 chars length should work on all browsers. https://stackoverflow.com/questions/417142/what-is-the-maximum-length-of-a-url-in-different-browsers https://stackoverflow.com/questions/417142/what-is-the-maxim...