Re: DCV has a new release.

2024-05-20 Thread Andrea Fontana via Digitalmars-d-announce

On Monday, 20 May 2024 at 11:47:25 UTC, Ferhat Kurtulmuş wrote:
I've been working on DCV for some years. Recently, DCV has 
started to be used by some projects, such as etichetta[1]. Even 
though it's still far from perfect, I think DCV deserves a new 
version. Existing unit tests pass. New ones are also necessary.


Great!

With your help etichetta would never have been able to use the AI.

I hope DCV will continue evolving. :)

Andrea


Etichetta v0.1.3 is here! (with AI)

2024-05-12 Thread Andrea Fontana via Digitalmars-d-announce
Hello! I’m excited to announce the release of a new application 
called “Etichetta”.


“Etichetta” is a straightforward program that allows you to label 
images for AI training. I’ve always found existing programs to be 
quite cumbersome, so I created one myself. Among its various 
features is the ability to use a YOLO model to simplify the 
labeling process by providing suggestions. 


The project utilizes gtkd for the interface and onnx runtime for 
AI (without any modifications, thanks to importc!).


Special thanks to Ferhat Kurtulmuş for assisting with the 
onnx-related aspects.


There’s a setup available for Windows and an AppImage that runs 
on any Linux distribution. It seems to work on macOS through 
docker + xquartz, for the brave ones!


GitHub: https://github.com/trikko/etichetta
Some super-short how-to videos: 
https://github.com/trikko/etichetta/blob/main/HOWTO.md


Andrea Fontana


Re: Serverino 0.7.0

2024-04-14 Thread Andrea Fontana via Digitalmars-d-announce

On Monday, 15 April 2024 at 01:04:40 UTC, aberba wrote:


Link to code sample?


https://github.com/trikko/serverino/tree/master/examples/06_websocket_noise_stream

Andrea


Serverino 0.7.0

2024-04-13 Thread Andrea Fontana via Digitalmars-d-announce

 Hey Serverino enthusiasts! 

Get ready to elevate your server game with the latest Serverino 
0.7.0 release! ✨


What’s new in this update? 

WebSockets are here! Now you can enjoy real-time bi-directional 
communication.


Some example I've posted on twitter:
https://twitter.com/twittatore/status/1775969115322147165
https://twitter.com/twittatore/status/1776613077053481078
https://twitter.com/twittatore/status/1774827657512841363


Have fun!
Andrea


Re: Upcoming ACCU 2024 Talk: How DLang Improves my Modern C++ and Vice Versa

2024-04-09 Thread Andrea Fontana via Digitalmars-d-announce

On Monday, 8 April 2024 at 01:38:20 UTC, Mike Shah wrote:
I'll be talking more about D (and modern C++) at the ACCU 2024 
conference in Bristol (Abstract below -- talk is on April 19, 
2024).


+1


Re: request assistance resolving curl error

2024-03-26 Thread Andrea Fontana via Digitalmars-d-learn

On Tuesday, 26 March 2024 at 07:13:24 UTC, confuzzled wrote:

Hello all,

I have two scripts. I copied the first directly from the alpaca 
website and massaged it with etc.c.curl until it compiled in D. 
The result is that it creates the order and returns the result 
to stdout. In the second script, I tried to use std.net.curl 
but cannot get it to work.


I think you should use the HTTP interface, did you check this 
docs?

https://dlang.org/phobos/std_net_curl.html#.HTTP
https://dlang.org/phobos/std_net_curl.html#.HTTP.addRequestHeader


Andrea


Re: Beta 2.108.0

2024-03-21 Thread Andrea Fontana via Digitalmars-d-announce

On Thursday, 21 March 2024 at 03:19:16 UTC, Salih Dincer wrote:

On Thursday, 21 March 2024 at 02:14:36 UTC, WebFreak001 wrote:

On Saturday, 2 March 2024 at 17:40:29 UTC, Iain Buclaw wrote:
.. since they drastically make things easier (hexstrings) or 
even possible in the first place (magic initializer thingies) 
for library code and generated code.


I cannot say the same thing. It is thought-provoking that even 
the toHex() function, which should be in std.conv, was not 
included and we had to write it ourselves.


SDB@79


This?

```
import std;

void main()
{
int number = 32409;
auto hex = format("%X", number);
writeln(hex);
}
```

or:

```
auto toHex(N)(N number) if (isIntegral!N) { return 
"%X".format(number); }

...
auto hex = 3432.toHex();
...

```



Re: DConf Online Livestream Link

2024-03-18 Thread Andrea Fontana via Digitalmars-d-announce

On Monday, 18 March 2024 at 11:11:03 UTC, Nick Treleaven wrote:

On Sunday, 10 March 2024 at 16:07:23 UTC, Mike Parker wrote:
The countdown is on! I'll kick off the DConf Online Livestream 
at 14:55 UTC on March 16. You can find it here:


https://www.youtube.com/live/8GV_TuYk3lk

And if you haven't seen the details yet, take a look here:
https://dconf.org/2024/online/index.html

See you there!


This was great, interesting selection of talks.

BTW each link to slides is giving me a 404. Luckily the live 
stream video is still up to rewind :-)


https://github.com/dlang/dconf.org/tree/master/2024/online/slides

Andrea


Re: Is D programming friendly for beginners?

2024-03-12 Thread Andrea Fontana via Digitalmars-d-announce

On Tuesday, 12 March 2024 at 19:12:03 UTC, H. S. Teoh wrote:
I don't know how CS programs are carried out these days, but 
back when I was in university, the choice of language is 
largely irrelevant, because the whole point of a programming 
course isn't to teach you a specific language, but to teach you 
the *principles* that underlie programming in general. There 
are really only a small handful of different paradigms that you 
need to learn; once you learned the principles behind them, 
they can be applied to any language out there.  You wouldn't 
need anyone to teach you a new language then; you could just 
learn it yourself by applying these same principles.


The rest, as they say, is just details. ;-)


T


I agree.

Andrea


Re:  Announcing Serverino 0.6.0! 

2024-03-10 Thread Andrea Fontana via Digitalmars-d-announce

Thank you! Inline replies >>>

On Sunday, 10 March 2024 at 21:04:05 UTC, aberba wrote:


1) I'm not sure I like concat (~=)
 style used on `Output output` and how it can determine the 
order routes are invoked. I would expect that to be explicitly 
defined by Dev using a catch-all route or else the sever 
returns 404 by default. That's going to prevent the chances of 
invoking the wrong route especially when it does something 
important/dangerous/unexpected.


Serverino works with priorities, that's the order the handlers 
are called! You're checks on handlers can easily filter request.





2) instead of doing:

```d
if (request.method != Request.Method.Get)
output.status = 405;
```

to determine the request method, why not use a UDA similar to 
`@route` ...like `@method(Request.Method.post)`? The use of UDA 
is so much cleaner and easier to deal with.




This works as well, indeed:
@route!(r => r.method == Request.Method.Post)



3) would be nice to have an `output.json()` function which both 
sets the response header and also calls `output.write()`


Just add content type and you're done!

4. I can't build anything significant in any http server 
library without support for middleware. Preferably support for 
multiple middlewares functions. A middleware would be a 
function that runs after the @onServerInit but BEFORE any route 
handler. It will be used to intercept all incoming requests for 
things like authentication, rate limiting, CORS, etc. 
Preferably provide a way to pass data to the target route e.g. 
user session, user permission, etc...like 
output.locals.set("userId", 123). The route will then be able 
to access this data.


Just use a high priority handler, check the tips on website, for 
example user auth.


That's a very clean way to add a layer of Auth, logging and so 
on...



All in all, everything else looks good. I would prefer 
something like:


```d
void hello (Request req, Response res) {
res.write("hello");
}
```
...but `Output` is also fine... just a small nitpick.


output.write() works as well.

Andrea



 Announcing Serverino 0.6.0! 

2024-03-07 Thread Andrea Fontana via Digitalmars-d-announce
Performance has been boosted once again, and those pesky little 
bugs? Squashed! Plus, there are fresh examples to try out and 
even a sleek new logo to admire!


Ready to dive in? Just spin up a new project using the provided 
template:


```
dub init -t serverino my_wonderful_project
cd my_wonderful_project
dub
```

And voilà! Your hello world will be up and running in **a couple 
of seconds**! 



Have fun!
Andrea Fontana

(I know some of you are already on board, but how many are 
sailing in secret? Come out of the shadows and let me know! Your 
feedback is the wind in serverino's sails)


Repository: https://github.com/trikko/serverino
Docs: https://trikko.github.io/serverino
Examples: https://github.com/trikko/serverino/tree/master/examples
Tips: https://github.com/trikko/serverino/wiki/


Re: SecureD 3.0 has been released!

2024-03-07 Thread Andrea Fontana via Digitalmars-d-announce

On Wednesday, 6 March 2024 at 07:47:04 UTC, Adam Wilson wrote:
SecureD 3.0 has been released. This version was set in motion 
by a Cedric Picard, a D community member with Cryptography 
experience, reaching out and suggesting a number of 
improvements to the Symmetric and KDF API's. This resulted in 
an API for symmetric encryption that improves correctness and 
security without significantly increasing developer workload. 
Also improved is the encryption envelope that contains 
symmetrically encrypted data.


Algorithm Changes:
- Removed: SHA2-224, AES-OFB
- Added: SHA3-224/256/384/512

And I even remembered to update the examples in the README.

Future work will focus on using the Operating System provided 
cryptography where available.


Check it out here: https://code.dlang.org/packages/secured


Well done Adam!

I only miss the docs :)

