Re: vibe.d and my first web service
On Thursday, 20 August 2020 at 18:13:46 UTC, ddcovery wrote: On Monday, 17 August 2020 at 15:45:05 UTC, aberba wrote: [...] After 18 years following DLang, and some disagrees about productivity lacks at the beggining (no IDE, Debugging?, an standard library battle, not a good database connection library, missing web framework) and Walter adding more and more compiler functionalities (all of them nice ones) I decided to forget DLang for a time (C# covered my needs really well). Last month I decided it was time to start a new project (my own company) and I reviewed some languages/frameworks for web development (REST services, image processing, PDF generation, ...): Java based ones (I'm experienced with scala/playframework and spring/java, and Kotlin is really nice), c# and Net core, Node/Typescript (Last 6 years I have been mainly a node backend developer) and, finally, native ones (GO, Rust and D... I developed some windows apps in 90's using Symantec C++ but 20 years are a really long time). I really wanted to give D an opportunity: lets go with vibe.d I tested vibe.d on my ubuntu 20.04 and SURPRISE: the hello world project began to eat all my machine memory (just requesting with Firefox and CTRL+F5 pressed continuosly). Using an HAPROXY between calls and backend memory problems disappeared. Process doesn't stop properly after CTRL+C... but I decided not to be so demanding. I discovered hunt-framework (with a fantastic ORM implementation) and my eyes shinned. I tried an example project. Like vibe.d, I began to perform requests with Firefox and CTRL+F5 pressed and application stopped immediately (yesterday I discovered it is a SIGPIPE unmanaged signal that stops the process). I'm quite sure if I use HAPROXY to intermediate between requests and backend, the problem will disappear, but I don't want to perform this test, because I decided not to use hunt-framework neither. Finally I'm using Rust (with Rocket and Diesel): it's my money folks :). Sorry for this not constructive post. DLang needs to bright in some market niche to attract developers and to solve the actual most demanded needs: a lot of developers, like me, expect a good/robust framework for backend development (web/rest/microservices/data processing) and a de-facto standard library for Database integration. In my opinion, "hunt-framework" (or similar) should be one of the central projects of DLang next years (like vibe.d in the past) with a really impressive documentation (English, please!!!) demonstrating how robust, performant and expressive D lang is. Actually your feedback is very constructive, thanks a lot. The ctrl+c issue can be solved with a work around, by adding the version "VibeHighEventPriority". I have only a very small vibed backend application (websockset) and never noticed the memory issue. Also another forum user which has a quite large web application in productive use didn't mentioned this issue. Could I ask you to open a github issue for vibe-d describing your findings regarding the memory issue? As far as I remember the GC does not immediately runs, but only at a certain limit. Maybe your memory issue isn't really an issue but the desired behavior. (Not an expert here, just what I remember). Kind regards Andre
Re: Is using floating point type for money/currency a good idea?
Me and my financial adviser think not. Unfortunately, this is not the best way..
Re: vibe.d and my first web service
"After 18 years following DLang," its not well expressed...may be "at first Dlang stages, after 2 years following its evolution, and ..."
Re: SIGUSR1 in clock_nanosleep()? how to isolate this issue?
On 8/20/20 2:58 PM, mw wrote: Hi, I run into an issue: it's SIGUSR1 in clock_nanosleep() The GC uses SIGUSR1 (and SIGUSR2). Maybe that's the issue? https://github.com/dlang/druntime/blob/e1fb19829ebef0419782de43ce4b0e2a1ba140be/src/core/thread/osthread.d#L1946 -Steve
Re: how stdin stream works?
On 8/19/20 11:46 AM, Flade wrote: Try instead getting a line via readln, and then trying to read that into your expected input. -Steve Thanks Steve! I will get the input a string then as you said and then I'll try to convert it! Thanks a lot, have a nice day! In some cases clearerr() and readln() may be what is needed: import std.stdio; void main() { int x; bool accepted = false; while (!accepted) { try { write("x: "); readf(" %d", x); accepted = true; } catch (Exception msg) { writeln("Please give a right coordinate"); stdin.clearerr(); stdin.readln(); } } writeln("x is ", x); } Note that I used " %d" because "%d/n" would not clean when nothing was input by just hitting the Enter key. A space character in the format string means "read and ignore any whitespace at this point" and I like it. :) Also note I changed the name of the variable as 'accepted'. :) Ali
SIGUSR1 in clock_nanosleep()? how to isolate this issue?
Hi, I run into an issue: it's SIGUSR1 in clock_nanosleep() --- ... [New Thread 0x70ae0700 (LWP 36860)] [New Thread 0x7fffcbfff700 (LWP 36861)] [Detaching after fork from child process 36862] [New Thread 0x7fffd2eff700 (LWP 36863)] [New Thread 0x7fffd26fe700 (LWP 36864)] [New Thread 0x7fffd1efd700 (LWP 36865)] [New Thread 0x7fffd16fc700 (LWP 36866)] Thread 10 "lt" received signal SIGUSR1, User defined signal 1. [Switching to Thread 0x70ae0700 (LWP 36860)] 0x75d99361 in clock_nanosleep () from /usr/lib/x86_64-linux-gnu/libc.so.6 (gdb) where #0 0x75d99361 in clock_nanosleep () from /usr/lib/x86_64-linux-gnu/libc.so.6 #1 0x75d9eeb7 in nanosleep () from /usr/lib/x86_64-linux-gnu/libc.so.6 #2 0x5585cb89 in _D4core6thread8osthread6Thread5sleepFNbNiSQBo4time8DurationZv () #3 0x555d42b2 in checktatus() (this=0x71262170) at ttt.d:1368 #4 0x55612ee5 in xxxThread() () at aaa.d:88 #5 0x555d736f in _D3std11concurrency__T6_spawnTPFZvZQnFbQjZ4execMFZv () at .../ldc2-1.23.0-linux-x86_64/bin/../import/std/concurrency.d:556 #6 0x5585c32a in thread_entryPoint () #7 0x76020609 in start_thread (arg=) at pthread_create.c:477 #8 0x75ddb103 in clone () from /usr/lib/x86_64-linux-gnu/libc.so.6 --- I tried some simple example which is similar to my app structure, e.g. -- void threadFunc() { foreach (i; 0..10) { auto stats = core.memory.GC.stats(); writeln(stats); Thread.sleep( dur!("msecs")( 50 ) ); } } void main() { spawn(); spawn(); thread_joinAll(); } -- however, it runs fine. Anyone has some suggestions on how to isolate this issue? Thanks.
Re: vibe.d and my first web service
On Monday, 17 August 2020 at 15:45:05 UTC, aberba wrote: On Thursday, 13 August 2020 at 09:54:06 UTC, Mr. Backup wrote: On Wednesday, 12 August 2020 at 13:46:06 UTC, James Blachly wrote: Unfortunately the problem still occurs with Vibe.d 0.9.0 IMO **this is the single most important problem to fix** for vibe.d -- if the most basic of examples (indeed, supplied by dub itself) fails so spectacularly, the casual new user will not spend the time to find out why this is happening, but instead move on. The ctrl-C non-termination bug has existed since at least 2015 from what I can tell from the forums. As a casual new novice, I really like dlang as such, and I think it should be the most widespread and popular language in the world. And as soon as I came across it, I wanted to use it in my project. But it has many packages for the same things, but these packages are unfinished. Everyone creates their own. You start comparing them and don't know what to choose for your job and then you find out that you should have chosen another and then find out that you should have written it yourself. And then I finally done it in golang in a while. I think the dlang community should focus on creating a quality standard library. We live in the 21st century where there are web technologies everywhere around us, so I think that the http package should be part of a standard library. It takes time. I was comparing packages available in D compared to say nodejs which I've been using for a while. Very few important ones are missing. The others too lack some documentation. Other than that, you get pretty much what you need. Except cloud sdks. also using vibe.d has some missing pieces on how to do certain things... that I agree we Users need to do writing about them. You're also right that people keep rolling their own implementations. Most people here are really good and can roll their own so its quite tempting...plus reading someone's code and implementation can be a lil...sometimes. except rolling your own means it'll be half baked and undocumented. Also I suspect lot of community members primary don't do web stuff primarily. If you ask me, I'll say vibe.d is the most solid and feature complete web framework at the moment...code, docs, libraries. It's not perfect but its never been a blocker. That's if you know your way around it. Sonke is a pretty cool guy. Will be nice if he had a GitHub sponsor or something for vibe.d Hunt framework is also your laravel D alternative. After 18 years following DLang, and some disagrees about productivity lacks at the beggining (no IDE, Debugging?, an standard library battle, not a good database connection library, missing web framework) and Walter adding more and more compiler functionalities (all of them nice ones) I decided to forget DLang for a time (C# covered my needs really well). Last month I decided it was time to start a new project (my own company) and I reviewed some languages/frameworks for web development (REST services, image processing, PDF generation, ...): Java based ones (I'm experienced with scala/playframework and spring/java, and Kotlin is really nice), c# and Net core, Node/Typescript (Last 6 years I have been mainly a node backend developer) and, finally, native ones (GO, Rust and D... I developed some windows apps in 90's using Symantec C++ but 20 years are a really long time). I really wanted to give D an opportunity: lets go with vibe.d I tested vibe.d on my ubuntu 20.04 and SURPRISE: the hello world project began to eat all my machine memory (just requesting with Firefox and CTRL+F5 pressed continuosly). Using an HAPROXY between calls and backend memory problems disappeared. Process doesn't stop properly after CTRL+C... but I decided not to be so demanding. I discovered hunt-framework (with a fantastic ORM implementation) and my eyes shinned. I tried an example project. Like vibe.d, I began to perform requests with Firefox and CTRL+F5 pressed and application stopped immediately (yesterday I discovered it is a SIGPIPE unmanaged signal that stops the process). I'm quite sure if I use HAPROXY to intermediate between requests and backend, the problem will disappear, but I don't want to perform this test, because I decided not to use hunt-framework neither. Finally I'm using Rust (with Rocket and Diesel): it's my money folks :). Sorry for this not constructive post. DLang needs to bright in some market niche to attract developers and to solve the actual most demanded needs: a lot of developers, like me, expect a good/robust framework for backend development (web/rest/microservices/data processing) and a de-facto standard library for Database integration. In my opinion, "hunt-framework" (or similar) should be one of the central projects of DLang next years (like vibe.d in the past) with a really impressive documentation (English, please!!!) demonstrating how
Re: vibe.d and my first web service
On Thursday, 13 August 2020 at 09:54:06 UTC, Mr. Backup wrote: And as soon as I came across it, I wanted to use it in my project. But it has many packages for the same things, but these packages are unfinished. Everyone creates their own. You start comparing them and don't know what to choose for your job and then you find out that you should have chosen another and then find out that you should have written it yourself. And then I finally done it in golang in a while. I think the dlang community should focus on creating a quality standard library. We live in the 21st century where there are web technologies everywhere around us, so I think that the http package should be part of a standard library. People have been pushing for that for years but the answer in D ( and some other languages ) always tend to be the same. "We do not want to bloat the standard library". In reality it comes down to: "We do not want the responsibility of maintaining a lot more code". So the buck gets pushed to the community and if its not a big community, you will see a of people starting projects. It works for them on their projects and then it get abandoned as they move to new languages or have no time. If we look at Go or Crystal or ... a lot of the reason why people pick up those languages, boils down to "its easy to get some output". A few lines of code and it makes people feel successful and they move on to the next step and forward from their on. Growing more into the languages. In D's case, we enjoy the constant Vibe.D warning hell ( when it did not break outright with specific D versions! ). That not only scares away people, it also makes development annoying when your constantly spammed with warnings and you can not see what is vibe.d's warnings and what is your code's warnings! And vibe.d is on the front pages, as the prime example for people to try out D. o_O Anyway, its a dead argument, go back in time to see that same suggestion in 2017, 2015, 201... And people argued about it, people telling other "no" and new users kept enjoying the vibe.d issue train ( among other issues ) while leaving fast. And then people keep wondering why a lot of people do not stick around and run towards Go or other languages ... I wonder why D has popularity issues.
Re: Disjoint slices of an array as reference
On Thursday, 20 August 2020 at 08:26:59 UTC, Ali Çehreli wrote: On 8/19/20 9:11 PM, data pulverizer wrote: Thanks. I might go for a design like this: ``` struct View(T){ T* data; long[2][] ranges; } ``` [...] I implemented the same idea recently; it's a fun exercise. :) I didn't bother with opIndex because my use case was happy with just the InputRange primitives (and .length I think). And I had to implement it because std.range.chain works only with statically known number of sub-ranges. :/ If the number of ranges are known, then this works: import std.stdio; import std.range; void main() { auto x = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]; auto y = chain(x[0..5], x[9..14]); writeln(y); } [1, 2, 3, 4, 5, 10, 11, 12, 13, 14] Ali Many thanks for confirming the internal structure of D's arrays and for the tip on std.range's chain function. It's exactly what I need. In fact the number of sub-ranges are statically known ... As an aside, the reason for this query is that I have written a small module for multidimensional arrays to be included in a GLM (generalized linear models) package I am writing in D (in fact this will be the second major version of the package in D) - I know about Mir but my array doesn't have to be feature rich and only requires very few methods, I'm also probably going to write an article about it's internal structure and I've learned a lot creating it, and it means the GLM library won't have dependencies outside D's standard library and BLAS/LAPACK. The multidimensional array is structured like this: ``` Array(long N, T) if(isFloatingPoint!T && (N >= 1)) { T[] data; long[N] dim; ... } ``` Where N is the number of dimensions. The indexing and stuff works fine but I wasn't happy that subsetting the array with slices returns a copy (for example an 2D array `A[0..2, 1..$]`) and since the subsetting is not necessarily contiguous, directly slicing from the data array was not feasible. But now N is known at compile time (`A[r[0][0]..r[0][1], r[1][0]..r[1][1], ... , r[N][0]..r[N][1]]`) so doing a subset using std.range's `chain` on `data` is easy. It also means I don't have to implement a separate `View` struct. This chain function will also simplify my indexing code, at the moment I am using string mixins to generate code for for loops over all the different dimensions where the function creating string the is recursive ... which was fun to write [:laugh:]!
Re: Disjoint slices of an array as reference
On 8/19/20 9:11 PM, data pulverizer wrote: On Thursday, 20 August 2020 at 03:47:15 UTC, Paul Backus wrote: double[][] y; y ~= x[0..5]; Thanks. I might go for a design like this: ``` struct View(T){ T* data; long[2][] ranges; } ``` The ranges are were the slices are stored and T* (maybe even immutable(T*)) is a pointer is to the start of the original array. I'll use an opIndex that calculates the correct index in the original array to obtain the right data. I implemented the same idea recently; it's a fun exercise. :) I didn't bother with opIndex because my use case was happy with just the InputRange primitives (and .length I think). And I had to implement it because std.range.chain works only with statically known number of sub-ranges. :/ If the number of ranges are known, then this works: import std.stdio; import std.range; void main() { auto x = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]; auto y = chain(x[0..5], x[9..14]); writeln(y); } [1, 2, 3, 4, 5, 10, 11, 12, 13, 14] Ali
Re: Disjoint slices of an array as reference
On 8/19/20 7:40 PM, data pulverizer wrote: > An array in D is either two pointers or one pointer and a length (I > don't know which) It is the length, followed by the pointer, equivalent of the following struct: struct A { size_t length_; void * ptr; size_t length() { return length_; } size_t length(size_t newLength) { // Modify length_ and ptr as necessary } } Ali
Re: Which version of DMD does GDC 10 target
On Thursday, 20 August 2020 at 05:49:29 UTC, Arun wrote: On Thursday, 20 August 2020 at 05:07:28 UTC, H. S. Teoh wrote: On Thu, Aug 20, 2020 at 04:28:41AM +, Arun via Digitalmars-d-learn wrote: Which version of DMD is GDC 10 based on? Compile the following D program to find out: - static assert(0, "Compiler language version: " ~ __VERSION__.stringof); - I have this line in a file called langver.d, and whenever the exact language version isn't obvious, I compile it to find out the version. :-) (And yes it deliberately asserts instead of using pragma(msg) so that I don't have to type -o- or -of- or -c or whatever to suppress actual code emission, just `$compiler langver.d`.) --T Nice trick. Thanks. For the benefit of others, GDC 10 is based on DMD 2.076. https://dlang.org/changelog/2.076.0.html Side note, Using $() is better than `` for subshells, as it makes nesting much easier. ;-) Side note: Usually a lot of bug fixes are backported to GDC, so even though it says 2.076 feature-wise, bugs that have been fixed much later might not be present. Which is great because it makes bootstrapping *SO MUCH* easier.