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.
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
I am coming, hold the door for me!
Are we going to meet up some place on Feb 1?
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.
Thank you Status.
Oh and are you using some library that might have it's own openssl needs like
curl, postgress, MySQL, crypto... ?
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.
[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
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
-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
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
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)
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
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
\--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)
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
Thanks! I am glad the explanation exists.
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
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.
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.
Nice, thank you for the write up!
Looks cool!
Can you compile your apk with Android studio without docker? Does it run? I
would try docker approach after I got that to work.
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.
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
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
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
Also don't forget mine!
[https://github.com/treeform/pg](https://github.com/treeform/pg)
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
Nice!
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:
Arn't we all beginners?
I prefer category-less forum.
You only need one socket to communicate between python and nim.
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
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
Yes [https://github.com/treeform/orbits](https://github.com/treeform/orbits)
Yes! Thank you everyone who contributed!
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.
And an "I agree with Araq" button.
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
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
nim jsondoc -o:doc.json
I use this for
[https://github.com/treeform/mddoc](https://github.com/treeform/mddoc)
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?
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
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%
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
I really liked the write up. Thank you for this!
nimatic
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
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
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.
I can see some thing like Glade needing this. I will be interested to see it
when you have some thing to show.
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)
You can use my quote, but I don't think "optimization walls" will be understood
by most people.
Nice! Good job. We need Nim in more places.
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
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
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.
> 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
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.
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.
> 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
I actually prefer the "original problem" syntax. It's only like couple of
characters of extra typing. The do, -> and => feel less clear.
For oldcommers too! Error should say x is not public, not that x is missing.
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
Wow thanks for all of the hard work! I love new new versions.
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.
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
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
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
.
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
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
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
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
Very nice blog post!
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.
Wow amazing improvement. It's nearly manual speed.
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
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
This is project structure I use:
[https://github.com/treeform/nimtemplate](https://github.com/treeform/nimtemplate)
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
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 *.
201 - 283 of 283 matches
Mail list logo