Andrea


Re: First Beta 2.106.0

2023-11-04 Thread Andrea Fontana via Digitalmars-d-announce

On Thursday, 2 November 2023 at 00:57:23 UTC, Iain Buclaw wrote:
Glad to announce the first beta for the 2.106.0 release, ♥ to 
the 33 contributors.


http://dlang.org/download.html#dmd_beta
http://dlang.org/changelog/2.106.0.html

As usual please report any bugs at
https://issues.dlang.org

-Iain
on behalf of the Dlang Core Team


Static AA init, finally! Great!

Andrea


Re: Blog post: How we are using D to develop Aspect from the ground up

2023-10-24 Thread Andrea Fontana via Digitalmars-d-announce

On Monday, 23 October 2023 at 19:02:46 UTC, Sönke Ludwig wrote:
I've written up an article that showcases how we use D in 
production and how that benefits us in unique ways.


Nice article. I agree with you about the pros and cons of 
language!


Andrea



Re: tshare/1.0 a fast way to share file using transfer.sh

2023-10-12 Thread Andrea Fontana via Digitalmars-d-announce

On Wednesday, 11 October 2023 at 14:30:50 UTC, kinke wrote:
On Saturday, 7 October 2023 at 22:40:58 UTC, Andrea Fontana 
wrote:

Question:
- Is there a way to compile curl statically with ldc for 
windows? If I try (using -static), it throws a runtime error.


Yes; IIRC, you need to link `curl_a.lib` *and* add `curl.exp` 
(as Phobos tries to find the exported functions in the .exe 
itself) to the linker cmdline too (both files in the LDC lib 
dir).


You're right!

On dub this works:

```
dflags "-link-defaultlib-shared=false" platform="ldc"
dflags "-static" platform="windows"
lflags "curl_a.lib" "crypt32.lib" "wldap32.lib" "curl.exp" 
platform="windows"

```

Thank you,
Andrea


Re: how to assign multiple variables at once by unpacking array?

2023-10-08 Thread Andrea Fontana via Digitalmars-d-learn

On Sunday, 8 October 2023 at 07:44:04 UTC, Andrea Fontana wrote:


```
int a,b,c;

"1,2,3"
.splitter(',')
.zip(only(, , ))
.each!(x => *x[1] = x[0].to!int);

writeln(a, b, c);
```


or:

```
int a,b,c;

only(, , )
.zip("1,2,3".splitter(','))
.each!(x => *x[0] = x[1].to!int);

writeln(a, b, c);
```


Re: how to assign multiple variables at once by unpacking array?

2023-10-08 Thread Andrea Fontana via Digitalmars-d-learn

On Saturday, 7 October 2023 at 07:31:45 UTC, mw wrote:

https://stackoverflow.com/questions/47046850/is-there-any-way-to-assign-multiple-variable-at-once-with-dlang

How to do this Python code in D:

```

s = "1 2 3"
A,B,C = map(int, s.split(" "))
A,B,C

(1, 2, 3)

```

Is there a better way (since 2017)?


Ranges for the win!

```
int a,b,c;

"1,2,3"
.splitter(',')
.zip(only(, , ))
.each!(x => *x[1] = x[0].to!int);

writeln(a, b, c);
```


Re: tshare/1.0 a fast way to share file using transfer.sh

2023-10-07 Thread Andrea Fontana via Digitalmars-d-announce
On Wednesday, 4 October 2023 at 23:02:39 UTC, Andrea Fontana 
wrote:
I've just released a simple tool for sharing files (similar to 
WeTransfer) directly from the terminal.



News:
- Added support for encryption (if gpg is available)
- Added binaries built by github
- Improved UI

Question:
- Is there a way to compile curl statically with ldc for windows? 
If I try (using -static), it throws a runtime error.


Andrea




tshare/1.0 a fast way to share file using transfer.sh

2023-10-04 Thread Andrea Fontana via Digitalmars-d-announce
I've just released a simple tool for sharing files (similar to 
WeTransfer) directly from the terminal.


Usage is incredibly straightforward:

Run ```dub build tshare``` to build the tool.
Use ```tshare /your/file``` to share your file, which will 
generate a public link.


For additional options, you can explore by running tshare -h.

On GitHub: https://github.com/trikko/tshare

Best regards,
Andrea


Re: LDC 1.31.0

2023-02-23 Thread Andrea Fontana via Digitalmars-d-announce

On Saturday, 11 February 2023 at 13:47:54 UTC, kinke wrote:

Glad to announce LDC 1.31.0. Major changes:

* Based on D 2.101.2.
  * ImportC: The C preprocessor isn't invoked yet.
* mac/iOS arm64: Linking with `-g` is working again without 
unaligned pointer warnings/errors.
* *Preliminary* support for LLVM 15. Thanks @jamesragray for 
helping out!

* Initial ABI support for 64-bit RISC-V. Thanks @Ast-x64!

Full release log and downloads: 
https://github.com/ldc-developers/ldc/releases/tag/v1.31.0


Thanks to all contributors & sponsors!


Build for raspberry pi + debian bullseye:
https://github.com/trikko/ldc2-rpi-build/releases/tag/v1.31.0

Andrea Fontana


Re: importC - how to use more effectively?

2023-02-22 Thread Andrea Fontana via Digitalmars-d-learn

On Wednesday, 22 February 2023 at 15:00:56 UTC, WebFreak001 wrote:
I just first time used importC in a prototype project I just 
worked on. I used it to just import `libevdev.h` on linux to 
register a custom input device / make a simple userspace input 
driver.


A suggestion: try tcc as preprocessor. It works better than gcc 
for importc.


Andrea Fontana


Re: Centroid tracking using DCV

2023-02-16 Thread Andrea Fontana via Digitalmars-d-announce
On Wednesday, 15 February 2023 at 17:32:33 UTC, Ferhat Kurtulmuş 
wrote:

I heard you are not having fun enough with d today.

Do you know you can do things like this with dlang now? After 
some fiddling with it, my last commits made this possible.


how it looks like: https://www.youtube.com/watch?v=ACC_-TDAtqc
source code: 
https://github.com/aferust/oclcv/tree/main/examples/centroidtracking

DCV: https://github.com/libmir/dcv

Sorry for the potato-quality video. My art director is on 
vacation.


I am cheating a little with OpenCL since things are not fast 
enough at the moment.


Hope you like it.

Enjoy!


Nice!


Re: LDC 1.31.0-beta1

2023-02-03 Thread Andrea Fontana via Digitalmars-d-announce

On Friday, 27 January 2023 at 20:35:01 UTC, kinke wrote:

Glad to announce the first beta for LDC 1.31. Major changes:

* Based on D 2.101.2.
  * ImportC: The C preprocessor isn't invoked yet.
* mac/iOS arm64: Linking with `-g` is working again without 
unaligned pointer warnings/errors.
* *Preliminary* support for LLVM 15. Thanks @jamesragray for 
helping out!

* Initial ABI support for 64-bit RISC-V. Thanks @Ast-x64!

Full release log and downloads: 
https://github.com/ldc-developers/ldc/releases/tag/v1.31.0-beta1


Please help test, and thanks to all contributors & sponsors!


Nice! Can we have a build for linux-arm (rpi)? The last one is 
oold :)


Andrea


Re: Serverino 0.4.0

2023-02-01 Thread Andrea Fontana via Digitalmars-d-announce
On Wednesday, 1 February 2023 at 20:01:13 UTC, Andrea Fontana 
wrote:
do you have any plans to do some benchmarks or if you did, 
please share the place to check it?



Here some results from may, but serverino went over a major arch 
rework after that, so I'm not sure they are still valid.


https://github.com/tchaloupka/httpbench

If you want to do some benchmarks your welcome!

Andrea


Re: Serverino 0.4.0

2023-02-01 Thread Andrea Fontana via Digitalmars-d-announce
On Wednesday, 1 February 2023 at 20:01:13 UTC, Andrea Fontana 
wrote:
do you have any plans to do some benchmarks or if you did, 
please share the place to check it?



Here some results from may, but serverino went over a major arch 
rework after that, so I'm not sure they are still valid.


https://github.com/tchaloupka/httpbench

If you want to do some benchmarks your welcome!

Andrea


Re: Serverino 0.4.0

2023-02-01 Thread Andrea Fontana via Digitalmars-d-announce

On Wednesday, 1 February 2023 at 19:49:40 UTC, psyscout wrote:
On Wednesday, 1 February 2023 at 17:36:07 UTC, Andrea Fontana 
wrote:

Hi! I've just release a new version of serverino, my pure-D...



First of all, thanks for your effort!

For the second, I have a couple of simple web services that are 
require small, simple and fast webapp. So I'm wondering, do you 
have any plans to do some benchmarks or if you did, please 
share the place to check it?


