Skip to content

Make use of code-run-websites #167

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

Open
june128 opened this issue Jun 29, 2018 · 9 comments
Open

Make use of code-run-websites #167

june128 opened this issue Jun 29, 2018 · 9 comments
Labels
Discussion This is open for a discussion. GitBook This is GitBook related.

Comments

@june128
Copy link
Member

june128 commented Jun 29, 2018

For many languages websites exist, where people can run code snippets.
We currently don't really do that in the AAA, but I think it's a cool thing to add for languages supporting it.
People wouldn't have to download and install everything needed just to run some code and people could also run code on mobile.

This topic came to my attention again, because of this #164 which included a convenient way to run the code.

So I open this issue for discussion about this topic. What do you guys think?

@june128 june128 added the Discussion This is open for a discussion. label Jun 29, 2018
@jiegillet
Copy link
Member

jiegillet commented Jun 29, 2018

I see the value in this. I myself tonight copy/pasted some matlab code in the matlab online website because I don't have matlab installed on this machine (... oh wait... I just realized I do have it... gah...).
What would be great is having some way of automatizing it. Are there tools like that?

@june128
Copy link
Member Author

june128 commented Jun 29, 2018

I can see two different methods of doing this. Either include just a link to the website or have it somehow integrate in the AAA.
I think the first one will be fine for now, while the second one is something to consider for the future, because I imagine to to be far more complex.

@jiegillet I would say just creating it manually and checking if the output is right is enough. We need to pay attention to this then in future PRs of course, but I think this will be fine. I don't know what you mean by tools... A GitBook plugin doing that would be neat (and cover the second method I named), but I highly doubt it exists.

@jiegillet
Copy link
Member

Yeah I was thinking GitBook plugin... We have all the informations, where the file is, what the language is. Some online interpreters can handle hundreds of languages. But yes, chances are low it exists.

@Butt4cak3
Copy link
Contributor

I must say I'm not a fan of integrating these tools. I'd support the decision to have an introduction chapter with a bunch of links to such online interpreters/compilers, but in the end, we're writing a book. I don't think it needs live code execution.

Secondly, I don't like the idea of creating a bunch of dependencies on third-party services. They can go down, change their APIs and it will be work to maintain working connections to them.

@leios
Copy link
Member

leios commented Jun 29, 2018

@Gustorn recently brought up that we could do something like this: https://doc.rust-lang.org/book/second-edition/ch01-02-hello-world.html, where each codeblock can be run in the background. I don't know how well this will play with the include-codeblocks and theme-api plugins.

@julianschacher mentioned we could use this too: https://docs.microsoft.com/en-us/dotnet/csharp/quick-starts/hello-world?tutorial-step=2, which brings up a separate editor so people can play with the code.

I also don't know what languages are supported for a similar feature. Like @Butt4cak3 I don't know if these services will be stable for a long time or not... But I am not sure how long our current tools will be stable for anyway.

@leios leios mentioned this issue Jun 29, 2018
@nikhiljha
Copy link
Contributor

A neat example of how to implement this can be seen in the Ant Design docs. Click on view code and note the small icons that link to the code preview sites.

@Butt4cak3 I don't think it would hurt too much to just link to their sites like in this example ^ (most projects do that). I know it's super annoying to deal with changing APIs and whatnot, but if they do go down it wouldn't be too hard to remove them.

@leios Something similar to what the rustlang book does is very hard for anything that's not JavaScript. I'd suggest linking to the code playground sites instead.

Here are a few good ones that we can link to:

JavaScript: https://codepen.io / https://jsfiddle.net/ / http://jsbin.com/
Rust: https://play.rust-lang.org
Python: https://trinket.io/python/
C/C++/C#/Java/PHP/Ruby: https://code.sololearn.com/

@xam4lor
Copy link
Contributor

xam4lor commented Jun 30, 2018

Cannot we just test in local what the results are, and cheat a little bit : when the user will press on buttons like 'play' or something like that, the results are stored somewhere and are just display!
It's not the best solution, but It will do the job!

@june128
Copy link
Member Author

june128 commented Jun 30, 2018

@xam4lor The cool thing with those code running websites is, that people can modify the code and see what happens. With our cheat this wouldn't be possible. We also decided not to provide output files (and maybe use random input) for our implementations, right here: #55 (scroll down a bit)

@xam4lor
Copy link
Contributor

xam4lor commented Jun 30, 2018

Yes that's right!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Discussion This is open for a discussion. GitBook This is GitBook related.
Projects
None yet
Development

No branches or pull requests

6 participants