HNHacker News
TopNewBestAskShowJobs

narimiran

807 karma · joined May 6, 2017

https://narimiran.github.io/about/
submissionscomments
narimiran··on Nim 0.19
It depends on your background.

If you would like to go from the very beginning (no or minimal programming experience): https://narimiran.github.io/nim-basics/ (disclamer: I'm the author of that tutorial)

If you are more experienced, and you want to explore all the possibilities that Nim provides, check the language manual: https://nim-lang.org/docs/manual.html

If you need any help with getting started, join Nim channel on IRC/Gitter and ask the questions. The community is very friendly and helpful! (It is one of the main reasons I kept using Nim in my Nim beginnings)

narimiran··on Nim 0.19
> So excited for this addition!

I've been using it for a while in the devel version (Nim v0.18.1), and it is great — I like it very much and I completely understand your excitement!

Before I didn't bother with {.noSideEffect.} pragma, and now with `func` here — my code is much more clear (at least to me ;)), and I can immediately tell which of my procs are 'pure'.

narimiran··on High Performance Computing: Are We Just Getting Wrong Answers Faster? (1998) [pdf]
>> a small change in parameters (for example, the initial conditions of a process) __can__ totally change the result. Say, for this reason a reliable long-term weather forecast is impossible and will remain impossible

(emphasis mine)

A small change in initial conditions can totally change the result in chaotic systems such as weather forecast, or a much simpler example — double pendulum.

There are systems where a small change changes the results only slightly. E.g. a single pendulum.

narimiran··on A Programming Language Underdog
I saved the data in .csv and then used that, because not only did I need/want to just plot the results, but I also wanted to explore and further analyse the data in a Jupyter Notebook.
narimiran··on A Programming Language Underdog
No, it isn't. `*` after a name means that the variable/function/type/etc. is public and can be seen/used when you import a module.

So the whole expression just means "a public constant string (automatically inferred type) named `hand`".

narimiran··on A Programming Language Underdog
A year ago I've started experimenting with Nim as a "faster Python" — put some declarations, change some keywords and you're ready to go — your "compiled Python" is now ~30x faster.

Recently I've used Nim for the first time for an official project at my job (at university). Instead of doing a simulation with Python+Numpy, I've decided to do it with Nim, and just plot the results with matplotlib. The whole experience was very pleasant.

Speaking of interoperability with Python, there is a great Nim library called Nimpy [0], which makes possible to use Nim as a more pleasant Cython — you can keep writing Python, and just use Nim for the intensive/slow stuff.

[0] https://github.com/yglukhov/nimpy

narimiran··on So far #macOS Mojave ships with Python 2.7.10
> No major Linux distro besides arch ships with 3 as it's base either.

To add one more entry to sslalready's list:

Don't know if you consider Manjaro just an Arch derivative, or not-major (despite being the most popular distro on Distrowatch), but Manjaro also ships with Python3 (to be more exact - Python 3.7) as a base.

    $ /usr/bin/python
    Python 3.7.0 (default, Jul 15 2018, 10:44:58) 
    [GCC 8.1.1 20180531] on linux
    Type "help", "copyright", "credits" or "license" for more information.
    >>>
narimiran··on MacBook Pro with faster performance and new features for pros
> someone had their caplocks setup to be esc on click, or control on hold

I have this setup, and it is great. After you switch capslock to be Ctrl, just run (at startup):

    xcape -e 'Control_L=Escape'
narimiran··on Learning Programming with Nim
> I hope you'll find this inspirational if you decide to take a moment to rethink typography, typesetting and the overall design of the website and PDF.

Thanks for the feedback!

I would very much like to improve the looks of the website and PDF.

The current situation is this: I have zero experience with html/css, so I just took some css template and tweaked some values (lots of trial and error) until it looked okayish (There is probably some unneeded stuff in there too). And PDF is created by using the default style of asciidoc-pdf - I guess this can also be customized, but haven't looked into it yet.

Having said that, if somebody with more web-experience would like to improve my style.css [0], PRs are welcome.

[0] https://github.com/narimiran/nim-basics/blob/master/style.cs...

narimiran··on Learning Programming with Nim
> That is the clearest, most succinct explanation of variables, types and mutability I’ve ever read.