Someone already did it (with a previous version!).

Anyway it's fast enough for real world usage if you're not 
running a million webpage website on it 


The company I work for uses it for many small simple and fast 
webapps!


In most cases the bottle neck is not serverino itself, but the 
code you're putting over it.


It works with a daemon and responders, not fibers. So it could be 
not efficient for long blocking operation. Let's say you want to 
replace PHP with a better and faster language, that's a good 
choice :)


It's really fast to setup for development and I suggest to put it 
under nginx if exposed into the wild (easy, explained on github 
page)


Give it a try!
Andrea



Serverino 0.4.0

2023-02-01 Thread Andrea Fontana via Digitalmars-d-announce
Hi! I've just release a new version of serverino, my pure-D 
webserver without 3rd party dependencies, super-fast to compile.


This version is featuring a basic & easy way to add routing using 
UDAs.


A big thank you to Ferhat Kurtulmuş that create a pull request 
for this :)


Just create a ready-to-go serverino using the project template:
```dub init -t serverino your_server```

And then test the new feature:
```d
import serverino;

mixin ServerinoMain;

@endpoint @route!"/hello/world" // also: @route!(request => 
request.uri == "/hello/world")

void your_request(const Request r, Output o)
{
   o ~= "Hello world!";
}

@endpoint @route!(request => r.get.has("item"))
void another_request(const Request r, Output o)
{
   o ~= "Item " ~ r.get.read("item");
}

@endpoint @priority(-1)
void this_is_a_fallback(const Request r, Output o)
{
   o ~= r.dump();
}

```

More info and docs: https://github.com/trikko/serverino




Re: Serverino 0.3.0 - now with windows support

2022-10-28 Thread Andrea Fontana via Digitalmars-d-announce

On Friday, 28 October 2022 at 09:25:11 UTC, Imperatorn wrote:
On Friday, 28 October 2022 at 07:42:26 UTC, Andrea Fontana 
wrote:

On Thursday, 27 October 2022 at 19:46:47 UTC, Imperatorn wrote:

Nice, sometimes you just need some quick and dirty http


That's exactly one of the use cases :)


I'm on Windows 10 and your three-liner just worked, thanks


Good to know. I have no windows machine, but unit-tests passed on 
github :)

Anyway if you see something strange, keep me posted on github!

Andrea


Re: Serverino 0.3.0 - now with windows support

2022-10-28 Thread Andrea Fontana via Digitalmars-d-announce

On Thursday, 27 October 2022 at 19:46:47 UTC, Imperatorn wrote:

Nice, sometimes you just need some quick and dirty http


That's exactly one of the use cases :)


Re: parserino 0.2.0

2022-10-23 Thread Andrea Fontana via Digitalmars-d-announce

On Saturday, 22 October 2022 at 22:14:26 UTC, Adam D Ruppe wrote:

On Saturday, 22 October 2022 at 21:58:54 UTC, Enjoys Math wrote:

Nice!  So it's D's answer to Python's BeautifulSoup.


D has had a html tag soup parser since 2009 in my dom.d.

The parserino might be more html5 compliant specifically 
though, as mine was written before html5 was a thing. It's been 
updated with it but still an independent parser (capable of 
reading in-the-wild html as well as things like xml and even 
php tags) instead of following their specific algorithm.


Ah-ah! Adam is worried 
Just kidding, he helped me to compile parserino on Windows, so 
thanks Adam!


Re: parserino 0.2.0

2022-10-20 Thread Andrea Fontana via Digitalmars-d-announce

On Thursday, 20 October 2022 at 13:24:27 UTC, psyscout wrote:
Wow, it uses builtin browser. Cool! I have a coming project, 
will try it out. Thank You for your effort!


You're welcome :)


parserino 0.2.0

2022-10-19 Thread Andrea Fontana via Digitalmars-d-announce

Hello!

Finally I released the public version of parserino, a html5 
parser for linux, macos and windows.


Link:
https://github.com/trikko/parserino


Serverino 0.3.0 - now with windows support

2022-10-16 Thread Andrea Fontana via Digitalmars-d-announce

Hello there.

I've just released a new version of serverino, a simple and 
ready-to-go http server with zero external dependencies (pure D!).


I changed a lot of things under the hood from the last version 
and tests are welcome.


It works on linux, macos and windows. I use only linux, so I 
didn't test so much on other platforms.


I started the project since we need a fast and easy way to setup 
a server for services, small websites or simply to do some tests 
on the browser and this is its main focus (but don't worry: it 
can handle several thousands of requests for seconds)


To start a new website just write:

```
dub init test_serverino -t serverino
cd test_serverino
dub

```

And you're done.

More info here: https://github.com/trikko/serverino

Andrea






Re: static assert("nothing")

2022-05-31 Thread Andrea Fontana via Digitalmars-d-learn

On Tuesday, 31 May 2022 at 09:52:10 UTC, realhet wrote:

On Tuesday, 31 May 2022 at 09:35:30 UTC, Andrea Fontana wrote:

On Tuesday, 31 May 2022 at 08:51:45 UTC, realhet wrote:
Check if that string is init.


assert("", "cool");
assert("ehh", "cool");
assert(string.init, "Not cool");

I feel some "JavaScript equality operator" vibes in this :D
Anyways, I will be extra careful with these.


assert(string.init is null) is the answer :)


Re: static assert("nothing")

2022-05-31 Thread Andrea Fontana via Digitalmars-d-learn

On Tuesday, 31 May 2022 at 08:51:45 UTC, realhet wrote:

Hi,

In my framework I just found a dozen of compile time error 
handling like:


...else static assert("Invalid type");

This compiles without error. And it was useless for detecting 
errors because I forgot the first "false" or "0" parameter.


The first is the assert condition, the message is opt.

I think it is because of the weird case of "every string casted 
to bool is true".


string s1;
string s2 = string.init; // Equivalent
string s3 = null; // Equivalent

string s4 = "";

assert(s1, "This fails");
assert(s2, "This fails too");
assert(s3, "This fails too");
assert(s4, "This pass");

There is an example in Phobos also:  
https://github.com/dlang/phobos/blob/master/std/uni/package.d

at line 8847: static assert("Unknown normalization form "~norm);

It is easy to make this mistake, but does static assert(string) 
has any meaningful use cases?


Check if that string is init.

Andrea




Re: HTTP frameworks benchmark focused on D libraries

2022-05-31 Thread Andrea Fontana via Digitalmars-d-announce

On Monday, 30 May 2022 at 20:57:02 UTC, tchaloupka wrote:

On Sunday, 29 May 2022 at 06:22:43 UTC, Andrea Fontana wrote:

On Thursday, 26 May 2022 at 07:49:23 UTC, tchaloupka wrote:

I see there is a test where numbers are identical to arsd 
ones, is it a typo or a coincidence?

Andrea


Hi Andrea,
it was just a coincidence, straight out copy of the tool 
results.
But as I've found some bugs calculating percentiles from `hey` 
properly, I've updated the results after the fix.


I've also added results for `geario` (thanks #zoujiaqing).
For `serverino`, I've added variant that uses 16 worker 
subprocesses in the pool, that should lead to less blocking and 
worse per request times in the test environment.


Tom


Thank's again! Benchmark are always welcome :)


Re: HTTP frameworks benchmark focused on D libraries

2022-05-29 Thread Andrea Fontana via Digitalmars-d-announce

On Thursday, 26 May 2022 at 07:49:23 UTC, tchaloupka wrote:

Hi,
as there are two more HTTP server implementations:

* 
[Serverino](https://forum.dlang.org/thread/bqsatbwjtoobpbzxd...@forum.dlang.org)


Thank you! Since it's just a young library that results sounds 
promising.


I'm just working on the next version, focusing on performance 
enhancement and windows support :)



I see there is a test where numbers are identical to arsd ones, 
is it a typo or a coincidence?

Andrea


Re: Release: serverino - please destroy it.

2022-05-15 Thread Andrea Fontana via Digitalmars-d-announce

On Sunday, 15 May 2022 at 06:37:08 UTC, frame wrote:

On Saturday, 14 May 2022 at 23:23:47 UTC, Andrea Fontana wrote:


Which kind of socket exception could be triggered by a client?

Andrea


It doesn't matter if triggered by a client or not, you need to 
deal with the possibility. A closed/destroyed socket is an 
invalid resource.


I recently had the scenario on Windows where a client crashed 
and the socket wasn't closed properly somehow. Now the server 
adds the socket to the set to see an update - boom! "Socket 
operation on non-socket" error.


Also accepting sockets can throw, for eg. by a stupid network 
time out error - not only on Windows. Other socket operations 
are no exceptions either.


`isAlive` is fine for properly shutdowned/closed sockets by you 
or peer. But it doesn't protect you from faulting ones.


Ok, added some checks on .select, .accept, .bind, .listen.
Thank you.

Andrea



Re: Release: serverino - please destroy it.

2022-05-14 Thread Andrea Fontana via Digitalmars-d-announce

On Saturday, 14 May 2022 at 20:44:54 UTC, frame wrote:
Take care of socket exceptions - especially if you want to make 
a port to Windows.


