Nim procedure args vs C and the need for pointers.

2024-03-04 Thread xioren
Admittedly I don't have much experience with C but as I understand it arguments are passed by value which means a copy is made of the argument value which can then be modified within the scope of the function without modifying the original value. Again as I understand it this is why you see so m

Resources for Web Authentication

2024-02-16 Thread xioren
Also <https://github.com/xioren/jwt-nim>

The power of a good standard library

2024-02-08 Thread xioren
No doubt there are trade offs but I am speaking strictly from the perspective of a user. When I choose a language to use I am going to choose one that puts the fewest barriers between me and wheat I am trying to achieve.

The power of a good standard library

2024-02-07 Thread xioren
The import statement from a project I am currently working on: import std/[asyncdispatch, asyncfile, asyncnet, base64, httpcore, logging, math, monotimes, os, strformat, strutils, terminal, times] Run Now imagine having to go find and manage third party dependencies fo

ANSI Escape Sequences

2024-02-06 Thread xioren
Yes I use the terminal library a lot but as far as I know it doesn't provide fine grained control for just (efficiently) colorizing a portion of a string.

ANSI Escape Sequences

2024-02-06 Thread xioren
Gotcha. For what it's worth a message stating they are unsupported might be preferable over one stating they don't exist.

ANSI Escape Sequences

2024-02-06 Thread xioren
Note: if I use hexadecimal "x1B" it does work.

ANSI Escape Sequences

2024-02-06 Thread xioren
Is there something special I need to do do use ANSI codes in Nim? This works in Python "\033[32mtesting\033[00m" but in Nim "![32mtesting![00m" gets written to stdout instead. I assume it has to do with the compiler warning "Warning: octal escape sequences do not exist; leading zero is ignored [

Argon2 in Pure Nim.

2024-01-28 Thread xioren
This is a project I did mostly for fun and to be able to implement Argon2 into some other projects I have, like a file encryption script. If I made a Nimble package people might think this is production ready which it is not. I lack to knowledge of Nim to truly optimize the code and I lack the e

Argon2 in Pure Nim.

2024-01-25 Thread xioren
Okay that makes sense thank you. So it's a question of efficiency rather than correctness. I will look into threadpool.

Argon2 in Pure Nim.

2024-01-25 Thread xioren
Sorry to belabor the point but getting this right is important to me and I am unable to verify what you guys are saying. I really can't see how using createThread is giving me the WRONG number of threads. From the documentation: import std/locks var thr: array[0..4, T

Argon2 in Pure Nim.

2024-01-24 Thread xioren
@araq So if the behavior of createThread is not 1:1 analogous to Go's go routine, that doesn't bother me so long as it doesn't impact the implementation of the algorithm. Does the difference in behavior mean I am ending up with a different number of threads (as mratsim suggested) given the analo

Argon2 in Pure Nim.

2024-01-23 Thread xioren
@arnetheduck Ah I should have know cheatfate would have already implemented this. Thanks. @mratsim Thanks for the input. I started with threadpool but moved away as its listed as deprecated. My logic here is basically strait from Google's Go implementation: for n := uint32(0); n <

Argon2 in Pure Nim.

2024-01-22 Thread xioren
can use it as a basis for implementing a production ready version. Comments and suggestions welcome. <https://github.com/xioren/argon2-nim>

A little guidance on threading needed.

2024-01-19 Thread xioren
@mratsim Thanks for that in depth response. Will take be a bit to parse through it. @Araq Yes I saw that but I am one of those people who hates having their code depend on someone elses code. As I am not writing commercial/production code, when at all possible I use only the standard library of

A little guidance on threading needed.

2024-01-19 Thread xioren
Thank you for the responses. @mratsim Argon2, 90% done implementing Argon2 just trying to get the threading working. And you are right, the threads access the "memory" in parallel but they are all assigned different regions which simplifies things. For better or worse I seem to be getting away

A little guidance on threading needed.

2024-01-19 Thread xioren
And beyond that, while I can access the global var x in a modified example from the docs, in my code, that uses a global var, I get this error when trying to create a thread: Error: 'processSegment' is not GC-safe as it accesses 'globalMem' which is a global using GC'ed memory

A little guidance on threading needed.

2024-01-18 Thread xioren
I am working on a project that spawns threads that operate on a global memory array (seq[seq[uint64]]) and am trying to wrap my head around the locks module and passing variables to a threaded funtion. If I pass a single variable it works, but fails with N>1 variables. Slightly modifying the ex

I asked chat-gpt to write a fft function in Nim

