5 ms·
Nim is the language I have always thought was a brilliant idea that I never get to use. It's a shame. Nim is to C/C++ as CoffeeScript is to JavaScript. A hig
by cjhanks 10y ago
Nim is the language I have always thought was a brilliant idea that I never get to use. It's a shame.
Nim is to C/C++ as CoffeeScript is to JavaScript. A highly extensible template language atop a portable language with libraries for practically everything.
So why haven't I hopped on the bandwagon? Outside of C++, C, and Fortran - the only way I have ever learned a new language is through using a REPL. How much of Python's and MATLAB's (and maybe even Julia's) success is due to having a brilliant REPL?
I am not complaining, and I do not have any free time to fix it. But man... if Nim just had a killer REPL that allowed me to slowly learn the language properly while not being blocked from my daily work... it would be just killer!
- Cyph0n 10y agoScala has an excellent REPL too. I often use it to test Java libraries without having to setup a full project. There is also the excellent 3rd-party REPL called Ammonite[1], which is maintained by Li Haoyi[2]. Not only is it a REPL, but it also provides a full-blown scripting interface in Scala! [1]: http://www.lihaoyi.com/Ammonite/#Ammonite-REPL http://www.lihaoyi.com/Ammonite/#Ammonite-REPL [2]: https://github.com/lihaoyi https://github.com/lihaoyi
- dom96 10y agoWhen I first started using Nim I felt the same way. While I still would love a REPL in Nim, I think you can get pretty close to one by just getting an IDE that can compile snippets of source code for you quickly and easily.
- cjhanks 10y agoWhich IDE?
- dom96 10y agoA text editor[1] I wrote a while ago has a feature that allows you to compile and run any tab by pressing F5, even when that tab is not saved anywhere it will save it to /tmp and compile it for you. It's a very simple feature that I'm sure can be implemented as a plugin in any IDE/Text editor. The Nim VS Code plugin sort of supports it, but the feature could be improved. (Nowadays, I wouldn't recommend using Aporia for various reasons). 1 - Aporia - https://github.com/nim-lang/Aporia https://github.com/nim-lang/Aporia
- kaushalmodi 10y ago> Nowadays, I wouldn't recommend using Aporia for various reasons On https://nim-lang.org/faq.html https://nim-lang.org/faq.html under "What about editor support?", Aporia is mentioned as the first option. Should it be moved lower in the list? Anyways I use nim-mode in emacs, and it works great!
- FridgeSeal 10y agoI've had success with vscode: I have it setup to build+run on save which has so far netted me very quick turnaround times for trying things out. Admittedly I'm still doing super basic stuff at the moment.
- partisan 10y agoSame here. It is a good combination and creating a build task for nim is super simple.
- deleted 10y ago[deleted]
- the_duke 10y agoI'm not sure this still works, but I wrote a nim playground a while ago that you can just run locally. (Similar to http://play.rust-lang.org http://play.rust-lang.org or https://play.go-lang.org https://play.go-lang.org). https://github.com/theduke/nim-playground https://github.com/theduke/nim-playground
- kaushalmodi 10y agoEmacs. I have the nim-mode and smart-compile packages installed, and I have bound F9 to compile the nim code in the current buffer, and run it in the emacs-inbuilt eshell. I have configured so that the point and buffer switching 'does the right thing'. - If the compilation fails, show the compilation buffer in the other window, and do not execute the binary, and keep the point in the code window. - If the compilation passes, execute the binary in the other window. - Now if the binary execution ends with showing the eshell prompt, move the point back to the other window (code window). - If not, that is, if the eshell prompt does not show up, keep the point in the eshell buffer, because that most likely means that some user input is expected. --- So my nim learning process goes as: type a code snippet, F9, type more, probably cause error, F9, fix that, F9, etc. Config: [1] [2] [1]: https://github.com/kaushalmodi/.emacs.d/blob/master/setup-files/setup-compile.el https://github.com/kaushalmodi/.emacs.d/blob/master/setup-fi... [2]: https://github.com/kaushalmodi/.emacs.d/blob/master/setup-files/setup-nim.el https://github.com/kaushalmodi/.emacs.d/blob/master/setup-fi...
- alphapapa 10y agoHey, fancy meeting you here. :) Thanks for sharing that, I'll have to give it a try.
- kevin_thibedeau 10y agoWith TinyCC Nim can compile fast enough to serve as a simple REPL[1]. It's already packaged for consumption: https://github.com/wheineman/nrpl https://github.com/wheineman/nrpl [1] https://hookrace.net/blog/what-makes-nim-practical/#use-as-a-scripting-language https://hookrace.net/blog/what-makes-nim-practical/#use-as-a...
- IronBacon 10y agoWhen I can't have a working REPL I use inotify or entr (entrproject.org) to compile and run the program I'm editing when saving. It's not the same thing but it spares a few key strokes...
- throwaway7645 10y agoI felt the same way. I am still learning it, but not as fast as I could with a REPL. Transpiling to C to get the optimizations in GCC is awesome.
- blt 10y agoWhat makes a REPL brilliant instead of average?
- yjgyhj 10y agoThat the repl is in your editor, and you can hit ctrl-c ctrl-e to evaluate anything on the fly.
- jernfrost 10y agoI love the REPL in the Julia programming language. What makes me love it is combination of many small things which makes it practical: (1) remember past written statements (2) completes both functions/types/variables and previously written statements (3) Whenever you write strings you get directory and file name completions. This is amazingly handy when doing some kind of scripting job. (4) The ability to jump into shell mode and help mode by just writing a single character. (5) The integration between the Julia REPL and Unix shell. When in shell mode my Julia variables are accessible as normal shell variables. It is really the combination of all these things which makes it feel very productive to work with.
- gigatexal 10y ago+1 to the usefulness of a REPL. Anyone know of a good one for the vanilla Java language?
- moomin 10y agoI don't, but I'll point out you can do a lot of exploration in the Clojure repl, and with leiningen it's really easy to set up anything in maven.
- gigatexal 10y agoI must have a really low I.Q. Or something because maven is all but broken in intellij for me. The Apache quickstart template defaults to jdk 5?!? And the pom file seems like it could get out of control fast.
- moomin 10y agoSorry, by "in maven" I meant "in a maven repository". Using Maven itself is a nightmare, I know, but if what you need is to download some jars and stick them on the classpath, leiningen is perfect (it even compiles regular Java and has control over JDK versions if you want that) And it generates the pom files so you don't have to...
- nonsince 10y agoIf you could do Clojure-style repl-driven development and hot code reloading with the libraries of C++ and the syntax of Python I would be using Nim for everything already
- pagnol 10y agoI recently had to learn a language whose REPL I didn't like and initially felt the same way, but then I did the following: I began writing 'unit tests' for each feature of the language I studied, and I had a Makefile to recompile and run my tests whenever I saved. This setup gives you instant feedback just like a REPL with the added convenience of being able to go back to previous examples without having to separately store your history. Depending on the testing library, you also get a detailed explanation of what's wrong. Now, when using the language, I still return to my 'tests' every once in a while for reference. In the Makefile itself I use entr: http://entrproject.org/ http://entrproject.org/
- noir_lord 10y agoYou can do something similar with the Code Runner extension with vscode [1] Been able to simply and quickly run code in a variety of languages with little friction is a handy thing to have, particularly when writing fragments in multiple languages at the same time. [1] https://marketplace.visualstudio.com/items?itemName=formulahendry.code-runner https://marketplace.visualstudio.com/items?itemName=formulah...