You should always expect one. It's not enough to test 
`Socket.isAlive` - a client socket may be faulty and any 
illegal socket operation throws and kills your loop. Even if 
`isAlive` works as expected, it may changes the status before 
you have add the socket to the set. You don't want your server 
to crash if a client misbehaves.


Which kind of socket exception could be triggered by a client?

Andrea


Re: Release: serverino - please destroy it.

2022-05-12 Thread Andrea Fontana via Digitalmars-d-announce

On Thursday, 12 May 2022 at 11:46:05 UTC, Guillaume Piolat wrote:

On Thursday, 12 May 2022 at 11:33:07 UTC, Andrea Fontana wrote:


Does dmd/rdmd work? Serverino uses std.net.curl just for 
running its unittests, so maybe that bug is not blocking.


Well tbh, the simple fact that I would have to use WSL is a 
blocker for me.

AFAIK vibe or cgi.d do not require that.


Yay. I need a Windows machine (or someone with it!) to rewrite 
some POSIX parts.


For example the part that send/receive the file descriptor (of a 
socket) from the master process to the worker (windows has its 
own API for this)


Re: Release: serverino - please destroy it.

2022-05-12 Thread Andrea Fontana via Digitalmars-d-announce

On Thursday, 12 May 2022 at 10:26:28 UTC, Guillaume Piolat wrote:

On Sunday, 8 May 2022 at 21:45:28 UTC, Andrea Fontana wrote:


If you can test it on windows with WSL, that would be 
appreciated a lot!




I tried to test servrino on WSL, but dub doesn't run on WSL.
=> https://github.com/dlang/dub/issues/2249


Hey thanks for your support!

Too bad dub doesn't work with wsl, it sounds like a lost 
opportunity.


Does dmd/rdmd work? Serverino uses std.net.curl just for running 
its unittests, so maybe that bug is not blocking.


Andrea


Re: Release: serverino - please destroy it.

2022-05-11 Thread Andrea Fontana via Digitalmars-d-announce

On Wednesday, 11 May 2022 at 06:50:37 UTC, Orfeo wrote:

well done Andrea!

(forum begins to be too crowded with Italians :) )


---
Orfeo


We all miss the good old bearophile!
I think the most active italian in this forum.

Andrea


Re: Release: serverino - please destroy it.

2022-05-10 Thread Andrea Fontana via Digitalmars-d-announce

On Tuesday, 10 May 2022 at 21:24:46 UTC, Paolo Invernizzi wrote:


Here I am ... Milanese: https://www.deepglance.com/about

/Paolo


Ok it's me getting old!

Andrea




Re: Release: serverino - please destroy it.

2022-05-10 Thread Andrea Fontana via Digitalmars-d-announce

On Tuesday, 10 May 2022 at 20:13:45 UTC, Paolo Invernizzi wrote:
Sinceramente non ricordo di averlo scritto, ma alla mia eta ... 
probabilmente dimentico qualcosa ... comunque piacere! E' bello 
vedere altri italiani apprezzare questo magnifico linguaggio!


(Frankly speaking, I don't remember to have written that, but 
hey, I'm getting old ... probably  I'm forgetting something ... 
anyway nice to meet you! It's great to see Italians here 
enjoying this great programming language!)


I wonder if you're making a fool of me. Or maybe it's me who is 
getting old.
I'm pretty sure that there's a user here with a really Italian 
name who was born somewhere in South America.


Andrea


Re: Release: serverino - please destroy it.

2022-05-10 Thread Andrea Fontana via Digitalmars-d-announce

On Tuesday, 10 May 2022 at 19:50:08 UTC, Paolo Invernizzi wrote:


Concordo ... (I agree!)

:-P


Wait, you have always said you're not Italian. Have you changed 
your mind?


Andrea




Re: Release: serverino - please destroy it.

2022-05-10 Thread Andrea Fontana via Digitalmars-d-announce

On Tuesday, 10 May 2022 at 18:33:18 UTC, Sebastiaan Koppe wrote:

On Tuesday, 10 May 2022 at 10:49:06 UTC, Andrea Fontana wrote:
On Tuesday, 10 May 2022 at 08:32:15 UTC, Sebastiaan Koppe 
wrote:
The difference is that with the route uda you can *only* map 
routes 1:1 exhaustively. With your approach it is up to the 
programmer to avoid errors. It is also hard to reason about 
the flow of requests through all those functions, and you 
have to look at the body of them to determine what will 
happen.


Sorry I don't follow you


It is simple, since all your handler are effectively chained, 
any error in any one of them can cause later ones to fail or 
misbehave. This decreases locality and increases the things you 
have to reason about.


Not sure. What if your uda (regex) match is too permissive? Is 
that different?


My code evaluates workers in order, just like yours, no?

Maybe I can enable some log if set on config, to track what's 
happening. That could help you to debug if something goes wrong.




There are other benefits to uda tagged endpoints too, for 
example they are easier to nest, or to programmatically 
generate them. In vibe-d I added the default option of 
generating OPTION handlers for every regular endpoint. This is 
required for CORS.



@endpoint void func(...){
   if(req.method == Method.OPTION){
   // THIS RUN FOR EVERY ENDPOINT
   }
}




In any case if you want to use a different routing strategy 
it's quite easy. I really don't like libraries that force you 
to use their own style/way.


That is good.


Andrea




Re: Release: serverino - please destroy it.

2022-05-10 Thread Andrea Fontana via Digitalmars-d-announce
On Tuesday, 10 May 2022 at 16:47:13 UTC, Ola Fosheim Grøstad 
wrote:

On Tuesday, 10 May 2022 at 16:05:11 UTC, Andrea Fontana wrote:
Oh, italian is full of suffixes. -ello means a slightly 
different thing. It's small but sounds like a bit pejorative.


Oh, and I loved the sound of it… suggests immaturity, perhaps?

(I love the -ello and -ella endings. «Bambinella» is one of my 
favourite words, turns out it is a fruit too!)


Maybe bambinetto is more about immaturity. Bambinuccio is cute. 
Bambinaccio is bad. Bambinone is big (an adult that behave like a 
child). -ello doesn't sound good with bambino, but it's very 
similar to -etto.


Good luck :)



Re: Release: serverino - please destroy it.

2022-05-10 Thread Andrea Fontana via Digitalmars-d-announce
On Tuesday, 10 May 2022 at 15:35:35 UTC, Ola Fosheim Grøstad 
wrote:

On Tuesday, 10 May 2022 at 15:27:48 UTC, Andrea Fontana wrote:
Indeed the "-ino" suffix in "serverino" stands for "small" in 
italian. :)


Bambino > bambinello? So, the embedded-version could be 
«serverinello»? :O)


Oh, italian is full of suffixes. -ello means a slightly different 
thing. It's small but sounds like a bit pejorative.


-ino in bambino is not (anymore) a suffix, anyway.


Andrea


Re: Release: serverino - please destroy it.

2022-05-10 Thread Andrea Fontana via Digitalmars-d-announce
On Tuesday, 10 May 2022 at 15:16:22 UTC, Ola Fosheim Grøstad 
wrote:

On Tuesday, 10 May 2022 at 15:00:06 UTC, Andrea Fontana wrote:
I work in the R and every single time I even have to write a 
small api or a simple html interface to control some strange 
machine I think "omg, I have to set nginx agaain".


Good point, there are more application areas than regular 
websites. Embedded remote applications could be another 
application area where you want something simple with HTTPS 
(monitoring webcams, sensors, solar panels, supervising farming 
houses or whatever).


Indeed the "-ino" suffix in "serverino" stands for "small" in 
italian. :)


Andrea


Re: Release: serverino - please destroy it.

2022-05-10 Thread Andrea Fontana via Digitalmars-d-announce

On Tuesday, 10 May 2022 at 15:01:43 UTC, Adam Ruppe wrote:

On Monday, 9 May 2022 at 19:20:27 UTC, Andrea Fontana wrote:
Thank you. Looking forward to getting feedback, bug reports 
and help :)


BTW I'm curious, what made you not want to use my cgi.d which 
has similar capabilities?


I was really tempted to start from that!
But it's difficult to fork and edit a 11kloc project like that :)

I had yet developed fastcgi and scgi code in the past so I've 
reused some code and it didn't take so much time to get to 
serverino.


Andrea




Re: Release: serverino - please destroy it.

2022-05-10 Thread Andrea Fontana via Digitalmars-d-announce
On Tuesday, 10 May 2022 at 13:15:38 UTC, Ola Fosheim Grøstad 
wrote:

On Tuesday, 10 May 2022 at 12:52:01 UTC, Andrea Fontana wrote:
I'm running a whole website in D using fastcgi and we have no 
problem at all, it's blazing fast. But it's not so easy to 
setup as serverino :)


Easy setup is probably the number one reason people land on a 
specific web-tech, so it is the best initial angle, I agree.


(By version 3.x you know what the practical weak spots are and 
can rethink the bottom layer.)


Right. But it's not just marketing.

I work in the R and every single time I even have to write a 
small api or a simple html interface to control some strange 
machine I think "omg, I have to set nginx agaain". It's 
pretty annoying especially if you're working on shared aws 
machine. (I know, docker & c. Exist, but they take a lot to setup 
and they are heavy for some simple api). I'm going to love 
serverino in the next months :)


