Announcement: Haxe REPL

(Philippe) #1

Hello there, I did a Haxe REPL for fun, maybe you want to check it out:

A REPL is a “Read-Eval-Print-Loop”, which means you type Haxe code and each line is evaluated. It works as expected, in the sense that code is incrementally executed.

It depends on npm because it’s using under the hood Node’s native REPL engine.

(Marcelo Serpa) #2

Nice. Btw, a useful use-case for it is a console for a [web] app to execute tasks that are not exposed to the UI for some reason. It was already possible with pure js, but keeping it at the Haxe level is better. I use the rails console all the time for such cases.

Thanks for sharing!

(Philippe) #3

That won’t work in the browser as it’s using the compiler - you’d have to expose the compiler as a service.

(Evan Montembeault) #4

Neat! Our company has a command line Haxe REPL internally that we don’t actually use much; maybe I can try to convince someone to let us clean it up and open source it if you think it would be useful for your own effort!

(Marcelo Serpa) #5

That won’t work in the browser as it’s using the compiler - you’d have to expose the compiler as a service.

Actually having it in the backend is more than enough for me, I wasn’t thinking about exposing the repl in the frontend (although it could have some interesting use-cases given the security aspect is taken into account).

(Philippe) #6

That could be interesting to see other approaches. There is another neko-based REPL but it just execute everything - my version is really incremental and uses the real compiler so you can import classes and haxelibs.

(Evan Montembeault) #7

Offhand, I recall ours being somewhere in the middle. I think it’s a neko program that generates a .hx file, compiles it targeting neko, then runs it and captures the output. I know it can do import and using but I don’t think we ever added haxelib support - it was mainly for presentation and training purposes.

(Philippe) #8

There’s another Haxe “REPL” like that, but re-executing the whole code isn’t REPL :wink:

I generate a hx file, compile to JS, and rewrite the output to be truly incrementally interpreted by node.

(Jdonaldson) #9

Could we get this working with python you think?

(Philippe) #10

Potentially - I’m really no expert in Python and you need to be able to execute arbitrary code from string in a separate context.