6 ms·
I love the simple and clean syntax of Nim. The first time I was very impressed with vim was when I used a wikipedia xml dump parser. What would have literally t
by sharmi 9y ago
I love the simple and clean syntax of Nim. The first time I was very impressed with vim was when I used a wikipedia xml dump parser. What would have literally taken days to complete in Python (atleast on my machine, and god forbid if it had crashed somewhere in the middle) was done in a few mins by nim (again on the same machine). I was blown away!
The one thing that concerns me a bit is that identifiers are partial case-insensitive right?
(That means only the first letters are compared in a case sensitive manner. Other letters are compared case insensitively and underscores are ignored.)
Does it hinder when you need to do refactoring?
Also, I work in vim, and grep for stuff when I need. I am not sure if autosuggests and locating definitions/usage for variables would work. I am sure I must be wrong as I believe the core developers would have thought about it :)
I just would like to know how
- girvo 9y agoBecause Nim has an excellent 'compiler service', the symbols can be identified at the AST level instead of the textual level. In practice, most code bases stick to some conventions, and the possible ambiguity is rarely an issue, in my experience
- ddlsmurf 9y agoIdentifiers are "style-insensitive", so case changes and single underscore insertions don't actually change the identifier. There is exhaustive tooling such as nimgrep and ide support built into the compiler (such as find symbol at point equivalents) for helping when a convention is different. It is a strong philosophical position, but it does allow style consistency across a code base even when dealing with foreign symbols.
- ma2rten 9y agoWouldn't it have been better to just enforce one style over all nim code?
- d33 9y agoSeconded. Being able to insert an underscore and have the code still compile sounds like a strange design choice to me. dom96, could you write more on this?
- dom96 9y agoA lot of people have this reaction, but I am still yet to find a single person that gave Nim a proper try only to decide that it is not for them because of style insensitivity. It's definitely weird and I personally could take it or leave it. But don't let it dissuade you from trying the language. The idea behind this feature is to let you choose which style you want to write code in.
- twic 9y agoThis sounds like Python's significant whitespace: weird, off-putting for newcomers, but not actually a problem in practice.
- dom96 9y agoyeah! That's exactly how I think of it.
- coldtea 9y agoSignificant whitespace has some real benefits (enforcing proper indentation, no lines wasted for "}" or "end", etc) too. Case insensitive and _ ignoring identifiers not so much -- they just add mental burden, encourage different styles in the same codebase, make things ungreppable without special tools, etc. And for what? If the best one can say about a feature is "people still like the language despite it", it might be better to axe it.
- jboy 9y agoI write my Nim code in Vim. I've never had any problems with auto-suggests. My Vim config for Nim can be found here: https://github.com/jboy/dotfiles/tree/master/vim https://github.com/jboy/dotfiles/tree/master/vim (based upon https://github.com/zah/nim.vim https://github.com/zah/nim.vim , with a few improvements to my taste). In particular, Vim syntax highlighting for Nim: https://github.com/jboy/dotfiles/blob/master/vim/syntax/nim.vim https://github.com/jboy/dotfiles/blob/master/vim/syntax/nim.... and some convenient Vim mappings to jump around in Nim: https://github.com/jboy/dotfiles/tree/master/vim/ftplugin/nim.vim https://github.com/jboy/dotfiles/tree/master/vim/ftplugin/ni... I also use (and recommend) the CamelCaseMode Vim plugin with Python & Nim.
- nimmer 9y ago> Does it hinder when you need to do refactoring? It has almost never been an issue for me and I don't use any case-insensitive refactoring tool. Just write variables in a consistent style and let completion help you stay consistent.