Dart needs a REPL #4409

Open
DartBot opened this Issue Aug 7, 2012 · 17 comments

Projects

None yet

10 participants

@DartBot
Member
DartBot commented Aug 7, 2012

This issue was originally filed by demis.b...@gmail.com


Dart needs a REPL - It's a glaring omission from a modern dynamic language :)

@iposva-google
Collaborator

Assigning to SDK for the moment, but there are many pieces in the VM on top of the getting the REPL binary built and included in the Editor.


Added Area-SDK, Triaged labels.

@DartBot
Member
DartBot commented Feb 4, 2014

This comment was originally written by dharcourt@chromium.org


A good place for this Read–Eval–Print Loop would be the Dartium developer tools console (and eventually the Chrome console). Switching the console language between Dart and JavaScript could be achieved with a console switch/setting.

A console REPL would be preferable to a standalone or IDE hosted REPL because it would maintain state like a Smalltalk workspace and allow interaction with the DOM.

@DartBot
Member
DartBot commented Feb 4, 2014

This comment was originally written by JayYoung990...@gmail.com


A console-based REPL in Dartium/Chrome would indeed be awesome, but this doesn't address the server-side use case.

@alan-knight
Member

The Dartium console would be very nice, and exists now. You can't define a top-level function, but you can define one that's assigned to a variable or passed as a closure e.g.

[1, 2, 3].forEach((x) => print(x));
1
2
3
null
var f = (x) => x + 2;
[Dart Function] {}
f(5)
7
blah(x) => x + 3;
"'': error: line 2 pos 9: ')' expected
blah(x) => x + 3
        ^"

@DartBot
Member
DartBot commented Feb 4, 2014

This comment was originally written by martyglaubit...@gmail.com


where this an improvement over ne REPL at all, it'd be much more
awesome to just being able to fire up the dartvm in repl mode. i got
somthing like "dart -i" in my mind...

Am Di, 4. Feb, 2014 um 9:41 ,dart@googlecode.com schrieb:

@DartBot
Member
DartBot commented Feb 5, 2014

This comment was originally written by dharcourt@chromium.org


#­5: This doesn't work for me using the developer tools console ('SyntaxError: Unexpected token >' on the first line in Dartium 32.0.1700.58 (247491))... what am I missing? Is the Dart console somewhere else, or is there a setting to change?

#­4, #­6: I'll create a separate issue for a Dartium console if there isn't one, and this issue can stay focussed on a standalone REPL.

@DartBot
Member
DartBot commented Feb 5, 2014

This comment was originally written by jesse.riggi...@gmail.com


I've found that I have to toggle the selector at the bottom and near the
left-middle of the tools window that says something like javascript context
to one of the dart packages. Once you do that, you should be able to
execute Dart code. Depending on what you need to access within your own
codebase, you may need to be more selective in your package choice.

I've only been using Dart for about 3 weeks, but I have to say that using
the Dartium web tools vs the Editor has ramped up my productivity (and I
just found out about it in the last 5 days :-) ). I think it should be
promoted more.

Hope that helps,
 Jesse

@DartBot
Member
DartBot commented Feb 5, 2014

This comment was originally written by dharcourt@chromium.org


Thanks Jesse, that works! Very neat and useful...

There is no need for a new Dartium console issue and this issue can be returned to its standalone REPL focus. Apologies for the noise.

@lrhn
Member
lrhn commented Feb 26, 2014

Issue #17133 has been merged into this issue.

@ghost
ghost commented Sep 4, 2015

This is still the single most-wished-for feature I would love to see as part of the Dart SDK.

Of course, ideally a Smalltalk-like workspace/kernel would be perfect, but a CLI REPL would already help a lot. I'm liking the language so much I'd like an opportunity to use it outside the context of compile-to-js web applications and standard backends, but lack of tooling gets in the way.

@zoechi
Contributor
zoechi commented Sep 4, 2015

I don't have a use case where a REPL would help. Out of curiousity, what do you want/need it for?
With fletch a Dart interpreter is in development and I expect a Dart REPL will be much easier to implement using an interpreter.

@sethladd
Member
sethladd commented Sep 4, 2015

I know it's not a full REPL, but dartpad.dartlang.org is a really useful tool for exploring Dart.

@alan-knight
Member

Dartpad really isn't a REPL at all. But depending on exactly what you're looking for, Devtools or Observatory both provide the ability to evaluate expressions, and so does the IntelliJ debugger. Devtools can declare variables, and you can assign functions to them.

 var foo = (x) => x + 42

but you can't define new functions or classes. Observatory has both debugger-like evaluation and the ability to evaluate expressions in the context of objects being inspected. I'm not sure what Observatory allows in terms of defining new entities, but it's been discussed there. If we're going to get something with those kind of capabilities Observatory seems the most likely thing to grow into that. I could wish the debugger there looked more like a REPL and less like GDB, but that's just cosmetics.

As far as a use case for where those kind of capabilities would help ... http://i.imgur.com/9q583jQ.gif

@ghost
ghost commented Sep 7, 2015

I agree with Observatory being the prime candidate, if such a thing is to be done -- the networked protocol for debugging is really great, too.

As about use cases, it would be great to do fraction of the same live-coding and exploration of libraries/language/concepts as I do with Jupyter/IPython, in Dart. Even if I know the language itself well enough, the ability to build things live really helps with exploring possibilities and new concepts.

I have not done any HTML5 gamedev with Dart yet, so I'm not sure how much that is to apply, but being able to write new functionality and classes on-the-fly might be good for solving certain problems there as well. Without using compilation and live reload, that is.

@tosh
tosh commented Feb 8, 2016

Not 100% related but imho Dart support for Jupyter would be amazing.
As far as I understand we'd just have to provide a Jupyter kernel implementation:

https://github.com/ipython/ipython/wiki/IPython-kernels-for-other-languages

@jirkadanek

@tosh Jupyter is just a fancy REPL. Once you have a REPL, "just providing a Jupyter kernel implementation" is easy. What Dart ultimately aims for is a live programming, though, which is a step more ambitious than REPL with a notebook-style interface. Check out https://groups.google.com/forum/#!topic/dartino-discuss/RxmXjJaASqg for a discussion on that.

@franklinyu

@alan-knight Good work-around for functions, but is there similar way to define classes? There is no "anonymous class" AFAIK.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment