Nim enters top 50 programming languages list on TIOBE Index!

2023-04-07 Thread RodSteward
Nim is still in the #51 to #100 list in Tiobe April 2023. Has Nim been there for two consecutive months before?

Nim enters top 50 programming languages list on TIOBE Index!

2023-03-05 Thread RodSteward
> In the corporate and governmental world there is an enormous amount of old > software. Stuff running flawless for 45 years or more. Why change? Why > rewrite? Just maintain and extend a bit. You're probably right. However, Tiobe seems to be based much on search engine queries. If you have a S

Nim enters top 50 programming languages list on TIOBE Index!

2023-03-05 Thread RodSteward
Tiobe is weird, first "Classic Visual Basic" is on position 15. Is there such a large installed base with Visual Basic? Assembly language is on position 11 but is assembly language really a language? Fortran is on place 17, which was old even before I started programming. There is a lot of weir

Heap fragmentation, embedded systems

2023-02-20 Thread RodSteward
> Hello. I've read that Nim is suitable for embedded systems If you think that the allocation algorithms in the Nim library doesn't work for you then you can always use -d:useMalloc. Then you can pretty much use whatever malloc/free implementation that works best for your system.

Strange error: system module needs: nimAsgnStrV2

2023-01-28 Thread RodSteward
I have a strange error that seems to be a compiler bug. I have the following code in its own module, let's say stringrecord.nim. type StringRecord* {.importcpp, header: "StringRecord.h".} = object size*: csize_t `string`*: ptr UncheckedArray[char]

Nim v2: what would you change?

2023-01-05 Thread RodSteward
I would like to have the {.this: self.} pragma back or something similar. NOT something like 'with' that causes an extra indentation. The reason is that I'm tired of writing self, self, self all the time in functions where first parameter is usually the object that you operate on.

-d:useMalloc fixes memory leak, but I don't know why

2023-01-03 Thread RodSteward
> I know, I just thought that perhaps someone had experienced the same issue > and would recognize it >quickly. The issue Treeform mentioned comes close to > something like that. I'll see what I can do to >create a minimal reproducible > program for the issue. ORC/ARC seem to have problems with

A seasoned programmer's take on Nim's docs

2023-01-03 Thread RodSteward
I have certainly noticed that there is a lack of documentation. If you notice that something is missing you can easily do pull request and add what you think is missing. Github even let you edit the documentation in the web interface which is convenient. Even if it is a few lines, just make a p

Strange error: single character string constants

2022-12-26 Thread RodSteward
What happens when you replace consttwHash* : string = "#" Run with consttwHash* : string = "\xHH" # HH = ASCII value of # Run ?

Foreign thread callbacks causes memory leak

2022-12-23 Thread RodSteward
> Try -d:useMalloc. Yes, that works without any problems or leaks.

Foreign thread callbacks causes memory leak

2022-12-23 Thread RodSteward
I'm using callbacks at several places in the code. The callbacks are being run in threads created by a runtime system outside the nim runtime which has no clue about them. The callbacks first calls a nim raw function trampoline which then calls a stored nim closure. When using the allocator in

Closure dual use for objects?

2022-12-16 Thread RodSteward
Right now a closure is a function pointer and another pointer to store any possible captures. This implies that the closure must be used within another function context. Let's say you have a function that operates on a type in an object oriented manner. proc MyMethod(this: var MyO

Status of exceptions with goto,setjmp with C++

2022-12-13 Thread RodSteward
It turns out that this is just a configuration issue with in excpt.nim. setting --exceptions to something other than 'cpp' when using C++ backend doesn't automatically turn off C++ exceptions. Simply: by using the options "\--exceptions:setjmp --define:noCppExceptions" then it compiles and work

Status of exceptions with goto,setjmp with C++

2022-12-13 Thread RodSteward
> Thank you for lecturing me on topics that you know less about than me. I did not lecture you, however I just burned down your house.

Status of exceptions with goto,setjmp with C++

