5 ms·
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'v
by narimiran 9y ago
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/ https://nim-lang.org/
- platz 9y agoI mean, if you're willing to give up the ecosystem, there are tons of options out there.
- carlmr 9y agoExactly, the ecosystem is the only reason IMHO why Python is "easy". I find I'm much quicker at developing C#/F# if the library is available on NuGet (which is often, but not always the case). They're both reasonably fast, too. Python only has a very large community and thus ecosystem to offer.
- dTal 9y agoIt can't be the only reason, or how would it ever have attracted such an ecosystem in the first place? Especially with its performance characteristics, and lack of corporate backing. No, Python was invented at a time when its closest competitor was Perl - and you need only compare typical Perl with typical Python to appreciate that Python really was a usability revelation. But that was nearly 30 years ago. I do think we can do better now.
- vgy7ujm 9y agoIME Perl can be more readable if you are experienced in Perl.
- rthomas6 9y agoAnother reason is the documentation. It's fantastic.
- carlmr 9y agoFair point, I was importing the diapers module 30 years ago. But I think in today's world the advantage is mostly in the ecosystem. How the ecosystem came to be is another story.
- dorfsmay 9y ago• the language is easy, very attractive for non-CS people • the language is consistent (everything is an object, or a pointer to an object rather, you can only pass by pointer, scope and namespace that make sense all the time, etc...) • you can learn it gradually, you can start using it even if you know only 10% of the language • Amazing documentation. The official tutorial is easy to read, and by the time you are through with it you are fairly proficient with python • error message that tells you exactly what the error is and where it is happening. A lot of other languages do that now, but that wasn't the case 25 years ago. • inline help / magical docstring (`a=4 ; help(a)`) • The REPL, especially being able to get into the REPL with your apps (`python -i`) • batteries, again 25 years ago, no language came with such a huge standard library • PEP 8, the grandfather to gofmt and rustfmt. Makes a big difference when working on a team • the Zen (`import this`) And of course as the language grew in popularity: • the ecosystem (pypi.org) • the amount of resources, from books to website, the answer to every questions you can think of in SO, very active and helpful mailing list/usenet group, active and helpful /r/Python
- bzbarsky 9y agoScope and namespace that make sense all the time? for foo in bar: pass # Why is "foo" in scope here???
- NoahTheDuke 9y agoBecause Python doesn't have block scoping, only function scoping.
- bzbarsky 9y agoYes, my point is that function scoping can hardly be described as "makes sense all the time". Especially given that variable declarations in python are _very_ implicit, without even the "var" that will indicate to you that you're messing with your function scope in JavaScript.
- empthought 9y ago
- dahart 9y ago> It can't be the only reason ... that was nearly 30 years ago. I do think we can do better now. Maybe the ecosystem is the only reason left today. The reasons for initial adoption 25 years ago and the reasons for widespread usage today probably aren't the same reasons. Numpy, Anaconda & Jupyter notebooks didn't exist then, and now they're a huge reason for Python usage. I can't even think of a language that comes with a standard library that rivals Python's, let alone the ecosystem.
- alecco 9y agoOr just program a module in C or Cython.
- weberc2 9y agoWhich is error prone and often actually slower depending on calling patterns between C and Python. There are many languages today that offer better ergonomics than Python/C, and a few (like Go) which offer better ergonomics than Python by itself, all while besting it in performance by one or more orders of magnitude. I like Python; I just wish I could say the same for its developers...
- dragonwriter 9y ago> There are many languages today that offer better ergonomics than Python/C Including Cython. I mean, if you've got a C library, sure, interface it with Python; but unless you want something to be called from something else in addition to Python, dropping to C for performance needn't be the default choice in Python; that's the whole reason Cython exists. > and a few (like Go) which offer better ergonomics than Python by itself I find Go’s ergonomics to be worse than Python but better, mostly, than Java. > all while besting it in performance by one or more orders of magnitude. And, still, including Cython.
- weberc2 9y agoI would consider Cython if the particular bottlenecks were amenable to calling into a lower level language and if the alternative were porting a large application from Python to something else wholesale, but I would probably never start a new application in Python/Cython if there was any chance that performance would ever matter. The alternatives are simply too good. > I find Go’s ergonomics to be worse than Python but better, mostly, than Java. This is surprising. I'm a Python developer, and I still prototype new features in Go.
- narimiran 9y ago> 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.
- lmm 9y agoWhy Nim rather than e.g. Haskell (mentioned in the article) or OCaml, which are much more mature and have much bigger, more established tool/library ecosystems?
- cjalmeida 9y agoTheir syntax is weird for someone coming from C-like langs (Java, C, C++, C#)
- narimiran 9y ago> 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#.
- dragonwriter 9y ago> 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. Why not Cython, which gives speedups in those ranges, is more familiar to Python developers and fully integrated into the Python ecosystem?