Git Product home page Git Product logo

Comments (9)

sbarzowski avatar sbarzowski commented on July 28, 2024 1

The main issue with repl is that, because Jsonnet is a functional, expression-oriented language, so your every entry in repl would basically need to be a separate program.

I think that an editable buffer which is evaluated as you edit it (i.e. "live preview"), is a more suitable approach to experimenting with Jsonnet than a traditional repl. So I imagine a bit more sophisticated version of the watch solution would be the best option. I mean stuff like automatically creating a temporary file and setting up "windows" for evaluation and for the input (maybe using tmux or something) and updating the output whenever the file is saved.

This would allow you to experiment locally and to use any libraries and existing code you have available.

What do you think @shaiguitar?

from jsonnet.

sparkprime avatar sparkprime commented on July 28, 2024

Ideally we would use libreadline, but would need an #ifdef for windows, and I'm not sure whether it'd work out-of-the-box on OSX.

On the plus side, this doesn't affect libjsonnet.so.

from jsonnet.

sparkprime avatar sparkprime commented on July 28, 2024

Thinking more about this, the only thing I know how to provide is the ability to execute complete programs on each line, i.e. the only benefit over using jsonnet -i 'foo' is avoiding typing jsonnet -i ''

Imperative languages like Scala have an easier time because they have this notion of intermediate state.

And in contrast with Haskell, Jsonnet does not have the notion of top-level declarations, it is not possible to parse just "local x = 4";

So given all that, do you still think it's worth it?

from jsonnet.

mbrukman avatar mbrukman commented on July 28, 2024

Jsonnet REPL should be more featureful than the standard language itself, because it would make it more useful for experimentation and learning the language. I believe both Scala and Haskell REPLs allow you to do more than what the languages themselves provide.

I agree, however, that it's a non-trivial project. As a first step, providing the same functionality as jsonnet -i would still be useful because not having to retype that (or press "up" and erase the previous command) would be quite useful to get a handle on the syntax.

Later on, allowing the addition of top-level bindings would be an additional useful feature; I suspect as soon as there's a REPL, this will be the first feature request. :-)

from jsonnet.

sbarzowski avatar sbarzowski commented on July 28, 2024
hmm... perhaps instead of REPL for exploration we can recommend that they edit a file and have it automatically executed?

In the simplest version it can be achieved with a one liner:

#!/bin/bash
watch -n 0.5 -- ./jsonnet "$@"`

This is actually better in many ways than a REPL, especially a primitive one, especially for a language like jsonnet.

It can be more fancy of course. You can watch for actual file changes instead of running it every 0.5 second for example (it's a bit tricky: some editors modify a file multiple times (vs code) or actually replace it with a new inode (vim), so there are some special cases). And we could use tmux to provide integrated experience, i.e. open editor pane and result pane for the user.

from jsonnet.

sparkprime avatar sparkprime commented on July 28, 2024

Since the new website has these interactive Javascript panels, do we think a REPL or watch-based solution is still necessary?

from jsonnet.

shaiguitar avatar shaiguitar commented on July 28, 2024

Upvote this issue. I would like my dev env to have a REPL, just like any other language development environment. I shouldn't need to resort to an external program (browser) if I have the language's environment set up on my device.

from jsonnet.

shaiguitar avatar shaiguitar commented on July 28, 2024

Also consider the case of using the REPL to load local libsonnet files in a given dev project and playing around with an internal objects and so forth.

from jsonnet.

shaiguitar avatar shaiguitar commented on July 28, 2024

Sure, that sounds good. As long as it's possible to load local libsonnet files and play with the REPL and the syntax alongside the project's objects. I would expect this sort of tooling to be part of the development environment.

from jsonnet.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.