Yay! 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?
The 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)
Related 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.
I'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?
I 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);
That'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.
This 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.
Rust 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.
I 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?
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.
I 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
Is 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.
It 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.
I 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.
I'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.
As 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.
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?