Re: What prevents you from using Nim as your main programming language?
No, I haven't tried. I want to explain that I would better understand - I admit that this is a good module, but the presence of such features out of the box in the design of the language itself, with a guarantee from the compiler is not the same. I liked the article on that - [https://blog.juliobiason.net/thoughts/things-i-learnt-the-hard-way](https://blog.juliobiason.net/thoughts/things-i-learnt-the-hard-way)/
optional params before `untyped` body
Is there a way to have optional params before an untyped body in templates/macros? The last case gives an error, that's the one I want: template foo(a1 = 10, a2 = "", body: untyped) = discard # works foo(3, "asdf"): for a in 0..<3: echo a echo 10 foo(body = (echo 10)) # doesn't work: Error: type mismatch: got foo(): for a in 0..<3: echo a echo 10 Run The rule could be: allow optional typed parameters before an untyped statement list; it would be un-ambiguous. Workarounds are not great: * create a dummy type to group all optional params * create multiple overloads of the template
Re: Dynamic Tuple creation
assert (1, 2, 3) is tuple Run 樂?
Re: What prevents you from using Nim as your main programming language?
@cantanima @avandy Have you tried the [contracts](https://github.com/Udiknedormin/NimContracts) module?
Re: exporting API from submodules
The way I shown just avoids the import/export pair :p If you have more advanced needs (ie. import all module in a folder), then some macro magic can be used.
Re: What prevents you from using Nim as your main programming language?
Got to agree regarding the language comparisons. D takes the same approach wrt comparing itself against c++ and it just detracts from the newer languages in comparison.
Re: What prevents you from using Nim as your main programming language?
I am also a fan of Ada language. The only thing that limits my use of this language wherever possible is essentially having a single compiler from Adacore (gnat) and a GPL license. I have thoughts to start developing software for a specific platform (not x86). This immediately limits the choice of tools. C++ is sometimes the easiest, win-win option, the compiler of which is almost any platform. Nim in this case can be a very good choice with its C++ compatibility. This attracts me very much and that's why I follow the development of this language. The movement from GC is also important for me, because in my projects the determinism of execution is very important. I would like to have more opportunities to write correct and secure code out of the box, as in Ada and SPARK (contracts, formal proofs, opportunities for restriction of freedom and special imposing of restrictions on coding). The bias towards correctness in my opinion can give the language an advantage to consolidate in the industrial industry (probably after standardization), the rapidly growing direction of IoT and embedded systems.
Re: Getting OrderedTable key/value pair by insertion order
> So indeed iterating over the keys and stopping after first one makes sense, I > think there is no function to retrieve the first added element. And I think I > can remember someone asking how to get the n-th. added element, conclusion > was to use a loop similar as you do. Thanks, Stefan. I'd though I was just being silly and missing something obvious. Good to know this is a reasonable solution. > use > > > iterator pairs[A, B](t: OrderedTable[A, B]): (A, B) > > > Run > > and break-out after first (does "... in insertion order." kind of implies > FIFO?) element. Hi, lucian. That's what I did in the code sample I provided, but I used the `keys` iterator instead of `pairs`.
Re: What prevents you from using Nim as your main programming language?
Same, ecosystem, I needed to do WebRTC, and I couldn't affort to write the spec from ground up. Just a step to Go and you have a full implementation: [https://github.com/pion/webrtc](https://github.com/pion/webrtc)
Re: exporting API from submodules
Thanks both of you :-) Is there any advantages of using one over the other (for bigger project perhaps)?
Re: What prevents you from using Nim as your main programming language?
For me it's the same as for few others here. Stability of the ecosystem/lack of libraries. The language itself is pretty neat though.
Re: What prevents you from using Nim as your main programming language?
> it became clear that everyone had been quiet about some really serious > problems. I don't think people were "quiet" per say. It's just such a small community that it took time for the problems to become apparent. It took time for projects to become big enough or creative enough to start hitting the bugs and edge cases :-)
Re: What prevents you from using Nim as your main programming language?
@andrea I 100% agree with your first point. It is one of the main reasons I can't use Nim as my main language, but use it as my main hobby language. The community just needs to grow, in all senses. We need more projects, more libraries, more users, and more marketing. These are hard things, and trying to grow too fast can be very detrimental, so I respect the situation. This is your personal opinion of course, but I have to disagree with your other points about the new runtime, as I feel that they misrepresent Nim. First, you seem to be implying that the GC is going to be completely removed for 1.0. AFAIK, this is definitely **not the case**. The Newruntime and the GC are going co-exist for a long time. (Core maintainers correct me if I am wrong here.) You don't like the new lifetime annotations. This is personal preference, and I respect that. I personally have been burned by Rust and find this syntax easier to reason about than Rust (by a large margin), while still giving many of the same benefits. But that is just my opinion. > Finally, the new runtime doe not seem to be based on sound research on formal > type systems... I think if one wants to really follow such an approach, it > must be tried on paper and proved correct with an actual demonstration before > jumping to the implementation. I think is a completely unreasonable thing to say. By this reasoning, the only language you should use are languages that have been formally verified like Ada Spark, Idris, or APL. There are many counter examples to your argument: You talk about Beacon and Dingle like they are bad things. Rust took a very similar approach, and is highly successful. The Rust borrow checker was based on Cyclone, an _extremely_ dead academic language. Rust took that idea and improved it by fixing many edge cases. A project that took years. People still see Rust as a "safe language based on sound research". The Midori project at Microsoft is a "dead" project that produced important research on async systems, that inspired many mainstream async concepts. Haskell was implementing state of the art lazy evaluation and Garbage Collection algorithms based on research paper drafts (not final publications) back in the 80's. Haskell is explicitly a research language that incorporates unfinished research even today. This is something Haskell is very proud of, Yet Haskell is still very popular in some industries, and is considered a fundamentally safe language based on "sound research". The Nim GC, as well as the allocator under the GC, are based on research papers that were considered cutting edge when Araq implemented them. The Nim GC is not just some generic GC based on Java from the 90's. It is actually quite advanced. **After several years of real world use** of the GC algorithm, serious flaws were discovered in the GC with regards to multi-threaded programs. Instead of trying to "hack" the GC to fix the problem, Araq searched the latest peer reviewed research to find a better solution to the problem. This is an extremely principled approach! Academia is not some "magic place" that researchers go to commune with the computer science gods, and come down with the perfect answer to a problem. That is the worst case of "waterfall" software development. This is a known anti-pattern, that does not work well. >From what I have seen, out of the "new languages" craze of the last few years, >Nim is one of the most principled when it comes to making decisions based on >academic papers. Araq spends much of his time keeping up with the latest >research. Compared to many of these other "new languages" that base their >design decisions purely on hype, by committee, or by uneducated personal >hunches, I personally find this very comforting.
Re: Getting OrderedTable key/value pair by insertion order
Ok, yeah, we have no api for that.
Re: exporting API from submodules
Make a nim file of your choice (`testPackage/prelude.nim`), with the following content import testPackage / [submodule1, submodule2, submodule3] Run Then just `include testPackage/prelude` and all of your imports should be there. This approach is used by Karax.
Re: exporting API from submodules
`import testPackage/submodule1 export submodule1 import testPackage/submodule2 export submodule2 import testPackage/submodule3 export submodule3 ` Run
Re: Getting OrderedTable key/value pair by insertion order
use iterator pairs[A, B](t: OrderedTable[A, B]): (A, B) Run and break-out after first (does "... in insertion order." kind of implies FIFO?) element.
exporting API from submodules
I have divided my package into submodules and would like to export their API via the main module so all submodules can be imported by just importing it./src| ---|--- \--- testPackage.nim --- /testPackage --- submodule1.nim --- submodule2.nim --- submodule3.nim I have put a "*" in front of all I want to export in the submodules already, what should I now write in testPackage.nim? Many thanks in advance :-D
Re: Getting OrderedTable key/value pair by insertion order
I'm not trying to get sorted items, just the first item added (hence why I used an OrderedTable).
Re: Getting OrderedTable key/value pair by insertion order
>From your last code sample, I think I understand that you want to retrieve the >table entry, that was added first to table. So indeed iterating over the keys >and stopping after first one makes sense, I think there is no function to >retrieve the first added element. And I think I can remember someone asking >how to get the n-th. added element, conclusion was to use a loop similar as >you do.
Re: Circular module dependencies
There is nothing wrong with asking in two places. Please don't criticize people for doing, or at least not in the way that you're doing it. It would be nice if the author added a link to Reddit and vice versa, but otherwise there is no problem in asking in both places.
Re: Getting OrderedTable key/value pair by insertion order
I don't understand the question: An OrderedTable keeps the insertion order, it's not a "SortedTable" (which the stdlib still lacks)
Re: Circular module dependencies
> will circular module dependencies be something that will be added to Nim? Yes, eventually. I personally would like to have a `submodule` concept for this so that the cycle is restricted to a set of "submodules" but the last time I brought it up it didn't have many sympathizers...
Re: Simple P2P library
> Nim implementation of the spec. Oh nice @mratsim. Where is the work happening?
Re: Sequence of typeclass
Typeclasses in Nim is only used for generics, meaning that they're a compile-time constraint, not a runtime one. You'd need an object variant for this case.
Re: Circular module dependencies
The usual way currently is to use a common "datatypes" file. See also the current discussion to improve the status quo: [https://forum.nim-lang.org/t/4745](https://forum.nim-lang.org/t/4745)
Re: What prevents you from using Nim as your main programming language?
I'm using it as my main language but there are several reason why I don't push it in my data science communities: * I'd like a jupyter kernel/REPL for quick experimentation (arguably this is possible now with hot-code reloading). * Vtable (or working generic methods) would be very useful * ecosystem is too small, especially for data visualizating and transformation: * data and serialization formats like protobuf, yaml or even jpeg would benefit a lot from an unified API * image loading and saving * sound files loading and saving * data visualization
Re: What prevents you from using Nim as your main programming language?
I have used Nim for many small experiments, but the main reason why I am not using Nim as my main programming language is that it is not popular enough. I know this is circular, but where I work I am the Nim person. If anything should go wrong on a project where Nim fails to deliver on some points, the burden of having chose that lies on me. If a project goes well, I am bound to maintain it indefinitely because I am the local Nim expert. All this means that using Nim in anger is too risky for me now, although I like to use it for experiments of many kinds. Other than that, I am worried about the new runtime. Starting to plan the move to a new runtime just before 1.0 is... well, not a good sign. I also don't especially like that this new runtime requires a complex set of lifetime annotations (sink, move, owned...), which makes code less understandable, while before that Nim could be considered a benchmark of readability. Finally, the new runtime doe not seem to be based on sound research on formal type systems (there's just Bacon and Dingle, but it seems an abandoned approach) and new special cases that evade the analyses done so far keep popping out. I think if one wants to really follow such an approach, it must be tried on paper and **proved correct** with an actual demonstration before jumping to the implementation.