News for hackers. Stuff that matters.
Re:Nim programming language by cjhanks on Tuesday April 18, 2017 @06:46PM (#14143720)
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!

Re:Nim programming language by Cyph0n on Tuesday April 18, 2017 @07:00PM (#14143806)
Scala 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

[2]: https://github.com/lihaoyi

Re:Nim programming language by pagnol on Wednesday April 19, 2017 @08:16AM (#14147158)
I 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/

Re:Nim programming language by noir_lord on Wednesday April 19, 2017 @09:40AM (#14147598)
You 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=formulah...

Re:Nim programming language by dom96 on Tuesday April 18, 2017 @07:01PM (#14143816)
When 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.
Re:Nim programming language by kevin_thibedeau on Tuesday April 18, 2017 @09:12PM (#14144641)
With TinyCC Nim can compile fast enough to serve as a simple REPL[1]. It's already packaged for consumption:

https://github.com/wheineman/nrpl

[1] https://hookrace.net/blog/what-makes-nim-practical/#use-as-a...

Re:Nim programming language by IronBacon on Wednesday April 19, 2017 @10:14AM (#14147834)
When 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...

Re:Nim programming language by cjhanks on Tuesday April 18, 2017 @07:12PM (#14143900)
Which IDE?
Re:Nim programming language by kaushalmodi on Tuesday April 18, 2017 @10:00PM (#14144879)
Emacs.

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-fi...

[2]: https://github.com/kaushalmodi/.emacs.d/blob/master/setup-fi...

Re:Nim programming language by alphapapa on Wednesday April 19, 2017 @12:15AM (#14145393)
Hey, fancy meeting you here. :) Thanks for sharing that, I'll have to give it a try.
Re:Nim programming language by dom96 on Tuesday April 18, 2017 @07:16PM (#14143925)
A 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

Re:Nim programming language by kaushalmodi on Wednesday April 19, 2017 @12:06PM (#14148761)
> Nowadays, I wouldn't recommend using Aporia for various reasons

On 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!

Re:Nim programming language by FridgeSeal on Tuesday April 18, 2017 @07:55PM (#14144217)
I'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.

Re:Nim programming language by partisan on Wednesday April 19, 2017 @09:31AM (#14147542)
Same here. It is a good combination and creating a build task for nim is super simple.
Re:Nim programming language by the_duke on Tuesday April 18, 2017 @08:25PM (#14144380)
I'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 or https://play.go-lang.org).

https://github.com/theduke/nim-playground

Re:Nim programming language by throwaway7645 on Tuesday April 18, 2017 @09:56PM (#14144865)
I 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.
Re:Nim programming language by nonsince on Wednesday April 19, 2017 @02:22AM (#14145874)
If 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
Re:Nim programming language by blt on Tuesday April 18, 2017 @10:41PM (#14145058)
What makes a REPL brilliant instead of average?
Re:Nim programming language by jernfrost on Wednesday April 19, 2017 @09:04AM (#14147384)
I 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.
Re:Nim programming language by yjgyhj on Wednesday April 19, 2017 @03:03AM (#14146028)
That the repl is in your editor, and you can hit ctrl-c ctrl-e to evaluate anything on the fly.
Re:Nim programming language by gigatexal on Tuesday April 18, 2017 @11:29PM (#14145247)
+1 to the usefulness of a REPL. Anyone know of a good one for the vanilla Java language?
Re:Nim programming language by moomin on Wednesday April 19, 2017 @02:31AM (#14145913)
I 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.
Re:Nim programming language by gigatexal on Wednesday April 19, 2017 @02:52AM (#14145991)
I 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.
Re:Nim programming language by moomin on Wednesday April 19, 2017 @03:29AM (#14146101)
Sorry, 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...

Re:Nim programming language by gigatexal on Wednesday April 19, 2017 @05:23AM (#14146507)
I guess I just need to read up on how to actually use maven the right way. Thanks.
Re:Nim programming language by moomin on Wednesday April 19, 2017 @10:59AM (#14148162)
I wouldn't use Maven, but there are multiple tools that can use Maven repositories that aren't Maven, and I'd recommend one of those. :)
Re:Nim programming language by gigatexal on Wednesday April 19, 2017 @11:47AM (#14148553)
I was only trying to learn it because a take home coding assignment for an interview asked to use maven for its build process. I found the whole experience (using maven) disheartening while I was able to code up the assignment using maven and my inexperience with it cost me going to the second round. I have only myself to blame though.
Re:Nim programming language by moomin on Wednesday April 19, 2017 @05:13PM (#14151829)
That sucks :(. But I can tell you there are plenty of organisations (e.g. Thoughtworks) where Maven is regarded as a bad tool that should be avoided. That doesn't help you much if it's part of a job you want, though. :(
Re:Nim programming language by quadrupleslap on Wednesday April 19, 2017 @05:01AM (#14146413)
If you don't mind something online, I hear repl.it is pretty good.
Re:Nim programming language by Solarsail on Wednesday April 19, 2017 @08:07AM (#14147114)
Well, I've used an unmaintained almost-vanilla-Java REPL: https://github.com/jacktasia/java-repl
Re:Nim programming language by kazagistar on Wednesday April 19, 2017 @02:49AM (#14145983)
There is an official one coming out in Java 9 soon.
Re:Nim programming language by gigatexal on Wednesday April 19, 2017 @02:52AM (#14145993)
Looking forward to it!