I have asked the creation of a new repository to the organizers of The Algorithms. This is an educational project that aims to collect implementations of mainstream algorithms and data structures.
AnupKumarPanwar created a new repository for Nim just here.
If you are not familiar with the project, you can check the repositories for other languages: C, Python, Javascript and more on their Github organization page.
They have also started a repository with explanations of the algorithms.
If there are any people wanting to contribute, do not hesitate to open a PR. Keep in mind that implementations are all distributed under the MIT License.
I will set some guidelines for contributing in the days to come.
I expect that good Nim implementations adhere to zen of Nim and nep 1. In addition, I would like that implementation precise side effects through the exception system and use funcs as much as possible.
Also since Nim 2.0 is around the corner, it would be cool if you can test your implementation against either Nim #devel version or Nim #version-2-0 git branch before PR. I would be glad to review your implementations, if I manage to become a maintainer of the Nim repository. I guess anyone can become a maintainer, if they contribute enough.
If you want to contact the organizers, you can do so through the discord. Enjoy coding in Nim!
Great news @dlesnoff! I think this is a great way to showcase Nim and it could be a good opportunity for beginners to start practicing Nim.
As far as organization goes I say you already have work done here: https://github.com/dlesnoff/TheAlgorithms-Nim and I guess you will be transferring that to the new repo correct? Should we wait for you to do that before contributing to the official repo?
I will definitely contribute something!
Hello! I want to share the latest progress we made on this project. With the help of ZoomRmc, we wrote a contributing.md file describing what we expect for new algorithmic contributions. We got several nice workflows from Vil02 checking the contributions on the three OSes for the latest compiler version at each commit and once per month. It also runs nimpretty and tells us if we can prettify our code.
You can check our contributions on the website: https://the-algorithms.com/language/nim One latest contribution from Satin Wuker is available here: https://github.com/TheAlgorithms/Nim/blob/main/searches/linear_search.nim
I would be happy to get your opinion on the style, possible improvements or algorithms you would like to see implemented.
By the way, it should be possible to ask ChatGPT to convert algo in lang X to Nim
I could also write a script downloading and converting all the algorithms. I should do the same to write my PhD thesis and change my job to one that is manual.
More seriously, need I remind you where the added value of a developer's work lies? – The implementations proposed by A.I. are often errorful and influenced by mainstream bad practices. I do not know about ChatGPT4, but asking ChatGPT Web to find memory leaks in a C implementation is terrible. They lack computational science context. A.I. answers are limited in the number of characters and will cut any unfitting responses. – Our implementations add complexity analyses and links to similar algorithms. – ZoomRmc found bugs and reported them in the Nim's compiler GitHub repo. Can a bot do that reliably? – We provided GitHub actions to streamline the usage of tools like nimpretty. – A.I. queries need massive servers running and have thus a significantly more impactful carbon footprint than a handful of developers.
I might spend more time improving A.I. answers than writing them directly (with GitHub Copilot :p).
That's cool stuff. Nim versions do not appear in the main pages whereas there is a separated Algorithm only for Nim, I am missing something or what (even Zig versions are available sometimes)?
Why doing this whereas there is something very very similar (Rosetta code https://rosettacode.org/wiki/Rosetta_Code) ?
RosettaCode is a great project, but it's a wiki and it's hard to collaborate on it in a controlled fashion, unless you have a dedicated git repo where all the active collaborators gather their work. The tasks there are more nuanced and the whole project is more like a snippet library focused on comparing the implementations. Also, they had some major migration when stuff just didn't work for a while. They are still hosted at miraheze that was about to shut down and might not survive another year.
TheAlgorithms is more basic and lacking the specific restrictions imposed on each algorithm it's much less suitable for comparing implementations in different languages. This, on the other hand, permits each contributor group to focus on what they deem important. Personally, I treat the project as if the code is going to be merged into the standard library and nudge others into the same approach.
Regarding the main site, it is a bit slow to update, so it's better to track the repo than the Nim page there.
Why doing this whereas there is something very very similar (Rosetta code https://rosettacode.org/wiki/Rosetta_Code) ?
I am impressed by the number of implementations the community made there. Sadly, many algorithms I found there were not running and became obsolete. They do not specify under which Nim versions they were written. They may lack tests, sometimes copy other languages implementations without bringing in Nim's idiomatic features and are not peer-reviewed. Sometimes, the implementation is partial.
I found the API to query algorithms unreliable. I tried to list the tasks that were not implemented in Nim and did found tasks with a Nim implementation. Some pages need about 5 seconds to load.
To add a new algorithm, in RC we need to write a coding task with implementations in about 5 different languages while for the Algorithms, you can write any algorithm that you judge relevant and teaches something directly in the Nim repository.
Finally, the Algorithms have a more pedagogical approach. Ideally, I want to be able to learn computer graphics just by looking at the repository, with the help of comments along the code.
While we do not write Nim versions under each script, we wrote unit tests to ensure that our implementations are still correct for the latest Nim version (currently 1.6.12).
On the Algorithm's website, Nim implementations do not appear by default contrarily to Python. The website is an open-source project too which is going to improve over time.