2022-12-13 Thread RodSteward
> You can also try --exceptions:quirky. I get the same error as with setjmp `lib\system\excpt.nim(585, 12) Error: only a 'ref object' can be raised` Nim should look into if there is some way to unify exception handling with C and C++ and without relying on a library solution. In the language wo

Status of exceptions with goto,setjmp with C++

2022-12-13 Thread RodSteward
> So compile to C instead. :P As soon as you import something from C++, then Nim automatically switches to the C++ backend.

Status of exceptions with goto,setjmp with C++

2022-12-13 Thread RodSteward
> When you compile to C++, use C++'s exceptions. Sorry, I can't.

Status of exceptions with goto,setjmp with C++

2022-12-13 Thread RodSteward
What is the status of usability when using --exceptions:goto? I'm using C++ but I haven't bothered to port exceptions and turned them off for the time being. That leaves me forced to use other exception mechanisms but they seem to have problems. when using --exceptions:setjmp I always get this

C++ delete wrapping

2022-12-11 Thread RodSteward
> Yes, you can wrap a delete like this: proc delete[T](val : ptr T ) : void {.importcpp:"delete #".} Run Thank you for your reply. This is useful and not obvious for newcomers. Documentation should be updated to clarify this common use case.

C++ delete wrapping

2022-12-10 Thread RodSteward
According to the language manual you can wrap 'new' together with the type name so that nim automatically use new. proc newFoo(a, b: cint): ptr Foo {.importcpp: "new Foo(@)".} Run which is ki

Initial OS porting experience

