Hacker News new | past | comments | ask | show | jobs | submit login
Show HN: ReplPad – Javascript Repl/Scratchpad (replpad.com)
54 points by amadeuspagel 12 days ago | hide | past | favorite | 17 comments

A few hours ago I was doing "repl driven development", meaning that I experimented with the repl, closed it by mistake (confusing Ctrl+D and Ctrl+C), tried to get the state I had before back using the up key, copied the history file into the project folder, removed everything unnecessary and pasted it into the repl again, and then kept developing by editing that file and pasting the result into the repl. I felt that this can't be it and made this as a demo of what I think a repl should be like.

Albeit in Clojure/Script, the Emacs + Cider experience is quite good, and I'm never using the REPL directly from CLI, I'm editing a file and sending forms to REPL that get eval'd inline. I wrote that sentence really backwards, sorry, I'm tired.

Also shoutout to https://jsconsole.com/ if you want a lightweight console-like experience in a browser tab.

This is basically a very light version of a reactive notebook like this one https://observablehq.com/demo

This is pretty fun. Reminds me of a bookmarklet I have somewhere that makes a self-editable webpage.

The only suggestion I have would be to make the right textarea non-editable, although I don't know how to do so while keeping selectability

Done. It actually keeps selectability by default, at least in chrome and firefox.

I do think a comment/title/something that uses the word "Javascript" would be helpful; I guessed it was so, but there's very little syntax here and I look at JS code about once a year on average.

Very cool, bookmarked.

Thanks, added javascript to the title.

What programming language is this? Is it available as some kind of framework for spinning up your own REPL website for your own language?

It's javascript. It's not available as a framework, but you can make your own repl website based on the code[1]. Though of course it would be much harder for another language, since you can't use eval().

[1]: https://gitlab.com/amadeuspagel/replpad

It's JavaScript. The REPL's code is evaluated by the page's JavaScript -- look directly in the page's source, there's an 'eval' call that evaluates the REPL's code.

Looks like it's just directly `eval`ing vanilla JS

This is fun. I'd really like to see an easy js scripting environment for slightly more complex logic. Though I suppose this accomplishes that since everything is reevaluated upon editing.

FYI If I highlight everything and delete, the right-hand side 'answers' remain there, with no text to the left

Inspired by repl.it by any chance? I am a heavy user of repl.it...

This is a neat little project and all but what is the value proposition? The JS console of any modern browser is much more feature-full.

Type `square(10)` on the last line.

Notice it doesn't give you the correct value.

Fix the square function to correctly return `n*n`. Everything updates instantly.

There's your answer. It's actually really neat to code that way, especially with a long chain of logic.

In your browser console, can you edit a previous statement and have everything recalculate?

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact