@shashlick thanks for the hint, I'll check it out, however now I'm also experimenting with:
vim z.nim && nim c -r z.nim
Wow, this is really nifty! Like some mutant cross of Vim and Code Runner, but also auto-compiling as you type...very impressed with this find. It rocks you can quickly spin up a new nim script without actually creating a file and have it auto-build and run on the fly. Nice choice of shortcut keys also, very intuitive and a great design. Plus a fast create gist feature, amazing. :)
Are any of these features on the to-do list/possible/not possible?
Forgive my ignorance, but what advantage would an actual repl have over snip?
Thanks shashlick.
Thanks Bevo. Honestly, the initial goal of snip was to quickly test out snippets posted by folks on #nim, edit on the fly until it worked and then repost back as a snippet for sharing. It just grew from there because it was a really fun project. No doubt you can do the same thing with the Nim playground but snip still has a place since the playground runs on a specific Nim release whereas snip runs locally and can work with any available Nim version including #head, or any programming language for that matter.
Also, I didn't want to make snip a full fledged editor or development environment since there are so many good ones out there. It is definitely works very well to develop snippets that can be tweaked and shared or integrated into a larger program. It really is a complement to a REPL which has its place with instantaneous feedback, hot loading, editing live objects, etc. Personally, I prefer the snip workflow but that's only because my use cases are okay with restarting the program on changes. That doesn't work for everything though.
I have a longer TODO but haven't added much off late due to limited interest. It should be easy to add some of the features you ask for:
Feel free to open issues and PRs on github as well.
I strongly believe that a local playground or REPL should be added to the Nim default installation. It may be based on snip itself, which is super slick indeed. Nowadays many modern user friendly programming languages provide some sort of playground or REPL system (including Crystal for instance).
Of course Nim users can find the proper package and install it with nimble, or can find "Nim Playground" online, but the problem is with new potential users looking around for interesting new languages to learn. There are so many interesting options out there, that they spend a few minutes on each one before deciding which one to learn better. With Nim, some of them may wrongly conclude that there is no easy way to experiment with the language and move over to the next one.
IMHO it is Nim's interest to add a proper playground (maybe snip itself) or REPL system to the default installation, and mention it in the tutorial to attract as many new users as possible.
Thanks for all the feedback. While I appreciate it, I think we might be better served to discuss this as issues in github rather than the forum since this forum is Nim specific and I don't want to distract the community with a tool specific discussion. I'll let @dom96 share his opinion on this.
Meanwhile, we could move this discussion to the issue ID shared by lucatrv and discuss keyboard shortcuts in general.
No worries shashlick, I've logged all the problems I found with Snip already. I think Snip would be a great lightweight learning tool for Nim that could be included in the Nim default install.
If you could get paste working with Snip, that would be a higher priority for me as then we could load gists easily and paste in code to test.
I get this error that borks snip on both windows (conEmu bash) and ubuntu (windows subsystem):
Load file: Error: unhandled exception: over- or underflow [OverflowError]
That's it, I won't continue in this thread.
Some brief replies:-
F5 - given realtime compile is working, F5 is effectively doing nothing. We can potentially remove this.
Ctrl-Z - on Linux suspends the process. You can bring it back by typing fg. It's not closing the application.
I've created issues for many of these in Github. Please review and chime in with your feedback.
Or anyway would it be feasible to add Python as a Nim Backend? (besides JavaScript).
Yes, it's technically feasible. It could even be useful, like for writing Nim add-ons for Sublime, GIMP, Inkscape, Blender, etc.
No, it's not a priority for the Nim core developer team, and for very good reasons - they need to focus on finalizing the Nim language, improving stability, and getting to version 1.0.
But this type of project should not depend on the Nim core devs. Anyone can create a fork of the Nim compiler and add a Python, Lua, Java, C#, Scheme, PL/pgSQL, VBA, Fortran, or whatever other backend they want. (It would be even better if the Nim compiler was more modular, so that backend plugins could be added more easily.)
It would be even better if the Nim compiler was more modular, so that backend plugins could be added more easily.
They can be added easily, without touching the compiler's source even, but a backend is much work, no matter how the compiler's internals look like.
Ctrl-Z - on Linux suspends the process. You can bring it back by typing fg. It's not closing the application. This is what I meant by a merged screen on Linux when ctrl-z is pressed: https://gyazo.com/5af8d2a9a1184857dddf23374f85a9b7
I added comments to the issues on github you opened, cheers.
As one more option, for Emacs users, there's Org Babel too. It's not exactly REPL, but close, and probably better.
I basically have a single Org mode file with hundreds of Nim snippets, which can all independently compile and run.
Using Noweb support in Org, I can also "construct" larger Nim snippets using smaller ones. This is useful if I want to define a proc once, and reuse it at many places.
As all snippets are stored in one document, I can reevaluate all using a single keyboard shortcut with Nim version updates. This helps me quickly catch syntax changes across versions. And.. my document stays updated with my current Nim version.
The end result is that I get all the benefits of a REPL (learning Nim, trying new snippets quickly) + a saved record of all snippets and their outputs.