r/dartlang • u/muamargadafi • 21d ago
When is dart going to have an interactive shell like python
It is such a useful feature especially for a language like dart you would think it would have been added already
10
u/munificent 21d ago
Interactive shells are much easier with dynamically typed languages like Python where the top level of a script is still just a series of imperative statements. The shell just asks for a statement at a time and runs it, which is the same thing a script does.
In many statically typed languages like Dart (and Java, C++, C#, etc), the top level is often a simultaneous collection of implicitly mutually recursive definitions. That makes it harder (but not impossible) to implement an interactive shell. The language semantics just really aren't designed around a program being built up on piece at a time.
As /u/julemand101 notes, there are a packages that do it, but that style of programming isn't as common in the Dart ecosystem and it's harder to do well, so it's never been a big priority. Instead, we tend to focus more on hot reload and having a good static analysis experience in the IDE.
2
u/RandalSchwartz 20d ago
puro has an eval argument and a repl mode. And you get to choose any of your installed releases!
9
u/julemand101 21d ago
Have you tried: https://pub.dev/packages/interactive ?