6 ms·
The REPL has spoilt me. Working with languages without a powerful REPL, even ones with a shell like JS/Python/Lua/Ruby feels like a regression comparable to mov
by divs1210 6y ago
The REPL has spoilt me. Working with languages without a powerful REPL, even ones with a shell like JS/Python/Lua/Ruby feels like a regression comparable to moving from zsh to windows cmd.
- veddox 6y agoOut of curiosity: what‘s the difference between a REPL and a shell?
- Jtsummers 6y agoA shell is a kind of REPL, specifically built around accessing OS level commands and features. Language REPLs offer that same kind of access but for your language and language runtime.
- divs1210 6y agoWith a REPL, you can connect to your running system and run code / edit existing functions, objects, etc. In a Python shell, for example, you can't redefine an existing function and see how it affects your system.
- errantspark 6y agoWhoa? JS? Really? The Chrome Dev Tools are probably the best REPL programming environment I've ever used.
- p_l 6y agoChrome Dev Tools do a lot of lifting, but they can't deal with the fact that JS just isn't designed for interactive development.
- Angeo34 6y agoIf you think zsh to cmd is a regression you should try out bash. It's vastly superior to zsh in literally every regard. If you still aren't stratified use fish. Genuinely never got how people use zsh. It's the slowest and clunkiest shell I've ever witnessed it's fucking slower than most electron gui software.
- Natfan 6y agoPersonally I've found zsh's features to massively outweigh it's "slowness" (although I haven't really noticed zsh as "slow", per se) `esc, esc` to prefix the line with `sudo`, better tab completion (both the navigatable UI with arrow keys, along with the intelligent tab completion (I type in "./llo" and it finds the file "./helloworld.sh")), combined with the massive amounts of customization and modules you can install makes it a shell killer. The only shell I've found that I like more is Windows' Powershell, however that's mostly because I __love__ the Powershell language and syntax. However I will admit that almost all of what I just complimented is part of oh-my-zsh, which is a community add-on for zsh which makes the experience so much nicer. In my time I've used bash, csh, pwsh and zsh and if I could, I'd always use zsh for termanal interactivity and pwsh (Powershell on Linux) for scripts.
- divs1210 6y agozsh + oh-my-zsh is a hassle-free batteries-included power-tool with a large community and lots of plugins. I don't use my shell for intensive computing so I've personally never perceived any slowness or clunkiness.
- minerjoe 6y agoHmm. Curious. How is it slow for you? I switched about a year ago to see what all the fuss was about and piled on as many addons as I could and yes it was slow - to start, but not to use. Which, if you like to pop up new terminals all the time, defintely is annoying. I then pruned it down to what I actually used and got the startup to less than a second, which is just fine for me as the benefits greatly outweight the little blip. No noticable slowness, except for that initial startup. And this is all on a circa 2008 Thinkpad clocking in at 1.8Ghz.
- nonbirithm 6y agoI have managed to program a REPL in Lua for game development. I also added a feature that lets you reload any single Lua module at runtime, thanks to late binding through tables. Nobody seems to standardize on a good way of doing it so I had to roll my own but I've saved countless hours of restart time doing so and had fun programming at times. There really, really should be a standard protocol for communicating with a REPL in a running program like there is for IDEs in the Language Server Protocol. Maybe that way the concept would become more mainstream if you could just take any REPL client and walk up to a program with a REPL server and interactively explore its state. The closest thing to said protocol is nREPL which is what Clojure uses, but there are a lot of nonstandard extensions to the protocol for edge case features only applicable to Clojure, so almost every client assumes you're using Clojure and it greatly reduces the viability of using it for Lua or other languages. It doesn't have the backing of something like Microsoft either, I guess because this REPL thing lives in its own world with the Clojure userbase. I opened an issue on Clojure's REPL integration with Emacs for supporting more languages[1]. I wanted to take advantage of the effort spent on Clojure's client side tooling for things like the command prompt and state visualiser but apply them to at least Lua and allow others to add their own support for other languages. It would be a really big effort but I've already seen the value of it by integrating a REPL with projects written in Lua. As you said I can't ever imagine using a dynamic language without one again. [1] https://github.com/clojure-emacs/cider/issues/2848 https://github.com/clojure-emacs/cider/issues/2848
- divs1210 6y agoWill it be possible for you to make the Lua REPL publicly available? Would love to give it a spin with Spring RTS!
- nonbirithm 6y agoIt is, it's just part of a project I'm working on that uses Love2D and integrated with it a bit tightly. But I think it could be useful. Actually when I think about it the thing I made probably isn't a "REPL" in the Clojure sense since all it has is a command line and module hotloading; there is no namespace support and the command line evaluation does not happen in the context of the program, but you can basically call a function that gives you the entire global state of the game to mess with and see changes instantly. Maybe that's a better approach than having global state shared between both as Lua has no namespace support built-in, and I don't want to hack it on to keep things simple. Here is the drawing code for the REPL in-game. https://github.com/Ruin0x11/OpenNefia/blob/master/src/api/gui/menu/ReplLayer.lua https://github.com/Ruin0x11/OpenNefia/blob/master/src/api/gu... Here is the server which listens for commands using a custom protocol. I want to use nREPL at some point but that requires merging some changes into external projects with the client side tooling. https://github.com/Ruin0x11/OpenNefia/blob/master/src/internal/debug_server.lua https://github.com/Ruin0x11/OpenNefia/blob/master/src/intern... Here is the code which handles hotloading. It's complicated but I had to write the system so that it also handles sandboxing external mods and hooks into Lua's module management, running special checks to see if the loaded code is not part of the base game. You can probably get away with the version in lume if you don't need as much. But the point is that this is what ultimately allows changing files and seeing the changes instantly without restarting the program. https://github.com/Ruin0x11/OpenNefia/blob/master/src/internal/env.lua https://github.com/Ruin0x11/OpenNefia/blob/master/src/intern... https://github.com/rxi/lume/blob/98847e7812cf28d3d64b289b03fad71dc704547d/lume.lua#L688 https://github.com/rxi/lume/blob/98847e7812cf28d3d64b289b03f... Here is the integration with Emacs. https://github.com/Ruin0x11/OpenNefia/blob/master/editor/emacs/open-nefia.el https://github.com/Ruin0x11/OpenNefia/blob/master/editor/ema...