Thank you very much! It means a lot to see this kind of feedback.

> It’s difficult to break ‘obvious’ things down to those without background while staying concise.

After writing this tutorial, I can only nod and agree with this statement - it took me much more time than I originally thought it would.

narimiran··on Learning Programming with Nim
> this is a very well written tutorial. Might be a nice format to use in other basic language tutorials.

Author of the tutorial here. Thank you very much for your kind words!

> Significant whitespace and case- and underscore insensitivity. That's pushing too many of my buttons for one language.

Coming from Python, I had no problem with the significant whitespace. I like it more than curly braces everywhere.

Case- and underscore- insensitivity were something I initially really didn't like. What were they thinking? Are they out of their minds?

After using Nim for a year, I must say I didn't experience any problem with it so far. All the code I have written, all the code from others I have read uses camelCase (which is a recommended, but not enforced, case). So basically, even though people have an option to use snake_case (or any other), the large majority of users use only the one style.

narimiran··on Learning Programming with Nim
Author of the tutorial here.

I didn't expect that somebody else might post a link to it - it seems I might be too late for the party.

If anybody has any questions regarding Nim or suggestions how to make the tutorial better - let me know.

narimiran··on Python vs. NumPy vs. Nim
> How does Nim compare with Haskell, including its maturity and community?

Nim is not as mature nor battle-tested as Haskell. Haskell has more users and it is more widely spread, so it would be a safe(r) bet.

I'm also coming from Python, and I have tried several languages (including Haskell) until I kinda settled with Nim.

I really like the similarities in the syntax between Nim and Python, which allows me to easily transfer my "Python thinking" into Nim code. There is also a possibility to only translate some slow/CPU-intensive parts of Python code to Nim, and then call it from Python (FFI).

Regarding community - the Nim community (IRC/Gitter) has been very welcoming to me and to my beginner/dumb questions - I guess this is the advantage of a small community - there's a sense of a connection and people want to help each other.

narimiran··on Python vs. NumPy vs. Nim
> What about Numba?

I'll copy-paste my Reddit comment:

Like pypy, numba was also on my radar, but I couldn't make it work by just slapping `@jit` decorator to the original code, and I didn't want to go into figuring out what's wrong nor making modifications to the original code.

>> I suspect it should be on par with Nim.

Somebody else [0] has run a comparison including Numba, where Numba is 1.5x faster than NumPy.

This means, if we can compare tests on the different machines, that Nim should be about 2x faster than Numba.

[0] https://github.com/henryiii/framework_compare/tree/master/li...

----

> What about Cython?

I haven't tried it. It would be interesting to see the results.

narimiran··on Python vs. NumPy vs. Nim
Author here.

If you have any questions and/or comments about Nim, I'm ready to answer.

narimiran··on Show HN: Arraymancer v0.4, Nim tensor library now with OpenCL and Keras-like API
Speed in benchmarks [0] looks impressive. But they seem to be run on the old version of Arraymancer (Arraymancer 0.2.90). Were there any speed improvements/regressions in the newer version(s)?

Is there any "production code" written in Arraymancer?

[0] https://github.com/mratsim/Arraymancer#speed

narimiran··on A Lengthy, Pedantic Review of Ubuntu 18.04 LTS (Bionic Beaver)
> Arch, though admittedly the installation process is much more elaborate than of Ubuntu

If you want easier-to-install-Arch and a bit more cautious/safer rolling release cycles, take a look at Manjaro.

narimiran··on VS Code can do that?
I'm a colemak user with no problems with shortcuts. Try putting in your settings:

    "keyboard.dispatch": "keyCode"
and see if it helps.
narimiran··on Widescreen laptops are dumb
> Tree-style or vertical tabs are perfect for this. But for some reason, all browser vendors follow each other, don't build alternative options (or count on the community to do it if they even allow that)

Vivaldi has in the options (without any 3rd party add-on) a possibility to put your tab bar either on top, left, right, or bottom.

narimiran··on Ask HN: What was your experience with alternate keyboard layouts such as dvorak?
Started using Colemak few months ago.

It was a very slow and frustrating start, but I gave myself one week to do deliberate practice every day for at least 15 minutes and then to see if I'll go back to qwerty.

