Re: [C++ coroutines] in GCC

2020-01-19 Thread treeform
I was excited about this till I read this: [https://news.ycombinator.com/item?id=22090942](https://news.ycombinator.com/item?id=22090942) If the author is to be believed its just a transformation that is applied to the code. Basically the same transformation that we do with async/await already.

Nim will silently auto convert a float64 to a float32 and loose precision... is that good? Thoughts?

2020-01-19 Thread treeform
I get why float32 can auto convert to float64... there is no loss in precision. But its strange to me that reverse is also true. Nim will auto convert a float64 to a float32 and loose precision!!! Silently! This is not true for ints. Here it states so in the manual: [https://nim-lang.org/docs/m

Re: FOSDEM 2020 - Brussels February 1st & 2nd

2020-01-28 Thread treeform
I am coming, hold the door for me!

Re: FOSDEM 2020 - Brussels February 1st & 2nd

2020-01-31 Thread treeform
Are we going to meet up some place on Feb 1?

Re: How to refer to a dynamically determined array

2020-02-05 Thread treeform
I would use not use array for this but pointer and pointer arithmetic. I also did this for leaning purposes, and learned that pointers are easier.

Re: Status status update ;) libp2p, etc

2020-02-05 Thread treeform
Thank you Status.

Re: SslError: ssl3_write_pending:bad write retry

2020-02-05 Thread treeform
Oh and are you using some library that might have it's own openssl needs like curl, postgress, MySQL, crypto... ?

Re: SslError: ssl3_write_pending:bad write retry

2020-02-05 Thread treeform
You need to do some digging. What version of ssl do you have installed? Do you have multiple ones? Is it libressl or openssl. Nim claims to support all versions, but it's not quite true... Openssl team and dev practices make compatibility really hard.

Re: Change server name in Jester

2020-02-06 Thread treeform
[https://serverfault.com/questions/925892/does-it-makes-sense-from-a-security-perspective-to-remove-the-server-http-header](https://serverfault.com/questions/925892/does-it-makes-sense-from-a-security-perspective-to-remove-the-server-http-header) > Though in practice, attackers don't really check

Re: Change server name in Jester

2020-02-06 Thread treeform
If you use httpbeast, its part of the serverInfo constant defined here: [https://github.com/dom96/httpbeast/blob/master/src/httpbeast.nim#L50](https://github.com/dom96/httpbeast/blob/master/src/httpbeast.nim#L50) and used here: [https://github.com/dom96/httpbeast/blob/master/src/httpbeast.nim#L3

Re: Nim problems. 1 internal, 1 mine

2020-02-07 Thread treeform
-Werror Is not useful for nim generated code. Warnings are for humans not compiler output. Nim compiler will do a ton of unsafe things in C because they are actually safe in nim. No one is going to spend time fixing auto generated warnings... thats not what warnings are for! See: [https://forum

Re: Parallel example for computing pi efficiently is actually slow

2020-02-10 Thread treeform
It uses threads to do very little amount of work: 4 * math.pow(-1, k) / (2*k + 1) ... creating a thread is a very heavy weight operation, while doing little math is really easy. So most of the time is spent doing thread bookkeeping. Your computation needs to justify running it in a thread ... wh

Re: Idiomatic sequence functions

2020-02-13 Thread treeform
Its [0 ..< 5] You want slicing: [https://narimiran.github.io/nim-basics/#_indexing_and_slicing](https://narimiran.github.io/nim-basics/#_indexing_and_slicing) See here: [https://play.nim-lang.org/#ix=2bFa](https://play.nim-lang.org/#ix=2bFa)

Re: Threadpool slower than single-core

2020-02-13 Thread treeform
I think your problem might come from: * trying to do too little work per thread - so thread stuff eats up all the time. * trying to write same cache line from multiple threads. * too much blocking

Re: Threadpool slower than single-core

2020-02-13 Thread treeform
I don't think threads run slower in my case. I changed your program slightly to support threads and non threads: [https://play.nim-lang.org/#ix=2bFk](https://play.nim-lang.org/#ix=2bFk) nim c -d:release -d:danger --threads:on "/p/tmp/prisoners.nim" time ./prisoners Succs: 31

Re: Threadpool slower than single-core

2020-02-13 Thread treeform
\--d:danger just does all of the possible optimizations.| ---|--- I use --threads:on and when compileOption("threads"): to include or not include threadpool. See line 3: [https://play.nim-lang.org/#ix=2bFk](https://play.nim-lang.org/#ix=2bFk)

Why does `k in t.keys.toSeq.sorted` works but `k in t.keys.toSeq.sorted()` does not.

2020-02-18 Thread treeform
import tables, sequtils, algorithm var t: Table[int, int] # this works: for k in t.keys.toSeq.sorted: echo $k # this does not? for k in t.keys.toSeq.sorted(): echo $k Run A very strange error in the second case: Error

Re: Why does `k in t.keys.toSeq.sorted` works but `k in t.keys.toSeq.sorted()` does not.

2020-02-18 Thread treeform
Thanks! I am glad the explanation exists.

Re: RayCasting Problem

2020-02-19 Thread treeform
I am pretty sure Nim's sin() and cos() work exact same way as the C++ ones. I never had an issue with them working differently. I think error is some place else. Some thing I noticed: * you use uint32 for time while C++ uses double. * you hard code w to 640 while C++ does not. * your righ

Re: RayCasting Problem

2020-02-19 Thread treeform
Here is your exact code fixed: [https://gist.github.com/treeform/bb3f4618d24535590043e264825f350d](https://gist.github.com/treeform/bb3f4618d24535590043e264825f350d) I recommend using getKeyboardState() like I did, other wise it moves only on key repeats.

Re: RayCasting Problem

2020-02-19 Thread treeform
Oh I diffed the two files and found the error: [https://dl3.pushbulletusercontent.com/XulFI2T1reCunTVRZEXwGlORRV28pdXi/image.png](https://dl3.pushbulletusercontent.com/XulFI2T1reCunTVRZEXwGlORRV28pdXi/image.png) You have one important "(" in the wrong place.

Re: Nim Community Survey 2019

2020-02-19 Thread treeform
Nice, thank you for the write up!

Re: Paranim and Pararules - my new gamedev libraries

2020-02-19 Thread treeform
Looks cool!

Re: How to package a nim program in an APK file

2020-02-20 Thread treeform
Can you compile your apk with Android studio without docker? Does it run? I would try docker approach after I got that to work.

Re: I have a super doubt

2020-02-20 Thread treeform
I also would recommend Kiloneie's videos: [https://www.youtube.com/watch?v=5tVIsDYPClA](https://www.youtube.com/watch?v=5tVIsDYPClA) They start with the very basic and work up.

Re: How to get Nim running on iOS and Android using GLFM.

2020-02-25 Thread treeform
It looks like your wiish project is exactly what I want! I am working on my own UI thing called fidget ( [https://github.com/treeform/fidget](https://github.com/treeform/fidget)/ ) - my long term goal is to make fidget just work on Android and iOS, just like it does on Win/Mac/Linux and Web

Re: Templates and imports

2020-02-26 Thread treeform
Hmm, I think it always worked like this. Template just substitute code. If the code where you have template can't access some thing... then it's an error. It also is an error if template calls a private proc: proc b() = # private b echo "hi" tempalte a*() = # public

Re: Bug with makeNimstrLit on JS backend

2020-02-26 Thread treeform
ve. See [https://mathiasbynens.be/notes/javascript-unicode](https://mathiasbynens.be/notes/javascript-unicode) But some times using JS strings in JS compile mode is useful I have defined some methods to make it easier and faster: [https://github.com/treeform/jsutils/blob/master/src/jsutils/strings.nim](htt

Re: Async web servers and database

2020-03-01 Thread treeform
Also don't forget mine! [https://github.com/treeform/pg](https://github.com/treeform/pg)

Re: Documenting one liner

2020-03-05 Thread treeform
Well its not 1 line any more? I would just make it 3 lines :) proc createMap(this: VS):ptr VSMap = ## Creates a new property map. It must be deallocated later with freeMap(). this.vsapi.createMap() Run

Re: Nim for Beginners Video Series

2020-03-13 Thread treeform
Nice!

Re: Help prlm this Time

2020-03-18 Thread treeform
I think the problem is that the strformat's fmt macro is not good enough to realize that date format is not part of it's format. So it gets confused. That is why you get the error: : could not parse `a.Data.format("HH`. Run I recommend doing what you already done:

Re: (Meta) Why is there no beginners' section in the forum?

2020-03-26 Thread treeform
Arn't we all beginners? I prefer category-less forum.

Re: ways to comunicate between different application

2020-03-27 Thread treeform
You only need one socket to communicate between python and nim.

Re: upperBound/lowerBound in algorithm O(log n) or O(n) ?

2020-03-27 Thread treeform
Yes shr 1 is divide by 2. It looks like the function does what you would except at O(log n). But... The O(log n) stuff works in theory, but in practice memory access and cache hotness have bigger impact on performance. I don't think it's that useful to specify this. [http://www.brendangregg

Re: Idea: Nim Online Conference

2020-03-30 Thread treeform
Twitch is probably the best place to stream things... then archive on Youtube. I can give a presentations on following topics: * Fidget Library and Desktop/Web UI programming. * Chrono Library and everything related to calendars and timezones. * Typography Library and everything about fonts

Re: Idea: Nim Online Conference

2020-03-30 Thread treeform
Yes [https://github.com/treeform/orbits](https://github.com/treeform/orbits)

Re: Nim 1.2 is here

2020-04-03 Thread treeform
Yes! Thank you everyone who contributed!

Re: Calling C function causes Sigsegv

2020-04-07 Thread treeform
I have wrapped plenty of C programs with Nim. My experience is that sig faults are caused by some thing simple ... like me not understanding the parameters. An equivalent C program should crash with a sig fault there too. I bet BASS_Init(-1, 44100, 0, 0, nil) would crash in C as well.

Re: String constant concatenation

2020-04-15 Thread treeform
And an "I agree with Araq" button.

Re: how to properly release memory?

2020-04-15 Thread treeform
Short answer you can't. Nim will keep the free memory for itself in case it needs to use it. Many libraries have a way to supply it a memory allocator: [https://github.com/nim-lang/Nim/blob/version-1-2/lib/wrappers/openssl.nim#L495](https://github.com/nim-lang/Nim/blob/version-1-2/lib/wrappers/o

Re: Iterate over fields

2020-04-15 Thread treeform
Field fieldPairs are great! I use it to print arbitrary structures and deserialize json in a more looser way: [https://github.com/treeform/print/blob/master/src/print.nim#L79](https://github.com/treeform/print/blob/master/src/print.nim#L79) [https://github.com/treeform/jsutils/blob/master/src

Re: What's the most favourable way to get documentation as an automated process?

2020-04-23 Thread treeform
nim jsondoc -o:doc.json I use this for [https://github.com/treeform/mddoc](https://github.com/treeform/mddoc)

Re: Introducing --gc:arc

2020-04-29 Thread treeform
Is there a way to disable automatic tracing runs of --gc:orc and only run them when we want to -- say between rendering frames or loading levels? Is there a way to limit the time the tracing step runs? You can pass --gc:arc refs between threads right? Which thread does --gc:orc run on?

Typography update - now it can render 99% the Google Fonts ttf.

2020-04-30 Thread treeform
When I started typography ( [https://github.com/treeform/typograph](https://github.com/treeform/typograph) ) with an aim for writing a full font and typography engine from scratch, I did not know much about fonts. I did not know what I was getting into, its been quite a journey. At first it

Re: Typography update - now it can render 99% the Google Fonts ttf.

2020-05-01 Thread treeform
Rmarkdown looks cool. But I think you might want to use a different tool to generate PDFs... they already support fonts! My plan is to use this for my UI framework called fidget ( [https://github.com/treeform/fidget](https://github.com/treeform/fidget) ). It turns out UI's are like 80%

Re: Typography update - now it can render 99% the Google Fonts ttf.

2020-05-01 Thread treeform
Kerning already supported ... text would look broken without it. glyph composition and rtl/ttb/btt - I don't support that now, but I want to support it eventually. Hebrew and Arabic are the only major rtl languages I want to support. Almost no one uses ttb/btt in computer UIs, CJK use it in sig

Re: Making 4k intro with Nim

2020-05-07 Thread treeform
I really liked the write up. Thank you for this!

Re: A good word for idiomatic nim?

2020-05-13 Thread treeform
nimatic

Re: New blog, with some Nim articles

2020-05-14 Thread treeform
Nice! I feel like its blog posts like you that get Nim out there and more popular. Thank you! Your points about private access are really good, instead of saying undeclared identifier or function it should say trying to call or access a private identifier or function. Would be great improvement

Re: help call string ??

2020-05-14 Thread treeform
One way to do that is to add them to some sort of structure like a hash table: [https://play.nim-lang.org/#ix=2m18](https://play.nim-lang.org/#ix=2m18) import tables var calls: Table[string, proc()] proc hi() = echo "hi" proc bye() = echo "bye" calls["h

Re: Sorting JSON data by a specified field

2020-05-14 Thread treeform
Unrelated "id":"582090251837636960" gives me flash backs on how JS can't store large numbers. I like making IDs ascii characters so that people don't accidentally parse them and have pain. Speaking for personal experience.

Re: help call string ??

2020-05-14 Thread treeform
I can see some thing like Glade needing this. I will be interested to see it when you have some thing to show.

Re: Some week-of-year procs for use with the times library

2020-05-14 Thread treeform
I like this I have weekday, but I don't have week of the year in my library, I should add it. [https://github.com/treeform/chrono/blob/master/src/chrono/calendars.nim#L224](https://github.com/treeform/chrono/blob/master/src/chrono/calendars.nim#L224)

Re: New blog, with some Nim articles

2020-05-15 Thread treeform
You can use my quote, but I don't think "optimization walls" will be understood by most people.

Re: Nim support for CodeRunner app

2020-05-15 Thread treeform
Nice! Good job. We need Nim in more places.

Re: New blog, with some Nim articles

2020-05-15 Thread treeform
Having written a fair amount of Assembly, it's kind of hard to optimize. Most optimizations are done with taking a different approach to solve your problem and not some cleaver SIMD instruction, in fact a random single SIMD can really slow down your code... I think this is what Nim does really

Revisiting my oldest Nim project.

2020-05-15 Thread treeform
My first serious project was Chrono a Timestamps, Calendars, and Timezones library for Nim. [https://github.com/treeform/chrono](https://github.com/treeform/chrono) I have become much better at Nim than when I first wrote it. I recently went over the project and wanted to share things that I

Re: Revisiting my oldest Nim project.

2020-05-17 Thread treeform
0_000_000 > That is why I use float64 seconds from 1970 utc. > leap seconds I should add a j2000 mode as that will enhance my [https://github.com/treeform/orbits](https://github.com/treeform/orbits) library.

Re: Revisiting my oldest Nim project.

2020-05-18 Thread treeform
> that's a C++ problem; nim doesn't have this problem. Look at the std/times > module which abstracts the internal representation as (secs,nsecs) For me Nim does have this problem. That is why I don't use std/times module. It just works badly in JS mode. Yes in theory a more accurate time repre

Re: How mature is async/threading in Nim?

2020-05-18 Thread treeform
I use async/await in production, but only server side on Linux. It's pretty mature for a simple web application. My app runs on multiple servers instead of threds. Async does not mesh well with threds. Multiprocessing is more scalable anyways.

Re: How mature is async/threading in Nim?

2020-05-19 Thread treeform
hreads to have a good UDP system. Here is what I use [https://github.com/treeform/netty](https://github.com/treeform/netty) if I control both ends. But some times you just have to go with WebSockets, I wrote a library for that too: [https://github.com/treeform/ws](https://github.com/treeform/ws) though its async based.

Re: How mature is async/threading in Nim?

2020-05-19 Thread treeform
> which GC is the default The _\--gc:refc_ (deferred reference counting/heap per thread) is the default right now. The _\--gc:arc_ (immediate reference counting/shared heap) or _\--gc:orc_ (immediate reference counting/shared heap + cycle detector) is set to replace it. The _async_ stuff works

Re: Lambda syntax is awkward

2020-06-02 Thread treeform
I actually prefer the "original problem" syntax. It's only like couple of characters of extra typing. The do, -> and => feel less clear.

Re: Can't access fields of object returned by a procedure

2020-06-15 Thread treeform
For oldcommers too! Error should say x is not public, not that x is missing.

Re: Nim's popularity

2020-06-15 Thread treeform
This talk has a pretty good part about how most popular languages got popular: [https://www.youtube.com/watch?v=QyJZzq0v7Z4](https://www.youtube.com/watch?v=QyJZzq0v7Z4) To summarize, according to the talk, there are 5 major ways to popularly (top 10): 1. Killer App: C, Ruby, PHP 2. Platfor

Re: Nim version 1.2.2 is out!

2020-06-17 Thread treeform
Wow thanks for all of the hard work! I love new new versions.

Re: Perf: Table.del(key)is taking 85% of my code's time

2020-06-17 Thread treeform
I also experienced really bad Table performance which was related to really bad hash generation. Print out the hash(key) and see if you hashes are usually bad.

Re: Has anyone wrapped zlib or reimplemented deflate?

2020-06-19 Thread treeform
I wrapped miniz which implements low level zip but not expanded gzip protocol [https://github.com/treeform/miniz](https://github.com/treeform/miniz) But if you control both ends, I highly recommend [https://github.com/jangko/snappy](https://github.com/jangko/snappy) . Its fast, its very simple

Re: jester: one handler for several routes?

2020-06-19 Thread treeform
You can use templates like this: [https://play.nim-lang.org/#ix=2pC5](https://play.nim-lang.org/#ix=2pC5) import tables var routeMap: Table[string, proc()] template routes(body: untyped) = # init server pre routs body template get(url: stri

Re: First look

2020-06-19 Thread treeform
Space between function and parameters is important. echo ("\nProcessor count ", countProcessors()) echo 1 echo () Run is same as: echo(("\nProcessor count ", countProcessors()) echo(1) echo(()) Run Just remove the space betw

New garbage collector --gc:orc is a joy to use.

2020-06-24 Thread treeform
. See my threaded work example here: [https://gist.github.com/treeform/3e8c3be53b2999d709dadc2bc2b4e097](https://gist.github.com/treeform/3e8c3be53b2999d709dadc2bc2b4e097) (Feedback on how to make it better welcome.) Before creating objects and passing them between threads was a big issue. Default

Re: New garbage collector --gc:orc is a joy to use.

2020-06-24 Thread treeform
There is this: * [https://nim-lang.org/docs/gc.html](https://nim-lang.org/docs/gc.html) * [https://www.youtube.com/watch?v=aUJcYTnPWCg](https://www.youtube.com/watch?v=aUJcYTnPWCg) * [https://www.youtube.com/watch?v=yA32Wxl59wo](https://www.youtube.com/watch?v=yA32Wxl59wo) * [https://ni

Re: New garbage collector --gc:orc is a joy to use.

2020-06-25 Thread treeform
Yes I "move" the ownership of objects from the main thread to the work threads. And I "move" the ownership back from work thread to the main thread. Once and objects moves a way from the thread it was created on I will not be touching the object or its internal sub objects on that thread. Nim do

Re: Problem sending binary file by socket never ending.

2020-06-26 Thread treeform
EOF or End of file in linux is usually when getChar returns -1. But you can't actually send -1 with a socket. All bytes must be 0-255. End of file in DOS was ASCII character 'x04', also known as End of Transmission or ^D in linux. You could send that and check for that character. But the proble

Re: New blog post: Ray tracing in Nim

2020-06-30 Thread treeform
Very nice blog post!

Re: Multithreaded await

2020-06-30 Thread treeform
In my system I do all async/await and asyncdispatch on a single thread. Then I have a work Q to do other the actual work. Was very simple to put together.

Re: Introducing --gc:arc

2020-07-05 Thread treeform
Wow amazing improvement. It's nearly manual speed.

Re: Why Seq search is faster than Table search

2020-07-06 Thread treeform
I love performance puzzles like this! Answer: Turns it it just optimizes the for loops away! Timings i get with the code provided: List: (seconds: 0, nanosecond: 9180) Table: (seconds: 0, nanosecond: 2794545) Run Really strange! Added dummy counter so that for lo

Re: Why Seq search is faster than Table search

2020-07-06 Thread treeform
I did some more work on it, I measured time at each array size from 0 to 10_000, see chart: [https://dl3.pushbulletusercontent.com/4m74W8NlcdcrpJnVgCT53RkL2nxUPimc/image.png](https://dl3.pushbulletusercontent.com/4m74W8NlcdcrpJnVgCT53RkL2nxUPimc/image.png) It shows you how much tables are faster

Re: How to set up/start a Project?

2020-07-07 Thread treeform
This is project structure I use: [https://github.com/treeform/nimtemplate](https://github.com/treeform/nimtemplate)

Re: Understanding Pragmas

2020-07-09 Thread treeform
Pragmas are just a way to attach more info to the functions. The compiler takes the data in the pragmas and does some thing special with it. Take the {.inline.} pragma it just marks the functions with inline=true and then when compiler sees the function it inlines it. You can also create your o

Re: using nimble for package management

2020-07-11 Thread treeform
I am not quite sure what you are asking? * If you have a package that you are developing and making local updates use nimble develop then you can make edits, use git pull etc... and package stays in sync. * If you want to update a package that you don't own, increment its version in your *.

<    1   2   3