News for hackers. Stuff that matters.
Re:Nim – Python-like statically-typed compiled language by Grimm1 on Sunday August 16, 2020 @12:04PM (#24178858)
I'm stuck in this cycle with langs like this. I want to use Nim I want to use Crystal they to me represent real tangible improvements over the languages they were based on but run into the issue of ecosystem and adoption every-time.

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.

Re:Nim – Python-like statically-typed compiled language by Naac on Sunday August 16, 2020 @12:29PM (#24179086)
Another problem I've found for me with Nim and Crystal is the lack of editor support compared to other statically typed languages like Java and C++.

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.

Re:Nim – Python-like statically-typed compiled language by hellofunk on Sunday August 16, 2020 @12:50PM (#24179250)
> 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.

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.

Re:Nim – Python-like statically-typed compiled language by omaranto on Sunday August 16, 2020 @06:23PM (#24181882)
In Vim I don't recommend running the compiler in the terminal, instead set makeprg and errorformat appropriately, and use the :make command and the quickfix list.
Re:Nim – Python-like statically-typed compiled language by Ancapistani on Monday August 17, 2020 @10:11AM (#24187375)
I’d appreciate a link describing this more fully if you have one handy.
Re:Nim – Python-like statically-typed compiled language by omaranto on Monday August 17, 2020 @03:53PM (#24191233)
Usually with Vim the manual is better written and more accurate than any external source of information, so I recommed using the command ":help quickfix". It explains usage of the quickfix list, the :make and :grep commands and how to configure the errorformat and makeprg variables.
Re:Nim – Python-like statically-typed compiled language by elcritch on Sunday August 16, 2020 @12:50PM (#24179247)
True, though the VSCode Nim plugin "just worked" for me. The compile messages work too, I think using the Nim LSP [1].

1: https://github.com/PMunch/nimlsp

Re:Nim – Python-like statically-typed compiled language by aidenn0 on Sunday August 16, 2020 @12:51PM (#24179252)
If the compiler is fast enough, you don't need LSP support; many editors can be configured to run any sort of compiler or linter for doing error checking, and can be configured to do so when saving or as you edit &c.

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.

Re:Nim – Python-like statically-typed compiled language by Naac on Sunday August 16, 2020 @02:10PM (#24179853)
>> and can be configured to do so when saving or as you edit

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

Re:Nim – Python-like statically-typed compiled language by aidenn0 on Sunday August 16, 2020 @09:43PM (#24183029)
>> 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.

In the event that the tool doesn't output in one of the common formats, it's usually just a regex; again I had this in Vim for several different languages back in the 90s.

>> My point was just that a tight integration between language and IDE/editor makes the overall language experience much nicer.

I agree (happy SLIME user here), but it often seems like I'm in the minority. I've literally never met someone in person besides me that uses pycharm, and you are about the 3rd person online I've seen mention it in a favorable light.

Re:Nim – Python-like statically-typed compiled language by fwip on Sunday August 16, 2020 @01:05PM (#24179352)
ALE is quite nice. LSP is nicer-still, but ALE is a good step up in usability from syntastic.
Re:Nim – Python-like statically-typed compiled language by llimllib on Sunday August 16, 2020 @01:23PM (#24179483)
ALE will use LSP servers when they are available
Re:Nim – Python-like statically-typed compiled language by qppo on Sunday August 16, 2020 @02:10PM (#24179854)
The LSP enables a lot more than diagnostic reporting
Re:Nim – Python-like statically-typed compiled language by aidenn0 on Sunday August 16, 2020 @09:44PM (#24183040)
It sure does, but GP specifically mentioned diagnostic reporting as something missing when using the "new hot" languages
Re:Nim – Python-like statically-typed compiled language by seventh-chord on Sunday August 16, 2020 @12:51PM (#24179258)
I don't get why more editors don't support parsing compiler output to get the file name and line for errors. Its dead simple, no need to run a server, just allow running the compiler from within the editor and have some way of configuring the parsing so it can work with different compilers. Gets you 90% of the value for 10% of the work (because you don't need to do anything to the compiler).
Re:Nim – Python-like statically-typed compiled language by aidenn0 on Sunday August 16, 2020 @09:48PM (#24183081)
Indeed. Emacs and Vim have both supported this for a long time. I used it in vim in the late '90s and Emacs usually got features like this before vim.

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...

Re:Nim – Python-like statically-typed compiled language by jlokier on Sunday August 16, 2020 @07:42PM (#24182367)
You don't even need to configure it in many cases. I've been doing it with numerous languages in Emacs, and I think I had to configure it (with a regex) maybe once for a compiler whose output it didn't already recognise.

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.

Re:Nim – Python-like statically-typed compiled language by zelly on Sunday August 16, 2020 @01:33PM (#24179573)
Emacs has been able to do this for a very very long time
Re:Nim – Python-like statically-typed compiled language by seventh-chord on Sunday August 16, 2020 @03:18PM (#24180398)
"Turing-complete text editor can do anything" :)

To be fair, I dont actually know what percentage of editors have that feature, my impression is just that many people arent aware of the idea. Maybe Im wrong though.

Re:Nim – Python-like statically-typed compiled language by war1025 on Sunday August 16, 2020 @01:23PM (#24179490)
> which speeds up development.

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.

Re:Nim – Python-like statically-typed compiled language by Naac on Sunday August 16, 2020 @02:13PM (#24179886)
I should clarify that when I wrote "speed", in my mind I was thinking of code navigation.

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.

Re:Nim – Python-like statically-typed compiled language by omaranto on Sunday August 16, 2020 @06:22PM (#24181866)
> 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.

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.

Re:Nim – Python-like statically-typed compiled language by zelly on Sunday August 16, 2020 @01:32PM (#24179562)
In the case of languages the chicken and the egg problem has been solved. Looking at every major PL with widespread adoption, the common theme is that was chosen by a big company (the chicken) as a natively-supported language for their platform. See: Obj-C and Swift with Apple, C# and C++ with Microsoft, Java with Sun, C with GNU, JS with Netscape, etc. If you build an ecosystem, they will come. Languages that rely on a community to build an ecosystem just for the sake of using the language itself are very few and far between.
Re:Nim – Python-like statically-typed compiled language by formerly_proven on Sunday August 16, 2020 @01:49PM (#24179681)
C++ has also been the lingua franca of media and game development since the mid-to-late 90s.
Re:Nim – Python-like statically-typed compiled language by CoolGuySteve on Sunday August 16, 2020 @01:51PM (#24179703)
SGI's STL implementation and later EA STL were game changers for C++ imo, they really kicked off "modern C++" as we knew it.
Re:Nim – Python-like statically-typed compiled language by jlokier on Sunday August 16, 2020 @07:46PM (#24182384)
C++ was used in game development long before the STL was widely used or even reliably supported by compilers.

The object-oriented and high performance features of C++ make it a good match for games. Seems to me this makes Rust a fairly natural choice for high-performance games in future.

Re:Nim – Python-like statically-typed compiled language by zelly on Sunday August 16, 2020 @11:23PM (#24183555)
Rust by design tries to discourage you from using object-oriented patterns. Not saying you can't write games with it, but it'd look more similar to C than C++.
Re:Nim – Python-like statically-typed compiled language by jlokier on Monday August 17, 2020 @02:24PM (#24190158)
Interesting, I hadn't thought of Rust as discouraging object orientation particularly. But then, I think of the Linux kernel as object-oriented C in places.

If you look at Unity, although the games are written in C#, there is a heavy emphasis on mixins for giving functionality to game objects, rather than inheritance or interfaces.

Between mixins and the ECS pattern, I think Rust's trait-oriented style looks aligned with that trend.

Re:Nim – Python-like statically-typed compiled language by aserafini on Sunday August 16, 2020 @01:37PM (#24179600)
But interestingly that was not the case for Python which is definitely in the top 5 most popular languages today. I wonder how/why Python accomplished this without any corporate backer?
Re:Nim – Python-like statically-typed compiled language by formerly_proven on Sunday August 16, 2020 @01:50PM (#24179698)
Python always has had a few really strong killer apps. In the past stuff like Zope (GvR himself worked for a few years on this, and it's still around), and more recently things like Django, numpy, scipy, matplotlib, PyTorch or open scientific computing in general.

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.

Re:Nim – Python-like statically-typed compiled language by gtt on Monday August 17, 2020 @06:41AM (#24185906)
I don't understand why people needed or used Zope. Can someone explain?
Re:Nim – Python-like statically-typed compiled language by CoolGuySteve on Sunday August 16, 2020 @01:49PM (#24179680)
Python was one of only 3 languages allowed at Google (along with Java and C++) back in the 2000s.
Re:Nim – Python-like statically-typed compiled language by zelly on Sunday August 16, 2020 @02:02PM (#24179785)
That's one exception I had in mind. It was a no-name language before Google adopted it in the 2000s, but that was internal and couldn't have had effects except the downstream effects on general sentiment around Python. Python was just so nice of a language compared to its competitors that the community created an ecosystem. That's very hard to replicate. A lot of these new languages I'm seeing are just incremental improvements.
Re:Nim – Python-like statically-typed compiled language by pjmlp on Sunday August 16, 2020 @02:41PM (#24180088)
That is what people tend think, the corporate backers were all the Guido employers, and back in the old days (Python 1.6 and such), Zope was the big reason to use Python.
Re:Nim – Python-like statically-typed compiled language by dnautics on Sunday August 16, 2020 @01:39PM (#24179616)
Schools. There was ba major push to teach python in high schools and colleges.
Re:Nim – Python-like statically-typed compiled language by tyingq on Sunday August 16, 2020 @01:41PM (#24179630)
Python, TCL, PHP, Perl, Ruby, Lua, and more. So it happens, just not recently.
Re:Nim – Python-like statically-typed compiled language by pjmlp on Sunday August 16, 2020 @02:47PM (#24180134)
Python, all the Guido employers, Zope was big during the early 2000's.

TCL designed at Sun, pushed on the Web early days with application servers like AOL Server and Revit (or something similar have forgotten the name).

Perl was introduced in UNIX since the early days and was the tool to use when sed and awk scripts got too complicated.

Ruby was made famous thanks to Rails, and gets very little use outside Rails.

Lua, used as scripting language in a couple of game engines, made famous via World of Warcraft.

Re:Nim – Python-like statically-typed compiled language by tyingq on Sunday August 16, 2020 @02:55PM (#24180200)
TCL was pretty well established before Ousterhout went to Sun.
Re:Nim – Python-like statically-typed compiled language by didibus on Sunday August 16, 2020 @01:47PM (#24179667)
You could argue it was chosen by Linux, since it was bundled in most distros.
Re:Nim – Python-like statically-typed compiled language by petra on Sunday August 16, 2020 @05:12PM (#24181365)
Was there any language that solved the chicken and egg problem using a nice ffi ?
Re:Nim – Python-like statically-typed compiled language by pas on Sunday August 16, 2020 @06:36PM (#24181959)
Go, Rust, Python, Ruby?
Re:Nim – Python-like statically-typed compiled language by dnautics on Sunday August 16, 2020 @01:38PM (#24179607)
Lisp, ruby, PHP (unless... WordPress? I'm pretty sure Facebook is "tail end" of php)...
Re:Nim – Python-like statically-typed compiled language by noobermin on Sunday August 16, 2020 @03:13PM (#24180357)
>C with GNU

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)

Re:Nim – Python-like statically-typed compiled language by tomrod on Sunday August 16, 2020 @12:11PM (#24178932)
I hear you.

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-...

Re:Nim – Python-like statically-typed compiled language by elcritch on Sunday August 16, 2020 @12:43PM (#24179197)
Second that, I find Nim fun to program. Not sure exactly why.. Perhaps, it‘a a bit of the feel of the old Python 2 days, but with better package management, less OO, and static binaries. Or it has more advanced abilities that solve annoying points with static languages like C++ via proper macros.

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

Re:Nim – Python-like statically-typed compiled language by triangleman on Sunday August 16, 2020 @01:02PM (#24179331)
Strange to see powershell core have such poor performance. Isn't it basically .NET in a scripting language? I've had great success grepping through gigs of log files with powershell, though I recognize that's apples to oranges.
Re:Nim – Python-like statically-typed compiled language by aldanor on Sunday August 16, 2020 @01:10PM (#24179390)
It's neat but (a) it's not a reproducive example as it mostly about the stack and not the computations, (b) you would probably just use Numba for any serious one-liner speeding up in Python (at least for scientific-like computations) and gain cffi, simd, vectorization, interoperatiblity with numpy, typed containers, etc.
Re:Nim – Python-like statically-typed compiled language by setzer22 on Sunday August 16, 2020 @02:39PM (#24180067)
The "python is performant because you call into C" argument implies that whenever any fundamentally new algorithm is developed you need to do it in C. This is actually gatekeeping things like machine learning to the few that can build and maintain the C code for libraries like TensorFlow.

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.

Re:Nim – Python-like statically-typed compiled language by aldanor on Sunday August 16, 2020 @02:58PM (#24180225)
?

Nim is compiled into C, IIRC, but it uses Nim syntax and rules and you don't call it "C". Same way, Python's Numba is compiled into LLVM IR at runtime, and you basically write Python, with a few limitations. You don't have to write or know any C/C++ to write high-performant numeric algos in numba (just clarifying) and there is no "C implementation underneath" as you're saying. It's also one of the easiest ways for "AI researchers in universities to do the work" because they and their friends probably already know Python but not Nim.

Re: ML libraries like lightgbm and many others - they are written in C++ so that there's a public C FFI which can then be wrapped in other languages, and not only in Python. This is probably the most flexible way to do things as opposed to limiting the whole thing to one niche/language.

// I'm not saying Nim is bad, Python is good, or any of that - I like alternative languages myself, but being an "AI researcher" and practitioner and spending most of my work time on developing numeric ML algorithms, I'd never look into Nim for doing any serious work, at least not now, partially because then I'd be the only person maintaining whatever I write alone and forever.

Re:Nim – Python-like statically-typed compiled language by setzer22 on Sunday August 16, 2020 @05:02PM (#24181274)
I stand corrected. I did not know numba and assumed it was similar to numpy and others, which do wrap C.

I still stand by my comment, though. We need to discuss technology by its own merits. Of course I'd also choose Python for an ML project any time of the day! But that's because Python won the popularity contest a long time ago. When discussing technology I think it's worth trying to see past that.

Exposing a C FFI may be flexible in the ways you mention (i.e. You can call the function from many languages). But I think we miss a lot on explorability. Let me elaborate a bit more with an example: Most people is not reallistically able to drill down on some implementation details when using neural network libraries like TensorFlow (which is not the whole field of AI, just an example!). At some point, if a feature is missing, you have to leave Python, learn a new language, and get a whole dev environment setup started. At that point, you're not using Python anymore, so I don't think it should count as a Python merit that you can do it.

That being said, I don't know Nim enough to validate whether using it for this would be a good idea.

Re:Nim – Python-like statically-typed compiled language by cb321 on Sunday August 16, 2020 @04:43PM (#24181132)
You can define an expose a C interface to Nim libraries, as you can with C++. See https://github.com/c-blake/lc/ and the extensions/lcNim.nim, for example. lc happens to load it from Nim, but the produced shared lib could also be dlopen()d from C.
Re:Nim – Python-like statically-typed compiled language by planetis on Sunday August 16, 2020 @03:33PM (#24180522)
With Arc's "deterministic" memory management interfacing Nim DLLs from other languages should be better, although never tried it.

One trick that works as a guarantee for me is writing Nim code in almost pseudo-language style, which in theory will be easier to port to other languages, it's very easy to do.

Re:Nim – Python-like statically-typed compiled language by dunefox on Sunday August 16, 2020 @01:06PM (#24179355)
Hm, Julia 1.4 takes 9.5 seconds on my machine (Intel i5 4460). Not bad at all.
Re:Nim – Python-like statically-typed compiled language by geodel on Sunday August 16, 2020 @01:24PM (#24179493)
Two ways to get infrastructure like libraries, editors, IDEs support and so on:

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.

Re:Nim – Python-like statically-typed compiled language by etxm on Sunday August 16, 2020 @12:38PM (#24179161)
Same. I was starting a new CLI project the other day and thought “ya know, I’ll try crystal instead of doing this in go.”

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.