I forced myself to use Colemak even when replying to instant messages, which raised couple of reactions when there was "X is typing..." for several minutes just to see a short reply :)

I also found a Colemak keyboard for my phone, so I had Colemak on all my devices. I found this to be really helpful.

----

That one week has passed, my speed and accuracy got better. I started to appreciate the layout more and more.

Now I have the same speed I had with qwerty, and I like typing with less movement of my hands. Many typical shortcuts stayed in the same place (not Vim's HJKL, unfortunately), which is a plus.

Cons of using Colemak? Now I can't type on other people's qwertys ;)

narimiran··on Make Medium Readable Again
It is quite easy to increase the percentage of the window filled by text - resize your window to take smaller part of your screen ;)
narimiran··on Professionals need our 4:3 screens
> *2560x2048 would be awesome (...) Two of those side by side would be perfect.

You have just turned two 5:4 monitors into a 10:4 monitor - and the closest format to that exists in a form of current 21:9 monitors, with acceptable prices.

narimiran··on Rust 1.24
> Can someone sell me on using rust over python?

I can't. But I can try to sell you Nim [0] as a compiled/faster addition to your Python, from my own experience of using it in last few months and coming from Python.

It uses significant whitespace and the syntax will surely look familiar to any Pythonista, and the entry barrier is much lower (i.e. learning curve is much shallower) than Rust.

Speed improvements I experienced are in the range of 10-100x, while the code doesn't look that much different than Python. I have solved Advent of Code in both Nim and Python in parallel [1] so you can compare the solutions/syntax yourself.

[0] https://nim-lang.org/

[1] https://github.com/narimiran/AdventOfCode2017

narimiran··on Atom 1.24
> Maybe there is some way to run vscode in a VM that is 100% blocked from the internet and that would prevent it from sending tons of data?

Wouldn't these user settings be enough?

    "telemetry.enableCrashReporter": false,
    "telemetry.enableTelemetry": false,
narimiran··on Python’s Weak Performance Matters
> In Matplotlib I still don't understand what is the right way of initializing a pyplot, there seems to be a million ways to do it and a million parameters you can give. API changes and inconsistencies too pain me at times

Matplotlib has the worst API of all Python libraries I have used over the years!

If there were a fork of it that got rid of Matlab-way of doing things (keeping only OOP style) and with consistent names (no more `twowords` and `two_words`), I would gladly switch in a heartbeat.

narimiran··on Python’s Weak Performance Matters
> Or just program a module in C

You can do that in Nim - it compiles to C.

If you have no previous knowledge of C, with Nim you get C-like speed with Python-like easy to write syntax.

narimiran··on Python’s Weak Performance Matters
> Why Nim rather than e.g. Haskell?

Because Nim syntax will be familiar to Python developer. Sometimes all you need to change is add variable declarations and rename `def` to `proc`.

Haskell has a much steeper learning curve. Been there, struggled with that. If I would recommend a functional language to Python developer, I would go with F#.

narimiran··on Python’s Weak Performance Matters
If you would like 10-100x faster performance than Python, but would like to keep the easy-to-read code, give Nim [0] a try.

I do all my work in Python, and I've been using Nim in last couple of months - it took me a week or two until I was able to be productive in Nim.

Don't expect Python's large ecosystem, nor some Python goodies, but if you're looking for a readable, writable, high-performance post-Python language - Nim is the way to go!

[0] https://nim-lang.org/

narimiran··on Why is Rust difficult?
> After years of using Python, it's been difficult to wrap my head around GO and Rust.

I had the similar post-Python problem, until I settled on Nim [0] - it has Python-like syntax, significant whitespace, and ease of writing (but don't expect Python level of it), while compiling to C and providing significant speed benefits.

Also there is a brief "Nim for Python Programmers" [1], which might interest you.

[0] https://nim-lang.org/

[1] https://github.com/nim-lang/Nim/wiki/Nim-for-Python-Programm...

narimiran··on Why is Rust difficult?
> I have done pascal before and I wish to have ADA more easily available

Then you might be interested in https://nim-lang.org/ as a Pascal-like Rust alternative.

← PreviousPage 3 of 5Next →