Re: Python transpiler
Ive read that parsing the .PYC is even easier, because some constructs are "expanded" there, like `:=` is a normal assign, `@decorator` is a normal function, and so on, I dont know if true tho.
Re: Python transpiler
I created the repo because people were asking for **an Example** on how to do that, it is an example it was not meant to be complete. ...but if people are interested on making a real working one, we can team-up or whatever. :)
Re: Why does wrapping the code in a top level procedure make it faster?
Otherwise all variables are global. I dont know whats a cinoaiker.
Connection-Pooling Compile-Time ORM
[https://juancarlospaco.github.io/nim-gatabase](https://juancarlospaco.github.io/nim-gatabase) * `0` Dependency, uses `system.nim` only, everything is done via `template` and `macro`, Docs, Examples, CI, etc etc (`db_postgres` for Postgres but Optional) * Running compile-time and JavaScript: [https://github.com/juancarlospaco/nim-gatabase/runs/820885295#step:13:49](https://github.com/juancarlospaco/nim-gatabase/runs/820885295#step:13:49) * Running static connection Array 100 Postgres: [https://github.com/juancarlospaco/nim-gatabase/runs/820885295#step:14:102](https://github.com/juancarlospaco/nim-gatabase/runs/820885295#step:14:102) :)
Re: advanced `nim doc` use
`--docInternal` ?.
Re: NvP: s = s & 'x'
Use a `main()` for bench.
Re: Help, I can't return an openarray
Return an array?.
Nim embedded inside Python
[https://github.com/juancarlospaco/nimscript4python#nimscript4python](https://github.com/juancarlospaco/nimscript4python#nimscript4python) Done after the talk of Nim Conf 2020.
Re: First take: parameters
Something like this? [https://github.com/Yardanico/nimpylib/blob/master/src/pylib/print.nim#L13](https://github.com/Yardanico/nimpylib/blob/master/src/pylib/print.nim#L13)
Re: First take: parameters
I dont understand what the problem is, if any.
Re: Unclear (for Python people) import behavior. And how to deal with it
* [imports](https://github.com/nim-lang/Nim/wiki/Nim-for-Python-Programmers#Imports) * [Objects](https://github.com/nim-lang/Nim/wiki/Nim-for-Python-Programmers#Objects) * [I recommend read it completely](https://github.com/nim-lang/Nim/wiki/Nim-for-Python-Programmers#table-of-contents)
Re: Perf: Table.del(key)is taking 85% of my code's time
`--opt:size` can me stuff slower, it changes file size for speed.
Re: Nim's popularity
[https://tjpalmer.github.io/languish/#y=mean=nim%2Ccrystal%2Craku%2Chaxe%2Celm%2Cd%2Cwebassembly%2Cpurescript%2Cracket%2Cllvm%2Cpony%2Cred%2Cgdscript%2Cmathematica%2Cvisual+basic%2Cprocessing](https://tjpalmer.github.io/languish/#y=mean=nim%2Ccrystal%2Craku%2Chaxe%2Celm%2Cd%2Cwebassembly%2Cpurescript%2Cracket%2Cllvm%2Cpony%2Cred%2Cgdscript%2Cmathematica%2Cvisual+basic%2Cprocessing)
Re: No `[]` iterators for collections?
Theres no `x`.
Re: Automated Nim Packages Security Audit
**Help Wanted** If you develop some kind of library that does Plotting, Charts, Visualizations, etc on Nim, would be nice to have some cool visualizations with the dataset of those audit logs!. Theres lots of data now... :)
Python PIP for Nim
`nimble_install` is 1 Python package that can install any Nim package directly from PIP, can be used from `requirements.txt` or command line terminal, it can install any number of packages by name separated by commas, no maintenance required, can install Nimpy from PIP, can install the Compiler from PIP, etc. [https://github.com/juancarlospaco/nimble_install#use](https://github.com/juancarlospaco/nimble_install#use) :)
Re: Lambda syntax is awkward
Python lambda is single line only. :)
Re: Lambda syntax is awkward
[https://github.com/Yardanico/nimpylib/blob/master/src/pylib.nim#L161](https://github.com/Yardanico/nimpylib/blob/master/src/pylib.nim#L161)
Re: What is -> in Nim?
[https://nim-lang.github.io/Nim/sugar.html#-%3E.m%2Cuntyped%2Cuntyped](https://nim-lang.github.io/Nim/sugar.html#-%3E.m%2Cuntyped%2Cuntyped) Syntax sugar for a function, it is an arrow.
Re: Nim Cheatsheet PDF (English+Spanish+Latex)
That was the idea, use it as template for more cheatsheets or other stuff. :)
Re: Nim Cheatsheet PDF (English+Spanish+Latex)
Fixed. Maybe we need that overload (???) ;P
Re: VSCode debug: strings and booleans are ugly
`assercho` is `assert` and `echo` combined, with extra Debug, it shows the Nim code line and the C code line, works with bool and string. [https://github.com/juancarlospaco/nim-contra](https://github.com/juancarlospaco/nim-contra)
Nim Cheatsheet PDF (English+Spanish+Latex)
* [https://www.overleaf.com/read/svnxffsjvscy](https://www.overleaf.com/read/svnxffsjvscy)
Re: Can I "prune" directories with walkDirRect?
... but walkPattern() does take a glob pattern. :)
Re: Setting up a FreeBSD VM for Nim development
Would be nice to have this on the Wiki. :)
Re: Archived Nimble package
Create your own repo with fixes and updates and make a pull request on nim-lang/packages
Re: A good word for idiomatic nim?
I read the 2 just Ok anyway. :P
Re: Exporting json objects to Javascript, how can I make this code more terse?
Compile with `-d:danger` and put name on everything relevant with `{.exportc.}`. Your code will probably go thru a Minifier anyways, so maybe better focus on tests and documentation.
Re: Typography update - now it can render 99% the Google Fonts ttf.
**Awesome!** , now it needs some kind of DSL to just write Latex-like syntax directly on Nim code, kinda like Rmarkdown but better. :P
Re: Automated Nim Packages Security Audit
I agree, a malicious actor can always just kick your door and hit you with a huge wrench.
Re: Using existFile or existDir correctly.
You seem correct, if I understand the question. :)
Re: Understanding "Error: cannot evaluate at compile time"
type B[S: static[int]] = object template foo(size: static[int]): auto = B[size]() echo foo(16).repr Run Works on my machine
Automated Nim Packages Security Audit
[https://github.com/juancarlospaco/nim_packages_security_audit#fully-automated-nim-packages-security-audit](https://github.com/juancarlospaco/nim_packages_security_audit#fully-automated-nim-packages-security-audit) **Examples:** * [https://github.com/juancarlospaco/nim_packages_security_audit/blob/master/z/zip.log](https://github.com/juancarlospaco/nim_packages_security_audit/blob/master/z/zip.log) * [https://github.com/juancarlospaco/nim_packages_security_audit/blob/master/s/sass.log](https://github.com/juancarlospaco/nim_packages_security_audit/blob/master/s/sass.log) * [https://github.com/juancarlospaco/nim_packages_security_audit/blob/master/w/webgui.log](https://github.com/juancarlospaco/nim_packages_security_audit/blob/master/w/webgui.log) More fresh data coming up everyday. :)
Re: NOOB: Few simple questions ...
import sugar let seto = {1, 2, 3} let seqo = sugar.collect(newSeq): for item in seto: $item echo seqo Run let seto = {1, 2, 3} let seqo2 = block: var lst: seq[string] for item in seto: lst.add($item) lst echo seqo2 Run Theres also `sequtils.toSeq`. Depending the use case it can be improved for sure. On Nim "methods" are like free floating functions, I dont think is possible to list all of them, because you can create custom ones, and theres functions that can take `any` or `T`, return `auto`, etc. If you want like an index to see which functions are on stdlib available, then CTRL+F on [https://nim-lang.github.io/Nim/theindex.html](https://nim-lang.github.io/Nim/theindex.html)
Re: Nim's strutils.split() slower than Python's string split()?
Compile with `-d:danger`.
Re: Help understanding simple string pointer indexing example
I dont troubleshoot the code, but from a quick look, basically the pointer is empty uninitialized. Kinda like doing `nil[1] = 'e'`
Re: How to return user defined type from a thread spawned?
import threadpool type Person = ref object name: string age: int proc worker(): Person = return Person(name: "john", age: 42) proc main() = for i in 0 .. 10: var t = spawn worker() echo type(t) sync() main() Run Prints `FlowVar[Person]`, I hope is what you needed...
Re: generate c++ code from .nim file
You can use a C++ code beautifier, like astyle, and skip the mangling with exportc pragma, but for reading only not for code thats actually used.
Re: Compile-time string obfuscation
This cool code worth a package IMHO.
Re: String constant concatenation
This is a bug Python never fixed, because on Python it can implicitly concatenate different strings, like F-Strings, non-Unicode strings, Raw strings, ASCII strings, etc, often a crash at run-time is the result.
New GUI Framework
New GUI Framework/toolkit/thingy: * [https://juancarlospaco.github.io/webgui](https://juancarlospaco.github.io/webgui) * [https://github.com/juancarlospaco/webgui/tree/master/examples](https://github.com/juancarlospaco/webgui/tree/master/examples) Each push is built with --panics:on --gc:arc
Re: Where can I deploy a Nim web application? Is there a "NimAnywhere" yet?
I think is kinda the reverse, Nim may run everywhere that can barely run C or JS. :)
Re: Web Scraping
[https://github.com/juancarlospaco/faster-than-requests#scraper](https://github.com/juancarlospaco/faster-than-requests#scraper)
Re: Nim programming book for kids
PDF Download would be cool. Awesome work!. :D
Re: Custom default for type
[https://nim-lang.github.io/Nim/manual.html#implementation-specific-pragmas-codegendecl-pragma](https://nim-lang.github.io/Nim/manual.html#implementation-specific-pragmas-codegendecl-pragma) ? Not sure if I understand the question tho.
Re: Nim Bugs
New version of nimbug with improvements from user feedback, feel free to give it a try. :)
Re: Nim 2, Nim 2020, and all that
Id say you can just check the `changelog.md` of `devel` today, to see whats coming up. :)
Re: {.this: self.} pragma
Std Lib `with` [https://nim-lang.github.io/Nim/with.html](https://nim-lang.github.io/Nim/with.html)
Nim Bugs
* [https://github.com/juancarlospaco/nimbug#nimbug](https://github.com/juancarlospaco/nimbug#nimbug) * `nimble install nimbug` Real life use case: * [https://github.com/nim-lang/Nim/issues/13722#issue-585682299](https://github.com/nim-lang/Nim/issues/13722#issue-585682299)
Re: Handling case in getSectionValue in parsecfg
`parseBool()`
Re: How to start a Jester server?
`nim c -r file.nim` _" Works on my machine"_ :)
Re: template expressions
Karax ?.
Re: Documenting one liner
proc createMap(this:VS):ptr VSMap = this.vsapi.createMap() ## \ ## Creates a new property map. It must be deallocated later with freeMap(). Run :)
Re: Arraymancer and --gc:arc
Report the Bug maybe.
Re: Some rant about nim
$ cat example.nim type iX = range[1..5] var a: iX = 3 var b = 10 a = b $ nim c -r -d:release -d:danger --rangeChecks:on example.nim Hint: 8022 LOC; 0.029 sec; 11.656MiB peakmem; Dangerous Release build; proj: Hint: /home/juan/code/temp1/example [Exec] fatal.nim(64)sysFatal Error: unhandled exception: value out of range: 10 [RangeError] Run
Re: Some rant about nim
It is _not_ a macro. :)
Re: Some rant about nim
That is literally an example on the documentation: [https://github.com/nim-lang/Nim/wiki/Nim-for-Python-Programmers#Templates](https://github.com/nim-lang/Nim/wiki/Nim-for-Python-Programmers#Templates)
Re: Some rant about nim
Maybe with all that knowledge you can help improve things, send PR to whatever you think you can improve!. :D
Re: How to declare a thread-global variable?
Try `--gc:go`.
Re: How to declare a thread-global variable?
Boehm is not about ownership models. Boehm was _not_ recently added nor removed. `--gc:boehm` refers to [https://en.wikipedia.org/wiki/Boehm_garbage_collector](https://en.wikipedia.org/wiki/Boehm_garbage_collector) On internet theres some articles saying is terribly slow in theory, but for some reason on Nim in actual usage is very fast, sometimes faster than Mark & Sweep. Nim can do thread with boehm.
Re: How to declare a thread-global variable?
Try `--gc:bohem`.
Re: Doubt! Proc and import
Just put all import at top of file and should work. Nim is Compiled, all import are resolved at compile time.
Re: Is this possible?
const some_module {.strdefine.} = "some_module" template makeAnImport(module: static[string]): untyped = import module makeAnImport(some_module) Run :)
Re: Templates and imports
[https://github.com/nim-lang/Nim/wiki/Nim-for-Python-Programmers#Templates](https://github.com/nim-lang/Nim/wiki/Nim-for-Python-Programmers#Templates) Far from perfect, but better than nothing, Templates explanation.
Re: How does nim infer that a cpu on windows is 64-bit
All PC hardware is 64Bit nowadays, since several decades ago, everything should be 64Bit.
Re: Styling Karax app
[https://jenil.github.io/bulmaswatch](https://jenil.github.io/bulmaswatch) Spectre is awesome but no themes.
Re: Nim's float issue?
`round` is Deprecated.
Re: func/proc blocks
imports can be an indented block.
Re: func/proc blocks
But you can have func inside func.
Nim new Playground/Pastebin of Spanish group
Hello!!, so we created a new web for our tiny Spanish-speaking community here, thats also a Pastebin, thats also a Playground, has some good features like 120 Examples, machine code and AST of your code and others, we added QR Code SVG URLs recently too, feel free to visit, should not break too much on mobile but we dont have Designers, and sorry about the "Spanglish": [http://argentina-ni.ml](http://argentina-ni.ml) :)
Re: How to package a nim program in an APK file
[https://github.com/akavel/hellomello#helloworldapk-built-with-nim-and-no-android-studio](https://github.com/akavel/hellomello#helloworldapk-built-with-nim-and-no-android-studio)
Re: soy nuevo en nim
Welcome!. Hay un grupo de [Chat Spanish](https://t.me/NimArgentina) , we also understand English.
Re: Why whitespace?
I agree, but can be useful, imagine that you have a char exclusively for indentation, then code Minification and Prettify can be super simplified, and even maybe Parsing too.
Re: Why whitespace?
True, but theres no dedicated Unicode codepoint for Indentation, then the most close is a generic space like the space character, would be interesting to have a Indentation dedicated Unicode codepoint, considering we got Poo on Unicode.
Re: Why whitespace?
Tabs are for Tabular Data by definition, source code is not Tabular Data.
Re: Zig as C compiler for Nim. How to feed him the code
So does GCC.
Re: Nim Compiling to js
[https://github.com/nim-lang/Nim/wiki/Nim-for-TypeScript-Programmers#table-of-contents](https://github.com/nim-lang/Nim/wiki/Nim-for-TypeScript-Programmers#table-of-contents)
Re: How to print output from two echo in a single line?
echo "hello", " ", "world" Run Or `writeLine(stdout, "hello", "world" )`
Re: Comparison Rust vs Nim binary sizes for IOT applications (just an FYI if you're interested)
If you want to strip the Nim binary a little bytes more, theres some strip options you can use, they are really long, but I contributed the improvements here on the "strip" task: [https://github.com/kaushalmodi/nim_config#list-available-tasks](https://github.com/kaushalmodi/nim_config#list-available-tasks)
Re: Suggestions for optimization?
const file = staticRead("dict.txt").strip.splitLines
Re: Parallel statement: procedure returning string
I am not sure I understand your code nor what you want to accomplish, but heres the same code returning string everywhere as you said: import strutils, math, threadpool {.experimental: "parallel".} proc term(k: float): string = var f = 4 * math.pow(-1, k) / (2*k + 1) result = $f proc pi(n: int): string = var ch = newSeq[string](n+1) parallel: for k in 0..ch.high: ch[k] = ^ spawn term(float(k)) result = ch.join echo pi(5000) Run Just need to make the math make sense. Flowvar is like a Promise on JavaScript or like a Future on Python, **but for parallel.** Like a container type thingy, to put other thingies inside, as they pop into existance at run time.
Re: Extended routes that return json doesn't compile
Add `import json` everywhere and try again, the compiler will tell you if some import is not needed and then remove it.
Re: Change server name in Jester
Adding a `{.strdefine.}` should not be that complicated. 樂
Re: Can someone explain how to use the ".since" pragma?
[https://github.com/nim-lang/Nim/blob/92010becbe00b338abd4d9ef1be17739be8f69b8/lib/system/inclrtl.nim#L52](https://github.com/nim-lang/Nim/blob/92010becbe00b338abd4d9ef1be17739be8f69b8/lib/system/inclrtl.nim#L52) It is just a `when` block. Similar to `when defined(release)`, but using the integers from the version number as conditional. template since(version, body: untyped) {.dirty.} = when (NimMajor, NimMinor) >= version: body Run
Re: Template with dirty pragma within an async context
Change template to proc with async and inline ?.
Re: Is "danger" define supposed to also define "release"?
Expected. (?)
Re: Help: Zip (Creating / Opening)
zip package from nimble. nimarchive package is also nice alternative.
Re: Nim 1.0.6 is out!
`devel` is never published as an `stable` version by definition.
Re: Nim macro help
`import macros`
Re: Code golfing in Nim
Person on Top of ranking should be emitting C++ or something... 樂
Re: conditional compilation from macro-generated code?
scope (?).
Re: Fizzbuzz game
[https://github.com/code-golf/code-golf/issues/6#issue-259618460](https://github.com/code-golf/code-golf/issues/6#issue-259618460) & [https://github.com/code-golf/code-golf/issues/34#issue-322536856](https://github.com/code-golf/code-golf/issues/34#issue-322536856)
Re: Fizzbuzz game
[https://code-golf.io/scores/all-holes/nim](https://code-golf.io/scores/all-holes/nim) & [https://code-golf.io/fizz-buzz#nim](https://code-golf.io/fizz-buzz#nim)
Re: future of htmlgen
It is not removed. htmlgen added MathML, allows to use Latex on the web.
Re: how can I use enum for collection of types
type Foo = int | bool assert Foo(42) is Foo assert Foo(true) is Foo Run Variant Type is probably what you are looking for.
Re: Naming conventions - need leading underscore
But Nim wont use underscore for private vs public. How underscores improve readability?. `let __variable = 42` Vs `let variable = 42`.
Re: Is this expected behaviour?
Start the Deprecation of `{.compileTime.}` ?.
Re: How do you add switched to the build task?
switch("define", "ssl")
Re: Introducing --gc:arc
Remember to add it to the `changelog.md` and to [https://nim-lang.github.io/Nim/gc.html](https://nim-lang.github.io/Nim/gc.html) is an awesome work to not be mentioned. :)
Re: understanding risk of shadowing
Nothing wrong with `n`. All `proc` and `func` have an automatic `result` variable created from the type on the signature of the function. Change `var result =` to `result =`