Skip to content
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

Print a message pointing to the online playground if compiled without it #9622

Conversation

deiv
Copy link
Contributor

@deiv deiv commented Jul 19, 2020

Hi,

For the Debian packaging, we remove the support for the playgroud due to the lack of octicons fonts in the archive. We will use the flag -Dwithout_playground, to deactivate it.

This change simply add a message pointing the user to the online version.


Maybe, the next if out of context for this pull request, but for what we know, the -Dwithout_playground flag was added only for the use case of compiling crystal in windows (that lacks sockets support) [0].

Is posible to maintain this flag for the entire lifecycle of crystal ? (we expect that at some point, when windows get's socket funcionality, the flag will be removed).

[0] #9031

@asterite
Copy link
Member

@deiv Thank you!

Just note that the online version is not the same thing. So I wouldn't mention play.crystal-lang.org in the message.

@asterite
Copy link
Member

Oh, actually, I don't think we should merge this exactly because the online version is not the same thing, and there's nothing equivalent online (maybe there should?).

@deiv
Copy link
Contributor Author

deiv commented Jul 19, 2020

@asterite yes, I wonder why are not the same ...

Maybe, adjusting the text, letting know the user that the online version is not the same (the online seems that has less features) ? Example:

Crystal was compiled without playground support
You can play with the online version (that doesn't have all the features) here: https://play.crystal-lang.org

Seems a better option, that simply don't give any alternative.

@asterite
Copy link
Member

It's not that the online version has different features: it's a completely different thing.

The embedded playground will show the type and value of each expression, and you can edit the code and it runs immediately. The online play page just let's you submit code which runs once, and you can share that code.

The fact that the both include "play" in their name is misleading.

I suggested many times that it would be great if crystal play would actually be a hosted site. The reason it's not is that in the local version you can use shards. In any case, we would need to do a survey to know how many people use the offline play feature, and how they use it.

@bcardiff
Copy link
Member

I think that the current message is enough.

We can keep the flag beyond windows socket support. Thanks for raising the need. It will go away if the playground is splitted in from the compiler, but not before.

To clarify @deiv , the lack of octicons in the archive is not a decision on our side. They are vendored to allow offline usage of the playground.

Thanks for the official Debian package 🙇

@jhass
Copy link
Member

jhass commented Jul 21, 2020

How about:

Crystal was compiled without playground support. Try the online code evaluation and sharing tool at https://play.crystal-lang.org

@deiv
Copy link
Contributor Author

deiv commented Jul 22, 2020

Hi,

@bcardiff; about the flag, good to know that could be keeped. On the other side, about the octicons, for "archive", I mean debian archive, so if our fault :)

@jhass: better, that clarifies the "thing" !

Thanks all !

@z64
Copy link
Contributor

z64 commented Jul 22, 2020

Is there a meaningful incentive to point people to use the online playground, when they already have the compiler installed..?

crystal eval 'code' and crystal foo.cr seem more sensible to me at that point than to say "if you're trying to test some code, maybe open your browser and use this site", as the playground currently does little more than either of those commands, with none of the possible options (--release, etc.)

The playground evaluations are shareable, but that also doesn't seem like something someone who wanted to use crystal play originally would be interested in.

@deiv
Copy link
Contributor Author

deiv commented Jul 22, 2020

HI @z64,

Is there a meaningful incentive to point people to use the online playground, when they already have the compiler installed..?

Yes, point to something similar.

Maybe the other option is to remove the commandline parameter. From a user view (that didn't compile crystal), sounds wrong to see "hey, crystal have a playground, but for you there's not (Crystal was compiled without playground support)".

crystal eval 'code' and crystal foo.cr seem more sensible to me at that point than to say "if you're trying to test some code, maybe open your browser and use this site", as the playground currently does little more than either of those commands, with none of the possible options (--release, etc.)

The playground is for testing code or to play with the language in some agile manner ?. I see more agile, using the browser interface, instead of open a text editor, edit the file, save, and run the crystal compiler to run the file.

@asterite
Copy link
Member

Yes, point to something similar.

Something similar is a file in your machine, and running it with crystal program.cr. That will have exactly the same result as play.crystal-lang.org except that for the latter you need an internet connection, it's slower, and it's harder to type in (instead of in your favorite editor).

Maybe the other option is to remove the command line parameter

I think the current situation is fine. Instead of saying "Unknown command" and having users say "I swear this was a thing", they get an explanation of why it's not working in their current version.

The playground is for testing code or to play with the language in some agile manner ?. I see more agile, using the browser interface, instead of open a text editor, edit the file, save, and run the crystal compiler to run the file.

Try hitting play.crystal-lang.org . For me it takes like 20 seconds to load. Probably because it's in heroku and it needs to spin up an instance. I don't see that as agile at all. The editor in the browser is not as convenient as your editor. You can't undo code once you submitted it. To edit the code you need to click a button, etc. That's the opposite of agile in my mind.

The solution here is for us or someone to host an exact equivalent of crystal play somewhere. Then people can play with the language without having to submit or reload pages. But of course someone has to pay for that so there's that issue...

@z64
Copy link
Contributor

z64 commented Jul 22, 2020

To go into more detail, the playground is very limited in what you can do; (some of these could be improved, but this is how it is today)

  • It is a stripped down, sandbox environment. Some things may not work correctly, if at all. The playground often gives poor diagnostics as well when errors occur.
  • You cannot pass compiler options. If you are testing something for performance, this means you can't use the standard benchmarking module.
  • You cannot use shards or other native libraries or tools you have installed on your host.
  • The embedded text editor is limited, and has several bugs that can make it very frustrating to use.
  • It requires an internet connection, and the service to be available.

These make the playground a very poor replacement for someone who was about to use crystal play, as crystal play has almost none of these limitations. The next best thing is the compiler itself, which the user already has installed. The online playground is most helpful for when you don't have a compiler on hand, or want to share proof of simple code.

You can write multiline eval in any decent terminal with ease:

~ $ cr eval '
    def fib(n)
      if n <= 1
        1
      else
        fib(n - 1) + fib(n - 2)
      end
    end
    puts fib(42)
    '
433494437

with none of the drawbacks above.

open a text editor, edit the file, save, and run the crystal compiler to run the file.

Considering all of the above, that is a very small thing to have to do for a predictable environment without unexpected limitations (your own).

@asterite
Copy link
Member

The next best thing

The compiler is actually better than crystal play because crystal play changes the actual code you run, and because of that there are several bugs in it which cannot be reproduced with the plain compiler.

@deiv
Copy link
Contributor Author

deiv commented Jul 22, 2020

Yes, point to something similar.

Something similar is a file in your machine, and running it with crystal program.cr. That will have exactly the same result as play.crystal-lang.org except that for the latter you need an internet connection, it's slower, and it's harder to type in (instead of in your favorite editor).

Not, it's not similar. See steps below...

By the way, you need an internet connection to download crystal... :p

Maybe the other option is to remove the command line parameter

I think the current situation is fine. Instead of saying "Unknown command" and having users say "I swear this was a thing", they get an explanation of why it's not working in their current version.

The point is that is not "not working", is that can't be compiled. I dunno what is worst:

  • pointing the user that crystal has the command (and later realize that has not support)
  • crystal don't pointing to play command

Maybe the two ...

The playground is for testing code or to play with the language in some agile manner ?. I see more agile, using the browser interface, instead of open a text editor, edit the file, save, and run the crystal compiler to run the file.

Try hitting play.crystal-lang.org . For me it takes like 20 seconds to load. Probably because it's in heroku and it needs to spin up an instance. I don't see that as agile at all. The editor in the browser is not as convenient as your editor. You can't undo code once you submitted it. To edit the code you need to click a button, etc. That's the opposite of agile in my mind.

For agile, I don't mean speed, I mean the easy to run some lines of code to test the language.

For a user that never used crystal, is better to have a html interface with the editor and the compiler in it, and pushing only a button to get the code executed.

Instead of:

  • open an editor (5 seconds to get to the taskmenu)
  • save the file (5 seconds to choose path and filename: yes we all hate to give a file a name)
  • (maybe another 5 seconds or more to think what extension is the correct for the crystal file; Probably not needed to put one...)
  • open a terminal (5 seconds to get to the taskmenu)
  • navigate to the path where the edited file is (5 seconds)
  • execute the file (5 seconds or more, because the user maybe doenst known how to execute a file with the compiler: at some point he has to take the decision to read the help/manual or ignore it, because he doesn't know if the language is cool)
  • once the user decided that he likes or don't likes the language, remove the file (5 seconds ?)

The solution here is for us or someone to host an exact equivalent of crystal play somewhere. Then people can play with the language without having to submit or reload pages. But of course someone has to pay for that so there's that issue...

Don't look at me :D

@deiv
Copy link
Contributor Author

deiv commented Jul 22, 2020

To go into more detail, the playground is very limited in what you can do; (some of these could be improved, but this is how it is today)

  • It is a stripped down, sandbox environment. Some things may not work correctly, if at all. The playground often gives poor diagnostics as well when errors occur.
  • You cannot pass compiler options. If you are testing something for performance, this means you can't use the standard benchmarking module.
  • You cannot use shards or other native libraries or tools you have installed on your host.
  • The embedded text editor is limited, and has several bugs that can make it very frustrating to use.
  • It requires an internet connection, and the service to be available.

These make the playground a very poor replacement for someone who was about to use crystal play, as crystal play has almost none of these limitations. The next best thing is the compiler itself, which the user already has installed. The online playground is most helpful for when you don't have a compiler on hand, or want to share proof of simple code.

You can write multiline eval in any decent terminal with ease:

~ $ cr eval '
    def fib(n)
      if n <= 1
        1
      else
        fib(n - 1) + fib(n - 2)
      end
    end
    puts fib(42)
    '
433494437

with none of the drawbacks above.

open a text editor, edit the file, save, and run the crystal compiler to run the file.

Considering all of the above, that is a very small thing to have to do for a predictable environment without unexpected limitations (your own).

There's not point here.

We are talking about an interface where some new user can test and "play" with the language without knowing nothing about it.
Or maybe without an experience in a shell doing "multiline eval i".

And to point the user to a replacement that could use to test crystal. Not about and IDE o enviroment for programing in crystal...

@deiv
Copy link
Contributor Author

deiv commented Jul 22, 2020

The next best thing

The compiler is actually better than crystal play because crystal play changes the actual code you run, and because of that there are several bugs in it which cannot be reproduced with the plain compiler.

Same as above.

Correct me if I'm wrong, but one use case for 'crystal play' or playground is not to give a try to crystal? (without the hassle to execute the binary, etc ...)

@z64
Copy link
Contributor

z64 commented Jul 22, 2020

For someone new to the language, before they even spent the time to install the package they would have seen this:

image

which directs them to the playground to try things.

Anyway, thats all the toughts I have; I overall disagree with this as stated.

@asterite
Copy link
Member

@deiv you make a lot of good points

@deiv
Copy link
Contributor Author

deiv commented Jul 22, 2020

For someone new to the language, before they even spent the time to install the package they would have seen this:

image

Yes, or someone tell's him about a new cool language named crystal, do an 'apt|yum search crystal' and later install it.

which directs them to the playground to try things.

That's the point, playground for play or try it... (well, without the message this pull request is adding... maybe the user has to go to the web page)...

Anyway, thats all the toughts I have; I overall disagree with this as stated.

That's life, if all people were equals, ¿ wheres the party ?

This way, is more clear, that the playground and the online page
are not the same tools.
@bcardiff bcardiff added this to the 1.0.0 milestone Jul 28, 2020
@bcardiff bcardiff merged commit 4847a14 into crystal-lang:master Jul 30, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants