Re: tests in the same files as the code

2020-07-13 Thread didlybom
At the topo of the unittest module documentation it says:

> Note: Instead of unittest.nim, please consider to use the testament tool 
> which offers process isolation for your tests. Also when isMainModule: 
> doAssert conditionHere is usually a much simpler solution for testing 
> purposes.

Does that mean that unittest is obsolete and should not be used? The docs do 
not provide a link to the testament module so the advice is not very actionable 
:-)


Re: Why does wrapping the code in a top level procedure make it faster?

2020-07-03 Thread didlybom
OK, it sense to focus on the higher impact optimizations. That being said, this 
is one of those things that are mentioned whenever somebody does a benchmark, 
so it might be good to optimize it at some point.


Re: Why does wrapping the code in a top level procedure make it faster?

2020-07-02 Thread didlybom
Sorry, I typed my previous message from my phone and did not notice the typo.

Couldn’t the compiler detect the case in which there is no main procedure yet 
none of the global variables is used in any procedures and optimize it?


Why does wrapping the code in a top level procedure make it faster?

2020-07-01 Thread didlybom
As the title of this thread says, I’ve seen many recommendations in this forum 
to wrap your code in a top level “main” procedure.

Why does that make it faster and why can’t the cinoaiker make that optimization 
automatically for you?


Re: Idea: Nim Online Conference

2020-06-21 Thread didlybom
I watched several of the talks and they were all great. I also saw a lot of 
discussion in hacker news which I think is also a very good sign.

Thanks a lot to all the presenters for taking the time to prepare these great 
talks!


Re: Is --gc:arc completely independent from the older ownership model?