2023-03-17 Thread xioren
Worth noting that neither of those examples compile as is. I don't know how close they are to being correct but it seems chat-gpt is convincingly wrong at best with anything more than basic examples. However I did have it correctly debug a small script I gave it that was deliberately invalid.

I asked chat-gpt to write a fft function in Nim

2023-03-16 Thread xioren
HTML parser... import htmlparser type NodeKind = enum textNode, elementNode Node = object kind: NodeKind case kind: of textNode: text: string of elementNode: tag: string attrs:

I asked chat-gpt to write a fft function in Nim

2023-03-16 Thread xioren
proc fft(input: seq[complex[float]]): seq[complex[float]] = let n = input.len if n == 1: return input var even = @[input[i] | i in 0 ..< n by 2] var odd = @[input[i] | i in 1 ..< n by 2] var y = fft(even) & fft(odd) for k in 0 ..< n div 2: le

Need some direction on macros.

2022-08-19 Thread xioren
Yeah I guess and interpreter is my next focus.

Need some direction on macros.

2022-08-19 Thread xioren
Yeah makes sense. Good explanation.

Need some direction on macros.

2022-08-19 Thread xioren
Unfortunately it's more complex than that. Here is the rube goldberg code I need to convert to Nim. These are steps operating on an array. (youtubes anti-piracy measure) try{try{4=c[62-Math.pow(3,3)%497]&&(c[33]>30*Math.pow(2,1)-53||((0,c[44])(c[0]),void 0))&&(0,c[56])(c[0]),1=c[1

Need some direction on macros.

2022-08-18 Thread xioren
Yeah your right, that limitation makes sense. I guess it's just shocking to learn given my (incorrect) assumptions of what macros were capable of.

Need some direction on macros.

2022-08-18 Thread xioren
If I understand it correctly static means known at compile time. Problem is these strings are NOT known at compile time. Is there a way to use macros dynamically?

Need some direction on macros.

2022-08-18 Thread xioren
One thing...I get this compile error when trying to run the code like so: let x = "1+1" echo nimify(x) /home/xioren/Documents/coding/nim/burner.nim(190, 12) Error: type mismatch: got but expected one of: macro nimify(s: static string): untyped

Need some direction on macros.

2022-08-18 Thread xioren
Hey that's more than I was hoping for. Thank you! I've been pulling my hair out with this thing.

Need some direction on macros.

2022-08-18 Thread xioren
I have a situation where I need to parse "compiled" javascript and execute equivalent code in Nim. I assume macros are the best (only?) way to achieve this. I have read all Macro resources + the Nim sections from Araq's book and I still don't have a clue where to begin; maybe I'm just a moron. I

downloading big files

2022-08-02 Thread xioren
actually that example might still have issues with large files.

downloading big files

2022-08-02 Thread xioren
proc download(url, filepath: string): Future[HttpCode] {.async.} = let client = newAsyncHttpClient() var file = openasync(filepath, fmWrite) try: let resp = await client.request(url) await file.writeFromStream(resp.bodyStream) result = resp.code

Mastering Nim: A complete guide to the programming language

2022-06-27 Thread xioren
Just ordered a copy. Looking forward to reading through it!

Hacker News discussion abou the recently discussed Rust vs Nim performance comparison

2022-04-22 Thread xioren
I'm not arguing. I'm just saying that despite your perception of them, they are popular and WILL continue to be utilized to compare languages; for better or worse.

Hacker News discussion abou the recently discussed Rust vs Nim performance comparison

2022-04-22 Thread xioren
Like them or not, these types of comparisons are popular and people do use them when comparing languages. The fact that it's being discussed on Hacker News proves this. Getting Nim removed from common and popular comparisons will do nothing but further ensure perpetual obscurity imo.

Issues with proxy authentication

2022-04-06 Thread xioren
What version of Nim are you running?

Must check to decide whether this current iteration in a loop is the last

2022-02-23 Thread xioren
Minor nit picky changes: for idx, item in mySeq: if idx == mySeq.high: echo "last" Run

Hacker News discussion abou the recently discussed Rust vs Nim performance comparison

2022-02-07 Thread xioren
For whatever reason rust has accrued a cult like following.

Nim Community Survey 2021

2022-01-15 Thread xioren
I hadn't seen that guide and I appreciate the effort, but speaking frankly it didn't "demystify" anything. Macros are one of the more complex aspects of Nim and require comprehensive and compounding explanations. This just isn't a topic you can gloss over. An issue with a lot of guides that I se

