Re: Search for the dialog library
On Sunday, 15 October 2023 at 23:01:05 UTC, Alexander Zhirov wrote: On Sunday, 15 October 2023 at 21:46:44 UTC, Dmitry Ponyatov wrote: Maybe it's time to port the old warm tubby Turbo Vision into the glorious D lang? https://github.com/magiblot/tvision Since there was a conversation about the implementation of the wrapper, it is easier to write a wrapper for the `dialog` library, in fact, which is probably what I will do. I'll share a link here a little later. If anyone wants to help, it will be very cool! I think this library can be useful to many people. Porting is also possible now pretty easy with the tools mentioned. Yesterday I ported a small project in C to D in 10 minutes using ctod + manual fixes. Anyway, whatever you choose, remember to put it on dub ❤️
Re: Forcing my module to be initialized first
On Monday, 16 October 2023 at 04:26:32 UTC, Paul Backus wrote: On Monday, 16 October 2023 at 03:31:13 UTC, dan wrote: I have some code that i would like executed before anything else is. The code is to set an environment variable which is used by a library. I'm trying to find some way to avoid setting the environment variable on the command line, or in any shell script or initialization file. I think the place to put such code would be in a 'static this' inside a module. So i need some way to force my module to be initialized first, ahead of all others. You may find this article enlightening: https://devblogs.microsoft.com/oldnewthing/20050607-00/?p=35413 Hi Paul, Thanks for the link. It was funny, and for sure too many cooks spoil the broth. I don't think that applies here, since i'm just trying to tweak the initialization order, and i'm the only programmer involved. Of course, i guess all sinners try to justify their wrongdoing --- hope i'm not doing that here!! Thanks for your reply. :) dan
Re: Forcing my module to be initialized first
On Monday, 16 October 2023 at 03:33:55 UTC, Richard (Rikki) Andrew Cattermole wrote: On 16/10/2023 4:31 PM, dan wrote: I suppose if i could figure out a way to make all other modules depend on my module this would happen, but the module which uses the variable i want to set is in some already-compiled dynamic library that i would prefer not to touch. If its in a shared library, then that shared library gets setup prior to your binary. There is nothing that you can do. You gotta override rather than initialize. Thanks Rikki. I was wrong in my statement of the problem: it is not a dynamic library, but rather a static library, libgtkd-3.a. I apologize for being so careless. libgtkd-3.a throws an exception before main is reached, in the Loader.d file, in a method with signature 'public static void loadLibrary(string library)'. That method is used trying to load a library which really is dynamic, libatk-1.0.0.dylib. That library is in my system, among the Mac ports files, in a standard place, namely /opt/local/lib. I can set the environment variable GTK_BASEPATH to help it out, and that works, but i would like to do all of this inside the executable rather than outside the executable. The Loader.d file depends on std.process. So, given that i was wrong and it is not a dynamic library i'm trying to get in ahead of, but a static one, is there a way to execute a small snippet of code after std.process is initialized, but before any other code (such as Loader.d) uses it? Thanks in advance for any ideas. dan
Re: Forcing my module to be initialized first
On Monday, 16 October 2023 at 03:31:13 UTC, dan wrote: I have some code that i would like executed before anything else is. The code is to set an environment variable which is used by a library. I'm trying to find some way to avoid setting the environment variable on the command line, or in any shell script or initialization file. I think the place to put such code would be in a 'static this' inside a module. So i need some way to force my module to be initialized first, ahead of all others. You may find this article enlightening: https://devblogs.microsoft.com/oldnewthing/20050607-00/?p=35413
Re: Forcing my module to be initialized first
On 16/10/2023 4:31 PM, dan wrote: I suppose if i could figure out a way to make all other modules depend on my module this would happen, but the module which uses the variable i want to set is in some already-compiled dynamic library that i would prefer not to touch. If its in a shared library, then that shared library gets setup prior to your binary. There is nothing that you can do. You gotta override rather than initialize.
Forcing my module to be initialized first
I have some code that i would like executed before anything else is. The code is to set an environment variable which is used by a library. I'm trying to find some way to avoid setting the environment variable on the command line, or in any shell script or initialization file. I think the place to put such code would be in a 'static this' inside a module. So i need some way to force my module to be initialized first, ahead of all others. I suppose if i could figure out a way to make all other modules depend on my module this would happen, but the module which uses the variable i want to set is in some already-compiled dynamic library that i would prefer not to touch. Alternatively, is there some entry point besides main that i could use, that executes before main and before any module initialization is done? (Is it possible to get in before the d runtime starts?) Although i would prefer to code in d, it would be ok to do it in c. This is on MacOS (Catalina) in case that makes a difference, and i'm using dmd v2.104.0. Thanks in advance for any clues. dan
Re: Search for the dialog library
On Sunday, 15 October 2023 at 21:46:44 UTC, Dmitry Ponyatov wrote: Maybe it's time to port the old warm tubby Turbo Vision into the glorious D lang? https://github.com/magiblot/tvision Since there was a conversation about the implementation of the wrapper, it is easier to write a wrapper for the `dialog` library, in fact, which is probably what I will do. I'll share a link here a little later. If anyone wants to help, it will be very cool! I think this library can be useful to many people.
Re: Search for the dialog library
On Saturday, 14 October 2023 at 23:02:34 UTC, Alexander Zhirov wrote: Colleagues, tell me, please, is there any library on D for drawing dialog boxes? Maybe it's time to port the old warm tubby Turbo Vision into the glorious D lang? https://github.com/magiblot/tvision
Re: Benchmarks
On Friday, 13 October 2023 at 22:45:19 UTC, Imperatorn wrote: https://github.com/jinyus/related_post_gen Sequential processing time, less is better |Language| Time (5k posts) | 20k posts | 60k posts | Total | |:--:|:---:|:--:|:-:|::| | D | 24.76 ms| 314.14 ms | 2.70 s | 3.04 s | | C++| 24.00 ms| 337.33 ms | 2.94 s| 3.30 s | | Rust | 23.51 ms | 341.02 ms | 3.04 s| 3.40 s | | Go | 24.22 ms| 371.65 ms | 3.28 s| 3.67 s | | Nim| 30.02 ms| 521.70 ms | 3.56 s| 4.11 s | | Zig| 28.62 ms| 430.33 ms | 3.81 s| 4.27 s | | F# (AOT) | 32.77 ms| 485.67 ms | 4.13 s| 4.65 s | | Julia | 30.15 ms| 481.00 ms | 4.24 s| 4.75 s | | Odin | 41.15 ms| 689.07 ms | 5.05 s| 5.78 s | | Java (GraalVM) | 41.00 ms| 495.33 ms | 5.28 s| 5.82 s | | C# (AOT) | 42.70 ms| 615.80 ms | 5.39 s| 6.05 s | | F# (JIT) | 45.15 ms| 623.67 ms | 5.49 s| 6.16 s | | Swift | 50.68 ms| 712.61 ms | 6.16 s| 6.93 s | | Java (JIT) | 54.77 ms| 757.00 ms | 6.44 s| 7.25 s | | Vlang | 51.35 ms| 756.63 ms | 6.66 s| 7.46 s | | C# (JIT) | 57.97 ms| 772.78 ms | 6.77 s| 7.60 s | | Crystal| 64.96 ms| 974.49 ms | 8.64 s| 9.68 s | | LuaJIT | 109.53 ms | 1.51 s | 12.93 s | 14.55 s | | Dart VM| 138.85 ms | 2.41 s | 20.96 s | 23.51 s | | JS (Node) | 182.00 ms | 2.44 s | 22.50 s | 25.12 s | | Dart AOT | 185.38 ms | 2.89 s | 25.75 s | 28.83 s | | ocaml | 140.00 ms | 2.76 s | 32.71 s | 35.61 s | | JS (Deno) | 192.31 ms | 2.26 s | 41.13 s | 43.58 s | | JS (Bun) | 763.15 ms | 11.82 s| 108.87 s | 121.45 s | | Lua| 1.09 s | 16.78 s| 150.00 s | 167.87 s | | Python | 1.47 s | 23.48 s| 214.99 s | 239.94 s | | Numpy | 349.48 ms | 6.67 s | OOM | N/A | Parallel processing time, less is better | Language | Time (5k posts) | 20k posts | 60k posts | Total | |:-:|:---:|:--:|:-:|:--:| | D Concurrent | 15.10 ms| 145.10 ms | 1.16 s | 1.32 s | | C++ Concurrent| 13.85 ms| 163.67 ms | 1.38 s| 1.56 s | | Go Concurrent | 13.13 ms | 166.03 ms | 1.42 s| 1.60 s | | Rust Concurrent | 14.39 ms| 186.87 ms | 1.58 s| 1.78 s | | Julia Concurrent | 16.85 ms| 222.67 ms | 1.94 s| 2.18 s | | F# Concurrent (JIT) | 22.31 ms| 288.33 ms | 2.46 s| 2.77 s | | F# Concurrent (AOT) | 19.00 ms| 290.00 ms | 2.47 s| 2.78 s | | Swift Concurrent | 31.32 ms| 393.54 ms | 3.50 s| 3.93 s | | Java (GraalVM) Concurrent | 38.77 ms| 592.33 ms | 4.12 s| 4.75 s |
Re: How to use ".stringof" to get the value of a variable and not the name of the variable (identifier) itself?
On Saturday, 14 October 2023 at 06:48:40 UTC, rempas wrote: On Friday, 13 October 2023 at 10:11:33 UTC, Nick Treleaven wrote: You can also do it using a string mixin: mixin(create_fn!(mixin("`", i, "`"))); I think that's equivalent to `i.stringof` anyway. Thank you for the info! You already got a lot of good answers, I thought I'd just share this for anyone searching for nogc string formatting compatible with betterC: https://code.dlang.org/packages/bc-string