Request for better REPL

The Kotlin language is excellent, but I have to emphasise a major drawback:
The standard distribution comes with a very weak REPL (Read Evaluate Print Loop), that does not
support even code completion. Other competitive languages as Java (with JShell) and Scala come
with more usable and much better REPLs, and I consider the REPL very important for the programmer.

There is a much better Kotlin REPL, with strong features:

but why is not integrated with the standard Kotlin installation?

I think it is urgent to bring to Kotlin users a much better REPL as soon as possible.

If you use it in-IDE, it does. I’m guessing that the Kotlin team has lots of goals that they’re working on right now, and bringing code analysis to a REPL shell when it already exists in the IDE has a much lower priority

2 Likes

I agree that the IntelliJ IDEA provides superb code completion and analysis,
but at least to me, a full-featured stand alone REPL is very important.

3 Likes

As far as I know, the current embedded kotlin shell is intended to be deprecated in the future.

About KI. When I was asked about should it be delivered together with the kotlin compiler, I said, that it should not. It is not a problem to download it separately. You do not download the kotlin compiler manually anyway. And if we are talking about the idea, there is a worksheet feature that allows you to get the same functionality much easier.

Being stand-alone, KI could develop much faster.

1 Like

O.K., I consider important Kotlin to have a better embedded shell.

It is difficult for the average user to search and install separately tools like KI,
Kotlin should be simple and direct in all aspects
(for example, the current KI archive operates with JDK11 but not with JDK16,
that can confuse most users).

1 Like

The “average user” that we’re talking about here is a programmer. If a programmer can’t install a separate tool like KI, there’s probably a bit more of an issue there, especially when that programmer specifically doesn’t want to use an IDE instead. Like either you go with the easy option and use an IDE or go with an interactive shell that just runs from a script and only needs minimal setup anyway.

5 Likes

Could you explain a use-case for a shell? As I said earlier, an “average user” does not install kotlin at all. It is automatically downloaded via the gradle plugin. In IDE. And in IDE you have better tools like scratch or worksheet.

4 Likes

I don’t know what the general use case might be. In my case, I’ve used the REPL occasionally because it launches far faster than a heavyweight IDE; it’s handy for writing simple one-liners, and for checking syntax. So removing the REPL would be a small inconvenience to me.

What do other folk use the REPL for?

Something what JRebel provides would be a real boost for developer productivity: No need to recompile and restart, because every code change becomes immediately effective. Java and all other JVM language are still weak on this and JRebel is way too expensive.

Every change becomes immediately effective wihtout restarting the application made development in Smalltalk back then extremely productive. Java is way more productive than C++ but without hot code replacement it still cannot beat Smalltalk in developer productivity. The reason Smalltalk is almost dead is for other reasons.

Hot code replacement makes developers much more productive than REPL. This is something that is only understood by former Smalltalk developers. As there were only were few Smalltalk people back then, this is not known and everybody thinks REPL make a big difference.

Hot code replacement for Kotlin would be a killer advantage over Java/Scala and others. Much better than going with a REPL. To have something like a REPL you would just test out some code in a scratch pad.

1 Like

I believe that that’s a platform-dependent issue really in that like if Kotlin somehow develops a solution for hot code reload on the JVM (which I think already exists out there, at least there’s definitely hot code reload for Android which has its own JVM-ish runtime flavour) it’ll just be a hot code reload solution for any JVM language because there’s really nothing special about Kotlin in that regard.

I don’t really see how hot replacement and REPL solve similar kind of problems. Maybe this is just me, but I usually use REPL (IPython) to calculate something I need, to transform some file into another format, to extract some data from a website, etc. I rarely use it for anything project-related, but rather for some one-time tasks. And even if I work on some kind of a library and I need to play with its API a little, then still I don’t see how hot replacement makes it easier. REPL does.

1 Like

Hot reload is available in some kotlin frameworks. I do not think there could be a general universal solution. In some cases, the code is just compiled statically and could not be replaced. You probably should open another thread and describe your use-cases.

1 Like

This solution is not for everyone. Depending on your needs, you can continue to use ipython as your REPL, test that your code works and then transpile it to Kotlin.

I am not sure, why anyone would want this. We have GitHub - Kotlin/kotlin-interactive-shell: Kotlin Language Interactive Shell (mentioned above) and fully featured GitHub - Kotlin/kotlin-jupyter: Kotlin kernel for Jupyter/IPython.

2 Likes

It works best when supported on vm level: Dynamic Code Evolution for Java

Kotlin 1.6.0 even does not come with a competitive REPL with elaborate code completion.

I consider that a significant drawback for such an advanced language,
and a major negligence of not to include something strong, like the ki shell.

It was decided to develop KI as a separate entity to make a more robust release cycle. All arguments above are relevant. Nobody really “installs kotlin” anyway, so if you need a shell, you just install KI.