ESP32 FreeRTOS (esp-idf) library wrappers: Nesper!

2020-09-19 Thread elcritch
Nesper is the beginning stages of porting over some wrappers for the ESP-IDF version of FreeRTOS from an internal project. You can see it here: PR's or recommendations welcome! Much of the FreeRTOS API wrappers feel a bit hacky, but they appear to work with

How Can I Convert An Integer to String?

2020-09-19 Thread doofenstein
> To go the other way (string to int) is a proc called parseInt(). To make it a > bit more robust: using varargs here works, but isn't optimal. A default param value is not only more clear regarding the intention, but it also doesn't allow for passing more than one extra parameter in.

How Can I Convert An Integer to String?

2020-09-19 Thread Hlaaftana
Your example should use a default argument, not `varargs`. proc str2int*(s: string, d: int = 0): int = result = try: parseInt(s) except ValueError: d Run

How Can I Convert An Integer to String?

2020-09-19 Thread stbalbach
To go the other way (string to int) is a proc called parseInt(). To make it a bit more robust: # # str2int([string], [default result]) # # . [default result] is an optional return value if parseInt() has an exception #If not default result and exception then re

Electron-like app with Nim

2020-09-19 Thread alexeypetrushin
> You describe the UI declaratively in Swift, and it builds it out of UIKit or > AppKit views This approach goes one step further. It not only builds the initial version of UI, but also magically updates it when you update the model. I don't know if Swift UI also does that.

Electron-like app with Nim

2020-09-19 Thread alexeypetrushin
> It sounds like this isn’t available in Nim, though, just Elixir? And > implementing all the DOM-diffing and updating sounds challenging. Hmm. Yes the LiveView is implementation of this concept in Elixir. I don't think it will be too complicated to implement. Following things need to be implem

Why does Random give the same value every time?

2020-09-19 Thread nhuman
thanks anyway!

Compile times

2020-09-19 Thread cblake
Well, I just say in my `$HOME/.config/nim.cfg` cc = tcc Run then further down just before the cross compiler examples I say @if r: #Allow short alias -d:r to activate fast release mode cc = gcc define:danger checks:off panics:on

Why does Random give the same value every time?

2020-09-19 Thread nhuman
Why does Random give the same value every time? I thought it was by luck, but seems like random(x..x) gives the same value every time... how do I fix it?

Why does Random give the same value every time?

2020-09-19 Thread nhuman
oh forgot that!

Why does Random give the same value every time?

2020-09-19 Thread Yardanico
That's because you didn't call `randomize()` :) If you check the first example in , it says: # Call randomize() once to initialize the default random number generator # If this is not called, the same results will occur every time these

Why does Random give the same value every time?

2020-09-19 Thread Recruit_main707
>From the random module docs: import random # Call randomize() once to initialize the default random number generator # If this is not called, the same results will occur every time these # examples are run randomize() Run

Growth of popularity and Nim community

2020-09-19 Thread Vindaar
I would argue the people who will care most about seamless Python interop will only show up, once it's there. That was certainly the case for me when I shortly started using Julia. If it hadn't provided super easy Python interop I would have never cared about any theoretical advantages over Pyth

Growth of popularity and Nim community

2020-09-19 Thread Recruit_main707
Id say that although python interoperability could be useful, not a lot of people are looking forwards to it, also, most important python libraries are written in c/c++ so you dont need python interop with those already.

How Can I Convert An Integer to String?

2020-09-19 Thread Yardanico
Welcome to the forum :) Yes, you can easily convert an int to a string by using `$` \- in Nim it's a convention to have a `$` operator for a type when you want to define a proc to convert it to a string, so: let myint = 5 let myintstr = $myint echo myintstr Ru

How Can I Convert An Integer to String?

2020-09-19 Thread nhuman
Thanks!

How Can I Convert An Integer to String?

2020-09-19 Thread nhuman
Is it possible to convert an int to a string? If yes, how?

Electron-like app with Nim

2020-09-19 Thread snej
> It works like React that implemented on Nim side. OK, that _really_ got my attention. I’ve been wanting to build a great social/collaboration app for a long time (with a distributed/p2p back end.) It makes sense to use a web view as the primary UI since it involves lots of text & multimedia l

Compile times

2020-09-19 Thread snej
That’s pretty cool. What sort of config would it take to have Nim use tcc for debug builds but the default cc for optimized builds?

Electron-like app with Nim

2020-09-19 Thread snej
For mobile apps there's Cordova aka PhoneGap. It’s a packaging layer that wraps your web-based app in a native (iOS or Android) web view. I don’t know if it supports desktop apps though. I agree about Electron being, um, sub-optimal. I hate the idea of each app carrying an entire Chromium brows

Growth of popularity and Nim community

2020-09-19 Thread allochi
man, you are such a child, you probably and extra reason why Nim doesn't get popular, people with your behavior. enjoy your bubble.

Compile times

2020-09-19 Thread cblake
Also, if you do update your `nim.cfg` or `config.nims` as I suggest above, you can add a `#!/usr/bin/nim r` "shebang" at the top of a file and chmod it and then treat it much like you would a scripting language. The compile (from uncached output) will be a little longer than most actual scriptin

Compile times

2020-09-19 Thread cblake
As a ballpark, it compiles about 19x faster than `gcc -O0` and 14x faster than `clang -O0` when compiling `tcc.c` (in the tcc mob branch I linked to above which gets updated often -- last update only a few hours ago).

Compile times

2020-09-19 Thread Yardanico
tcc is a relatively small C compiler, but it implements most of ISO C99 and it's very fast to compile, so fast that people use it as a REPL. But of course because it's fast to compile - it does much less optimizations :) / Also it didn't get any updates in a few years

Compile times

2020-09-19 Thread Clonk
Out of curiosity, what is the benefit of tinycc compared with gcc or clang ?

Object with same name as module

2020-09-19 Thread Clonk
Python "private" keyword is naming things with an underscore. It's a convention but it works. Otherwise, @pietropetter proposed a valid solution as well.

Growth of popularity and Nim community

2020-09-19 Thread Clonk
Honestly, GCs problematics are overrated. Current default GC works really well and I have very good performance with it. I'd say, the only time you need to worry about GC is when working on embedded with hard real time requirement. As @Vindaar pointed out there is a blocking PR to allow arc, or

Growth of popularity and Nim community

2020-09-19 Thread Rooibos
@Vindaar Thanks very much for various links! First, Weave looks very nice and I got to know it when I asked about parallel programming in this thread: Parallel coding in Nim (as compared to OpenMP/MPI) On the other hand, I came across various threads a

Growth of popularity and Nim community

2020-09-19 Thread sdmcallister
There has been a lot of discussion around language design. Personally, I like the design and find the language very easy to read and use. I'm coming from programming mainly in Python, Julia, and Go. I'm now using it at work and also have been talking about Nim with technology groups in the same

Growth of popularity and Nim community

2020-09-19 Thread Vindaar
As @Clonk mentions check out Weave for multithreading: / Regarding better Python / Numpy interop: Once we can finally (hopefully soon) merge the following PR: we'd be able to achieve that. For the time being we

Growth of popularity and Nim community

2020-09-19 Thread Clonk
Would it be possible to have a civil discussion without egos measuring contest ? In my experience, as a C & C++ developer for several years, I've had a harder time going from C to Java (because people still use Java in embedded systems for some reason) than from C to Nim because the way I think