Re: Release: serverino - please destroy it.

2022-05-10 Thread Andrea Fontana via Digitalmars-d-announce

On Tuesday, 10 May 2022 at 13:34:27 UTC, Adam D Ruppe wrote:

On Monday, 9 May 2022 at 20:37:50 UTC, Andrea Fontana wrote:

The same goes for cgi/fastcgi/scgi and so on.


Well, cgi does one process per request, so there is no worker 
pool (it is the original "serverless" lol).


fastcgi is interesting because the Apache module for it will 
actually start and stop worker processes as-needed. I don't 
think the the nginx impl does that though.


Some daemons can manage this by themselves (once again: check  
php-fpm  "dynamic" setting).


Serverino can do it as well. You can set in configuration the max 
and min number of workers. It's easy:


```
@onServerInit auto setup()
{
ServerinoConfig sc = ServerinoConfig.create();
sc.setMinWorkers(5);
sc.setMaxWorkers(100);
return sc;
}
```

If all workers are busy the daemon will launch a new one. You 
might be interested in

setMaxWorkerLifetime() and  sc.setMaxWorkerIdling() too!

But the nicest thing about all these application models is if 
you write it in the right way, you can swap out the approach, 
either transparently adding the i/o event waits or just adding 
additional servers without touching the application code. 
That's a lot harder to do when you expect shared state etc. 
like other things encourage.


I would mention that if something goes wrong and a process crash 
or get caught in an infinite loop, it's not a problem. Process is 
killed and wake up again without pull all the server down.


Andrea




Re: Release: serverino - please destroy it.

2022-05-10 Thread Andrea Fontana via Digitalmars-d-announce
On Tuesday, 10 May 2022 at 12:31:23 UTC, Ola Fosheim Grøstad 
wrote:

On Tuesday, 10 May 2022 at 10:49:06 UTC, Andrea Fontana wrote:

And you can still handle 700k/views per hour with 20 workers!


Requests tend to come in bursts from the same client, thanks to 
clunky javascript APIs and clutters of resources (and careless 
web developers). For a typical D user ease-of-use is probably 
more important at this point, though, so good luck with your 
project!


In my opnioni IRL that's not a big problem as it can seem.

Again: that's just how nginx and apache handle php/cgi/fcgi/scgi 
requests.
Wikipedia runs wikimedia software. Written in php. Running on 
apache with php-fpm (and cache!).


And I'm not suggesting to run wikipedia on serverino, *for now*.

If you try to open a lot of wikipedia pages at the same time in a 
burst, they will be served (probably using keep-alive connection) 
not in parallel: you're queued. And the 99.9% of users will never 
notice this. Is it a problem?


If you need much control, you can use an http accelerator and/or 
you can use a reverse proxy (like nginx) to control bursts et 
similia.


I'm running a whole website in D using fastcgi and we have no 
problem at all, it's blazing fast. But it's not so easy to setup 
as serverino :)


Andrea




Re: Release: serverino - please destroy it.

2022-05-10 Thread Andrea Fontana via Digitalmars-d-announce

On Tuesday, 10 May 2022 at 08:32:15 UTC, Sebastiaan Koppe wrote:

On Monday, 9 May 2022 at 20:37:50 UTC, Andrea Fontana wrote:

On Monday, 9 May 2022 at 20:08:38 UTC, Sebastiaan Koppe wrote:
As an example, how many requests per second can you manage if 
all requests have to wait 100 msecs?


For non critical workload you will probably still hit good 
enough performance though.


Firstly, it depends on how many workers you have.

Then you should consider that a lot of (most?) websites use 
php-fpm, that works using the same approach (but php is much 
slower than D). The same goes for cgi/fastcgi/scgi and so on.


Let's say you have just 20 workers. 100msecs for each request 
(a lot of time for my standards, I would say). That means 
20*10 = 200 webpages/s = 720k pages/h. I don't think your 
website has so much traffic...


And I hope not every request will take 100msecs!


100msecs is on the upper end for sure, but if you add a 
database, external service call, etc. it is not uncommon to 
reach that.


And you can still handle 700k/views per hour with 20 workers!

The point however, is that the architecture breaks down because 
it is unable to do work concurrently. Every requests blocks a 
worker from start to finish.


Unless it is CPU heavy the system will be under utilized. That 
is not necessarily bad though. The simplicity has something 
going for it, but it is definitely a tradeoff that you should 
consider highlighting.


Every server has its own target. BTW, I'm not developing 
serverino to use it as a building block of a CDN.


In real-life projects, I think you can use it without any problem 
for not-huge projects.


You can also put it under a reverse proxy (f.e. nginx), to handle 
just the requests you need to write in D.


The difference is that with the route uda you can *only* map 
routes 1:1 exhaustively. With your approach it is up to the 
programmer to avoid errors. It is also hard to reason about the 
flow of requests through all those functions, and you have to 
look at the body of them to determine what will happen.


Sorry I don't follow you: I don't know which framework you're 
using, but if you're using UDA with matches (something like: 
@matchUri("/main") void renderMain(...) { ... }) you still have 
to check all the functions if a request is not handled correctly. 
Or am I missing something?


Using my approach if you want to check which functions escape 
from routing you can just add a catch-all endpoint with low 
priority.


```
@priority(-1000) @endpoint
void wtf(Request r, Output o)
{
  fatal("Request NOT HANDLED: ", r.dump());
}
```

And if a request doesn't match your UDA constraint, how do you 
debug what's wrong with it? I think it's easier to add a 
checkpoint/log on the first lines of your functions body to guess 
why the function is skipped.


In any case if you want to use a different routing strategy it's 
quite easy. I really don't like libraries that force you to use 
their own style/way.


So you can even drop my UDAs and write the app like this. It 
still works:


```
mixin ServerinoMain;

void entry(Request r, Output o)
{
// Use your routing strategy here
// ...
// YourRouter router;
// router.do(r, "/hello/world", );
// router.do(r, "/bla", );
}
```

Andrea


Re: Release: serverino - please destroy it.

2022-05-09 Thread Andrea Fontana via Digitalmars-d-announce

On Monday, 9 May 2022 at 20:08:38 UTC, Sebastiaan Koppe wrote:

On Sunday, 8 May 2022 at 21:32:42 UTC, Andrea Fontana wrote:
Every request is processed by a worker running in an isolated 
process, no fibers/threads, sorry (or thanks?)


I did some tests and the performance sounds good: on a local 
machine it can handle more than 100_000 reqs/sec for a simple 
page containing just "hello world!".Of course that's not a 
good benchmark, if you can help me with other benchmarks it 
would be much appreciated (a big thanks to Tomáš Chaloupka who 
did some tests!)


Typically server applications are IO heavy. I expect your 
isolated-process approach to break down with that kind of work.


I know. We all know :) Benchmarks are just benchmarks. They are 
useful to understand how much overhead your server adds to the 
whole project. These benchmarks are made in the local machine, 
with almost no connection overhead.


Not every application is IO heavy, anyway.

As an example, how many requests per second can you manage if 
all requests have to wait 100 msecs?


For non critical workload you will probably still hit good 
enough performance though.


Firstly, it depends on how many workers you have.
Then you should consider that a lot of (most?) websites use 
php-fpm, that works using the same approach (but php is much 
slower than D). The same goes for cgi/fastcgi/scgi and so on.


Let's say you have just 20 workers. 100msecs for each request (a 
lot of time for my standards, I would say). That means 20*10 = 
200 webpages/s = 720k pages/h. I don't think your website has so 
much traffic...


And I hope not every request will take 100msecs!



Instead of using a lot of different UDAs to set routing rules, 
you can simply write them in your endpoint's body and exit 
from it to pass to the next endpoint.


My experience is that exhaustive matching is easier to reason 
about at larger scale.


Yes, but exactly the same thing can be done without uda.

```
@endpoint void my_end(Request r, Output o)
{
 if (r.uri == "/asd") // or whatever you want: regex, or 
checking another field

return false; //
}
```

This is just like:

```
@matchuda(uri, "/asd") void my_end() { ... }
```

What's the difference? The first one is much more flexible, IMHO.


Please help me testing it, I'm looking forward to receiving 
your shiny new issues on github.


I noticed it has zero unittests, that is probably a good place 
to start.


Of course! They will come for sure. :)

Andrea



Re: Release: serverino - please destroy it.

2022-05-09 Thread Andrea Fontana via Digitalmars-d-announce

On Monday, 9 May 2022 at 19:09:40 UTC, Guillaume Piolat wrote:

On Sunday, 8 May 2022 at 21:32:42 UTC, Andrea Fontana wrote:

Hello!

I've just released serverino. It's a small & ready-to-go 
http/https server.


Dub package: https://code.dlang.org/packages/serverino

Andrea


Looks very useful, congratulations!


Thank you. Looking forward to getting feedback, bug reports and 
help :)


Andrea


Re: Release: serverino - please destroy it.

2022-05-08 Thread Andrea Fontana via Digitalmars-d-announce

