Example for multi level template composition

2022-10-10 Thread Arun via Digitalmars-d-learn
Stumbled upon this question on HN 
https://news.ycombinator.com/item?id=33142751#33147401


Can I write template A and then apply it to itself to get 
template B and then apply that onto template C to get template 
D.


Does anyone have an example for this?


Re: vibe.d / experience / feedback

2020-10-06 Thread Arun via Digitalmars-d-learn
On Thursday, 1 October 2020 at 06:32:23 UTC, Robert M. Münch 
wrote:
Hi, we are currently using vibe.d for a prototype and I want to 
post some experiences. I know one shouldn't only address the 
problems but provide some solutions.


However, our current use-case is that we want to get a job 
done, and not creating a web-framework.


1. For many things the docs are missing, or inconsistent, or 
wrong. So, it's pretty hard to make your way through it. Or you 
just start reading the code and reverse engineer vibe. => We 
are waisting a lot of time.


2. There are many inconsistencies / half-done implementations 
in vibe. Again, this makes it hard to find out what works, what 
doesn't or which parts behave differently. => Costs a lot of 
time.


3. Vibe can't handle GET & POST on the same URL... and the bad 
thing is, the later route will just be ignored, so you don't 
get any hint or crash. The docs don't mention this clearly. => 
We waisted a lot of time to find out, that this doesn't work.


4. Vide uses an own JSON type, not the standard one. We don't 
understand why, this just makes things much more complicated 
and one has to mess around with this.


5. One can't access the raw HTTP request body, things must be 
go through Vibe's JSON parser. To get access to the raw body, a 
lot of workarounds are necessary.


So, overall... compared to other web-frameworks we know, there 
are many pitfalls which just cost a lot of time... We think 
it's a good base, but there needs to be much less magic, much 
better docs, much less complexity.


I concur with 1 and 2. We waste lot of time trying to understand 
vibe code instead of working on the business logic.


Never had issues with 3.

I've found vibe JSON to be a relative of nlohmann::json 
https://github.com/nlohmann/json
Similar API, seamless code reusability (copy paste). I never 
really cared about std.json as the usability is not good.


5. is definitely possible with readAll. Never had issues with 
this. Just dig more into the code ☺️




Fiber based HTTP client for load testing

2020-09-30 Thread Arun via Digitalmars-d-learn
I have a REST client that can do load test of my REST services. 
It uses ikod's dlang-requests under the hood. 
https://github.com/ikod/dlang-requests


At the moment I use a thread pool to dispatch the runtime 
operation and send the requests to the server.


/// Iterates over the enum members and builds a switch case 
statement at compile time.
/// If the input operation matches the case, the runtime 
dispatches the corresponding

/// task pool with it's options.
auto pool = new TaskPool(options.threadCount);
foreach (_; 0 .. options.threadCount) {
foreach (__; 0 .. options.iterationCount) {
final switch (options.operation) {
foreach (e; EnumMembers!Operation) {
case e:
pool.put(mixin("task!" ~ e.to!string ~ 
"(options)"));

break;
}
}
}
}
pool.finish();

As seen, the downside is that the more threads we use the more 
memory the app consumes. Is there a way to replace the threads 
with fibers in this particular case so that instead of spawning 
1000 threads, we spawn 1000 fibers with just 1 thread?




Re: Master Thesis using D Programming language.

2020-08-25 Thread Arun via Digitalmars-d-learn

On Monday, 24 August 2020 at 19:56:49 UTC, Tariq Siddiqui wrote:

Hello everyone,

I am looking for a master thesis topic using D Programming 
language. Earlier I choose Design by Introspection, but I did 
not find enough material in academic journals. DbI total 
material which I found is DConf Andrei talk and the similar 
talk at Google campus, which starts with 50 Deutsche Mark story 
and ends with explaining PbD, DbI and other Dlang internals. No 
doubt that Andrei's discussion was great. DbI as a topic is 
excellent, but as per my university requirements, I was not 
able to find five articles in the last five years in any 
academic journal, to start the initial discussion about the 
research topic.


I am still opened with my topic, next week, I have to submit my 
draft proposal. Till now, I did not meet my dissertation 
advisor.


I am looking for something practical and less theoretical. I 
have found some thesis done using Rust, you guys as a language 
expert can these below projects be achievable using D 
Programming language.


http://www.barrelfish.org/publications/ma-foellmic-bfrust.pdf
https://www.diva-portal.org/smash/get/diva2:1238890/FULLTEXT01.pdf
https://github.com/Gankra/thesis/blob/master/thesis.pdf

Regards,
Tariq Siddiqui.


D for a @safer Linux Kernel was worked on by Alexandru Militaru: 
https://www.youtube.com/watch?v=weRSwbZtKu0


You can also browse the previous GSoC proposals at 
https://wiki.dlang.org/GSOC_2019_Ideas and 
https://wiki.dlang.org/GSOC_2018_Ideas of which some might 
qualify as masters thesis. These are pretty hands on requiring 
good understanding of the theory as well.


D blog had a similar post recently. 
https://dlang.org/blog/2020/08/23/symmetry-autumn-of-code-2020-projects-and-participants/


--
Arun


Re: Which version of DMD does GDC 10 target

2020-08-19 Thread Arun via Digitalmars-d-learn

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. ;-)


Which version of DMD does GDC 10 target

2020-08-19 Thread Arun via Digitalmars-d-learn

Which version of DMD is GDC 10 based on?

2020-08-19 19:36:17 ~/code/es-v2-d (master)
$ gdc --version
gdc (Ubuntu 10-20200411-0ubuntu1) 10.0.1 20200411 (experimental) 
[master revision 
bb87d5cc77d:75961caccb7:f883c46b4877f637e0fa5025b4d6b5c9040ec566]

Copyright (C) 2020 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  
There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A 
PARTICULAR PURPOSE.


2020-08-19 21:24:10 ~/code/es-v2-d (master)
$

LDC is smart enough to print the frontend version.

2020-08-19 21:25:39 ~/code/es-v2-d (master)
$ ldc2 --version
LDC - the LLVM D compiler (1.17.0):
  based on DMD v2.087.1 and LLVM 8.0.1
  built with LDC - the LLVM D compiler (1.17.0)
  Default target: x86_64-unknown-linux-gnu
  Host CPU: haswell
  http://dlang.org - http://wiki.dlang.org/LDC

  Registered Targets:
aarch64- AArch64 (little endian)
aarch64_be - AArch64 (big endian)
arm- ARM
arm64  - ARM64 (little endian)
armeb  - ARM (big endian)
mips   - MIPS (32-bit big endian)
mips64 - MIPS (64-bit big endian)
mips64el   - MIPS (64-bit little endian)
mipsel - MIPS (32-bit little endian)
msp430 - MSP430 [experimental]
nvptx  - NVIDIA PTX 32-bit
nvptx64- NVIDIA PTX 64-bit
ppc32  - PowerPC 32
ppc64  - PowerPC 64
ppc64le- PowerPC 64 LE
riscv32- 32-bit RISC-V
riscv64- 64-bit RISC-V
thumb  - Thumb
thumbeb- Thumb (big endian)
wasm32 - WebAssembly 32-bit
wasm64 - WebAssembly 64-bit
x86- 32-bit X86: Pentium-Pro and above
x86-64 - 64-bit X86: EM64T and AMD64
2020-08-19 21:27:35 ~/code/es-v2-d (master)
$

--
Arun