1. 1

    I’m excited about Nim. I spent some time last week playing around and really liked what I see.

    But somehow I found the import mechanism a bit confusing. I didn’t quite understand that importing a module makes all its members available in the current scope, but they’re also dot-accessible using the module name. And also, since func(a) and a.func() are equivalent (correct me if I’m wrong), there are like 3 ways to call a function defined in another module.

    For instance, in the strutils example, if I start reading this code with no other context, I would assume that split() is defined for string types. But it’s actually a part of strutils module. And s.split(), strutils.split(s), and split(s) are all doing the same thing.

    I guess you start picking these things up the more you work with a language. But I have a Python background, so code being very explicit is something I’m used to and have really come to appreciate.

    1. 1

      Yeah, I hear you. Nim is a little different in this regard, but we do get a lot of the same sentiment. If you’re interested do give us your thoughts in this RFC on GitHub: https://github.com/nim-lang/Nim/issues/8013

      1. 1

        Done!

    1. 1

      This is very cool! Congrats on shipping.

      Using control-click to open in a new tab is broken for some reason, fixing that would be great!

      1. 1

        Thank you, and thank you for taking a look :)

        Odd that the control-click issue is still present. I thought I fixed it for both Ctrl and Cmd (for Macs), unfortunately I only have a Mac with me so I can’t verify the Ctrl issue. I’m checking for ctrlKey, I wonder if it isn’t true for some reason.

        1. 1

          I’m on Firefox on Windows, hm. Maybe I’ll see if I can fix the bug.

          1. 1

            So, I went to look at this today and it works perfectly now. I don’t know if anything changed, but it seems to work just fine.

            1. 1

              Wow, you have a good memory :)

              We did fix some IE bugs, likely was the same issue.

        1. 3

          I love the minimal dependencies and easy database. Should make it much easier for hobbyist operators.

          The advantage of Discourse is the business model. They will be in business and supporting their system 5 years from now. The odds are that this project will not.

          1. 2

            Thank you! Glad you love it :)

            Indeed, that is Discourse’s advantage. All I can say is that this project has already been around for more than 5 years, albeit in a much different form, so it is likely to stick around for another 5. Perhaps I should look into copying their business model, I do find it sorta insane that they are charging $100/month minimum for hosted instances of Discourse, but I suppose that is how they make money to support their project.

            1. 3

              You are thinking like a developer, not a pricing expert. There are plenty of cases where $100/mo is quite cheap. As a business, you want to get customers with lots of budget and little actual traffic demand. Customers are thinking of it as a service they don’t need to staff and manage through IT. Think in terms of value you provide, not your costs to provide that value, when pricing.

              Feel free to join my happy hour some week if you want to talk about building a business on your open source:

              https://sidekiq.org/support.html

              1. 1

                Just saw your reply. Makes a lot of sense! I’ll definitely check out your happy hour, thanks :)

          1. 5

            i didn’t see anything with noscript turned on, which unfortunately disqualifies the project from use.

            some lightweight discourse alternatives which don’t require javascript are fluxbb, and mailing lists.

            to not leave anything out, i should also say that nim-forum is using a fairly loose definition of “lightweight.” maybe compared to discourse it is. but fluxbb 1.2.24 is written in under 9000 lines of PHP, with the only other dependency being some database. nim has a longer list of dependencies, and the dependencies themselves are quite heavy.

            1. 2

              I’m genuinely curious why this disqualifies the project. Is it just a point of principle? Is it that you do not deem it safe to execute JS on websites?

              I don’t consider fluxbb and mailing lists to be alternatives to be honest. The former is a classic forum and the latter is, well, a mailing list.

              I just checked and the current codebase is 5300 lines of code. Which dependencies are heavy?

              1. 4

                One example of why SPAs cannot be used: if anything goes wrong, the whole site just breaks. On my phone (Blackberry Q10) https://forum.nim-lang.org/ just loads a blank white page and nothing more.

                1. 1

                  That’s a good point. In the future it might be possible to pre-render the HTML on the server-side (it should be especially easy as the frontend is written in Nim too) and gracefully downgrade the experience (full page reloads on all links). I think for right now though, the current forum handles 90% of the use cases well, do remember that this is the initial version.

                  Btw I would appreciate any more information about the Q10 failure, is JS simply disabled there? or is it not handling the forum’s JS properly? If you could open an issue on GitHub that would be brilliant.

                  1. 2

                    I assume it’s not handling the forum’s JS properly. If I get some time I’ll try to figure out how to hook up the web inspector, see what the error is, and open an issue :)

                    1. 1

                      Thank you!

                2. 3

                  ah, i was being an idiot w/r/t to the listed dependencies. none of those are all that heavy. sorry about that!

                  but there is one huge unlisted dependency: one of three major web engines. this is part of why i don’t support projects that don’t work without javascript. plenty of web forums are usable in dillo, netsurf, mothra, and lynx. people should not have to depend on the insane treadmill of ever-expanding web complexity for simple text-based communication.

                  the other part is that javascript can be used to track you. people cannot be expected to review all the javascript that their browser might run to ensure that it’s not doing something malicious, so they should be able to disable it and still function online.

                  why is a “classic” forum like fluxbb not considered an alternative to discourse/nimforum?

                  1. 2

                    Honestly, the only differences between classic forums and Discourse I’ve ever noticed are (1) the default Discourse theme is “modern looking” [meh] (2) Discourse integrates very well with email and is basically a fancy mailing list archive where you can choose to get only some threads or categories by email [very good]

                    1. 2

                      ah so you can post via email? that does seem useful.

              1. 1

                It’s not listed in the features and I can’t load the demo… does this support receiving all forum messages by email and replying by email? I consider those the killer features that set discourse apart from other forums

                1. 2

                  You should look at D language forum’s source for that. It is an NNTP / mailing list web frontend / forum software, news aggregator and IRC bot in one.

                  1. 1

                    Afraid not. That would indeed be a very nice feature.

                  1. 2

                    How much Nim should one know in order to be able to maintain an instance? I tried setting up a Discourse server and found it somewhat onerous - even knowing JS and Rails.

                    1. 1

                      There should be no knowledge necessary. If you want some advanced customisation of the produced HTML then you may need to dive into the code, but otherwise my aim is to just give you two executables, one for the backend and one for the initial set up.

                      My main priority so far was to get forum.nim-lang.org up and running. I also wanted to gauge interest to see if people would actually like to use this instead of Discourse. My objective in the long run is to provide release tarballs to spare the trouble of installing the whole Nim ecosystem. If there is interest I will certainly do that.

                    1. 2

                      How does one properly back up a SQLite based application like this? Regular DUMP to text files and then put it in S3 or somesuch?

                      1. 12

                        There are two options - a shared lock, or the online backup API

                        https://sqlite.org/backup.html describes both.

                        1. 4

                          Much better answer than mine. I’m going to downvote myself.

                          1. 1

                            Thanks for sharing this link. I have been using the “copy” method described by @akkartik for years with no issues, but I can understand why that is risky. I’ll have to look into implementing this in the NimForum.

                          2. 1

                            You can literally just copy the .sqlite3 file(s).

                            “A complete database is stored in a single cross-platform disk file. Great for use as an application file format.” (https://www.sqlite.org/features.html)

                            1. 1

                              How does that work? As in, how do you guarantee that the DB is in a consistent state when you do the copy? Or for a large DB how do you guarantee that the state won’t change DURING a copy?

                              1. 2

                                Oh yes you have to bring it down to ensure consistency. But that would also be true for the options you listed above.

                                1. 2

                                  I didn’t see any options listed by @feoh, but you probably already know this but I’ll say it for others: DBs like PostgreSQL, Cassandra, Riak, etc provides mechanisms to do backups without stopping your application. At an administrative cost, though.

                                  1. 1

                                    It’s a nonissue, lvm volumes can do live snapshots of ext4 filesystems, so can zfs and btrfs and others. Very easy to do live backups of sqlite with no downtime. Sqlite itself has no problem with snapshots as it is designed to be resilient to power failure, which is what that would look like.

                                    1. 1

                                      I was referring to “Regular DUMP to text files and then put it in S3 or somesuch?”

                            1. 5

                              Looks really cool, there are way too little alternatives to Discourse and I hope most developers/admins will agree - that mailman or hyperkitty never managed to become a decent web-application (with, or without JavaScript).

                              A link to forum.nim-lang.org in the git repo would be nice, though. :-)

                              The rst-syntax example page is interesting, as we’ve learned on 1st April on @lobsters, you want to scrape/mirror/resize/convert foreign image embeddings.

                              1. 5

                                Thanks for the feedback, I added a little link below the image to forum.nim-lang.org.

                                Indeed, this issue regarding foreign image embeddings didn’t even pop into my head. I shall make a note of it and hope nobody embeds a huge image in the meantime :)

                                1. 3

                                  Sure! :-)

                                  Ah, completely missed that the image is a link to the forum, but now it’s better - might become a longer list, once more projects are using NimForum :-).

                                  PS: Maybe one could get you a lobsters “nim-hat”.

                              1. 4

                                I’ve really enjoyed writing in Nim for this year’s Advent of Code puzzles. Its type inference support enables static typing, which I find comforting, with the clean syntax of a dynamic language like Python. In fact the syntax is largely similar to Python. Love that it compiles to C like a “real program”, and I’m interested to try out its JavaScript compilation backend.

                                1. 1

                                  Glad you’re enjoying the language :)

                                  Be sure to pop into #nim on Freenode (or Gitter or Discord) if you’ve got any questions.

                                1. 3

                                  Can anyone familiar with Nim comment on the quality of the contents? I like the “in Action” part as it shows real examples but would like to learn idiomatic language if possible.

                                  1. 4

                                    Author here. Unfortunately I cannot comment on the quality as I am biased. But the book does show many practical examples and thus teaches you the idiomatic way to do things. Hope that helps :)

                                    1. 4

                                      dom is being a bit modest below - in addition to being the author of the book, he’s also the second-most prolific contributor to the language itself and has written much of the core tooling besides. Which is to say—you can trust that you’re learning idiomatic language from him because he wrote the idiom.

                                      1. 2

                                        Excellent reply! That’s what I wanted to hear. Thank you.