On Sunday, 8 May 2022 at 22:09:37 UTC, Ali Çehreli wrote:
Congratulations! :) Looking forward to watching your 
presentation at DConf... ;)


I wish I was able to speak publicly in English in front of an 
audience :)




On 5/8/22 14:32, Andrea Fontana wrote:

> Every request is processed by a worker running in an isolated
process,
> no fibers/threads, sorry (or thanks?)

That effectively uses multiple GCs. I always suspected that 
approach would provide better latency.


I think it depends on what your server is doing, anyway.



> sending opened file descriptors between processes thru sockets


I sent a pull request (merged!) for druntime to make this work on 
macOS too!




Sweet!

Ali





Re: Release: serverino - please destroy it.

2022-05-08 Thread Andrea Fontana via Digitalmars-d-announce

On Sunday, 8 May 2022 at 21:32:42 UTC, Andrea Fontana wrote:

[...]
Andrea


Whoops, I forgot a couple of things. This was tested on linux 
only and it should work fine on other posix systems (macOS 
included!).


I don't have windows, but I think you need WSL to run it, since 
I'm using a lot of strange posix tricks to keep performace at a 
good level (like sending opened file descriptors between 
processes thru sockets).


If you can test it on windows with WSL, that would be appreciated 
a lot!


Andrea





Release: serverino - please destroy it.

2022-05-08 Thread Andrea Fontana via Digitalmars-d-announce

Hello!

I've just released serverino. It's a small & ready-to-go 
http/https server.


Every request is processed by a worker running in an isolated 
process, no fibers/threads, sorry (or thanks?)


I did some tests and the performance sounds good: on a local 
machine it can handle more than 100_000 reqs/sec for a simple 
page containing just "hello world!".Of course that's not a good 
benchmark, if you can help me with other benchmarks it would be 
much appreciated (a big thanks to Tomáš Chaloupka who did some 
tests!)


I'm trying to keep it simple and easy to compile. It has no 
external deps in its base configuration and only one external 
library (libretls) is required if you need/want to enable https.


For your first project you need just three lines of code as you 
can see here:

https://github.com/trikko/serverino/

I didn't implement a traditional router for uris as probably many 
of you expected. I use a different approach. Check out this 
example: 
https://github.com/trikko/serverino/#defining-more-than-one-endpoint


This allows you to do some interesting things giving higher or 
lower priority to each endpoint (for example you can force 
something to always running first like redirect, logging, checks 
on login...)


Instead of using a lot of different UDAs to set routing rules, 
you can simply write them in your endpoint's body and exit from 
it to pass to the next endpoint.


Please help me testing it, I'm looking forward to receiving your 
shiny new issues on github.


Dub package: https://code.dlang.org/packages/serverino

Andrea





Re: GCC 12.1 Released (D v2.100-rc.1)

2022-05-08 Thread Andrea Fontana via Digitalmars-d-announce

On Friday, 6 May 2022 at 11:57:47 UTC, Iain Buclaw wrote:

Hi,

I am proud to announce another major GCC release, 12.1.
[...]
Regards,
Iain.


Great!



Re: CTFE and BetterC compatibility

2022-04-27 Thread Andrea Fontana via Digitalmars-d-learn

On Wednesday, 27 April 2022 at 14:21:15 UTC, Claude wrote:

data.digits ~= parseDigit(str[0]);


Dynamic arrays are not supported using -betterC

Andrea





Re: mysql-native v3.2.0 - the safe update

2022-04-27 Thread Andrea Fontana via Digitalmars-d-announce
On Saturday, 23 April 2022 at 05:12:30 UTC, Steven Schveighoffer 
wrote:
This is a huge huge update. I've never done anything like this 
before, but I think it works as a drop-in replacement, while 
allowing you to migrate any piece you wish from unsafe code to 
safe code. Please let me know if there are *any* problems you 
find with this.


Well done Steven!

Note this does *not* build with dip1000, because the two 
underlying libraries (Phobos sockets and vibe.d) do not build 
as safe with dip1000.


Dip1000 is marked as "superseded". I don't understand what the 
plan is.


Andrea






Re: How to print or check if a string is "\0" (null) terminated in the D programming language?

2022-04-06 Thread Andrea Fontana via Digitalmars-d-learn

On Wednesday, 6 April 2022 at 08:55:43 UTC, BoQsc wrote:
I have a feeling that some parts of my code contains 
unterminated strings and they do overflow into other string 
that is to be combined. I'd like to take a look at strings, 
analyse them manually and see if any of them end up terminated 
or not.


Please provide any relevant examples of how you do this.


string literals are zero-terminated in d.

If you need to pass a D string to a C function use toStringz()
https://dlang.org/library/std/string/to_stringz.html




Re: Added copy constructors to "Programming in D"

2022-01-13 Thread Andrea Fontana via Digitalmars-d-announce

On Saturday, 8 January 2022 at 13:23:52 UTC, Imperatorn wrote:

On Saturday, 8 January 2022 at 02:07:10 UTC, Ali Çehreli wrote:

1) After about three years, I finally added copy constructors:


http://ddili.org/ders/d.en/special_functions.html#ix_special_functions.copy%20constructor

[...]


Splendid!

Will the physical book also be updated?

Thanks!


I don't think it is possible. You have to buy a new copy when 
published. /s


Re: D Language Foundation Monthly Meeting Summary (September 24, 2021)

2021-10-19 Thread Andrea Fontana via Digitalmars-d-announce

On Wednesday, 6 October 2021 at 06:23:01 UTC, WebFreak001 wrote:

On Friday, 1 October 2021 at 12:32:20 UTC, Mike Parker wrote:

[...]
new slogan
[...]


want to generate controversial heat?

Do it in D (DIID)

(careful with there being a trademark for DiiD though)


You mean:

Just D it


Re: how to enable safeD ? dmd.conf ? dmd switch ?

2021-06-08 Thread Andrea Fontana via Digitalmars-d-learn

On Tuesday, 8 June 2021 at 02:47:18 UTC, someone wrote:

https://dlang.org/articles/safed.html
https://dlang.org/dmd-linux.html#switches
http://ddili.org/ders/d.en/functions_more.html

Neither man dmd nor man dmd.conf appear to have a 
related/switch setting.


Does it means safeD is achieved by placing @safe attributes all 
over the place ? Or is it achieved by setting some global 
switch elsewhere ? Am I missing something ?


Just mark main() function with @safe and you're done.


Re: (Oh My) Gentool 0.4.0 released

2021-06-07 Thread Andrea Fontana via Digitalmars-d-announce

On Sunday, 6 June 2021 at 10:03:11 UTC, evilrat wrote:

## (oh my) gentool v0.4 is now out.

It is my fancy tool to generate extern(C++) stuff quicker, it 
takes regular compiler flags that you usually pass to clang and 
translates C/C++ code to D.


This release has one new feature: support pragma mangle on 
aggregates (class, struct, etc...).


Also a lot of work was put into template support, but it is 
still has lots of unhandled cases, so do not expect it will 
translate STL or Boost without need of manual fixes.


Source
https://github.com/Superbelko/ohmygentool

Windows binaries
https://github.com/Superbelko/ohmygentool/releases/tag/v0.4.0


Nice work. Is there a docker somewhere in order to test it?


Re: D + raylib = BlobEditor

2020-11-04 Thread Andrea Fontana via Digitalmars-d-announce
On Wednesday, 4 November 2020 at 07:45:46 UTC, Ferhat Kurtulmuş 
wrote:
looks so funny. As if an alien material is trying to grow and 
eat worlds.


Yes. But it's so relaxing, isn't it?


D + raylib = BlobEditor

2020-11-02 Thread Andrea Fontana via Digitalmars-d-announce

Hello.

I've just published a small toy/demo project.

I use D and raylib to create and render a blob in real time.

Here a video: https://www.youtube.com/watch?v=RIVDdXV6D-A
Here the source: https://github.com/trikko/BlobEditor

It runs fine on my 7yo laptop.

Andrea


Re: bindbc-sfml 0.1.0

2020-11-02 Thread Andrea Fontana via Digitalmars-d-announce

On Monday, 2 November 2020 at 11:01:53 UTC, Mike Parker wrote:
I've finally gotten around to finishing up the port of 
DerelictSFML2 to BindBC:


http://bindbc-sfml.dub.pm/


+1

Great job Mike!



Re: MetaCall Polyglot is now available form D

2020-08-14 Thread Andrea Fontana via Digitalmars-d-announce
On Tuesday, 4 August 2020 at 22:25:19 UTC, Vicente Eduardo Ferrer 
Garcia wrote:

[...]
If someone is interested in the D port you can find the source 
here: https://github.com/metacall/dlang-port



Nice! Maybe you can use a bit of syntax sugar for D. Check this 
example:

https://run.dlang.io/is/TKkmbe

Andrea



Re: Idiomatic D code to avoid or detect devision by zero

2020-07-31 Thread Andrea Fontana via Digitalmars-d-learn
On Friday, 31 July 2020 at 13:55:18 UTC, Martin Tschierschke 
wrote:
What would be the idiomatic way to write a floating point 
division

occuring inside a loop and handle the case of division by zero.

c = a/b; // b might be zero sometimes, than set c to an other 
value (d).


