Raku / user-experience

Identifying issues in and improving the Raku user experience
Artistic License 2.0
25 stars 5 forks source link

Perl6 needs a good REPL #2

Open JuneKelly opened 8 years ago

JuneKelly commented 8 years ago

Programmers coming from Ruby, Python, Node, Clojure, (etc) will expect a decent REPL, with history, arrow navigation and tab completion.

Ideally the perl6 executable from Rakudo could be improved to meet these needs. Otherwise a port of the perl5 module Devel::REPL would also work.

hoelzro commented 8 years ago

@ShaneKilkelly Let's say that rakudo bundled Linenoise so that history, line editing, and tab completion worked out of the box. Would that be enough, or are there more things you would like to have added?

JuneKelly commented 8 years ago

I'd presume so. If it means executing $ perl6 would Do The Right Thing™, then sure, that would be a great solution.

NOTE: I hadn't seen the Linenoise package on modules.perl6.org before it was mentioned here.

hoelzro commented 8 years ago

Rakudo will support line editing and history if either Readline or Linenoise are available, and tab completion with Linenoise. It also recommends you install one of them if neither is found, but I think I made that change post-Christmas.

JuneKelly commented 8 years ago

Ah, now that's cool. It sounds like this issue should be wrapped up pretty easily then :smiley:

hoelzro commented 8 years ago

Thanks for bringing it up! The tab completion could probably be improved, as could multi-line editing. We might want to consider bundling Linenoise or a better line editor with Rakudo, but it feels to me like we'll be moving away from bundling modules with Rakudo itself. I can write up some more notes and stick them into this repo.

JuneKelly commented 8 years ago

NP.