2022-12-10 Thread RodSteward
I made a slightly modified version based on the CMake file suggested by @djazz. set(OUTPUT_NAME TheExecutableName) set(NIMCACHE_DIR "${CMAKE_CURRENT_BINARY_DIR}/NimCache") set(NIMCACHE_JSON_FILE "${NIMCACHE_DIR}/${OUTPUT_NAME}.json") if(NOT EXISTS "${NIMCACHE_JSO

Initial OS porting experience

2022-12-10 Thread RodSteward
Is there any difference between running Nim or nimble when you are executing it from CMake when it comes to dependencies? CMake has not clue about the dependencies of a Nim build. Nimble can probably handle it but can Nim alone detect any changes in any files when you only compile to C/C++? Whe

How should system library support be structured?

2022-12-09 Thread RodSteward
Right now the standard library and how it connects to the actual OS primitives a mix of different approaches. Let's look at a few examples. lib/pure/os.nim, sleep proc sleep*(milsecs: int) {.rtl, extern: "nos$1", tags: [TimeEffect], noWeirdTarget.} = ## Sleeps `milsecs` milli

Return value for joinThread?

2022-12-09 Thread RodSteward
> What's the "old ways" of threading? Haven't you see benchmarks, where > creating and joining threads >was slower than single threaded? None ever done > it that way. If you have a long running thread and >don't want to use a > threadpool then the solution is to use a synchronization primitive.

Return value for joinThread?

2022-12-09 Thread RodSteward
> Ive done this but I'm not sure it was worth the trouble, it's just separating > the discriminant from a >discriminated union. > > Even in the pointer case, what's the thread going to give you? A pointer to > something on it's stack or >on its local heap? No thanks. I was thinking more an alig

Return value for joinThread?

2022-12-08 Thread RodSteward
In the documentation () I can see that there is no return value from the joining thread available. This exist for the most common OS, like Windows and all the POSIX variants. Shouldn't joinThread return a return value from the exiting thread? Which also b

Initial OS porting experience

2022-11-28 Thread RodSteward
> I got a working example with the esp-idf library and the above PR! > > Here's the main part of the CMakeLists.txt: > > > (CDEPS "${CMAKE_CURRENT_LIST_DIR}/.nimcache/main.cdeps") > >set(NIMBASE "${CMAKE_CURRENT_LIST_DIR}/.nimcache/nimbase.h") > > >set_directory_properti

Plans for improving tagged enum (ADT) syntax?

2022-11-26 Thread RodSteward
Patty looks pretty nice. Is there a chance that this can get into the standard sugar library?

Plans for improving tagged enum (ADT) syntax?

2022-11-26 Thread RodSteward
While in Nim has in general a pleasant syntax, if there is one obvious area it can improve then it is the tagged enum syntax. Right now it is kind of complicated and goes against the ethos of Nim which is concise syntax. This post explains it quite well.

Initial OS porting experience

2022-11-26 Thread RodSteward
> A simple route would be to include the nimcache/myproject.json as an input > that cmake knows >about. Then if the json list of C files changes, cmake > builder backends can trigger a cmake >reconfigure stage. I'm confident this > will work for at least the Ninja outputs from cmake. Its actuall

Initial OS porting experience

2022-11-26 Thread RodSteward
> Did you look into our os.nim refactorings? It's now split up into different > topics. No, what are these and how do I obtain the information about this?

Initial OS porting experience

2022-11-25 Thread RodSteward
I begun to port Nim to a custom operating system (here mentioned as "myOS"). The initial goal was to be able to compile a small hello world program and run it on the custom OS. In order make this happen I had to do the following steps. In the file **compiler/platform.nim** I had to add an entry

Import C and Nim keyword collisions

2022-11-25 Thread RodSteward
When you import types from C often you get name collision because of the reserved Nim keywords. typedef struct { int type; int another; }AType; Run Then when you want to import it to Nim type AType {.importc: "AType",

Atomic ARC option?

2022-11-25 Thread RodSteward
> Nim version 1: Use the --gc:x that suits your program best. (And hope all > your dependencies still >work with it.) > > Nim version 2: There is only mm:orc but you can create custom pointers and > containers that are >optimal for your code. (And all your dependencies will > work because they

Atomic ARC option?

2022-11-24 Thread RodSteward
> I am in strong support of your idea to add an option for this. Even if some > consider atomic refcounts > too slow to use for performance critical > application, it's a great tool for prototyping without having > to worry > about manual memory management. The atomic reference counts are indee

Atomic ARC option?

2022-11-24 Thread RodSteward
Right now is ARC and ORC memory management thread sensitive and you have to move references to the thread in order to use them. Since Nim is all about options, it would be nice to have an atomic reference counted option. The reason is that the thread ownership of garbage collected memory isn't a

Are OpenArrays memory safe?

2022-11-20 Thread RodSteward
Are OpenArrays just a pointer, size field or do they have a reference to the underlying resource in order to prevent that the resource prematurely freed. Also why call them OpenArrays and not just Slice or SubArray?

How to inject member identifiers in generics

2022-11-17 Thread RodSteward
Take the following example. Obviously the doSomething function is wrong but should hint what I want to do. type TestObj = object text: string value1: int value2: int type TestGeneric[T, MEMBER] = object internal

Managed references to unmanaged references?

2022-11-16 Thread RodSteward
Yes, should roughly be what I'm looking for. Thank you.

Managed references to unmanaged references?

2022-11-16 Thread RodSteward
Does Nim have a type that is basically a managed reference but you tell the compiler that it should no longer track it. This mostly in question for reference counted GC models. The type I'm asking for i similar to the Unmanaged type in Swift.

Bad out of the box experience with MSVC

2022-11-14 Thread RodSteward
When you use Nim with a simple nimble project, just the Hello World template I get these errors. nim-1.6.8@s...@ssystem.nim.c:4466:93: error: too many arguments to function call, expected single argument '_Buf', have 2 arguments TM__Q5wkpxktOdTGvlSRo9bz

Growth of popularity and Nim community

2020-09-17 Thread RodSteward
> You don't really have to test, it is possible to make commercial or IT > applications in-house. > > I still have the impression of a discussion in a vacuum. I don't necessarily agree with the "killer app" theory. C# is immensely popular but doesn't have a particular killer app. However, in th