(In the moment I check the divisor being zero or not, with an 
if-than-else structure,

but I find it ugly and so I ask here.)


You should give a look at:
https://dlang.org/phobos/std_experimental_checkedint.html

You can try with checked!Throw and catch exceptions, for example.

Andrea


Re: Origins of the D Programming Language now published by ACM!

2020-06-26 Thread Andrea Fontana via Digitalmars-d-announce

On Saturday, 20 June 2020 at 22:12:21 UTC, Walter Bright wrote:

On 6/20/2020 2:59 PM, Bill Baxter wrote:
Whoa! Page 23 -- a wild Bill Baxter appears! That was 
unexpected.  :-D

--bb


So many contributors - we tried hard to credit where things 
came from.


Nice paper.

It would be nice to have a graphical timeline with most important 
additions/dips :)


Andrea


Re: in not working for arrays is silly, change my view

2020-03-02 Thread Andrea Fontana via Digitalmars-d-learn
On Saturday, 29 February 2020 at 20:11:24 UTC, Steven 
Schveighoffer wrote:
1. in is supposed to be O(lg(n)) or better. Generic code may 
depend on this property. Searching an array is O(n).


Probably it should work if we're using a "SortedRange".


int[] a = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9];
auto p = assumeSorted(a);

assert(3 in p);




Re: How to sum multidimensional arrays?

2020-02-27 Thread Andrea Fontana via Digitalmars-d-learn

On Thursday, 27 February 2020 at 14:15:26 UTC, p.shkadzko wrote:

void main() {
int[][] m1 = rndMatrix(10, 2, 3);
int[][] m2 = rndMatrix(10, 2, 3);

auto c = m1[] + m2[];
}



I think you're trying to do this:

int[][] m1 = rndMatrix(10, 2, 3);
int[][] m2 = rndMatrix(10, 2, 3);
int[][] m3;

m3.length = m1.length;
foreach(i; 0..m1.length)
{
m3[i].length = m1[i].length;
m3[i][] = m1[i][] + m2[i][];
}

But of course that's not the best solution :)


Re: Earcut polygon triangulation

2020-02-25 Thread Andrea Fontana via Digitalmars-d-announce

On Monday, 24 February 2020 at 20:28:20 UTC, Ben Jones wrote:

On Monday, 24 February 2020 at 19:15:13 UTC, JN wrote:

On Sunday, 23 February 2020 at 16:20:09 UTC, Ahmet Sait wrote:
Out of curiosity, why would you need to triangulate polygons 
instead of using stencil buffer? I'm assuming you're using 
OpenGL (or something similar) since you talked about your 
hobby game. Any advantage of triangulating shapes? 
(anti-aliasing maybe?)


Triangulation goes beyond rendering. I imagine this library 
might be useful when making a level editor for a DOOM-like 
2.5D engine.


It's very poorly documented, but I wrote a delaunay refinement 
triangulator: https://github.com/benjones/dtriangulate .  It's 
mostly a reimplementation of Shewchuk's Triangle which is 
probably the most common delaunay triangulator.


Both of these libraries would have been useful a year ago when I 
was writing my 3d printable vases generator in D :)


Re: The good old CGI

2020-02-17 Thread Andrea Fontana via Digitalmars-d-announce

On Saturday, 15 February 2020 at 22:06:42 UTC, Tier wrote:
It might not change the world, but I'm going to try it 
regardless. So thank you!


You're welcome :)

P.S. I know you made an scgi client. Do you plan on making a 
fcgi one too?


I don't like fastcgi protocol that much. I think scgi is 
equivalent but it is much easier to parse :)


Andrea




The good old CGI

2020-02-14 Thread Andrea Fontana via Digitalmars-d-announce
I've just released [1] a simple single-file-library you can use 
to build cgi-enabled app with d.


Not a big innovation, so I don't expect a lot of interest about 
it.
Anyway it's small and light, so it's a fast (not so efficient) 
way to run web-based scripts.


Check the basic example [2] and the docs [3].

Andrea Fontana

[1] https://code.dlang.org/packages/dcgi
[2] https://github.com/2night/dcgi
[3] https://dcgi.dpldocs.info/dcgi.html


Re: Error on using regex in dmd v2.088.1

2020-02-03 Thread Andrea Fontana via Digitalmars-d-learn

On Monday, 3 February 2020 at 07:11:34 UTC, Dharmil Patel wrote:

On Monday, 3 February 2020 at 07:03:03 UTC, Dharmil Patel wrote:

In my code I am using regex like this:

   auto rgxComma = regex(r",");

On compiling with dmd v2.076.1, it compiles successfully, but 
on compiling with dmd v2.088.1, I am getting lots of errors 
like:


/src/phobos/std/regex/internal/thompson.d-mixin-836(837): 
Error: template instance 
std.regex.internal.thompson.ThompsonOps!(EngineType!(char, 
Input!char), State, true).op!cast(IR)164u error instantiating


Can someone please help me solve this error?

Thanks
Dharmil


Hi Dharmil!
It works for me using 2.088.1 with docker.
Are you sure your installation is ok?

Andrea


Re: format with floating points GC allocating in DMD 2.090

2020-01-31 Thread Andrea Fontana via Digitalmars-d-learn

On Friday, 31 January 2020 at 08:45:55 UTC, bauss wrote:

On Friday, 31 January 2020 at 07:20:17 UTC, cc wrote:

char[4096] buf;
writeln(GC.stats.usedSize);
foreach (i; 0 .. 10) {
sformat(buf, "%f", 1.234f);
writeln(GC.stats.usedSize);
}



Report it as a bug because it's definitely a bug and there was 
changes to the GC in 2.090.0


2.086 x64 on linux:

0
64
112
160
208
256
304
352
400
448
496



Re: Release D 2.090.0

2020-01-07 Thread Andrea Fontana via Digitalmars-d-announce

On Tuesday, 7 January 2020 at 11:12:09 UTC, JN wrote:

Loving the JSON getter :)



Did you give jsonwrap[1] a try?


[1] https://code.dlang.org/packages/jsonwrap


Re: code.dlang.org downtime

2019-12-18 Thread Andrea Fontana via Digitalmars-d-announce

On Wednesday, 18 December 2019 at 09:29:50 UTC, John Colvin wrote:


This is still down for me, regardless of using the IP or 
address. I don't think it's just me either: 
https://stats.uptimerobot.com/6mQX4Crw2L/783838659


https://downforeveryoneorjustme.com/code.dlang.org

Connection timeout here.



Re: code.dlang.org downtime

2019-12-18 Thread Andrea Fontana via Digitalmars-d-announce
On Wednesday, 18 December 2019 at 11:03:04 UTC, Andrea Fontana 
wrote:
On Wednesday, 18 December 2019 at 09:29:50 UTC, John Colvin 
wrote:


This is still down for me, regardless of using the IP or 
address. I don't think it's just me either: 
https://stats.uptimerobot.com/6mQX4Crw2L/783838659


https://downforeveryoneorjustme.com/code.dlang.org

Connection timeout here.


Just said. Up now.


Re: How to create a custom max() function without the ambiguity error.

2019-12-06 Thread Andrea Fontana via Digitalmars-d-learn

On Friday, 6 December 2019 at 12:34:17 UTC, realhet wrote:

Hi,

I'm trying to use a popular function name "max", and extend it 
for my special types:


For example:

module utils;
MyType max(in MyType a, in MyType a){...}  //static function

struct V3f{
  V3f max(in V2f b){...} //member function
}

module gl3n;
vec3 max(in vec3 a, in vec3 a) //another static function in 
different module


I also want to use std.algorithm.comparison.max as well.


I know that the ambiguity error can be avoided by public 
importing all the various max implementations into one place, 
but how to do this when I want to use 3 modules? Need a 4th 
module to combine them all? Is there a nicer way?
Another question that is it possible to extend the the template 
function "to" in more than one module and use it easily from my 
main project modules?


What about:

int max(int a, int b){ return 0; }

void main()
{
.max(3,4).writeln;  // 0
std.algorithm.comparison.max(3,4).writeln; // 4
}


Re: Slice/Substr [0..?lastIndexOf(".")] How refer itself without create a variable?

2019-12-05 Thread Andrea Fontana via Digitalmars-d-learn

On Thursday, 5 December 2019 at 11:28:51 UTC, Marcone wrote:

Simple example:

writeln("Hi\nHow are 
you?\nGood".splitLines()[0][0..?lastIndexOf(r"\")]);


How to refer to this string in lastIndexOf() without create a 
variable?


Thank you.


One solution:

writeln(
"Hello\nHow are you?\nGood"
.splitLines()
.map!(x => x[0..x.lastIndexOf("o")])
);

But be careful: lastIndexOf could be < 0 if string is not found.


Re: Unexpectedly nice case of auto return type

2019-12-03 Thread Andrea Fontana via Digitalmars-d-learn

On Tuesday, 3 December 2019 at 09:48:39 UTC, Basile B. wrote:
You see what surprises me here is that we cannot express the 
special type that is `TypeNull` and that can only have one 
value (`null`) so instead we have to use `auto` or 
`typeof(null)`.


You can still create an alias anyway :)