I think as long a perl6 noob can install rakudo, type perl6 and have the up-arrow not produce ^[[A, we'll be on the right track.

arnsholt commented 8 years ago

For people who have tuits in this area, I'd also like to plug the IPython kernel @timo and I have been working on: timo/iperl6kernel. There are some issues in the tracker that can give some ideas on where to start, and I'd be happy to advice if people drop by #perl6.

An OK REPL is clearly important, but I think plugging into something like IPython would give us a pretty good bang for buck factor as well.

JuneKelly commented 8 years ago

Agreed with @arnsholt, a combination of a decent default REPL and a good Jupyter implementation would be awesome.

wollmers commented 8 years ago

Where is the issue tracker of the REPL/Linenoise? Have some bugs.

zoffixznet commented 8 years ago

@wollmers, this should be it: https://github.com/hoelzro/p6-linenoise

uvtc commented 8 years ago

Didn't know Linenoise supported tab-completion. I'd just used Readline because I figured that was the stock GNU/Linux solution. Had some issues with it (or rakudobrew, or panda, not sure), and then fell back to using rlwrap: $ rlwrap perl6.

Also, aside: although I haven't used it in a while, I remember being impressed with the stock Julia repl. I remember it being colorful, and supporting multiline nicely (in fact, I think you could type a multi-line statement, hit Enter, then up-arrow and get the whole multi-line input again).

hoelzro commented 8 years ago

@wollmers @zoffixznet REPL bugs should be reported on rt.perl.org; please feel free to CC me!

fecundf commented 8 years ago

I'm using Rakudo* on Windows; its suggestions to install Readline or Linenoise aren't too helpful as neither of those install with Panda on this platform.

Since Windows cmd shell supports up-arrow and other basic arrows, the suggestion isn't really needed on this platform.

On the other hand, tab completion is nice. since Linenoise has it with P6 and Readline doesn't, mention that in the default "you can install one of these" message. And consider making Linenoise part of Rakudo* - with it working on Windows of course!

(And a ++to uvtc's suggestion at looking at Julia's REPL, multi-line and colors are nice.)

hoelzro commented 8 years ago

@fecundf Did you have problems installing Linenoise? I try to make sure it stays working on Windows, but please let me know if there are any problems!

hoelzro commented 8 years ago

@fecundf Also, Linenoise is in R*, I just screwed up when I added it so it didn't get built =/

hoelzro commented 8 years ago

@uvtc @fecundf As far as taking inspiration from Julia goes, it's just the multi-line input and the colors? I just spun up Julia's REPL for fun; it seems like it just uses color to differentiate modes; is that what you're after?

fecundf commented 8 years ago

Good handling of multi-line expressions is what I'm after. Coloring is less important, half the time I'm using the REPL inside an emacs shell.

In general IMHO when it comes to colors from shell commands, there's always some color that is hard-to-read against some background!

hoelzro commented 8 years ago

@fecundf Thanks for the feedback; I'm working on a little experiment with multi-line input today!

calopter commented 8 years ago

Coming from lisps/haskell, I would love to have a reference to the last returned result ('it' in ghci), and the ability to load source files. That said with the caveat that I have no sense of what would be involved in making this happen.

awwaiid commented 8 years ago

@calopter I think that we should at the very least have $_ set. In irb/pry they define a lexical _ to do this, so pretty similar.

grondilu commented 8 years ago

to load source files you can just do

EVAL slurp($filename)

Regarding the last returned result, I think we should resist the temptation of setting $ . That would be a Pythonism, imho, as $ in Perl is not at all Python's '_'.

JuneKelly commented 8 years ago

Maybe $__? or something semantically close to the topic variable, but still distinct?

tony-o commented 8 years ago

For clarity sake, what do you mean by ‘load source files?’

On Aug 31, 2016, at 3:31 PM, Shane Kilkelly notifications@github.com<mailto:notifications@github.com> wrote:

Maybe $__? or something semantically close to the topic variable, but still distinct?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHubhttps://github.com/perl6/user-experience/issues/2#issuecomment-243922809, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AB75kI41A3yY0ZQZ0nruTBhKcRNQnw06ks5qlgDBgaJpZM4HFN0p.

grondilu commented 8 years ago

If we really want to imitate python we should just use a sigilless _

The last returned value is almost always a read-only one, anyway.

AlexDaniel commented 8 years ago

Why not use something readable like $result?

In a long run I don't want to have to explain the difference between $_ and _/$__, maybe we can avoid it?

grondilu commented 8 years ago

You want something quick to type. A single character is the best. A sigilless "it" would do too, I guess.

calopter commented 8 years ago

@tony-o To clarify, I mean the ability to enter the namespace of a given module and have access to its bindings. Thus, you could run and interact with individual functions, modify them in the source file, reload and repeat.

JJ commented 7 years ago

I would also like some way of adding new functionalities via plugins. I am still baffled at how Linenoise works. I guess it's got something to do with NativeCall, but I really have no idea.

RichardJActon commented 7 years ago

Just FYI I just installed rakudo on a system running xubuntu and the xfce terminal emulator does not handle REPL well by default. ^[[A when you hit up for history and no tab completion, even after installing linenoise. I'm currently using @uvtc 's suggestion of rlwrap.

ps just checked and readline is also installed, by default I think.

hoelzro commented 7 years ago

@RichardJActon OOC, what's echo $TERM give you?

hoelzro commented 7 years ago

@RichardJActon Also, did you install linenoise as an Ubuntu package or the Linenoise Perl 6 module?

mrbrahman commented 7 years ago

It would be nice to get a list of all available options when tab is pressed (similar to nodejs). Currently linenoise forces the user to cycle through the available ones by having to press tab for each one.

bduggan commented 7 years ago

It would be nice to get a list of all available options when tab is pressed (similar to nodejs).

For what it's worth, I've recently added some autocompletion features to the jupyter-kernel

drforr commented 7 years ago

Seconding JJ on the plugin ability - I'd love to be able to add a regex/grammar debugger plugin... when I have the time, of course. I treated the last portion of my ... enforced vacation ... as a hiatus from hacking, but I've got ideas and want to pull something together.

JJ commented 7 years ago

@bduggan can that be ported back to Linenoise or some of the other REPL modules?

bduggan commented 6 years ago

I don't see why not. The only edge case I can think of so far is that the jupyter autocomplete API allows one to specify a cursor position in the input string other than the end, which allows for completions that aren't really completions (e.g. finding unicode operators). I'm not sure how well-supported that would be in linenoise et al.

RichardJActon commented 6 years ago

Hi Sorry for the rather long lag time in getting back on this. I originally installed Rakudo with a sudo apt-get install rakudo rather than getting an up-to-date version of rakudo star or installing the relevant packages with zef - all works fine after doing this. I was just trying out perl6 at the time and didn't have time to use it much or learn more between then and now. Using it more now an quite enjoying it!

alsymd commented 5 years ago

Wondering if there's any update on multi-line statement. I was trying to add perl6 to org-babel but I couldn't find a good way to handle multi-line input without support from the repl. The non-interactive mode works perfectly but then it wouldn't be possible to support sessions.

chee commented 5 years ago

using a fork of Linenoise that supports utf-8 (multibyte chars etc) would be so good :3