2020-06-18 Thread didlybom
Thank you @Araq, that is pretty clear. This matched what I would expect from a 
“deterministic” memory management model. I don’t take that to mean I know 
_[exactly](https://forum.nim-lang.org/postActivity.xml#exactly) when me left is 
freed but that you can reason about it (as opposed to a garbage collector that 
can run more or less at any time).

What kinds of optimizations are currently done by arc? Would it be fair to say 
that the baseline is that everything (other than value types) is handled more 
or less like a shared_ptr by default but that the compiler is able to do some 
optimizations, which would be equivalent to using a unique_ptr in C++ where it 
makes sense or even not using any kind of reference counting at all (at 
runtime)? That is, is it possible for the compiler to completely eliminate the 
cost of reference counting during compilation, achieving the same performance 
that you could achieve if you managed your memory manually? I guess that is 
what it would mean to do “compile time reference counting”.

Also, how does orc change the picture?


Re: Visual Studio Code plugin

2020-06-18 Thread didlybom
Thanks Iscrd. I am not saying that the old plugin is abandoned but it certainly 
seems to be updated much more slowly than nim itself.


Visual Studio Code plugin

2020-06-18 Thread didlybom
I see that there are 2 Visual Studio Code extensions for nim. The one that has 
the most downloads by far is vscode-Nin 
([https://github.com/pragmagic/vscode-nim)](https://github.com/pragmagic/vscode-nim\)).
 That one is not updated very frequently. I don’t think it even claims to 
support nim 1.0, let alone 1.2. In its documentation it still references VSCode 
0.10!

There is another one called Nim-alt 
([https://marketplace.visualstudio.com/items?itemName=garym.nim-alt](https://marketplace.visualstudio.com/items?itemName=garym.nim-alt))
 which seems to be a fork of the first one (perhaps due to the lack of activity 
in the first one?). It has been updated more recently and claims to have fixed 
some problems with the original extension. Which one do you guys recommend?

I know that editors and IDEs are very personal choices for a lot of people. Yet 
I think that I order for nim to become a more mainstream language there should 
be at least one good quality, up to date extension for at least one of the 
major editors. From what I’ve read in this forum VSCode seems to be the most 
commonly recommended nim programming environment. The fact that the available 
VSCode extensions seem to lag significantly behind the language does not look 
great.


Re: Is --gc:arc completely independent from the older ownership model?

2020-06-18 Thread didlybom
I have not followed the arc story too closely but I have a few questions about 
it. In particular I’d like to understand how it compares to the C++ memory 
model.

I skimmed the Lobster memory model document referenced by @Araq. In it they 
talk about “in-line, by-value structs”. Is this model used by arc for local, 
“simple” variables? That is, with arc, are Integers, floats, etc stored in the 
stack like they are in C++? What about strings and seqs? Are those immediately 
destroyed when the procedure in which they are declared exits? What about 
objects in general?

In another part of the Lobster memory management document they say:

Lobster combines its original (runtime) reference counting with a lifetime 
analysis algorithm, to get “compile time reference counting”.

Is this applicable to arc? If so, when do we get the compile time reference 
counting and when do we get the runtime reference counting?

Would it be correct to assume that arc would be equivalent to wrapping all 
variables of “non simple” types with std::shared_ptr in C++? Or perhaps with 
std::uniqur_ptr or a mix of both?

How deterministic is the memory management with arc? What about orc? Is there a 
garbage collector still needed and running in either case? Is there any runtime 
overhead due to the reference counting compared to what would be achieved with 
C++’s manual memory management?

Sorry if these questions have very obvious answers. I really think that some 
documentation comparing the arc (and the future orc?) memory model to the C++ 
model would be very useful that come from that kind of language.


Re: Nim in business

2020-06-05 Thread didlybom
I’ve written some simple tools in nim for my company. Basically some little 
console programs that in the past I would have written in Python. Writing them 
was pretty much as easy a with python but the resulting programs were very fast.

I’d say nim’s standard library is pretty good. Definitely sufficient for the 
kind of simple command line tools that I’ve written so far. In fact I found 
some of the nim standard libraries better than Python (e.g. I found nim’s path 
handling even better than Puthin’s Pathlib, which IMHO is sting a lot). I only 
miss a good built-in command line parsing library, but there are some good 
alternatives that you can install with nimble.


Re: ggplotnim - pretty native plots for us

2020-04-27 Thread didlybom
Do you have instructions on how to properly package a program that uses this 
library? I managed to get ggplotnim working on my windows system, but it was 
harder than I’d like. I downloaded the gtk libraries and placed them on the 
executable folder but that did not work. In the end what worked was copying the 
dll of another gym based program (Inkscape) into the ggplotnim-based 
executable. It’s be nice if the library came with some tool that helped you 
collect the libraries it needs or if there was a way to create stand-alone 
executables.


Re: ggplotnim - pretty native plots for us

2020-03-25 Thread didlybom
Thank you for your detailed explanation of the current situation and how you 
got there. I hope you can find a way to improve the interoperability story of 
this promising library.

Regarding the performance of the library I’d say that to me the most important 
requirement is to be able to plot huge amounts of data. Ideally, hundreds of 
thousands, even millions of points should not be a problem and should not take 
more than a few seconds to plot (the less time the better of course :-) ). 
Being able to update the plot a few times per second (with a reasonably small 
dataset and simple plot) would be nice too (but not need to achieve tens of FPS 
or something like that IMHO).

As for the “complex signal” plot, I was referring to a plot with two separate 
subplots (place one above the other) where the Y axis zoom is independent but 
the X-axis zoom and pan are linked. The idea is that if I want to view the real 
component in the range of the 3000th to the 5000th sample I’ll also like to 
view the imaginary component in the same range.

Ideally I’d like to be able to simply pass a complex number data frame to the 
plotting functions and the library would just know what to do with it (i.e. the 
creation of the 2 subplots would be done implicitly and automatically).

I sometimes need to plot the real and imaginary components of a complex signal 
on same plot, so supporting that would also be nice but I don’t need it as 
often.


Re: ggplotnim - pretty native plots for us

2020-03-24 Thread didlybom
This is awesome! I have not really used nim for signal processing or data 
science work yet, but I think it would work very well with the right libraries, 
and this is one of the libraries that could make that happen.

Is this compatible with other libraries, such as arraymancer, etc? I think that 
one of the biggest strengths of the python numerical ecosystem is the good 
inter-operability of most plotting libraries with numpy. So if that is not 
already the case I would suggest making that your highest priority.

Other than that, I didn't see mention of support for contour plots in the docs. 
It is surprising how often those come in handy in many scenarios so I'd like 
for you to add that if it is not available yet. Another thing I like to do is 
to combine line plots with histograms and/or kernel density plots on the X and 
Y axis (to get a quick idea of the distribution of the values, particularly in 
time series). It would be neat to support for that too.

Finally, in signal processing work you are often working with complex samples. 
In that context it is often handy to plot the I and Q components vs time, 
placing 2 subplots on top of each other, and 
_[linking](https://forum.nim-lang.org/postActivity.xml#linking) the X (time) 
zoom/pan of the two subplots. It would be really nice if that were supported.


Nim mention in arstechnica

2020-03-20 Thread didlybom
Today I read an article about the Windows Linux Subsystem and I was surprised 
and happy to see that they mentioned nim. The used it as a quick way to make a 
“Hello world” program. Here is the article:

[https://arstechnica.com/information-technology/2020/03/the-windows-subsystem-for-linux-conference-was-a-virtual-success](https://arstechnica.com/information-technology/2020/03/the-windows-subsystem-for-linux-conference-was-a-virtual-success)/

I think this is another indication that nim is becoming a mainstream language 
little by little :-)


Re: re or nre. What should i use? What will be supported in future?

2020-03-10 Thread didlybom
Does this mean that the plan is to remove nre in the future? That is, is it the 
recommendation to use re for new projects? If such a change is being 
considered, it would be nice to have a built in stand-alone regular expression 
library. Its a bit annoying to have to distribute the pcre dll with your 
compiled executable.


Re: Nested list comprehension

2020-03-07 Thread didlybom
It would be nice if when something is deprecated in the standard library there 
was a link to the associated discussion/decision summary (if any). I found the 
deprecated list comprehension type a while ago and was curious about why it was 
deprecated.


Re: Nim Community Survey 2019

2020-02-20 Thread didlybom
According to the survey, Visual Studio Code is by far the most used editor for 
nim work. However the VSCode nim plugin is quite out of date. The latest 
version, 0.6.4 was released in September, before nim 1.0.0 was released. It 
also does not support (AFAIK) using nimpretty and is missing other features.

Do you guys know if there are plans to update the plugin to at least be 
compatible with the official 1.0 nim release?


Re: Nim Community Survey 2019

2020-02-20 Thread didlybom
I had the exact same reaction as akavel regarding the "Have you made 
contributions?“ question. The wording of the last answer was very odd.


Re: Nim 1.0.6 is out!

2020-01-28 Thread didlybom
Thanks. That one did not have a Windows build either, but an older one did.


Re: Nim 1.0.6 is out!

2020-01-28 Thread didlybom
Is there no windows nightly build?


Re: Nim 1.0.6 is out!

2020-01-27 Thread didlybom
Does this include the new --gc:arc option? I guess not?


Re: Nim now has Godbolt Compiler Support!

2020-01-05 Thread didlybom
This is great! Now if repl.it would update their nim version from 0.17 to 1.0...


Re: Introducing --gc:arc

2019-12-25 Thread didlybom
> Correct, it's very close to how C++ works.

This is awesome then! Can’t wait to try it :-)

Can you explain what the .cursor pragma does and how it must be used?


Re: Introducing --gc:arc

2019-12-25 Thread didlybom
This looks awesome!

Can you give more info on what you mean when you say that this new GC will 
provide a “deterministic memory management”?

For example, if I create a local seq or string variable on a procedure A, and 
that variable is only used within that procedure A or at most is used by 
procedures called within that procedure A, will it’s memory be freed 
immediately when the procedure A is done (and before other code is executed)? I 
guess my question is if this will behave like a shared pointer in C++ (or 
perhaps even like a unique pointer in certain cases)?

That is, are there separate, non deterministic garbage collection events? Is 
this suitable for embedded, hard real-time code?

Also, does this require anything that is not in nim v1.0?


Re: Should we get rid of style insensitivity?

2018-11-23 Thread didlybom
Completely agree. If that is the main benefit, why not focus on giving a non 
controversial solution to that particular problem?


Re: Should we get rid of style insensitivity?

2018-11-22 Thread didlybom
I’d like a vote.

I completely see where Dom is coming from with this proposal. This is mentioned 
as a negative in every discussion about been that I’ve seen in reddit and 
proggit I’m sure there are people who would give Nim a chance but which are 
very put off by this.

Personally I am not against this in principle, and I can understand some of the 
proposed benefits. I haven’t needed it myself and I prefer to be consistent 
when I write code but I imagine it could be useful when interfacing with 
external libraries and with non nim code for example. However I believe that 
people in favor of it minimize the drawbacks a bit. For example the fact that 
it makes identifiers harder to find is a real problem. I don’t think that 
saying that you should use ningrep to search is a good answer. People like to 
use their existing tools such as their editor of choice’s search box and won’t 
happily change that just to use a new language.

I think we can keep the benefits of this controversial feature without most of 
its drawbacks. To me the biggest problem is that it is enabled by default, for 
all the code in all the files. Instead I’d suggest making it optional and 
letting the user explicitly enable the style insensitivity on a particular 
section of the code or for a particular library, etc. I believe someone else 
proposed something similar earlier in the thread. 


Re: Perfecting Nim

2018-04-30 Thread didlybom
> @didlybom The names follow 
> [https://nim-lang.org/docs/apis.html](https://nim-lang.org/docs/apis.html) (a 
> document that is not well known). initT is used for value-based types, newT 
> for pointer-based types. newSeq and newString depart from it because they 
> were created early on.

Thanks for the explanation @araq. The problem is that seqs and strings are 
likely to be the very first kind of thing that a new user is going to create. 
The fact that those two deviate from the general rule makes the rule hard to 
understand, IMHO. What good is a rule that is not applicable to the most common 
use case?

Wouldn't it make sense to define "initSeq" and "initString" procedures? It 
those were then used in the tutorials and the documentation it would help new 
users learn the rule you mentioned. Ideally the existing newSeq and newString 
could be marked as deprecated as well, but I do not know if that would be 
feasible given that it would basically make almost 
_[all](https://forum.nim-lang.org/postActivity.xml#all) existing nim code 
deprecated. 


Re: Perfecting Nim

2018-04-26 Thread didlybom
One small thing that feels inconsistent in the standard library (and which has 
confused me a bit since I started using nim) is that in addition to the new 
keyword different standard library classes have different new and/or init 
procedures. For example there is newSeq and newSeqWith, newTable, newTableWith, 
initTable, etc.

Perhaps there is a clear rule to choose which is which and when to use which 
(or create initXXX vs newXXX procedures on your own libraries), but (on the 
surface) it feels inconsistent and is confusing (at least it was for me).

I'd prefer that you could always use new (and define a constructor procedure if 
you need some custom initialization).

I also agree that it would be best for not nil to be the default, but I don't 
know if that is too much of a change this close to v1.0. It would probably 
break a lot of existing code (and perhaps find a few bugs in the process).


Re: Calling staticExec inside a function

2018-04-18 Thread didlybom
Thank you for the clarification. Adding the compiletime directive fixes it.

I would argue however that using const (instead of let) is a very strong 
indication that the developer wants to execute an operation at compile time. I 
don't think compiletime should be needed except as a check if you wanted the 
compiler to verify that a procedure 
_[can](https://forum.nim-lang.org/postActivity.xml#can) be used at compile time 
(and fail if that is not the case).


Re: Calling staticExec inside a function

2018-04-18 Thread didlybom
Thank you, that works great! Simply being careful to assign the output of the 
staticExec calls to const variables did the trick. As a nice side effect it 
also fixes the issue I had with the more complex version of my function.

I have a final question which is: shouldn't the compiler be able to see that 
the output of get_version() is being assigned to a const variable, even if I 
did not use the intermediate const variable? That is, shouldn't these two 
functions work the same?:


# This procedure compiles fine
proc get_version_compiles_ok(): string =
const res = staticExec("hg log -r . --template 
\"{latesttag}+{latesttagdistance} ({node}|short})\"")
result = res

const version_info_ok = get_version_compiles_ok()

# This procedure does not compile
proc get_version_compile_failure(): string =
result = staticExec("hg log -r . --template 
\"{latesttag}+{latesttagdistance} ({node}|short})\"")

const version_info_fail = get_version_compile_failure()



Re: Results of our community survey

2016-09-06 Thread didlybom
I agree that for the IDE it would be best to focus on using an existing 
extensible editor than on making a new one from scratch. However it will be 
hard to get people to agree on which editors to base that work on. Personally I 
wouldn't focus on a closed source editor (such as Sublime) when Atom and VSCode 
offer a similar feature set and are open source.


Re: What are

2016-09-05 Thread didlybom
Thank you. That seems interesting. It seems this could be used to simply memory 
management when not using a GC... Hopefully the syntax will be nice and will 
make it easy to add variables to regions and not require manually destroying 
the region when you area done unless you want to (i.e. make it possible to 
associate a memory region to a scope, for example).


What are "memory regions"

2016-09-05 Thread didlybom
In another thread (related to working without a GC) there was some mention of 
"memory regions". Could somebody kindly give an overview of what they are and 
how they would be used? Is this something that is being worked on for pre-1.0?


Re: Improved Complex number string representation

2016-09-02 Thread didlybom
@Krux02 I disagree with your assessment. It is true that both representation 
types (tuple and arithmetic) are valid. However one of them is much more used 
both in real life (i.e. people doing arithmetic on paper) and in those 
programming languages that have made good math support one of their key 
objectives.

I think the "echo" advantage is quite minor, and is much less important that 
simply being able to view complex number using their usual "paper" 
representation. This is even more important now that there are projects to 
create a Jupyter nim kernel, for example.


Re: Improved Complex number string representation

2016-08-30 Thread didlybom
It is true that every programming language represents complex numbers 
differently. However most use a variation on the "mathematical representation" 
A + Bj (or A + Bi). Nim and C++ are a bit unique in this regard IMHO.

I think that for a language that can be used for mathematical work, such as 
Nim, it does not make sense to follow C++'s lead here.


What are concepts?

2016-08-12 Thread didlybom
I've seen quite a bit of discussion about concepts on this forum. However I 
have not seen much description of what the end goal is for concepts (maybe I 
missed it?).

In particular, are nim´s concepts mean to be similar to the equally named work 
in progress C++ feature? If so, what are the differences? What is the main 
purpose of concepts and what is the main use case for them in nim (i.e. what do 
they let you do that is not possible or easy with nim without them)?

Thanks!


Improved Complex number string representation

2016-08-12 Thread didlybom
I find that the string representation of the complex numbers defined on the 
complex module could be improved. Currently they are just represented as 
tuples. Instead I think it would be much nicer if nim did an arithmetic 
representation (e.g. 1.5-2.2j). Do you think that would be a good idea?

That is, rather than:


proc `$`*(z: Complex): string =
  ## Returns `z`'s string representation as ``"(re, im)"``.
  result = "(" & $z.re & ", " & $z.im & ")"


I'd prefer if nim did something like:


proc `$`*(z: Complex): string =
  ## Returns `z`'s string representation (e.g. 2.1-1.3j).
  result =
if z.im == 0.0:
  $z.re
elif z.re == 0.0:
  $z.im & "j"
elif z.im < 0.0:
  $z.re & "-" & $(-z.im) & "j"
else:
  $z.re & "+" & $z.im & "j"


This is what Python and tools such as Matlab do.

Additionally it would be great if it were possible to use the same sort of 
representation in complex literals, e.g.: 


var a = 1.0+2.2j


. 


Cannot compile httpserver2.nim

2016-08-11 Thread didlybom
I cannot compile examples/httpserver2.nim with the latest release (0.14.2) on 
Windows. I get the following error:

c:nimlibpuresockets.nim(174, 6) Error: ambiguous call; both system.==(x: T, y: 
T) and unsigned.==(x: T, y: T) match for: (uint16, uint16)

Is that normal? 


Re: Execution speed Nim vs. Python

2016-08-11 Thread didlybom
I think it was already discussed a while ago but I think this thread shows that 
"openarray" is not a very good name. IMHO it really does not convey what it 
really means. Something else such as "anyarray" or "arraylike" might be less 
accurate but easiert o inderstand (again, IMVHO). 


Re: VSCode Editor Nim Extension (free Visual Studio Code Editor by Microsoft)

2016-07-15 Thread didlybom
OderWat, I quite like VS Code in general (the latest version in particular is 
really great). However I find that the nim plugin for atom works much better 
than the one for VSCode. The nim plugin for Atom uses nimsuggest and does on 
the fly syntax checks (marking the lines with syntax errors with a red marker 
on the gutter). The nim plugin for VS Code does not seem to be able to do that. 
Perhaps I did not configure it correctly?


Re: What are the important features that are missing in Nim?

2016-07-01 Thread didlybom
> | Ideally, I'd like to get a REPL based on Jupyter (formerly known as 
> ipython).
> 
> That would mean Python becomes an essential dependency for Nim development. 
> I'm sure Nim can come up with a stand-alone feature-rich REPL, and optional 
> Jupyter integration.

Actually it doesn´t mean that. Jupyter _started_ as a Python tool, but it has 
since been heavily refactored so that it is completely language agnostic. It 
provides a REPL that can be used with any language. There are Jupyter-based 
REPLs for Haskell, Ruby, Julia, Javascript, Csharp, and so on 
([https://github.com/ipython/ipython/wiki/IPython-kernels-for-other-languages)](https://github.com/ipython/ipython/wiki/IPython-kernels-for-other-languages\)).
 Having a Jupyter-based nim environment would be wonderful.