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!
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!
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.
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).
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.
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.
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.
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...
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.
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. :(
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
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.
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.
Nim seems like a great language -- certainly people who use it seem to extoll its virtues -- but I see this getting submitted and making it to the front page essentially every month. Unless there's some news about Nim that's pertinent, perhaps we could give it a rest?
The reason that it was submitted this time is because of a new website that we just released. I hope you can agree that this is a valid reason for the submission.
This feels like one of the exceptions where you should be allowed to change the page title. Perhaps if you prefix the title with "Show HN: " it would be ok to not use the default title. Something like "Show HN: Nim revamped its website" might be worth a try.
I like that. I was originally with venantius where it should be something new. That was by looking at the title alone, though. Yours would be much better.
Uber gets submitted. Go. Erlang. Machine learning libraries. Stratups advice. A lot of things get submitted over and over. If people want to give it a rest they won't upvote and it won't show up on the front page. It's pretty simple. But there is interest so it shows up. Don't see it as a big deal, seems to work as designed.
I think GP's point might be that the Nim homepage gets submitted fairly often. For the other examples you mentioned, there's usually more variety in the content being submitted.
However, as noted in another comment, Nim has a new website up hence the post this time.
Whenever I see a new project my first question is always "why?".
From the FAQ:
Why yet another programming language?
Nim is one of the very few programmable statically typed languages, and one of the even fewer that produces native binaries that require no runtime or interpreter.
That's it? That doesn't answer the question at all. In fact, it makes it even less clear. All it says it that there are other programming languages that have similar features. Who cares?
> The GC is only triggered in a memory allocation operation. It is not triggered by some timer and does not run in a background thread.
I think this is what D does as well. This means you have to be mindful of what you're doing and if you want few pauses then you need to perform all your allocations ahead of time or disable it entirely in certain sections.
As someone who does a lot of Python programming, I really love the idea of Nim, and I've started learning it, I just need to find some more time to get back to learning it.
Given there's a pandas style + out-of-core support I'm interested in trying to use it for a lot of data extraction + cleaning + prep sort of tasks given how speedy it can be, being built on top of C...
Nim is a great little language - it is enjoyable to work in and small enough to learn easily. It's neat for little utility programs that are "too big for bash" and "too small for java/C". Sometimes I think of it as an alternative to python.
Like the new design, old site looked very dated, which unfortunately matters a lot when attracting mindshare.
Kudos to the team that rolled this out, nim looks much more modern and loved at first glance now.
I dig the changes in the landing pages, but I wished the documentation pages got the same treatment. At present, the documentation is not readable easily on mobile browsers.
Are you considering converting the documentation pages to responsive design too?
Also the black and yellow theme looks great on the home page, but that theme loses its continuity on all the other pages. It's as if the home page was designed by a different person, the feature and other landing pages by someone else, and the documentation pages by someone else altogether.
> Are you considering converting the documentation pages to responsive design too?
Unless someone volunteers to do this it likely won't happen any time soon.
As for the continuity. Not all pages can have the same "section" style, the documentation page for example is just composed of a list of links and descriptions. Of course, if you have ideas on how to improve the continuity then I'm all ears :)
> It works great on desktop as well as phone, and a common theme is seen all across the site.
I might be missing something but the website you linked has only two pages and I would consider them to lack continuity even more than the current Nim website. The layout for the "docs" page is completely different to the home page.
Oh I understand where you're coming from a bit more now. Everything under the `docs/` is sort of separate, it's part of Nim's doc gen generator and thus has a different style associated with it. But I can see why you think it loses continuity.
I've just submitted a tiny PR¹ that makes docs a bit mobile-friendlier. It turns out that the docs template already uses media queries to rebuild the layout for smaller screens, it's just that these queries are not triggered on mobile.
I've applied to Terminal.app now. Works like a charm. The only thing is that by cloning the git repo using "git clone https://github.com/dracula/terminal.app.git" it gets put into a folder called terminal.app, which is not readable when trying to import it from Terminal since it thinks it's an app. The solution is to move the Dracula.terminal file to another location before importing.
When trying out a new language, one of the first things I look for is a Getting Started/Quick Start guide that'll get me up and running with executing some code on my computer.
Is there something like that on the Nim website? There's a code example on the home page but after doing a `brew install nim` I don't actually know how to run it. In the Documentation section there are guides about the standard library and so on but I can't find a 'quick start' that'll get my hands just a little dirty without feeling overwhelmed with too much information.
One thing I have always hated about languages that tout easy C interop is the fact that you have to declare the C function first. A lot of C libraries e.g. Guile uses all sorts of Makefile hacks that makes it impossible, not to mention extremely time consuming to write a function declaration. Things would be so much easier if languages can implement something like Julia's ccall or a similar mechanism to allow direct calling of C libraries without any for of headers or wrapping.
Very nice dark main page, but the others have a different brighter (ouch!) theme, and the Examples one renders badly here (small netbook, Palemoon 27.2.1 on Debian amd64) due to high pitched fonts. Examples code blocks also do not use the same font size so I believe it's just a matter of fixing the theme. Other pages look nice despite the small screen size I'm using right now.
I can see some interesting applications once we can target WASM, libraries that are client/server agnostic with clients that can join in the cloud workload comes to mind.
i'd love to see something that compiles into two parts, one for the browser and one for the server from a single source and also maybe distributes trusted computations among the user base.
I am stuck working on a C++ code base using Qt. Could I in theory use Nim to accelerate my development, or would it produce incomprehensible or ugly C++ code?
Alternatively are there other alternatives to C++ for people who have to submit C++ code into the repository?
I use other languages than C++ on a regular basis and I find it annoying to tedious the language is. So much boilerplate and repetitions.
Some years ago I had the idea to create something similar to CoffeeScript for C++: https://bixense.com/coffeepp/
Never got through to finish it though :/
Looks pretty cool, I'd love to have something like that. Preferably something which you could tweak to output C++ code matching company code style guidelines.
I am not sure how incomprehensible it is, but I can say that the c2nim wrapper tool is pretty darn good. Andreas (author of Nim) quickly wrapped all of Urho3d in Nim almost fully automated. So IMHO Nim is a great companion to C++ libraries.
Perhaps I misunderstand, but you are speaking of going from C++ to Nim, while I have to be able to go from Nim to C++ as co-workers are not going to want to look at Nim code. Nim would have to be a personal tool for me to write C++ faster.
96 comments
[ 1123 ms ] story [ 2598 ms ] threadNim 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!
[1]: http://www.lihaoyi.com/Ammonite/#Ammonite-REPL
[2]: https://github.com/lihaoyi
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
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!
Admittedly I'm still doing super basic stuff at the moment.
(Similar to http://play.rust-lang.org or https://play.go-lang.org).
https://github.com/theduke/nim-playground
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...
https://github.com/wheineman/nrpl
[1] https://hookrace.net/blog/what-makes-nim-practical/#use-as-a...
It's not the same thing but it spares a few key strokes...
And it generates the pom files so you don't have to...
In the Makefile itself I use entr: http://entrproject.org/
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...
However, as noted in another comment, Nim has a new website up hence the post this time.
From the FAQ:
That's it? That doesn't answer the question at all. In fact, it makes it even less clear. All it says it that there are other programming languages that have similar features. Who cares?In particular, why Nim over Go (or why Go over Nim)?
Is the Python's established presence and resource base (not trivial at all) the only reason one would prefer it over Nim?
And Go doesn't give you access to as many system libraries, for a second. There's cgo, of course, but that has its own can of worms.
I hear the type systems are fairly different as well, which is important to some.
Anyways I'm sorta being pedantic that it obviously has some sort of runtime. Maybe they meant to say not a runtime like a full VM ala Java?
I think this is what D does as well. This means you have to be mindful of what you're doing and if you want few pauses then you need to perform all your allocations ahead of time or disable it entirely in certain sections.
* https://github.com/qqtop/nimdataframe
And
* https://github.com/bluenote10/NimData
Are you considering converting the documentation pages to responsive design too?
Also the black and yellow theme looks great on the home page, but that theme loses its continuity on all the other pages. It's as if the home page was designed by a different person, the feature and other landing pages by someone else, and the documentation pages by someone else altogether.
Unless someone volunteers to do this it likely won't happen any time soon.
As for the continuity. Not all pages can have the same "section" style, the documentation page for example is just composed of a list of links and descriptions. Of course, if you have ideas on how to improve the continuity then I'm all ears :)
But they can have the same CSS styling (colors, fonts, responsiveness, etc) that ties the whole site together.
A good example that's at the top of my mind is this: https://hugodocs.info
It works great on desktop as well as phone, and a common theme is seen all across the site.
> the documentation page for example is just composed of a list of links and descriptions.
By the documentation page, I meant a page like this: https://nim-lang.org/docs/manual.html
That's a lot of good info but is not accessible in a good way on phone.
For sort of an equivalent reference, see https://hugodocs.info/templates/base/
It has a similar collection of help pages and the design is responsive too.
> But they can have the same CSS styling (colors, fonts, responsiveness, etc) that ties the whole site together.
> A good example that's at the top of my mind is this: https://hugodocs.info
> It works great on desktop as well as phone, and a common theme is seen all across the site.
I might be missing something but the website you linked has only two pages and I would consider them to lack continuity even more than the current Nim website. The layout for the "docs" page is completely different to the home page.
> By the documentation page, I meant a page like this: https://nim-lang.org/docs/manual.html
Oh I understand where you're coming from a bit more now. Everything under the `docs/` is sort of separate, it's part of Nim's doc gen generator and thus has a different style associated with it. But I can see why you think it loses continuity.
[1] https://github.com/nim-lang/Nim/pull/5737
[1]: https://draculatheme.com/
Is there something like that on the Nim website? There's a code example on the home page but after doing a `brew install nim` I don't actually know how to run it. In the Documentation section there are guides about the standard library and so on but I can't find a 'quick start' that'll get my hands just a little dirty without feeling overwhelmed with too much information.
[0]https://hookrace.net/
1 - https://github.com/nim-lang/website
1 - https://forum.nim-lang.org/t/2838
Alternatively are there other alternatives to C++ for people who have to submit C++ code into the repository?
I use other languages than C++ on a regular basis and I find it annoying to tedious the language is. So much boilerplate and repetitions.