5 ms·
Rust Playground
- deleted 11y ago[deleted]
- pshc 11y agoIR output is too cool. It's really nice of LLVM to let you use arbitrary strings in identifiers, like %"2.core::fmt::rt::v1::Position" %"2.core::option::Option<&'static [core::fmt::rt::v1::Argument]>" makes it easy to understand.
- deleted 11y ago[deleted]
- neverminder 11y agoCircumvented duplicated submission by removing https? Interesting. https://news.ycombinator.com/item?id=9543909 https://news.ycombinator.com/item?id=9543909
- flippant 11y agoI am not aware of HN etiquette. Is pointing out a duplicate submission frowned upon?
- thristian 11y agoSee the question "Are reposts ok?" in the FAQ linked at the bottom of the page.
- tinco 11y agoAs a guideline you can expect anything that's off-topic (like a meta remark about it being a repost) to get at least a few downvotes. This is because when you post a new comment it'll (often) show up as the top comment, and someone will deem it not top-comment worthy and downvote it. i.e.: sometimes a title is really wrong and a comment about it will get a bunch of upvotes, and then when the title is corrected the comment will actually get voted to the bottom because its no longer relevant or useful to the discussion.
- vegedor 11y ago> someone will deem it not top-comment worthy and downvote it That's unnecessary, because points degrade quickly if not up-voted. New posts receive points specifically to achieve exposure.
- maxerickson 11y agoPointing out recent previous discussions (with more than a couple of comments) is usually appreciated. A complaint that someone reposted "your" link usually is not.
- woah 11y agoWow they totally robbed you of that sweet, sweet karma.
- rtz12 11y agoWow they totally robbed you of that sweet, sweet karma.
- Intermernet 11y agoYay! I'll just mention that this one feature will help this language immensely. The standard method for sharing Go code snippets is on play.golang.org, and the huge number of JS/HTML/CSS sandboxes out there have shown that an online, linkable code execution environment can really help with language adoption. What are the limitations of the online environment vs the full language? (I presume a lot of low level stuff is sand-boxed or mocked) What features aren't available?
- ben0x539 11y agoThe biggest limitation is probably that you can't use packages from the cargo ecosystem. I haven't looked in detail but afaik it runs genuine rust binaries in a sandbox. You can investigate at https://github.com/rust-lang/rust-playpen https://github.com/rust-lang/rust-playpen / https://github.com/thestinger/playpen https://github.com/thestinger/playpen if you feel like it. :P
- rattray 11y agoThe gist feature is great. They seem to have thought this through well without adding too many bells & whistles. (though I do find the url animation when you create a shortened/gist url unnecessary)
- hamidr 11y agoThis is awesome :)
- IshKebab 11y agoThis editor has interesting tab behaviour. It uses spaces, but some more actions than usual make it act like tabs. Specifically, if you press tab (insert 4 spaces) and then the left arrow, it actually jumps left 4 spaces instead of 1. Unfortunately it doesn't fully behave like tabs because you can still click inside the indentation which makes selection and cursor positioning harder.
- ewillbefull 11y agoRust convention is for 4-space indentation, not tabs. In fact, in the compiler's own code tabbed indentation fails tests. The way the playpen works is a "best of both worlds" approach I guess.
- ancarda 11y agoI don't know a lot about compilers or assembly but the ASM output seems a longer than it needs to be for just printing hello world. Can anyone provide some insight? Is it just long to provide a good foundation for bigger programs?
- thristian 11y agoAre you talking about Debug mode or Release mode? I don't know much about assembly, but in release mode it looks like you wind up with just some setup code (starting from the label "_ZN4main20h79637ebf645455fbeaaE") which is probably doing generic process-startup stuff, and thenthe actual body of main (starting from the label "main"). All the directives starting with a "." are meta-data directives, they're not actually instructions the CPU executes.
- programmer_dude 11y agoNo Intel syntax dis-assembly?
- rer0tsaz 11y agohttps://rust.godbolt.org/ https://rust.godbolt.org/ has that and more disassembly options
- S4M 11y agoIt's really nicely done, but I would love it even more if they could add some more examples, like in Golang's "Try Go" [0]. [0] http://golang.org/ http://golang.org/
- broodbucket 11y agoI'm certain this is on their to-do list.
- steveklabnik 11y agoThis is the purpose of http://rustbyexample.com http://rustbyexample.com, not the playpen, specifically.
- mbrubeck 11y agoRelated tip: If you click the arrow that appears when hovering over any of the example code in the Rust book [1] or other Rust documentation, it will open the example in the playpen. [1]: http://doc.rust-lang.org/book/ http://doc.rust-lang.org/book/
- tkubacki 11y agointellisense like in https://dartpad.dartlang.org/ https://dartpad.dartlang.org/ would be nice
- kid0m4n 11y agoI wonder if it is wise to have the first example as something which panics. Also that extra new line at the end bothers me!
- ewillbefull 11y agoI don't know what you mean. The example they show is hello world. The website will remember the last thing you compiled and ran on it, and display that again when you come back. Perhaps you're looking at a different code snippet.
- kid0m4n 11y agoThat a very weird semantic to have. I expect URLs (particularly GET requests) to never exhibit this behavior.
- woah 11y agoI've noticed a lot of sites exhibiting these faulty semantics recently. For instance, twitter.com seems to have different content almost any time I refresh. Me and a colleague did a quick test, submitting a GET to Twitter at the same exact time. Her screen showed a completely different set of content. Strange and troubling.
- oldmanjay 11y agoyour expectation is fundamentally flawed for many reasons, but I'll stick with the most general: the Internet has no HTTP police.
- cmrx64 11y agoFortunately there are no HTTP requests going on that cause this behavior. It is done by JS, using Local Storage.
- contradictioned 11y agoIt has multicursor support. Press Ctrl + Click :)
- peferron 11y agoI've been using the Rust playground a lot this week, and I wish it had a history feature - I often closed a tab and later wished I could get the code back. I'm thinking about trying to contribute a localStorage-based history mechanism. Does anyone else think it'd be a good addition? And if so, any suggestions regarding the behavior?
- MJSplot_author 11y agoI think I would be good. They are using the ace text editor, so something simple like: on pageload: var t = localStorage.getItem("textbackup"); if (t){ __editor.setValue(t); console.log('restoring from backup'); } else { __editor.setValue(document.getElementById('basic_intro').innerHTML); console.log('putting in the intro'); } and on any action: var text = __editor.getValue(); localStorage.setItem('textbackup', text); It's the approach I've taken in my version a playground for a different program. http://xqt2.com/mjslab/mjslab.html http://xqt2.com/mjslab/mjslab.html
- peferron 11y agoThat's definitely useful, but the current Rust playground already does this (sorry for not being clear in my post). I meant a more full-featured history where you can view multiple previous edits, not just restore the last one.
- mbrubeck 11y agoIt would be great if this could also show diffs to previous versions!
- deleted 11y ago[deleted]
- deleted 11y ago[deleted]
- scanr 11y agoThis looks like it's done server side. How is it sandboxed, I wonder? Would it be feasible to do it with emscripten instead?
- cmrx64 11y agohttps://github.com/thestinger/playpen https://github.com/thestinger/playpen (whitelist: https://github.com/rust-lang/rust-playpen/blob/master/whitelist https://github.com/rust-lang/rust-playpen/blob/master/whitel...) It'd probably be feasible, but a royal pain to setup.
- chrismorgan 11y agoIt would require running rustc through emscripten, which is not feasible; as ELF binaries and .so objects and .rlib files, it’s currently in the vicinity of 150MB, of which 100MB is binaries which I expect would be somewhat larger in JavaScript.
- tennix 11y agoI have wrote a playpen-mode for emacs last week with which we can play rust without installing rust and without opening rust playpen in your browser. https://github.com/tennix/playpen-mode https://github.com/tennix/playpen-mode
- fny 11y agoIs backend code for this and the design for the server architecture backing it open source? It's quite a feat to host a computing experience like this for so many people for free.