Nim Community Survey 2021

2022-01-15 Thread xioren
Well I think there is a **strong** need for a full fledged macros tutorial. That is one place where the docs falls short imo.

Nim Community Survey 2021

2022-01-14 Thread xioren
No I understood what he meant. Just pointing out the humor in that sentence when taken at face value.

Nim Community Survey 2021

2022-01-14 Thread xioren
> we are noticing a trend where our users are on average a bit older than the > year before

Thoughts on error vs fatal log levels?

2022-01-12 Thread xioren
I am probably over thinking this but I can't seem to make up my mind on which situations call for one or the other. An example would be a program that reads from a file and then does something with that data. If the file does not exist, the program logs a "file not found" message and exits. Woul

Proper way to open and close async files?

2021-12-27 Thread xioren
Yeah that might be the simplest solution, thanks. While not a direct comparison, I did see that the close proc for (async)http clients has an "if connected" safety check like that built in which is a nice quality of life feature.

Proper way to open and close async files?

2021-12-26 Thread xioren
This isn't something I expected to get hung up on but for the life of me I can't think of a simple solution. For normal file i.o. as per the docs: var f: File if f.open(filepath, filemode): try: ... except: ... finally: f.close()

Issues with proxy authentication

2021-12-19 Thread xioren
Yessir, already merged to devel.

Nim with curly brace and tab

2021-12-19 Thread xioren
Context is important here. Certainly a keyboard first approach in a user environment designed for mouse interaction is going to be slower. But imo using a keyboard in an environment designed for keyboards (i3 wm) will almost always be faster than using a mouse in an environment designed for mice

Issues with proxy authentication

2021-12-18 Thread xioren
Yeah cURL and my python test code use basic auth too. My naive assumption is that there is something different about how the "proxy-authorization" header is handled with Nim. I'm currently reading through the source code to see if I can figure it out.

Issues with proxy authentication

2021-12-18 Thread xioren
last addition: Apart from cURL, similar code also works in Python so I'm not sure there isn't some issue with Nims proxy auth handling.

Issues with proxy authentication

2021-12-17 Thread xioren
FWIW if and only if I manually add the "proxy-authorization" header entry _and_ use the proxy url in the form does it work...which is weird.

Issues with proxy authentication

2021-12-17 Thread xioren
I am having issues authenticating with a specific proxy provider. let someProxy = newProxy("http://hostname:port";, "username:password") let client = newHttpClient(proxy=someProxy) echo client.getContent("http://ipv4.icanhazip.com";) Run While this code works wi

looking for some insight into HttpClient and proxy authorization

