6 ms·
Too bad nim uses a whitespace-sensitive syntax like python, something I personally dislike.
by runald 6y ago
Too bad nim uses a whitespace-sensitive syntax like python, something I personally dislike.
- echelon 6y agoYou're free to use Golang or another language. Nim has a great feature set and will be a good fit for Python or Ruby teams wanting a more performant language. At the same time, it's more expressive than Golang and will fill a niche Golang couldn't meet. I like that we now have Golang, Rust, Swift, Nim, and Kotlin. They're all doing new things and excelling at their own niches.
- gideon13 6y agoZig?
- pjmlp 6y agoBest of all, they also provided that required punch in the Java and .NET design room to force them to revisit not having a proper AOT toolchain available since version 1.0.
- runald 6y agoI already use golang for work, and now I'm just doing a little toy project in nim. What I like most about nim is that it has generics, and produces binaries with small size. I'm creating a graphical program with a http server running in the background, and mixing asynchttp with UI threads is a bit of a pain in the posterior. Granted, I'm new to the language, I'm considering using channels, maybe that will make it easier to share state between threads. At least compared to golang, nim hasn't been a smooth experience yet when it comes to threads. Anyways, I'm just voicing my personal gripe with the use of whitespace-sensitive syntax. Nim is a overall a good language to use.
- dom96 6y ago> I'm creating a graphical program with a http server running in the background, and mixing asynchttp with UI threads is a bit of a pain in the posterior. Granted, I'm new to the language, I'm considering using channels, maybe that will make it easier to share state between threads. Ideally you shouldn't need to use UI threads and instead integrate the async loop into the UI's event loop or vice versa. Happy to advise more if you can let me know which UI framework you are using :) This being said, I am hoping to implement better support for using `spawn` and channels with async, i.e. the ability to await the result of `spawn` or a channel. I think that will make a lot of use cases much easier.
- odiroot 6y agoThat's actually one of it biggest advantages over the competition. I wish more languages cared about readability.
- magicalhippo 6y agoReadability is exactly the reason why I prefer explicit start/end markers, and dislike the Python-like implicit style. So yeah, for me it makes the language less readable, that is, it makes it harder to parse the code as I read it. Your mileage may vary indeed...
- co_dh 6y agoreadability <> verbosity
- kindofajsdev 6y agoI think Ruby's do/end is most readable variant. Python using whitespace doesn't allow me to mess up and have my formatter autoformat it. Js and others with {} have way too many symbols flying around for easy parsing. Thats why I really like crystal! Do/end, low level, elegant. Wish the devs would focus more on wasm and other features that would put it more in the spotlight.
- dom96 6y agoI wish IDEs/text editors enabled code to be rendered and edited in different ways: braces, do/end, whitespace. That could very well be a good way to resolve these disagreements.
- magicalhippo 6y agoI agree that the lack of explicit start/end markers for code blocks is a very unfortunate choice. It was a bold choice by Python, but in my experience it turned out to be a poor choice, and not one to be copied. That being said, it looks like a very exciting language and like Python I think I'd manage to enjoy it overall despite of that choice.
- dxdm 6y ago> the lack of explicit start/end markers for code blocks is a very unfortunate choice. > It was a bold choice by Python, but in my experience it turned out to be a poor choice Could you explain why? I've heavily used languages with explicit block delimiters as well as Python, in collaborative environments, and the significant whitespace in Python does not really cause me any trouble. There is some slight overhead of making sure of the indentation when copy-pasting, but a decent text editor will make fixing things simple. As for the theoretical mixing of or trade-offs between tabs and spaces - that's just not a practical concern that exists in my experience. Of course that's a matter of taste, but the whole thing just seems like a minor detail to me - especially when we have the option of code autoformatting now. Am I missing something here that makes other people's experiences much worse?
- magicalhippo 6y agoJust to give a bit of context, I've been programming for almost 30 years, using many different languages. I've worked on many things, but of particular relevance I was part of a small team for several years which amongst other things had a 100kloc Python project that I did significant work on. I continue to use Python for all sorts of smaller projects, and for the most part enjoy it a lot. I've worked on large C++ code bases for years as well, and many of the usual suspects. To take the most subjective part first, for me, I just find implicit blocks much harder to parse than with explicit start/stop symbols/keywords. My eyes and brain just seem to have an easier time identifying the explicit blocks. It's like writing sentences without using a period to end them, but just three spaces say. Yes it's a bit more verbose, but I find it really helps readability for me. This of course might very well be the way my brain works, or the way my brain learned to work as a result of my first programming experiences, hence being subjective. A bit more objectively, in my experience it seems easier for myself and others to make mistakes at the end of implicit blocks, either having a line indented that shouldn't be or vice versa. It is my experience that with explicit blocks those faults tend to stick out like a sore thumb. I even have an add-on for my current IDE which, amongst other issues, complains loudly about that. If the language had had implicit blocks it couldn't really do that to the same degree. I also find explicit blocks is easier to use with tools, especially when diffing. When using a language with explicit blocks I can enable the ignore whitespace feature of the diff tool and if say an outer "if" was added, you get about two lines that changed. With implicit blocks all the lines of the block change, so you got to scan through them to make sure no "real" changes were made. I tended to spend a lot longer on non-trivial Python merges compared to say C++ due to this. I've also had the misfortune to have to edit Python code using only simple tools, without any Python-magic or similar. It's a royal pain if you have to copy/paste code around. But yeah, I accept it mostly boils down to preference. I mean clearly there are some more objective metrics, but how you weigh those will be subjective so, yeah...
- marcoms 6y agoThis might have been excused if they didn't also forbid tabs unless you use a hack (https://github.com/nim-lang/Nim/wiki/Whitespace-FAQ#tabs-vs-spaces https://github.com/nim-lang/Nim/wiki/Whitespace-FAQ#tabs-vs-...), was interested in learning until I found this out
- girvo 6y agoSo I used to totally agree with you... then I used Nim in anger. Honestly the whole white space thing barely even registered in the end for me!
- lostdog 6y agoI worked in Python for a while, and once you have a production bug because the indentation shifted around on one line when you moved some code around, you start to get really cautious and nervous every time you cut-and-paste. I much prefer C++ and Java now, where I can just paste and reformat without fear. (I still use Python, and I'm still going to try Nim some day. Syntactic whitespace is a pain, and, in my opinion, a bad design decision, but it isn't everything.)
- pjmlp 6y agoWell, then you can have a go at D (pun intended).
- sigzero 6y agoWhitespace is just something to get used to I think. It's a higher barrier for some people though, I agree.
- JNRowe 6y agoOne of my favourite things about working with Vala¹ was being able to use Genie² with the off-side rule syntax where it felt appropriate. Some chunks of code feel better to me when structured in certain ways. I often find myself wondering why other languages haven't implemented support for an alternative syntax. I suspect the answer is that simply no one cares enough to put the work in, but perhaps there is a better reason. ¹ https://en.m.wikipedia.org/wiki/Vala_programming_language https://en.m.wikipedia.org/wiki/Vala_programming_language ² https://en.m.wikipedia.org/wiki/Genie_(programming_language) https://en.m.wikipedia.org/wiki/Genie_(programming_language)
- cb321 6y agoThis comes up all the time, but in Nim you can almost always use parenthesis instead of whitespace [1] if you really love that redundancy/style. [1] https://forum.nim-lang.org/t/6897#43184 https://forum.nim-lang.org/t/6897#43184
- GordonS 6y agoYeah, but having 2 ways is a cop-out, IMO - if I'm writing code in a language, or reading someone else's for that matter, there is an expectation of it being idiomatic.
- cb321 6y agoIn this, and a great many other ways Nim provides a lot of syntactic choice. A pro to some. A con to others.
- m45t3r 6y agoI also have many thing I don't like in every language I use, but I still use them because they're still useful. If we're talking about syntax for example, for me it is Clojure > Python > Elixir >> Ruby, but I know lots of people that thing Ruby is the most beautiful language on earth. BTW, if we are talking about things that really goes on nerve for me it is the fact that Golang doesn't compile when there is unused imports in the module, so I can't simple comment a random line and try to compile it again. But I know people that like this because they editor are configured so the import is automatically removed. Ok I guess, but I still find this behavior annoying (I would much prefer that this was a compiler warning).
- cb321 6y agoIn Nim, a warning is exactly what happens for unused imports. I also think that is the right level of pestering.
- notdang 6y agoAlways wondering how blind people can use these whitespace-sensitive languages. Are there specialized screen readers?