155 points · by tomrod · 6y ago · 190 comments
I know it's chicken or the egg but I have real problems choosing these languages when they just aren't as battle hardened or package wise versatile as say python or ruby when making decisions for my own tech stacks in a startup or for other companies I have or will work for.
Arguably a really nice benefit of these languages is the inline error highlighting, which speeds up development. I've found for Nim and Crystal I have to run the compiler in the terminal, look where the errors were, and then find those lines in my editor.
LSP support is minimal ( especially when a language is starting out ). My ideal editor for Nim would be Pycharm-like ( open source edition ) with an LSP backend.
I pretty much do this with any language I use, including C++ or even Java and Kotlin. I just use vim for everything, it makes it easy to switch around between languages without dealing with a new IDE, and I haven't used any autocompletion in any language in probably 10 years -- that aspect is over-rated.
Vim, for example, has a plugin called "syntastic" that is kind of a meta-plugin aggregating lots of these, and indeed it seems to have support for nim error checking.
LSP is a nice step forward, but people had error highlighting for decades before it was invented.
[edit]
Doesn't change anything above, but someone pointed me at ALE which is a newer tool that can run lint engines asynchronously (using interfaces that didn't exist when syntastic was created). For vim specifically that may be a better tool, but I haven't tried it yet.
That's true, but being able to quickly click on the line that has the error and have your editor navigate to the file automatically is slightly more painful to setup, and is bespoke for whatever tool you are using.
My point was just that a tight integration between language and IDE/editor makes the overall language experience much nicer. For example:
Racket/Dr. Racket Python/Pycharm Java/Intellij Emacs lisp/Emacs
I was working on integrating a language with a "programmers editor" <name omitted to protect the guilty> and asked how to extend the editor to indent a new language. The response was "it should already support all C/Java like languages with the configuration format." My response "this isn't a C-like language". The community response "Uh, I guess write a plugin that installs a hook on the carraige-return key and manually position the cursor?" It blew my mind that anything billed as a programmer's editor couldn't be customized for doing this already...
The syntax compilers use to indicate filename and error location are similar among compilers, and generally quite unambiguous anyway, so in many cases no configuration is needed. A small list of regexes built in to the editor is enough.
Perhaps its because the product I work on is fairly mature at this point, but "speed" isn't something I really optimize my workflow for.
It's much more important that I solve the right problem than that I solve "a problem" quickly.
When the lifetime of the code you write is measured in years / decades, saving minutes seems much less relevant.
I found that tight language integration to the IDE/Editor makes jumping into new code bases in the language much easier. I've found refactoring also becomes easier.
So I guess I agree with you that for the very common programming task of "Thinking about the problem" tight language integration doesn't help much. But in order for me to gather data points about the problem, I usually have to jump in and explore the code base, which is where I feel the advantage comes from.
Definitely setup your editor to run the compiler for you, and give you a list of errors that are links to the locations they occur.
In Vim, for example, you can configure the makeprg and errorformat variables and the use the :make command to run the compiler, which populates the quickfix list with the errors. From the quickfix list you can jump directly to the locations. In Emacs there is the M-x compile command with very similar functionality.
Python seems like a very popular choice when the time comes to replace bash or perl scripting from the 90s. Oodles of internal tooling and OS tools in the Linux space use it.
Instead of this pondering and retroactive application of intuition in one's head onto history it would help to learn history. (Hint, what is GNU's name)
For me it makes compiled languages fun again. I like rust but package maintenance gets rough.
Things like this are what I'm enjoying discovering: https://robert-mcdermott.gitlab.io/posts/speeding-up-python-...
Crystal looks nice too, but I want code that compiles to C/C++, not llvm for embedded work.
Not sure about Crystal, but I’ve been able to find all the packages I needed for embedded and even some ML work. That Nim can wrap C/C++ libraries really helps there, otherwise it’d be a pain. For example I wanted to load PNG images, well someone wrapped a C library [1]. Or to create Elixir NIFs (with exception safety!) [2]. Generally if there’s a C/C++ package it only takes a few hours to wrap and use.
Nim has some annoying parts, like understanding the ref/var distinction and lack of examples. The documentation is fairly complete otherwise.
1: https://github.com/define-private-public/stb_image-Nim 2: https://github.com/wltsmrz/nimler
Python is the ultimate glue code scripting language, but you can't build a performant algorithm without an efficient C implementation underneath. With languages like Nim taking performance seriously, people could build a complete implementation of such algorithms from the ground up.
This doesn't just mean the core implementation would be easier to maintain. There's a huge gap between people who use the python libraries and people who build the efficient code that runs underneath. This clear division between those two worlds is what makes it difficult from people to jump from one side to the other, and that's why I'm calling this gatekeeping.
Not necessarily Nim, but using a performant, simple high level language for this sort of tasks would blur this divide. In practice, this means AI researchers in universities could dive into the code that's actually doing the work, not just play with the toy buttons and levers Google and Amazon left for them to play with.
1) Language is sponsored by tech giant or
2) It slowly evolve over period of 15-20 years, provided enough people see usefulness even in face of lacking features/libraries/tooling etc.
But then I got to the home page and saw “fund crystal and help make it production ready” and felt like it wasn’t a risk for something I needed to get out the door.
I did build a small toy project in Crystal and really enjoyed working with it.
I found it easy to get up to speed and do something useful with it. The language is also in my opinion very readable. The documentation could use some more (larger) examples though.
For this wrappers tool I needed a front-end for which I wanted to create an interface with argparse. Unfortunately the standard library lacks an implementation, and third-party packages did not deliver what I needed. In the end I wrote that part in Python still.
The biggest issue I currently find is the lack of a lock file format for its package manager. It's being developed, and as soon as its there I intend to implement support for it in Nixpkgs. https://github.com/nim-lang/nimble/issues/127.
The compiler gives very useful output and is fast as well, and the generated binaries are small. I like this language!
One thing I noticed right away that it seems to be lacking (judging from the `nimph.json` assuming that is the lock file) are checksums over the data or hashes of revisions the references correspond to. References such as tags are mutable, and thus hashes are needed to validate them. See e.g. the discussion over at https://github.com/NixOS/nix/pull/3216.
Reality doesn’t work like that, of course. Hype is important, and not just because that will mean more libraries. Hype motivates people to do things they wouldn’t have otherwise done at all. Rust demonstrates this well.
And good multithreading and network libraries.
Python has strong types. It's just that it checks them at runtime, not before.
If you don't use MyPy or similar, anyway.
Common Lisp allows for type inference and some compilers use that to various degree, as well as to declare a type of a given symbol (or the signature of a function). Depending on compiler and optimization settings, that information is then used to generate optimized code, much like a compiler for a (weakly) statically typed language would or detect mismatches. SBCL is probably one of the most advanced Common Lisp compilers in this regard.
class Testing123:
def __init__(self):
self.blah = whatever()I see a pattern of sorts for some new(ish) languages: without a prominent, well-known sponsor, the language might struggle to gain attention among developers. I wonder what will be the fate of other languages without generous sponsors as they head to their version 1.00 e.g. Crystal or Zig?
Julia is doing relatively well without a big main sponsor - interest seems to be growing in the language.
Rust and Go are two languages that have benefited hugely from support from Mozilla (Rust) and Google (Go).
But back to Nim. Who's using Nim? What are you using it for and how are you finding it?
I am using it for game and music programming: https://github.com/paranim
Only been using it since the beginning of the year and it is fantastic. Much less development friction than rust, and perf is very good, especially with ARC.
Also for linear algebra and machine learning they're a couple of good libraries:
1) Arraymancer https://github.com/mratsim/Arraymancer
2) Neo https://github.com/unicredit/neo
3) my own :) not meant for when performance is required. https://github.com/planetis-m/manu
https://www.youtube.com/playlist?list=PLxLdEZg8DRwTIEzUpfaIc...
If for some reason the nim compiler starts becoming slow, then this could also drastically speed up development
https://github.com/nim-lang/Nim/blob/cd28fe2ef7a204721efa720...
It's calling `quit` which cannot be caught in a try statement.
Also, Nim seems to be targeting a different niche from Python. As Nim is statically-typed and AOT-compiled, its closest competitor is probably Go. The difference is that Go deliberately tries to be a simple language, while Nim is much more complex.
However for me Nim appeared simpler when starting out. Not much get in your way when prototyping and scripting. Other languages require some mental overhead. I'm referring to Go's error handling, Java's mandatory exception handling, Rust's tracking lifetimes, etc. Thus it's much more pleasant to use than the rest.
I think that authors of Nim libraries get so tied up in their superiority over having types and being compiled that they forget that most devs don’t really care about these things on their own. It’s only when these things are combined with good documentation and tooling (see Rust for example) that they become useful.
So here's a simple project I wrote that's easier to understand. I work on this every couple of weeks on Saturdays.
https://github.com/sergiotapia/torrentinim
For example: parsing html https://github.com/sergiotapia/torrentinim/blob/master/src/c...
I wish the Nim team worked on an easier onboarding process to the language. The documentation is in depth but it just throws everything it has at you all at once with no progression.
This sums my experience as well. But nowadays there are more resources to learn Nim. The Nim in action book is a few years old but still holds. Nim basics is a free tutorial for beginners https://narimiran.github.io/nim-basics/ When did you start learning Nim?
I still went with Rust in the end, though. Nim’s documentation was rough going and I hit a lot of walls. The initial learning curve for Rust was way higher (borrow checker and all that) but once I got up to speed it was a great experience.
[1]: https://conf.nim-lang.org/
Hacker news coverage: https://news.ycombinator.com/item?id=23585006
Cython is a superset of Python that allows super easily compiling custom Python extension modules directly in C or C++, interoperates easily with Python packaging, and is very battle tested.
It allows you to “just write for loops in native Python” and get the statically typed & compiled optimizations you’d get in C or C++ for free. It also supports fused types for multiple dispatch of compiled functions.
I’ve used it in production workflows at many companies. It’s very easy to use.
The best part is that you can apply it gradually, only bothering to implement small sections of code as Cython extension modules when there’s real proof from a profiler that the code is a bottleneck for reasons addressable with static typing. You don’t have to live with the huge premature optimization baked in as a premise to languages that enforce this for all code. “Static typing when _you_ need it.”
> Numba translates Python functions to optimized machine code at runtime using the industry-standard LLVM compiler library.
Anything like coroutines, async-await etc? Or just OS threads?
What might those "pretty" "simpler tools" be? Perl? Heh.