2021-12-17 Thread xioren
I'm having some trouble getting a proxy to work that requires authorization. I'm trying to get my head around how authorization works in httpclient so I can fix the issue. let someProxy = newProxy(url=proxyUrl, auth=myAuth) let client = newAsyncHttpClient(headers=newHttpHeaders(

Nim with curly brace and tab

2021-12-17 Thread xioren
I understand but as @Araq already mentioned, maintaining two separate parsers for the language is untenable and simply an unreasonable request.

What am I missing here? (async)

2021-12-17 Thread xioren
Thanks for the reminder, I thankfully did in my real code but clearly it is not habitual for me to do so.

What am I missing here? (async)

2021-12-17 Thread xioren
Ah that makes sense. Thanks!

What am I missing here? (async)

2021-12-17 Thread xioren
Quick question. Making testType a ref object fixed the issue but does it still need to be a var? The code still works when I use let which is slightly confusing to me. e.g.: import asyncdispatch type testType = ref object testField: bool proc testP

Nim with curly brace and tab

2021-12-17 Thread xioren
A better c++ is rust. A lot of people, myself included chose Nim in part **because** of its clean syntax. I don't see the rational of choosing a language where you don't like the syntax and then expecting them to make changes to accommodate your personal preference.

What am I missing here? (async)

2021-12-17 Thread xioren
I see, thanks.

What am I missing here? (async)

2021-12-17 Thread xioren
import asyncdispatch type testType = object testField: bool proc testProc(thing: var testType) {.async.} = if not thing.testField: thing.testField = true var x: testType waitFor testProc(x) Run

The Cylons have a Plan

2021-11-21 Thread xioren
> Yes, but right now there is no plan to "ship" a "distribution" with the > "approved" packages anymore. Instead we'll simply link to them in our > official docs. I just can't fathom taking a well rounded stdlib and turning it into dependency hell. Depending on the extent this is done, this alo

Best way to turn byte array into int?

2021-11-05 Thread xioren
Think this will work for me, thanks.

Best way to turn byte array into int?

2021-11-05 Thread xioren
Playing around with the new urandom proc from sysrand and am wondering how best to go about turning the returned byte array int a single int. I have a couple ideas but none seem like "the right way".

Hacktoberfest 2021 Megathread

2021-10-05 Thread xioren
rn

How to make Nim more popular

2021-08-20 Thread xioren
I agree. I started to make some pull requests adding examples to the docs and the response I got was "most things are self explanatory"; which is easy to say for someone who knows the language inside and out.

A look at Dart's null safety syntax

2021-08-17 Thread xioren
I prefer Nims explicitness. String? abc; Run Makes me cringe.

Possible to have a reference in a seq of another type?

2021-08-02 Thread xioren
Right well I didn't think it would be of much benefit as I solved MY problem, but not the problem in the op. Basically figured out I can pass the dynamically changing string as an independent argument, rather than adding it to the seq of other strings. Not the way its done in the JavaScript, but

Possible to have a reference in a seq of another type?

2021-08-01 Thread xioren
Well either way, I just had an epiphany and solved the issue lol. Thanks for the input.

Possible to have a reference in a seq of another type?

2021-08-01 Thread xioren
Yes but i'm converting compiled javascript code to nim code (reverse engineering youtubes cipher logic) and thats what they do in the js; so im trying to write something functionally equivalent in nim.

Possible to have a reference in a seq of another type?

2021-08-01 Thread xioren
Yeah I suppose a seq of refs would work but I am in the debug phase after several days of coding and id have to go back and rework a lot if I did that which would not be fun. -.-

Possible to have a reference in a seq of another type?

2021-08-01 Thread xioren
Something along the lines of var x: ref string new(x) x[] = "blue" var y = @["blue", x[], "blue", x[]] # @["blue", "blue", "blue", "blue"] x[] = "red" # @["blue", "red", "blue", "red"] Run In practice I have a seq of strings but I need one s

Nim GDB Youtube Video

2021-07-31 Thread xioren
also tried to download the video but it was not possible Run [:)](https://github.com/xioren/uvd)

random async exception when downloading

2021-07-23 Thread xioren
No, Debian testing has 1.4.2.

random async exception when downloading

2021-07-23 Thread xioren
I have a youtube downloader that works fine 99% of the time however sometimes, seemingly at random the download will fail with this (async) error: Error: unhandled exception: No handles or timers registered in dispatcher. [ValueError] Run Any ideas on what might cause th

Don't understand macros compile error

2021-07-12 Thread xioren
I am trying to learn about macros and get the incredibly vague error Error: request to generate code for .compileTime proc: newProc Run when trying to compile: discard newProc(name=newIdentNode("test"), params=[ newId

Unable to create a flowVar

2021-07-06 Thread xioren
One way you could implement async: import json, httpclient, asyncdispatch, strformat type Guild = object name: string desc: string inviter_name: string inviter_discrim: string channel: string var gui

Unable to create a flowVar

2021-07-05 Thread xioren
Using async instead of threads might be a better approach but you can try compiling with --gc:arc and changing: guilds.add(some_guild) Run to guilds.add(^some_guild) Run fyi im no expert with Nim threading so take it with a grain of salt.

Idea: 30 days of Nim learning resource

2021-06-26 Thread xioren
Nothing concrete. First wanted to see how much interest there is. But broadly speaking I think first deciding what core Nim concepts are essential and need to be covered and then coming up with an outline for the 30 days. Then the task of writing up a lesson for each day.

Idea: 30 days of Nim learning resource

2021-06-26 Thread xioren
I've been thinking over how to make Nim more accessible to new users and expanding the available learning resources and I think a community driven Nim version of [30-Days-Of-Python](https://github.com/Asabeneh/30-Days-Of-Python) (or similar) would be an invaluable resource. I wanted to gauge com

Using streams in Nim?

2021-06-26 Thread xioren
Theres not much outside of whats already in the [docs](https://nim-lang.org/docs/streams.html)? I've been a proponent of adding more examples to the docs but that seems to be an uphill battle.

Why does Nim compiler allways depends on another's language compiler?

2021-06-23 Thread xioren
> What problem do you have that would be solved more efficiently by generating > "lower level" code ? Honestly I don't particularly care as it doesn't effect me but to play devils advocate, and correct me if i'm wrong but by compiling to another language, doesn't that limit Nims performance to

Why does Nim compiler allways depends on another's language compiler?

2021-06-21 Thread xioren
If i'm not mistaken it made sense for compatibility reasons back when Nim was originally written but think I saw Araq say somewhere that eventually it will compile directly to machine code with something like llvm, but don't quote me on that.

Noob var/let question

2021-06-21 Thread xioren
This is quite a useful read

Noob var/let question

2021-06-21 Thread xioren
Yeah the first example I just made up on the cuff. I'm not really concerned about scope so much as optimal memory memory usage. I guess let would be preferable so that distinct contextual variable names can be used instead of a single var.

Noob var/let question

2021-06-21 Thread xioren
Is there any practical difference between: var n: int for i in 0..100: n = i Run and for i in 0..100: let n = i Run In practice i'm making multiple http requests and am unsure if assigning each request body to a single var i

Improving the documentation: Roadmap, community engagement.

2021-06-12 Thread xioren
As someone who has spent the last half year learning Nim and used the docs heavily, I'm 100% for adding more examples and explanations. I'm of the opinion that a strong accessible standard library is of very high importance to a language. Yes third part libraries are important too but third part

Catching shell resizes (asynchronously?)

2021-06-01 Thread xioren
SIGWINCH looks promising, thank you.

Catching shell resizes (asynchronously?)

2021-05-26 Thread xioren
I have a program that outputs continuously to the terminal (think cmatrix) and I need to immediately catch terminal resizes to reset the output, but cant figure out how to do it properly. I need something to the effect of: while true: if terminalWasResized(): break

How to escape colon in the '&' macro in strformat ?

2021-05-22 Thread xioren
Ah I see what you mean. That example makes more sense.

How to escape colon in the '&' macro in strformat ?

2021-05-22 Thread xioren
That's quite an odd thing your trying to do. Like kaushalmodi strformat is for embedding variables into string. import strformat let x = "url = http://example.com"; echo &"""{x}""" Run

At what likelihood do likely/unlikely become useful?

2021-05-18 Thread xioren
Fair enough, thanks.

At what likelihood do likely/unlikely become useful?

2021-05-18 Thread xioren
I'm going through old code seeing where I can optimize and am unsure when adding "likely" or "unlikely" is appropriate. Would any likelihood above 50% benefit from "likely"? 75%? 90? What is the cutoff?

Nim 2.0 -- thoughts

2021-05-15 Thread xioren
> Gzip not part of standard lib, DLL hell on windows with 32/64 bit mismatch. > > Using zlib on windows is hard due to DLL issues. Nim's HTTP stack can’t deal > with Gzip bodies. Just use the excellent zippy library instead. Yes, please. We need some compression libraries in the stdlib.

How to make Nim more popular

2021-05-14 Thread xioren
Four articles about rust on the front page of [ycombinator](https://news.ycombinator.com/) Just sayin...

How to make Nim more popular

2021-05-12 Thread xioren
I'd have to disagree. While it is true that having strong libraries is essential to the survival and adoption of a language, they do no good if no one knows about the language in the first place. Like it or not being talked about on social media is a great way to bolster visibility. Nim is a fan

Best way to check for Json null values?

2021-05-10 Thread xioren
import json let x = parseJson("""{"audio": null}""") if x["audio"] != newJNull(): doStuff() Run Another possible approach.

Best way to check for Json null values?

2021-05-10 Thread xioren
perfect, thanks

Best way to check for Json null values?

2021-05-10 Thread xioren
I have a situation where I recieve Json from the web and sometimes the "audio" key has a value and sometimes its "null". What would be the "proper" way to test "null"? I have: if $response["audio"] != "null": do stuff Run but this doesn't seem right.

How to http post nested data?

2021-05-05 Thread xioren
I need to use json but the post procs only accept MultipartData/Entries.

How to http post nested data?

2021-05-05 Thread xioren
I am trying to make a post request with nested data, {"keyA": {"keyB": "valueB"}} Run however MultipartEntries only accepts strings. MultipartEntries = openArray[tuple[name, content: string]] Run Am I missing something?

learn Nim regular expressions - regex, re , NRE

2021-05-01 Thread xioren
I won't argue which is better but I always believe in starting with the stdlib of a language then progressing to third party projects if needed.

How to make Nim more popular

2021-05-01 Thread xioren
I've thought about it a lot. A few things come to mind: 1: A larger presence on Youtube. Both in terms of tutorials and videos such as "Best languages to learn 2021" that get tons of views. Easier said than done but getting Nim featured on some bigger channels would go a long way. 2: Lowest pos

  1   2   >