Why is reading lines from stdin so slow for me?

2020-11-29 Thread mratsim
Top-level variables are globals and so not optimized by the compiler and also never released if they do allocate. They are fine for quick scripting or quick prototyping. Similarly, top level statement are not optimized. So it's more of a performance issue than correctness issue. That said, read

How mature is async/threading in Nim?

2020-11-29 Thread mratsim
The usual recommendation for CPU intensive task is to use Rayon. Tokio is ill-suited even if it uses a threadpool underneath. The role of the threadpool is to avoid the overhead of create/teardown thread. What makes a multithreading runtime suitable for IO or CPU is its scheduler. The Tokio sch

How to rewrite nim programming langauge to be pythonic as possible?

2020-11-29 Thread mratsim
This question reads like "I want faster horses for my carriage" while someone is building a car.

SIGSEGV on deleteContent

2020-11-29 Thread tinygiant
That seems to have done it. Would this be considered an "issue" as far as the language goes? GitHub documentation states that a delete request should return `204 No Content`, but not sure if the code is returned or if, literally, nothing (nil) is returned. Thanks for the pointer to the other pr

SIGSEGV on deleteContent

2020-11-29 Thread xigoi
The proc does what it says in the documentation and is consistent with the other procs for requests. > Connects to the hostname specified by the URL and **returns the content** of > a DELETE request.

SIGSEGV on deleteContent

2020-11-29 Thread xigoi
Have you tried using just `delete` instead of `deleteContent`? The procs ending with `Content` always return the body.

SIGSEGV on deleteContent

2020-11-29 Thread xigoi
Note that a segmentation fault can't be `except` ed because it's not an exception.

SIGSEGV on deleteContent

2020-11-29 Thread tinygiant
`deleteContent` question ... I'm sending a `deleteContent` request to GitHub and successfully deleting a repo. However, after it deletes the repo, I get these errors a list of errors that ends with these: C:\Users\\.choosenim\toolchains\nim-1.4.0\lib\pure\httpclient.nim(1108) del

Why is reading lines from stdin so slow for me?

2020-11-29 Thread fxn
> Also, the compiler doesn't like top level statements, you should put the for > loop into a proc. Can you elaborate on that? Is that still the case today?

Example of a simply UDP client

2020-11-29 Thread JohnAD
On the off change that @dom96's advice to use async was part of the problem. I converted it to async: import asyncdispatch, asyncnet import std/[net, selectors, strformat, strutils] const cfgMaxPacket = 500 clientPort = 8800 clientHost = "127.0.0.1"

Example of a simply UDP client

2020-11-29 Thread JohnAD
Anyone know why I cant seem to use `sendTo` for an off-machine address? Using @jrfonden 's example above, if I set the `sendTo` address to `192.168.1.44` which is the machine I'm on, it works just fine. (Especially if I'm also running the UDP server on my local machine.) But, if I set the addre

How to rewrite nim programming langauge to be pythonic as possible?

2020-11-29 Thread xigoi
Your example doesn't compile, in would have to be discard x := (y := 3) Run

How to rewrite nim programming langauge to be pythonic as possible?

2020-11-29 Thread Niminem
Exactly!

How to rewrite nim programming langauge to be pythonic as possible?

2020-11-29 Thread Hlaaftana
Nim isn't C, `x = y` could have complicated behavior, so it's best that it stays void. You could define the walrus operator in Nim with a template like so: template `:=`(a, b): untyped = let a = b a x := y := 3 while (y := fct(x)) > 0: discard

How to rewrite nim programming langauge to be pythonic as possible?

2020-11-29 Thread moigagoo
But you can easily do that in Nim already: while (let y = fact(x); y > 0): Run

How to rewrite nim programming langauge to be pythonic as possible?

2020-11-29 Thread HJarausch
There is one thing I'd like to add to the _wish list_. It's a personal(!) preference. Sometimes it's called _orthogonality_ , or in simple words: _what makes sense, should be possible_. Of course, it's hard to define _what makes sense_. An example is "things that are thought being passable to

How to rewrite nim programming langauge to be pythonic as possible?

2020-11-29 Thread slonik_az
> @nocturn9x: Could you elaborate a bit on why this is a bad design choice? It > is indeed debatable, also because in general python violates the general rule > of "exceptions should be used for exceptional behaviors", but not outright > wrong The quote from your own message already answers you

How to rewrite nim programming langauge to be pythonic as possible?

2020-11-29 Thread nocturn9x
Just as a side note, I agree that trying to make nim become python is dumb. People need to understand that nim is not compiled Python, it's an awesome new language, but since they see some similar behavior they tend to jump to this wrong conclusion. The thing I do not agree with is Python, or dy

How to rewrite nim programming langauge to be pythonic as possible?

2020-11-29 Thread nocturn9x
Could you elaborate a bit on why this is a bad design choice? It is indeed debatable, also because in general python violates the general rule of "exceptions should be used for exceptional behaviors", but not outright wrong

How to rewrite nim programming langauge to be pythonic as possible?

2020-11-29 Thread nocturn9x
Well, regarding the `3 < "abc"` thing, at least the Python development team had the guts to deprecate that behavior in the new versions of Python (looking at you Javascript 😂)

I make my first $ with Nim in two days

2020-11-29 Thread b3liever
Congrats! Hope everything works out for you! In about a year I'm going to need your services.

How to rewrite nim programming langauge to be pythonic as possible?

2020-11-29 Thread lscrd
Yes, you are right. This is the standard rounding in IEEE 754. I suppose that with this rounding, errors in one direction better compensates errors in another direction.

How to rewrite nim programming langauge to be pythonic as possible?

2020-11-29 Thread HJarausch
Just a comment w.r.t. rounding. The Python way is THE accepted way of rounding in Numerical Analysis! Always rounding n+0.5 (where n is integer) up is biased and makes problems. People have computed long time astronomical calculations and they experienced that our planets leave our solar system.

Eminim - JSON deserialization macro for Nim

2020-11-29 Thread b3liever
I have updated eminim with an [jsonItems](https://github.com/planetis-m/eminim#the-jsonitems-iterator) iterator, that reads a top-level JSON array file. type IrisPlant = object sepalLength: float32 sepalWidth: float32 petalLength: float32 petalW

How to rewrite nim programming langauge to be pythonic as possible?

2020-11-29 Thread moigagoo
...or the ability to work on Windows.