alias TypeNull = typeof(null);





Re: Unexpectedly nice case of auto return type

2019-12-03 Thread Andrea Fontana via Digitalmars-d-learn

On Tuesday, 3 December 2019 at 07:24:31 UTC, Basile B. wrote:


A testA()
{
return alwaysReturnNull(); // Tnull can be implictly 
converted to A

}

still nice tho.


Why not [1]?

[1] typeof(null) alwaysReturnNull() { ... }

Andrea


Re: static assert(version(x)) ?

2019-11-26 Thread Andrea Fontana via Digitalmars-d-learn
On Tuesday, 26 November 2019 at 10:24:00 UTC, Robert M. Münch 
wrote:
How can I write something like this to check if any of a set of 
specific versions is used?


static assert(!(version(a) | version(b) | version(c)):

The problem is that I can use version(a) like a test, and the 
symbol a is not accessbile from assert (different, 
non-accessible namespace).


version(A) { enum isA = true; } else { enum isA = false; }
version(B) { enum isB = true; } else { enum isB = false; }

static assert(!(isA || isB));


Re: wiki tutorial: D on esp32/esp8266(llvm-xtensa+ldc) and how to get started

2019-11-26 Thread Andrea Fontana via Digitalmars-d-announce

On Tuesday, 26 November 2019 at 08:57:49 UTC, dangbinghoo wrote:

hi,

I just added a simple tutorial to running D betterC on the 
popular ESP32/esp8266 IoT chip.


referenced with the Rust community's Rust on ESP32.

https://wiki.dlang.org/D_on_esp32/esp8266(llvm-xtensa%2Bldc)_and_how_to_get_started

As esp32 IDF is using newlib as it's libc, the druntime and 
phobos just simply won't build.


But betterC seems working, I didn't do with a very strong 
test(actually I don't know if there's betterC test case 
exists), so, just for fun with your own risk!



And, Can we do some work to support druntime building against 
with newlib? If this is true, many MCU would have(newlib 
supports many MCUs) a `real D` running on it.


---
Binghoo Dang


That's great!


Re: Anything like HPPTOD out there?

2019-11-25 Thread Andrea Fontana via Digitalmars-d-learn

On Monday, 25 November 2019 at 16:35:21 UTC, ParticlePeter wrote:
I would like to auto convert c++ header to d module. Is there 
some project aiming for this?


I know of VisualD c++ to d conversion wizzard [1] and LLVM 
tooling based CPP2D [2], both of them aiming for whole cpp 
conversion. But I a searching for something lightweight like 
HTOD extended to C++.


[1] https://rainers.github.io/visuald/visuald/CppConversion.html
[2] https://github.com/lhamot/CPP2D


Give DPP[1] a try!

[1] https://github.com/atilaneves/dpp




Re: What is the point of a synchronized lock on a single return statement?

2019-11-25 Thread Andrea Fontana via Digitalmars-d-learn
On Monday, 25 November 2019 at 09:24:43 UTC, Jonathan M Davis 
wrote:
On Monday, November 25, 2019 1:22:17 AM MST Andrej Mitrovic via 
Digitalmars- d-learn wrote:
From: 
https://github.com/dlang/phobos/blob/10b9174ddcadac52f6a1ea532deab3310d3a8 c03/std/concurrency.d#L1913-L1916:


-
///
final @property bool isClosed() @safe @nogc pure
{
 synchronized (m_lock)
 {
 return m_closed;
 }
}
-

I don't understand the purpose of this lock. The lock will be 
released as soon as the function returns, and it returns a 
copy of a boolean anyway. Am I missing something here?


It ensures that no other code that locks m_lock is running when 
m_closed is accessed. I'd have to study std.concurrency in 
detail to know for sure why that would be needed, but it's not 
atypical when trying to maintain consistent state when multiple 
threads are interacting with each other.


- Jonathan M Davis



Probably to be sure to have a consistent status returned. See for 
example:


https://github.com/dlang/phobos/blob/10b9174ddcadac52f6a1ea532deab3310d3a8c03/std/concurrency.d#L2250




Re: Release D 2.089.0

2019-11-08 Thread Andrea Fontana via Digitalmars-d-announce
On Thursday, 7 November 2019 at 16:37:56 UTC, Andrea Fontana 
wrote:

On Sunday, 3 November 2019 at 13:35:36 UTC, Martin Nowak wrote:

Glad to announce D 2.089.0, ♥ to the 44 contributors.

This release comes with corrected extern(C) mangling in mixin 
templates, atomicFetchAdd and atomicFetchSub in core.atomic, 
support for link driver arguments, better support of LDC in 
dub, and plenty of other bug fixes and improvements.


http://dlang.org/download.html
http://dlang.org/changelog/2.089.0.html

-Martin


My code hit a regression on 2.089.




https://issues.dlang.org/show_bug.cgi?id=20368


Re: Release D 2.089.0

2019-11-07 Thread Andrea Fontana via Digitalmars-d-announce

On Sunday, 3 November 2019 at 13:35:36 UTC, Martin Nowak wrote:

Glad to announce D 2.089.0, ♥ to the 44 contributors.

This release comes with corrected extern(C) mangling in mixin 
templates, atomicFetchAdd and atomicFetchSub in core.atomic, 
support for link driver arguments, better support of LDC in 
dub, and plenty of other bug fixes and improvements.


http://dlang.org/download.html
http://dlang.org/changelog/2.089.0.html

-Martin


My code hit a regression on 2.089.

This worked fine, before dmd 2.089 (reduced):

mixin Bug!"asd";

enum test;

template Bug(string n)
{
   int main()
   {
 import std;
 foreach(name;  __traits(allMembers,  __traits(parent, 
main)))
static if (hasUDA!(__traits(getMember, 
__traits(parent, main), name), test))

   return 0;

 return 0;
   }
}



Re: Meta question - what about moving the D - Learn Forum to a seperate StackExchange platform?

2019-10-18 Thread Andrea Fontana via Digitalmars-d-learn
On Friday, 18 October 2019 at 10:55:59 UTC, Martin Tschierschke 
wrote:
Yes, it works as it is, but it is not the best solution to 
share know how.


I agree. I think D.learn should be moved to stackoverflow and 
D.general should stay here.


Re: How does one cast to an array type?

2019-10-17 Thread Andrea Fontana via Digitalmars-d-learn

On Thursday, 17 October 2019 at 12:19:03 UTC, Vinay Sajip wrote:
Are arrays and objects part of a unified type system? 
Specifically, if I do


void foo(Object x) {
if (typeid(x) == typeid(Object[])) {
auto a = cast(Object[]) x;
}
}

I get a compilation error:

onlineapp.d(3): Error: cannot cast expression x of type 
object.Object to Object[]


What's the way to achieve the cast, which should be safe given 
the typeid check?


Thanks and regards,

Vinay Sajip


Did you try templates? It seems easier:
https://run.dlang.io/is/BbkTCw

Andrea



Re: rapidxml for D has been ported.

2019-10-08 Thread Andrea Fontana via Digitalmars-d-announce

On Tuesday, 8 October 2019 at 08:56:26 UTC, zoujiaqing wrote:

[...]


So finally we have a working xml parser!


Re: How does D distnguish managed pointers from raw pointers?

2019-10-03 Thread Andrea Fontana via Digitalmars-d-learn

On Thursday, 3 October 2019 at 14:13:55 UTC, IGotD- wrote:

According to the GC documentation this code snippet

char* p = new char[10];
char* q = p + 6; // ok
q = p + 11;  // error: undefined behavior
q = p - 1;   // error: undefined behavior

suggests that char *p is really a "fat pointer" with size 
information.


No it's not. char* is a plain pointer.

The example is wrong, since you can't assign a new char[10] to 
char*.


Probably they mean something like:
auto arr = new char[10]
char* p = arr.ptr;
...

This code actually compiles, but its behaviour is undefined, so 
it is a logical error.



In D arrays are fat pointer instead:

int[10] my_array;

my_array is actually a pair ptr+length.



Re: Using algorithms with ranges

2019-10-03 Thread Andrea Fontana via Digitalmars-d-learn

On Thursday, 3 October 2019 at 05:33:04 UTC, mipri wrote:

void main() {
import std.range : iota;

foreach (x; iota(1, 10).withHistory)
writeln(x);
}



This doesn't work as expected, I think.

auto r = iota(1,10).withHistory;

writeln(r.front);
writeln(r.front);


Re: Avoid gratuitous closure allocations

2019-09-20 Thread Andrea Fontana via Digitalmars-d-learn

On Friday, 20 September 2019 at 11:21:22 UTC, Ali Çehreli wrote:
tl;dr Instead of returning an object that uses local state, 
return an object that uses member variables.


Really good to know tips!


Re: How'd I store possible types for each item of a list of Variants ?

2019-09-20 Thread Andrea Fontana via Digitalmars-d-learn

On Friday, 20 September 2019 at 08:58:09 UTC, oleobal wrote:


I'm kind of out of ideas at this point. Would anyone have an 
elegant solution to this problem?


Thanks !


Is this ok for you: https://run.dlang.io/is/VllpJk ?

Andrea



  1   2   3   4   5   6   >