Re: Demo for The Art of Reflection released (a 3D game and engine fully written in D)

2024-06-18 Thread Mike Shah via Digitalmars-d-announce

On Tuesday, 18 June 2024 at 08:49:57 UTC, cookiewitch wrote:

On Friday, 24 May 2024 at 17:45:31 UTC, Lewis wrote:
Hello! Not sure if it's of interest, but I've been developing 
a 3D game and engine in D for a few years, and finally have a 
demo up on Steam for anyone interested in poking around 
(Windows only unfortunately).


[...]

https://store.steampowered.com/app/2290770/The_Art_of_Reflection/



I've just played through the demo, it's impressive! It's a 
pleasantly confusing experience and my brain hurts now. Also, 
it works perfectly fine on Linux via Proton.


Added to my wishlist, as I always like to share with others 
projects built in D :)


Re: Demo for The Art of Reflection released (a 3D game and engine fully written in D)

2024-06-18 Thread cookiewitch via Digitalmars-d-announce

On Friday, 24 May 2024 at 17:45:31 UTC, Lewis wrote:
Hello! Not sure if it's of interest, but I've been developing a 
3D game and engine in D for a few years, and finally have a 
demo up on Steam for anyone interested in poking around 
(Windows only unfortunately).


[...]

https://store.steampowered.com/app/2290770/The_Art_of_Reflection/



I've just played through the demo, it's impressive! It's a 
pleasantly confusing experience and my brain hurts now. Also, it 
works perfectly fine on Linux via Proton.


Re: Demo for The Art of Reflection released (a 3D game and engine fully written in D)

2024-06-16 Thread Lurker via Digitalmars-d-announce

On Friday, 24 May 2024 at 17:45:31 UTC, Lewis wrote:
Hello! Not sure if it's of interest, but I've been developing a 
3D game and engine in D for a few years, and finally have a 
demo up on Steam for anyone interested in poking around 
(Windows only unfortunately).


- All code (engine and game) written in D. Shaders in HLSL. 
External libraries used for some subsystems (eg. PhysX, FMOD)

- Custom 3D DX11 renderer using PBR + IBL
- Supports mirror rendering, with hundreds of simultaneous 
mirrors and recursive mirrors (passing seamlessly through 
mirrors is a core game mechanic)
- Asset burning/cooking system for textures, geometry, 
materials, and shaders. All asset types support hotswapping.
- Flexible code hotswapping, by putting 99% of the game and 
engine in a DLL
- Scrappy in-game level editor that supports editing during 
gameplay


Since I'm building the game as a commercial project I haven't 
released source code, but plan to open source it after the game 
releases. Happy though of course to answer any questions, share 
code snippets, techniques, general experiences, etc.


https://store.steampowered.com/app/2290770/The_Art_of_Reflection/


Nice, experience is quite smooth.
But it does feel a bit like a tech demo. I want to know why I am 
trying to get out of this wizard home. Maybe he is also walking 
around here and I need to hide my movement from him as well later 
in the game :)


Re: How to use D without the GC ?

2024-06-14 Thread Dukc via Digitalmars-d-learn

bachmeier kirjoitti 14.6.2024 klo 16.48:
See the example I posted elsewhere in this thread: 
https://forum.dlang.org/post/mwerxaolbkuxlgfep...@forum.dlang.org


I defined

```
@nogc ~this() {
   free(ptr);
   printf("Data has been freed\n");
}
```

and that gets called when the reference count hits zero.


Oh sorry, missed that.


Re: How to use D without the GC ?

2024-06-14 Thread bachmeier via Digitalmars-d-learn

On Friday, 14 June 2024 at 07:52:35 UTC, Dukc wrote:

Lance Bachmeier kirjoitti 14.6.2024 klo 4.23:
We must be talking about different things. You could, for 
instance, call a function in a C library to allocate memory at 
runtime. That function returns a pointer and you pass it to 
SafeRefCounted to ensure it gets freed. Nothing is known about 
the allocation at compile time. This is in fact my primary use 
case - allocating an opaque struct allocated by a C library, 
and not wanting to concern myself with freeing it when I'm 
done with it.


Using a raw pointer as the `SafeRefCounted` type like that 
isn't going to work. `SafeRefCounted` will free only the 
pointer itself at the end, not the struct it's referring to. If 
you use some sort of RAII wrapper for the pointer that `free`s 
it at it's destructor, then it'll work - maybe that's what you 
meant.


See the example I posted elsewhere in this thread: 
https://forum.dlang.org/post/mwerxaolbkuxlgfep...@forum.dlang.org


I defined

```
@nogc ~this() {
  free(ptr);
  printf("Data has been freed\n");
}
```

and that gets called when the reference count hits zero.


Re: How to use D without the GC ?

2024-06-14 Thread Dukc via Digitalmars-d-learn

Lance Bachmeier kirjoitti 14.6.2024 klo 4.23:
We must be talking about different things. You could, for instance, call 
a function in a C library to allocate memory at runtime. That function 
returns a pointer and you pass it to SafeRefCounted to ensure it gets 
freed. Nothing is known about the allocation at compile time. This is in 
fact my primary use case - allocating an opaque struct allocated by a C 
library, and not wanting to concern myself with freeing it when I'm done 
with it.


Using a raw pointer as the `SafeRefCounted` type like that isn't going 
to work. `SafeRefCounted` will free only the pointer itself at the end, 
not the struct it's referring to. If you use some sort of RAII wrapper 
for the pointer that `free`s it at it's destructor, then it'll work - 
maybe that's what you meant.


Re: How to use D without the GC ?

2024-06-13 Thread Lance Bachmeier via Digitalmars-d-learn

On Thursday, 13 June 2024 at 07:18:48 UTC, Dukc wrote:

Lance Bachmeier kirjoitti 13.6.2024 klo 1.32:


Why would it be different from calling malloc and free 
manually? I guess I'm not understanding, because you put the 
same calls to malloc and free that you'd otherwise be doing 
inside this and ~this.


Because with `SafeRefCounted`, you have to decide the size of 
your allocations at compile time, meaning you need to do a 
varying number of `malloc`s and `free`s to vary the size of 
your allocation at runtime. Even if you were to use templates 
to vary the type of `SafeRefCounted` object based on size of 
your allocation, the spec puts an upper bound of 16MiB to size 
of a static array.


We must be talking about different things. You could, for 
instance, call a function in a C library to allocate memory at 
runtime. That function returns a pointer and you pass it to 
SafeRefCounted to ensure it gets freed. Nothing is known about 
the allocation at compile time. This is in fact my primary use 
case - allocating an opaque struct allocated by a C library, and 
not wanting to concern myself with freeing it when I'm done with 
it.


Re: D Language Foundation February 2024 Monthly Meeting Summary

2024-06-13 Thread Anonymouse via Digitalmars-d-announce

On Thursday, 13 June 2024 at 10:20:03 UTC, Mike Parker wrote:

[...]


Thanks!


D Language Foundation February 2024 Monthly Meeting Summary

2024-06-13 Thread Mike Parker via Digitalmars-d-announce
The D Language Foundation's monthly meeting for February 2024 
took place on Friday the 9th. It lasted around an hour.


Razvan was the only member who sent in any agenda items before 
the meeting.


## The Attendees

The following people attended:

* Paul Backus
* Walter Bright
* Iain Buclaw
* Ali Çehreli
* Jonathan M. Davis
* Martin Kinkelin
* Dennis Korpel
* Mathais Lang
* Átila Neves
* Razvan Nitu
* Mike Parker
* Robert Schadek
* Steven Schveighoffer
* Adam Wilson

## The Summary

Before getting to the first agenda item, I updated everyone on 
DConf planning. Symmetry had recently finalized the contract with 
Brightspace, our event planner. I was waiting for confirmation 
that Brightspace had signed the venue contract before making the 
initial announcement.


Next, I told everyone that [the first video in the revival of the 
Community Conversations series](https://youtu.be/XpPV5OBJEvg) had 
gone pretty well. I thought Martin had done an excellent job. 
Since Razvan and I had already discussed his participation, I 
asked if he was willing to do the next one. [He 
accepted](https://youtu.be/Wndz2hLpbdM).


I then asked for a volunteer for the March episode. No one 
stepped forward, so Walter suggested I just pick somebody. I said 
I'd allow time for a volunteer to email me, but I'd pick if no 
one stepped forward. (In the end, I asked Dennis, [and he 
accepted](https://youtu.be/KxlY2ZQpiuI) )


### Item 1: DRuntime hook implementation for array literals

Razvan summarized an issue that Teodor Dutu had encountered in 
his project to replace DRuntime hooks with templates. 
Specifically, the approach he'd been taking to lowering, handling 
it during expression semantic and storing the lowering in an 
expression node, wasn't possible with `ArrayLiteralExp` because 
of the way the compiler handled it. (Rather than summarize 
Razvan's summary here, I'll point you to [Teodor's forum 
post](https://forum.dlang.org/thread/ykojheyrmrmpxgjfc...@forum.dlang.org), which Razvan linked in the meeting chat, if you want the details).


Other hooks had a similar issue. The solution Razvan and Teodor 
had discussed was to save pointers to the expressions that needed 
lowering in an array or a list, and then just do the lowering 
after semantic. This would also allow them to get rid of the 
fields they'd been using in the AST nodes to store the lowerings.


Martin noted that Iain had proposed that approach in past 
discussions about lowering. The main reason they'd gone with 
fields in the AST nodes was that post-semantic lowering caused a 
performance problem with the CTFE engine. Using the fields was 
just simpler. That was why these AST nodes with the lowering 
fields still existed.


Razvan said that what he was proposing wouldn't affect CTFE. The 
main problem with Iain's proposed approach was that it required 
another pass on the AST. But what he and Teodor were proposing 
would avoid that, since they were going to globally store 
pointers to the expressions that needed lowering.


Martin said he supposed it was an optimization thing, then. We'd 
have to see if the cache would pay off or if there would still be 
a performance hit. He then recalled another issue with Iain's 
proposal, which was that in some cases when outputting the AST 
nodes, you didn't want to see the lowering, for example, when 
generating C and C++ headers or DI files. He had no idea how to 
proceed, but it seemed we were reaching the limitations of the 
lowering field.


Razvan said they did have workarounds for this, but they made the 
code uglier. The new approach would be much cleaner.


Walter noted that he'd recently run into a problem where DRuntime 
was calling an array constructor, and that was removed and 
replaced with a template in the semantic pass. Then the inliner 
tried to generate more cases that needed to be converted from an 
array constructor to the template, and the back end would just 
fail because it couldn't call the array constructor anymore. So 
he'd added code to the inliner to prevent it from inlining code 
that would cause another runtime hook to be generated.


So he thought re-engineering when the runtime hooks get lowered 
was a good idea. Right now, it was ad hoc and causing problems.


Razvan said that the new hooks were being lowered during 
semantic, but the old hooks were lowered after semantic during 
the IR generation. Since they'd been implementing the new hooks 
incrementally, they currently had both old and new hooks in the 
code. When they finished, they wanted them all in one place, and 
Razvan thought doing it after semantic was best.


Walter said another problem was that CTFE would be faced with a 
lowered array constructor, so he'd had to put in code to unwind 
the constructor in CTFE. So when to do the lowerings was a 
problem. Doing them as a separate pass might be the only 
solution. He asked what some of the new lowerings should be.


Razvan said that they'd just been picking the ones the IR

Re: How to use D without the GC ?

2024-06-13 Thread Dukc via Digitalmars-d-learn

Dukc kirjoitti 13.6.2024 klo 10.18:
So for example, if you have a program that sometimes needs 600Mib and 
sometimes needs 1100MiB, you can in any case allocate all that in one go 
with one `malloc` or one `new`, but you'll need at least 38/59 
`SafeRefCounted` static arrays, and therefore `malloc`s, to accomplish 
the same.


Now granted, 16MiB (or even smaller amounts, like 256 KiB) sounds big 
enough that it probably isn't making a difference since it's a long way 
into multiples of page size anyway. But I'm not sure.


Re: How to use D without the GC ?

2024-06-13 Thread Dukc via Digitalmars-d-learn

Lance Bachmeier kirjoitti 13.6.2024 klo 1.32:


Why would it be different from calling malloc and free manually? I guess 
I'm not understanding, because you put the same calls to malloc and free 
that you'd otherwise be doing inside this and ~this.


Because with `SafeRefCounted`, you have to decide the size of your 
allocations at compile time, meaning you need to do a varying number of 
`malloc`s and `free`s to vary the size of your allocation at runtime. 
Even if you were to use templates to vary the type of `SafeRefCounted` 
object based on size of your allocation, the spec puts an upper bound of 
16MiB to size of a static array.


So for example, if you have a program that sometimes needs 600Mib and 
sometimes needs 1100MiB, you can in any case allocate all that in one go 
with one `malloc` or one `new`, but you'll need at least 38/59 
`SafeRefCounted` static arrays, and therefore `malloc`s, to accomplish 
the same.


Re: How to use D without the GC ?

2024-06-12 Thread monkyyy via Digitalmars-d-learn
On Wednesday, 12 June 2024 at 16:50:04 UTC, Vinod K Chandran 
wrote:

On Wednesday, 12 June 2024 at 01:35:26 UTC, monkyyy wrote:


rather then worring about the gc, just have 95% of data on the 
stack


How's that even possible ? AFAIK, we need heap allocated memory 
in order to make GUI lib as a DLL. So creating things in heap 
and modify it, that's the nature of my project.


gui is a bit harder and maybe aim for 70%

but if you went down the rabbit hole you could have strings be in 
an "arena" of which the first 5000 chars are a global scope 
array; or full me and just an array that doesnt expand


Re: How to use D without the GC ?

2024-06-12 Thread Lance Bachmeier via Digitalmars-d-learn

On Wednesday, 12 June 2024 at 21:59:54 UTC, drug007 wrote:

Yes, but you get all the benefits of `double[]` for free if 
you do it that way, including the more concise foo[10] syntax.


I meant you do not need to add `ptr` field at all


I see. You're right. I thought it would be easier for someone new 
to the language to read more explicit code rather than assuming 
knowledge about data.ptr. In practice it's better to not have a 
ptr field.


Re: How to use D without the GC ?

2024-06-12 Thread Lance Bachmeier via Digitalmars-d-learn

On Wednesday, 12 June 2024 at 21:36:30 UTC, Dukc wrote:

bachmeier kirjoitti 12.6.2024 klo 18.21:
You're splitting things into GC-allocated memory and manually 
managed memory. There's also SafeRefCounted, which handles the 
malloc and free for you.


I suspect `SafeRefCounted` (or `RefCounted`) is not the best 
fit for this scenario. The problem with it is it `malloc`s and 
`free`s individual objects, which doesn't sound efficient to me.


Maybe it performs if the objects in question are big enough, or 
if they can be bundled to static arrays so there's no need to 
refcount individual objects. But even then, you can't just 
allocate and free dozens or hundreds of megabytes with one 
call, unlike with the GC or manual `malloc`/`free`. I honestly 
don't know if calling malloc/free for, say each 64KiB, would 
have performance implications over a single allocation.


Why would it be different from calling malloc and free manually? 
I guess I'm not understanding, because you put the same calls to 
malloc and free that you'd otherwise be doing inside this and 
~this.


Re: How to use D without the GC ?

2024-06-12 Thread drug007 via Digitalmars-d-learn

On 12.06.2024 23:56, bachmeier wrote:

On Wednesday, 12 June 2024 at 20:37:36 UTC, drug007 wrote:

On 12.06.2024 21:57, bachmeier wrote:

On Wednesday, 12 June 2024 at 18:36:26 UTC, Vinod K Chandran wrote:

On Wednesday, 12 June 2024 at 15:33:39 UTC, bachmeier wrote:

A SafeRefCounted example with main marked @nogc:

```
import std;
import core.stdc.stdlib;

struct Foo {
  double[] data;
  double * ptr;
  alias data this;

  @nogc this(int n) {
    ptr = cast(double*) malloc(n*double.sizeof);
    data = ptr[0..n];
    printf("Data has been allocated\n");
  }
 }

```


Why not just use `ptr` ? Why did you `data` with `ptr` ?


Try `foo[10] = 1.5` and `foo.ptr[10] = 1.5`. The first correctly 
throws an out of bounds error. The second gives `Segmentation fault 
(core dumped)`.


I think you can use data only because data contains data.ptr


Yes, but you get all the benefits of `double[]` for free if you do it 
that way, including the more concise foo[10] syntax.


I meant you do not need to add `ptr` field at all
```D
import std;
import core.stdc.stdlib;

struct Foo {
@nogc:
double[] data;
alias data this;

this(int n)
{
auto ptr = cast(double*) malloc(n*double.sizeof);
data = ptr[0..n];
}
}

@nogc void main() {
auto foo = SafeRefCounted!Foo(3);
foo[0..3] = 1.5;
printf("%f %f %f\n", foo[0], foo[1], foo[2]);
foo.ptr[10] = 1.5; // no need for separate ptr field
}
```


Re: How to use D without the GC ?

2024-06-12 Thread Dukc via Digitalmars-d-learn

bachmeier kirjoitti 12.6.2024 klo 18.21:
You're splitting things into GC-allocated memory and manually managed 
memory. There's also SafeRefCounted, which handles the malloc and free 
for you.


I suspect `SafeRefCounted` (or `RefCounted`) is not the best fit for 
this scenario. The problem with it is it `malloc`s and `free`s 
individual objects, which doesn't sound efficient to me.


Maybe it performs if the objects in question are big enough, or if they 
can be bundled to static arrays so there's no need to refcount 
individual objects. But even then, you can't just allocate and free 
dozens or hundreds of megabytes with one call, unlike with the GC or 
manual `malloc`/`free`. I honestly don't know if calling malloc/free 
for, say each 64KiB, would have performance implications over a single 
allocation.


Re: How to use D without the GC ?

2024-06-12 Thread bachmeier via Digitalmars-d-learn

On Wednesday, 12 June 2024 at 20:37:36 UTC, drug007 wrote:

On 12.06.2024 21:57, bachmeier wrote:
On Wednesday, 12 June 2024 at 18:36:26 UTC, Vinod K Chandran 
wrote:

On Wednesday, 12 June 2024 at 15:33:39 UTC, bachmeier wrote:

A SafeRefCounted example with main marked @nogc:

```
import std;
import core.stdc.stdlib;

struct Foo {
  double[] data;
  double * ptr;
  alias data this;

  @nogc this(int n) {
    ptr = cast(double*) malloc(n*double.sizeof);
    data = ptr[0..n];
    printf("Data has been allocated\n");
  }
 }

```


Why not just use `ptr` ? Why did you `data` with `ptr` ?


Try `foo[10] = 1.5` and `foo.ptr[10] = 1.5`. The first 
correctly throws an out of bounds error. The second gives 
`Segmentation fault (core dumped)`.


I think you can use data only because data contains data.ptr


Yes, but you get all the benefits of `double[]` for free if you 
do it that way, including the more concise foo[10] syntax.


Re: How to use D without the GC ?

2024-06-12 Thread bachmeier via Digitalmars-d-learn
On Wednesday, 12 June 2024 at 20:31:34 UTC, Vinod K Chandran 
wrote:

On Wednesday, 12 June 2024 at 18:57:41 UTC, bachmeier wrote:


Try `foo[10] = 1.5` and `foo.ptr[10] = 1.5`. The first 
correctly throws an out of bounds error. The second gives 
`Segmentation fault (core dumped)`.


We can use it like this, i think.
```
struct Foo {
  double * ptr;
  uint capacity;
  uint legnth;
  alias data this;

}
```
And then we use an index, we can perform a bound check.
I am not sure but I hope this will work.


Yes, you can do that, but then you're replicating what you get 
for free by taking a slice. You'd have to write your own opIndex, 
opSlice, etc., and I don't think there's any performance benefit 
from doing so.


Re: How to use D without the GC ?

2024-06-12 Thread drug007 via Digitalmars-d-learn

On 12.06.2024 21:57, bachmeier wrote:

On Wednesday, 12 June 2024 at 18:36:26 UTC, Vinod K Chandran wrote:

On Wednesday, 12 June 2024 at 15:33:39 UTC, bachmeier wrote:

A SafeRefCounted example with main marked @nogc:

```
import std;
import core.stdc.stdlib;

struct Foo {
  double[] data;
  double * ptr;
  alias data this;

  @nogc this(int n) {
    ptr = cast(double*) malloc(n*double.sizeof);
    data = ptr[0..n];
    printf("Data has been allocated\n");
  }
 }

```


Why not just use `ptr` ? Why did you `data` with `ptr` ?


Try `foo[10] = 1.5` and `foo.ptr[10] = 1.5`. The first correctly throws 
an out of bounds error. The second gives `Segmentation fault (core 
dumped)`.


I think you can use data only because data contains data.ptr


Re: How to use D without the GC ?

2024-06-12 Thread Vinod K Chandran via Digitalmars-d-learn

On Wednesday, 12 June 2024 at 18:57:41 UTC, bachmeier wrote:


Try `foo[10] = 1.5` and `foo.ptr[10] = 1.5`. The first 
correctly throws an out of bounds error. The second gives 
`Segmentation fault (core dumped)`.


We can use it like this, i think.
```
struct Foo {
  double * ptr;
  uint capacity;
  uint legnth;
  alias data this;

}
```
And then we use an index, we can perform a bound check.
I am not sure but I hope this will work.




Re: How to use D without the GC ?

2024-06-12 Thread Vinod K Chandran via Digitalmars-d-learn

On Wednesday, 12 June 2024 at 18:58:49 UTC, evilrat wrote:
the only problem is that it seems to leak a lot PydObjects so i 
have to manually free them, even scope doesn't helps with that 
which is sad.




Oh I see. I did some experiments with nimpy and pybind11. Both 
experiments were resulted in slower than ctypes dll calling 
method. That's why I didn't take much interest in binding with 
Python C API. Even Cython is slower compare to ctypes. But it can 
be used when we call the dll in Cython and call the cython code 
from python. But then you will have to face some other obstacles. 
In my case, callback functions are the reason. When using a dll 
in cython, you need to pass a cython function as callback and 
inside that func, you need to convert everything into pyobject 
back and forth. That will take time. Imagine that you want to do 
some heavy lifting in a mouse move event ? No one will be happy 
with at snail's pace.
But yeah, Cython is a nice language and we can create an entire 
gui lib in Cython but the execution speed is 2.5X slower than my 
current c3 dll.





Re: How to use D without the GC ?

2024-06-12 Thread Ferhat Kurtulmuş via Digitalmars-d-learn

On Wednesday, 12 June 2024 at 18:58:49 UTC, evilrat wrote:
On Wednesday, 12 June 2024 at 17:00:14 UTC, Vinod K Chandran 
wrote:

[...]


It is probably not that well maintained, but it definitely 
works with python 3.10 and maybe even 3.11, i use it to 
interface with pytorch and numpy and PIL, but my use case is 
pretty simple, i just write some wrapper python functions to 
run inference and pass images back and forth using embedded 
py_stmts. the only problem is that it seems to leak a lot 
PydObjects so i have to manually free them, even scope doesn't 
helps with that which is sad.


[...]


You can use libonnx via importc to do inference of pytorch models 
after converting them *.onnx. in this way you won't need python 
at all. Please refer to the etichetta. instead of PIL for 
preprocessing just use DCV.


https://github.com/trikko/etichetta



Re: How to use D without the GC ?

2024-06-12 Thread evilrat via Digitalmars-d-learn
On Wednesday, 12 June 2024 at 17:00:14 UTC, Vinod K Chandran 
wrote:

On Wednesday, 12 June 2024 at 10:16:26 UTC, Sergey wrote:


Btw are you going to use PyD or doing everything manually from 
scratch?


Does PyD active now ? I didn't tested it. My approach is using 
"ctypes" library with my dll. Ctypes is the fastes FFI in my 
experience. I tested Cython, Pybind11 and CFFI. But None can 
beat the speed of ctypes. Currently the fastest experiments 
were the dlls created in Odin & C3. Both are non-GC languages.


It is probably not that well maintained, but it definitely works 
with python 3.10 and maybe even 3.11, i use it to interface with 
pytorch and numpy and PIL, but my use case is pretty simple, i 
just write some wrapper python functions to run inference and 
pass images back and forth using embedded py_stmts. the only 
problem is that it seems to leak a lot PydObjects so i have to 
manually free them, even scope doesn't helps with that which is 
sad.


example classifier python
```python
def inference(image: Image):
""" Predicts the image class and returns confidences for 
every class

To get the class one can use the following code
> conf = inference(image)
> index = conf.argmax()
> cls = classes[index]
"""

# this detector doesn't works with more than 3 channels
ch = len(image.getbands())
has_transparency = image.info.get('transparency', None) is 
not None

if ch > 3 or has_transparency:
image = image.convert("RGB")

image_tensor = prep_transform(image).float()
image_tensor = image_tensor.unsqueeze_(0)

# it is fast enough to run on CPU
#if torch.cuda.is_available():
#image_tensor.cuda()

with torch.inference_mode():
# NOTE: read the comment on model
output = model(image_tensor)
    index = output.data.numpy()

return index
```

and some of D functions

```d
ImageData aiGoesB(string path, int strength = 50) {
try {
if (!pymod)
py_stmts("import sys; 
sys.path.append('modules/xyz')");

initOnce!pymod(py_import("xyz.inference"));
if (!pymod.hasattr("model"))
pymod.model = pymod.method("load_model", 
"modules/xyz/pre_trained/weights.pth");


PydObject ipath = py(path);
scope(exit) destroy(ipath);

auto context = new InterpContext();
context.path = ipath;

context.py_stmts("
from PIL import Image
image = Image.open(path)
ch = len(image.getbands())
if ch > 3:
image = image.convert('RGB')
");

// signature: def run(model, imagepath, alpha=45) -> 
numpy.Array
PydObject output = pymod.method("run", pymod.model, 
context.image, 100-strength);

context.output = output;
scope(exit) destroy(output);

PydObject shape = output.getattr("shape");
scope(exit) destroy(shape);

// int n = ...;
int c = shape[2].to_d!int;
int w = shape[1].to_d!int;
int h = shape[0].to_d!int;

// numpy array
void* raw_ptr = output.buffer_view().item_ptr([0,0,0]);

ubyte* d_ptr = cast(ubyte*) raw_ptr;
ubyte[] d_img = d_ptr[0..h*w*c];

return ImageData(d_img.dup, h ,w ,c);
} catch (PythonException e) {
// oh no...
auto context = new InterpContext();
context.trace = new PydObject(e.traceback);
context.py_stmts("from traceback import format_tb; trace 
= format_tb(trace)");

printerr(e.py_message, "\n", context.trace.to_d!string);
}
return ImageData.init;
```



Re: How to use D without the GC ?

2024-06-12 Thread bachmeier via Digitalmars-d-learn
On Wednesday, 12 June 2024 at 18:36:26 UTC, Vinod K Chandran 
wrote:

On Wednesday, 12 June 2024 at 15:33:39 UTC, bachmeier wrote:

A SafeRefCounted example with main marked @nogc:

```
import std;
import core.stdc.stdlib;

struct Foo {
  double[] data;
  double * ptr;
  alias data this;

  @nogc this(int n) {
ptr = cast(double*) malloc(n*double.sizeof);
data = ptr[0..n];
printf("Data has been allocated\n");
  }
 }

```


Why not just use `ptr` ? Why did you `data` with `ptr` ?


Try `foo[10] = 1.5` and `foo.ptr[10] = 1.5`. The first correctly 
throws an out of bounds error. The second gives `Segmentation 
fault (core dumped)`.


Re: How to use D without the GC ?

2024-06-12 Thread Vinod K Chandran via Digitalmars-d-learn

On Wednesday, 12 June 2024 at 15:33:39 UTC, bachmeier wrote:

A SafeRefCounted example with main marked @nogc:

```
import std;
import core.stdc.stdlib;

struct Foo {
  double[] data;
  double * ptr;
  alias data this;

  @nogc this(int n) {
ptr = cast(double*) malloc(n*double.sizeof);
data = ptr[0..n];
printf("Data has been allocated\n");
  }
 }

```


Why not just use `ptr` ? Why did you `data` with `ptr` ?




Re: How to use D without the GC ?

2024-06-12 Thread Vinod K Chandran via Digitalmars-d-learn

On Wednesday, 12 June 2024 at 15:33:39 UTC, bachmeier wrote:

A SafeRefCounted example with main marked @nogc:


Thanks for the sample. It looks tempting! Let me check that.


Re: How to use D without the GC ?

2024-06-12 Thread Vinod K Chandran via Digitalmars-d-learn

On Wednesday, 12 June 2024 at 15:21:22 UTC, bachmeier wrote:


You're splitting things into GC-allocated memory and manually 
managed memory. There's also SafeRefCounted, which handles the 
malloc and free for you.


Thanks, I have read about the possibilities of "using malloc and 
free from D" in some other post. I think I should need to check 
that.




Re: How to use D without the GC ?

2024-06-12 Thread Vinod K Chandran via Digitalmars-d-learn

On Wednesday, 12 June 2024 at 10:16:26 UTC, Sergey wrote:


Btw are you going to use PyD or doing everything manually from 
scratch?


Does PyD active now ? I didn't tested it. My approach is using 
"ctypes" library with my dll. Ctypes is the fastes FFI in my 
experience. I tested Cython, Pybind11 and CFFI. But None can beat 
the speed of ctypes. Currently the fastest experiments were the 
dlls created in Odin & C3. Both are non-GC languages.





Re: How to use D without the GC ?

2024-06-12 Thread Vinod K Chandran via Digitalmars-d-learn

On Wednesday, 12 June 2024 at 09:44:05 UTC, DrDread wrote:


also just slap @nogc on your main function to avoid accidential 
allocations.



Thanks for the suggestion. Let me check that idea.




Re: How to use D without the GC ?

2024-06-12 Thread Vinod K Chandran via Digitalmars-d-learn

On Wednesday, 12 June 2024 at 01:35:26 UTC, monkyyy wrote:


rather then worring about the gc, just have 95% of data on the 
stack


How's that even possible ? AFAIK, we need heap allocated memory 
in order to make GUI lib as a DLL. So creating things in heap and 
modify it, that's the nature of my project.




Re: How to use D without the GC ?

2024-06-12 Thread bachmeier via Digitalmars-d-learn

A SafeRefCounted example with main marked @nogc:

```
import std;
import core.stdc.stdlib;

struct Foo {
  double[] data;
  double * ptr;
  alias data this;

  @nogc this(int n) {
ptr = cast(double*) malloc(n*double.sizeof);
data = ptr[0..n];
printf("Data has been allocated\n");
  }

  @nogc ~this() {
free(ptr);
printf("Data has been freed\n");
  }
}

@nogc void main() {
  auto foo = SafeRefCounted!Foo(3);
  foo[0..3] = 1.5;
  printf("%f %f %f\n", foo[0], foo[1], foo[2]);
}
```


Re: How to use D without the GC ?

2024-06-12 Thread Sergey via Digitalmars-d-learn

On Tuesday, 11 June 2024 at 17:15:07 UTC, Vinod K Chandran wrote:
On Tuesday, 11 June 2024 at 16:54:44 UTC, Steven Schveighoffer 
wrote:



Two reasons.
1. I am writting a dll to use in Python. So I am assuming that


Btw are you going to use PyD or doing everything manually from 
scratch?


Re: How to use D without the GC ?

2024-06-12 Thread DrDread via Digitalmars-d-learn

On Tuesday, 11 June 2024 at 17:15:07 UTC, Vinod K Chandran wrote:
On Tuesday, 11 June 2024 at 16:54:44 UTC, Steven Schveighoffer 
wrote:



I would instead ask the reason for wanting to write D code 
without the GC.


-Steve


Hi Steve,
Two reasons.
1. I am writting a dll to use in Python. So I am assuming that 
manual memory management is better for this project. It will 
give finer control to me.

2. To squeeze out the last bit of performance from D.


the GC only runs on allocation. if you want to squeeze out the 
last bit of performance, you should preallocate all bufferes 
anyway, and GC vs no GC doesn't matter.
also just slap @nogc on your main function to avoid accidential 
allocations.


Re: How to use D without the GC ?

2024-06-11 Thread monkyyy via Digitalmars-d-learn

On Tuesday, 11 June 2024 at 17:15:07 UTC, Vinod K Chandran wrote:
On Tuesday, 11 June 2024 at 16:54:44 UTC, Steven Schveighoffer 
wrote:



I would instead ask the reason for wanting to write D code 
without the GC.


-Steve


Hi Steve,
Two reasons.
1. I am writting a dll to use in Python. So I am assuming that 
manual memory management is better for this project. It will 
give finer control to me.

2. To squeeze out the last bit of performance from D.


rather then worring about the gc, just have 95% of data on the 
stack


Re: How to use D without the GC ?

2024-06-11 Thread Vinod K Chandran via Digitalmars-d-learn
On Tuesday, 11 June 2024 at 16:54:44 UTC, Steven Schveighoffer 
wrote:



I would instead ask the reason for wanting to write D code 
without the GC.


-Steve


Hi Steve,
Two reasons.
1. I am writting a dll to use in Python. So I am assuming that 
manual memory management is better for this project. It will give 
finer control to me.

2. To squeeze out the last bit of performance from D.





Re: How to use D without the GC ?

2024-06-11 Thread Steven Schveighoffer via Digitalmars-d-learn

On Tuesday, 11 June 2024 at 13:00:50 UTC, Vinod K Chandran wrote:

Hi all,
I am planning to write some D code without GC. But I have no 
prior experience with it. I have experience using manual memory 
management languages. But D has so far been used with GC. So I 
want to know what pitfalls it has and what things I should 
watch out for. Also, I want to know what high level features I 
will be missing.

Thanks in advance.


I could answer the question directly, but it seems others have 
already done so.


I would instead ask the reason for wanting to write D code 
without the GC. In many cases, you can write code without 
*regularly* using the GC (i.e. preallocate, or reuse buffers), 
but still use the GC in the sense that it is there as your 
allocator.


A great example is exceptions. Something that has the code `throw 
new Exception(...)` is going to need the GC in order to build 
that exception. But if your code is written such that this never 
(normally) happens, then you aren't using the GC for that code.


So I would call this kind of style writing code that avoids 
creating garbage. To me, this is the most productive way to 
minimize GC usage, while still allowing one to use D as it was 
intended.


-Steve


Re: How to use D without the GC ?

2024-06-11 Thread drug007 via Digitalmars-d-learn

On 11.06.2024 17:59, Kagamin wrote:
1) arena allocator makes memory manageable with occasional cache 
invalidation problem

2) no hashtable no problem


[OT] could you elaborate what problems they cause?

3) error handling depends on your code complexity, but even in complex 
C# code I found exceptions as boolean: you either have an exception or 
you don't

4) I occasionally use CTFE, where `@nogc` is a nuisance
5) polymorphism can be a little quirky




Re: How to use D without the GC ?

2024-06-11 Thread Vinod K Chandran via Digitalmars-d-learn

On Tuesday, 11 June 2024 at 14:59:24 UTC, Kagamin wrote:
1) arena allocator makes memory manageable with occasional 
cache invalidation problem

2) no hashtable no problem
3) error handling depends on your code complexity, but even in 
complex C# code I found exceptions as boolean: you either have 
an exception or you don't

4) I occasionally use CTFE, where `@nogc` is a nuisance
5) polymorphism can be a little quirky


Oh thank you @Kagamin. That's some valuable comments. I will take 
special care.


Re: How to use D without the GC ?

2024-06-11 Thread Kagamin via Digitalmars-d-learn
1) arena allocator makes memory manageable with occasional cache 
invalidation problem

2) no hashtable no problem
3) error handling depends on your code complexity, but even in 
complex C# code I found exceptions as boolean: you either have an 
exception or you don't

4) I occasionally use CTFE, where `@nogc` is a nuisance
5) polymorphism can be a little quirky


Re: How to use D without the GC ?

2024-06-11 Thread Vinod K Chandran via Digitalmars-d-learn

On Tuesday, 11 June 2024 at 13:35:19 UTC, matheus wrote:
On Tuesday, 11 June 2024 at 13:00:50 UTC, Vinod K Chandran 
wrote:

...


Similar posts that may help:

https://forum.dlang.org/thread/hryadrwplyezihwag...@forum.dlang.org

https://forum.dlang.org/thread/dblfikgnzqfmmglwd...@forum.dlang.org

Matheus.

Thank you Matheus, let me check that. :)



Re: How to use D without the GC ?

2024-06-11 Thread matheus via Digitalmars-d-learn

On Tuesday, 11 June 2024 at 13:00:50 UTC, Vinod K Chandran wrote:

...


Similar posts that may help:

https://forum.dlang.org/thread/hryadrwplyezihwag...@forum.dlang.org

https://forum.dlang.org/thread/dblfikgnzqfmmglwd...@forum.dlang.org

Matheus.


Re: D officially supported on Apache NuttX RTOS

2024-06-10 Thread Matheus Catarino via Digitalmars-d-announce

On Monday, 10 June 2024 at 14:59:53 UTC, Denis Feklushkin wrote:


Official esp32 software environment (ESP IDF) internally uses 
FreeRTOS. Thus, if you write hello_world_LED_blink snippet and 
compile it by ESP IDF your binary will contain FreeRTOS


Exactly! However, NuttX can replace ESP-IDF if desired. Espressif 
itself approves and provides an HAL for this access. (Same goes 
for Zephyr)


https://github.com/espressif/esp-hal-3rdparty


Re: D officially supported on Apache NuttX RTOS

2024-06-10 Thread Denis Feklushkin via Digitalmars-d-announce

On Sunday, 9 June 2024 at 23:19:44 UTC, Matheus Catarino wrote:

So, I take the opportunity to carry out some tests with the 
architectures available through NuttX (stm32/esp32/riscv/arm, 
etc...)


Official esp32 software environment (ESP IDF) internally uses 
FreeRTOS. Thus, if you write hello_world_LED_blink snippet and 
compile it by ESP IDF your binary will contain FreeRTOS


Re: D officially supported on Apache NuttX RTOS

2024-06-09 Thread Sergey via Digitalmars-d-announce

On Friday, 7 June 2024 at 12:23:54 UTC, Matheus Catarino wrote:

ref.: https://x.com/MisterTechBlog/status/1798918878350950840

**Note:** Currently, ldc2 compiler only for 
riscv/arm/sim[ulator]. gdc and dmd need PR!


For those who far away from embedding maybe you can add a couple 
of words about this system, and which applications it allows to 
create with D?
I suppose only betterC mode is supported, so there is no Phobos 
on those tiny machines?





Re: How do I install a non-outdated D compiler on Linux? (not in userspace-container)

2024-06-08 Thread solidstate1991 via Digitalmars-d-learn

On Saturday, 8 June 2024 at 03:36:05 UTC, bachmeier wrote:
For Mint, I'd use the .deb and let it handle that stuff. For 
LDC, I have a bash alias for ldmd2 that points to the ldmd2 
binary. Of course there are multiple ways to handle this, but I 
don't understand the point of the install script, since it 
leaves you without a working installation.


Okay, does someone know how to set up the path for LDC on Linux, 
without the bash alias?


Re: How do I install a non-outdated D compiler on Linux? (not in userspace-container)

2024-06-07 Thread bachmeier via Digitalmars-d-learn

On Saturday, 8 June 2024 at 00:21:59 UTC, solidstate1991 wrote:

On Friday, 7 June 2024 at 23:19:37 UTC, solidstate1991 wrote:
I **need** to link against various system libraries, and 
otherwise some tools won't be able to access the D compiler 
unless I start them from a command line after an 
initialization script.


I'm using Linux Mint, it's much more stable than Ubuntu (which 
started to completely collapse on me for just looking the 
wrong way at it), but unfortunately some packages are 
outdated, especially the D compilers.


Okay, I installed the "curl" versions, how do I edit the 
activating shell scripts of DMD and LDC that they'd work as if 
they were installed "normally"? I don't have the time, not the 
capacity to test my libraries with multiple different compiler 
versions, and document any oddities between them (and I almost 
never need it thanks to D).


For Mint, I'd use the .deb and let it handle that stuff. For LDC, 
I have a bash alias for ldmd2 that points to the ldmd2 binary. Of 
course there are multiple ways to handle this, but I don't 
understand the point of the install script, since it leaves you 
without a working installation.


Re: How do I install a non-outdated D compiler on Linux? (not in userspace-container)

2024-06-07 Thread solidstate1991 via Digitalmars-d-learn

On Friday, 7 June 2024 at 23:19:37 UTC, solidstate1991 wrote:
I **need** to link against various system libraries, and 
otherwise some tools won't be able to access the D compiler 
unless I start them from a command line after an initialization 
script.


I'm using Linux Mint, it's much more stable than Ubuntu (which 
started to completely collapse on me for just looking the wrong 
way at it), but unfortunately some packages are outdated, 
especially the D compilers.


Okay, I installed the "curl" versions, how do I edit the 
activating shell scripts of DMD and LDC that they'd work as if 
they were installed "normally"? I don't have the time, not the 
capacity to test my libraries with multiple different compiler 
versions, and document any oddities between them (and I almost 
never need it thanks to D).


How do I install a non-outdated D compiler on Linux? (not in userspace-container)

2024-06-07 Thread solidstate1991 via Digitalmars-d-learn
I **need** to link against various system libraries, and 
otherwise some tools won't be able to access the D compiler 
unless I start them from a command line after an initialization 
script.


I'm using Linux Mint, it's much more stable than Ubuntu (which 
started to completely collapse on me for just looking the wrong 
way at it), but unfortunately some packages are outdated, 
especially the D compilers.


D officially supported on Apache NuttX RTOS

2024-06-07 Thread Matheus Catarino via Digitalmars-d-announce

ref.: https://x.com/MisterTechBlog/status/1798918878350950840

**Note:** Currently, ldc2 compiler only for 
riscv/arm/sim[ulator]. gdc and dmd need PR!


**Preview - qemu-armv7a:nsh**

```bash
$ qemu-system-arm -cpu cortex-a7 -nographic -M 
virt,virtualization=off,gic-version=2 -net none -chardev 
stdio,id=con,mux=on -serial chardev:con -mon 
chardev=con,mode=readline -kernel nuttx

psci_detect: Detected PSCI v1.1
nx_start: Entry
uart_register: Registering /dev/console
uart_register: Registering /dev/ttyS1
work_start_highpri: Starting high-priority kernel worker thread(s)
nxtask_activate: hpwork pid=1,TCB=0x4013b2d8
nx_start_application: Starting init thread
task_spawn: name=nsh_main entry=0x4010b18c file_actions=0 
attr=0x4013afbc argv=0x4013afb8

nxtask_activate: nsh_main pid=2,TCB=0x4013c690
lib_cxx_initialize: _sinit: 0x4012c000 _einit: 0x4012c000

NuttShell (NSH) NuttX-12.5.1
nsh> nx_start: CPU0: Beginning Idle Loop
nsh> hello_d
task_spawn: name=hello_d entry=0x4011e824 file_actions=0x4013d8e4 
attr=0x4013d8ec argv=0x4013d980

spawn_execattrs: Setting policy=2 priority=100 for pid=3
nxtask_activate: hello_d pid=3,TCB=0x4013dd80
Hello World, [cortex-a7]!
hello_d_main: Saying hello from the dynamically constructed 
instance

DHelloWorld.HelloWorld: CONSTRUCTION FAILED!
hello_d_main: Saying hello from the instance constructed on the 
stack

DHelloWorld.HelloWorld: Hello, World!!
nxtask_exit: hello_d pid=3,TCB=0x4013dd80
```


Re: Release D 2.109.0

2024-06-03 Thread Nick Treleaven via Digitalmars-d-announce

On Sunday, 2 June 2024 at 15:51:04 UTC, Iain Buclaw wrote:

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

This release comes with 15 major changes and 26 fixed Bugzilla 
issues, including:


Thanks!

I've written a changelog entry about reinterpreting a byte as 
bool being unsafe:

https://github.com/dlang/dmd/pull/16560

I hope it's OK to update the online changelog with that.


Re: How does one attach a manifest file to a D executable on Windows?

2024-06-02 Thread John Chapman via Digitalmars-d-learn

On Sunday, 2 June 2024 at 21:46:41 UTC, solidstate1991 wrote:
Well, it turns out I used the windres found in mingw instead of 
`rc.exe` since the latter cannot be found anywhere on my PC, 
even after reinstalling stuff. I need to hunt it down somehow.


rc.exe comes with the Windows SDK - it gets installed in one of 
the subfolders of "C:\Program Files (x86)\Windows Kits\10\bin" 
(on my machine it's in "10.0.22000.0\x64").


Re: How does one attach a manifest file to a D executable on Windows?

2024-06-02 Thread solidstate1991 via Digitalmars-d-learn

On Sunday, 2 June 2024 at 19:11:10 UTC, solidstate1991 wrote:


Added a few more line to my `resources.rc` file, it seems like 
the issue is the resource file not being touched at all.


I've put `dflags "resources.res" platform="windows"` in my 
`dub.sdl` file, it doesn't even care if there's a typo in the 
resource file's path.


Well, it turns out I used the windres found in mingw instead of 
`rc.exe` since the latter cannot be found anywhere on my PC, even 
after reinstalling stuff. I need to hunt it down somehow.


Re: How does one attach a manifest file to a D executable on Windows?

2024-06-02 Thread solidstate1991 via Digitalmars-d-learn

On Saturday, 25 May 2024 at 19:51:25 UTC, John Chapman wrote:


Not tested but from memory I do this:

1) Copy that first XML snippet from the page you linked, save 
to a file called example.exe.manifest
2) Create a resource script file called resources.rc, with this 
at the top:

   1 24 "example.exe.manifest"
3) Compile it with rc.exe
4) Include the resulting resources.res on your DMD command line

You might also need to call InitCommonControls or 
InitCommonControlsEx before creating any windows.


Added a few more line to my `resources.rc` file, it seems like 
the issue is the resource file not being touched at all.


I've put `dflags "resources.res" platform="windows"` in my 
`dub.sdl` file, it doesn't even care if there's a typo in the 
resource file's path.


Release D 2.109.0

2024-06-02 Thread Iain Buclaw via Digitalmars-d-announce

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

This release comes with 15 major changes and 26 fixed Bugzilla 
issues, including:


- In the language, a new function `__ctfeWrite` has been added to 
allow writing messages from CTFE to console.
- `__traits(isBitfeld)`, and the properties `.bitoffsetof` and 
`.bitwidth` have been added to give new introspection 
capabilities to bit-fields.
- In the compiler, after two years of making PE-COFF support the 
default on Windows, OMF support has now been removed. This 
includes the switch `-m32omf`.


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

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

-Iain
on behalf of the Dlang Core Team


Re: How does one attach a manifest file to a D executable on Windows?

2024-06-02 Thread solidstate1991 via Digitalmars-d-learn

On Saturday, 25 May 2024 at 19:51:25 UTC, John Chapman wrote:

Not tested but from memory I do this:

1) Copy that first XML snippet from the page you linked, save 
to a file called example.exe.manifest
2) Create a resource script file called resources.rc, with this 
at the top:

   1 24 "example.exe.manifest"
3) Compile it with rc.exe
4) Include the resulting resources.res on your DMD command line

You might also need to call InitCommonControls or 
InitCommonControlsEx before creating any windows.



Did just that too, didn't change anything.


[Issue 15587] Enable use of D keywords as identifiers when interfacing to C/C++

2024-06-01 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=15587

Tim  changed:

   What|Removed |Added

 CC||tim.dl...@t-online.de

--- Comment #4 from Tim  ---
Using `pragma(mangle)` is also annoying for type names, because every function
using the renamed type needs to use the changed mangling. This is for example
necessary for `std::function`, because `function` is a keyword in D. It would
be nice if you could change the mangled name of a type once and every function
using the type gets the changed name automatically. It could look something
like this:
```
import core.stdcpp.xutility : StdNamespace;
import std.traits;

extern(C++, (StdNamespace)) extern(C++, class)
pragma(mangle_name, "function") // This type is called function in C++
struct std_function(F)
{
// ...
}

extern(C++) void f(ref const std_function!(FunctionTypeOf!(void function()))
callback);
```

Currently every function like `f` using `std_function` would need
`pragma(mangle)` and the exact mangling depends on operating system and
processor architecture. It is possible to generate the correct mangling using
CTFE, but this still needs to be done for every function.

--


Re: The D Programming Language and Its Role in Cybersecurity

2024-05-26 Thread Dukc via Digitalmars-d-announce

Dukc kirjoitti 26.5.2024 klo 21.39:
I hope he/she hasn't earned 
his/her position with opinion pieces like this.


Stupid me, his name is on your post. So "he" and "his" obviously.


Re: The D Programming Language and Its Role in Cybersecurity

2024-05-26 Thread Dukc via Digitalmars-d-announce

aberba kirjoitti 25.5.2024 klo 10.58:

On Friday, 24 May 2024 at 19:54:16 UTC, Steven Schveighoffer wrote:

On Monday, 20 May 2024 at 21:21:24 UTC, aberba wrote:

Found this article by Raymond Andrè Hagen:

https://www.linkedin.com/pulse/d-programming-language-its-role-cybersecurity-raymond-andr%C3%A8-hagen-nfvgf/


My goodness this is a terrible article. Almost no substance. Is this 
AI generated?


-Steve


Lol, the author looks like a seasoned security professional.


All the worse if so. 4 / 5 of the article is just repeating itself or 
obvious conclusions that should not need explicit mentioning. It isn't a 
shame if the writer doesn't know D deeper than this - no one can be an 
expert in every field after all. But it's worrying the writer is 
concealing that - intentionally or not - by bloating the article with 
apparent but false depth of analysis. I hope he/she hasn't earned 
his/her position with opinion pieces like this.


Re: Demo for The Art of Reflection released (a 3D game and engine fully written in D)

2024-05-26 Thread Dukc via Digitalmars-d-announce

Lewis kirjoitti 24.5.2024 klo 20.45:
Hello! Not sure if it's of interest, but I've been developing a 3D game 
and engine in D for a few years, and finally have a demo up on Steam for 
anyone interested in poking around (Windows only unfortunately).


- All code (engine and game) written in D. Shaders in HLSL. External 
libraries used for some subsystems (eg. PhysX, FMOD)

- Custom 3D DX11 renderer using PBR + IBL
- Supports mirror rendering, with hundreds of simultaneous mirrors and 
recursive mirrors (passing seamlessly through mirrors is a core game 
mechanic)
- Asset burning/cooking system for textures, geometry, materials, and 
shaders. All asset types support hotswapping.

- Flexible code hotswapping, by putting 99% of the game and engine in a DLL
- Scrappy in-game level editor that supports editing during gameplay

Since I'm building the game as a commercial project I haven't released 
source code, but plan to open source it after the game releases. Happy 
though of course to answer any questions, share code snippets, 
techniques, general experiences, etc.


https://store.steampowered.com/app/2290770/The_Art_of_Reflection/


While I'm personally probably not going to use this (I'm currently very 
happy with Godot and it's D binding for what I'm doing), I'll opinion 
that it's impressive that if/when when you release this one, we'll have 
three purely D 3D game engines (this, Dagon and Hipreme Engine), and 
maybe on top of these some less well known ones.


I'll be happy to read updates about them once in a while even if I'm 
probably not having a need for them.


Re: Demo for The Art of Reflection released (a 3D game and engine fully written in D)

2024-05-26 Thread Bastiaan Veelo via Digitalmars-d-announce

On Friday, 24 May 2024 at 17:45:31 UTC, Lewis wrote:
Hello! Not sure if it's of interest, but I've been developing a 
3D game and engine in D for a few years, and finally have a 
demo up on Steam for anyone interested in poking around 
(Windows only unfortunately).


Seems worthy of a DConf presentation!

-- Bastiaan.


Re: How does one attach a manifest file to a D executable on Windows?

2024-05-25 Thread John Chapman via Digitalmars-d-learn

On Saturday, 25 May 2024 at 13:13:08 UTC, solidstate1991 wrote:

No, I meant something like this:

https://learn.microsoft.com/en-us/windows/win32/controls/cookbook-overview


Not tested but from memory I do this:

1) Copy that first XML snippet from the page you linked, save to 
a file called example.exe.manifest
2) Create a resource script file called resources.rc, with this 
at the top:

   1 24 "example.exe.manifest"
3) Compile it with rc.exe
4) Include the resulting resources.res on your DMD command line

You might also need to call InitCommonControls or 
InitCommonControlsEx before creating any windows.


Re: How does one attach a manifest file to a D executable on Windows?

2024-05-25 Thread solidstate1991 via Digitalmars-d-learn

On Friday, 24 May 2024 at 21:26:12 UTC, Ferhat Kurtulmuş wrote:

I think this is what you need

https://github.com/aferust/doitlater/tree/master/views/res


No, I meant something like this:

https://learn.microsoft.com/en-us/windows/win32/controls/cookbook-overview


Re: The D Programming Language and Its Role in Cybersecurity

2024-05-25 Thread Dom DiSc via Digitalmars-d-announce

On Saturday, 25 May 2024 at 07:58:35 UTC, aberba wrote:
On Friday, 24 May 2024 at 19:54:16 UTC, Steven Schveighoffer 
wrote:

On Monday, 20 May 2024 at 21:21:24 UTC, aberba wrote:

Found this article by Raymond Andrè Hagen:

https://www.linkedin.com/pulse/d-programming-language-its-role-cybersecurity-raymond-andr%C3%A8-hagen-nfvgf/


My goodness this is a terrible article. Almost no substance. 
Is this AI generated?


-Steve


Lol, the author looks like a seasoned security professional.


Not for long if he continues to produce such garbage. The article 
contains  almost no arguments, only a few claims without 
deeper reasoning, but those  are repeated in each chapter with 
almost the same words.

I assume even an AI can do better.


Re: The D Programming Language and Its Role in Cybersecurity

2024-05-25 Thread aberba via Digitalmars-d-announce
On Friday, 24 May 2024 at 19:54:16 UTC, Steven Schveighoffer 
wrote:

On Monday, 20 May 2024 at 21:21:24 UTC, aberba wrote:

Found this article by Raymond Andrè Hagen:

https://www.linkedin.com/pulse/d-programming-language-its-role-cybersecurity-raymond-andr%C3%A8-hagen-nfvgf/


My goodness this is a terrible article. Almost no substance. Is 
this AI generated?


-Steve


Lol, the author looks like a seasoned security professional.


Re: Demo for The Art of Reflection released (a 3D game and engine fully written in D)

2024-05-24 Thread Lewis via Digitalmars-d-announce

On Friday, 24 May 2024 at 19:22:32 UTC, Jonathan Gerlach wrote:
I'm impressed. Are you using DirectX "11 on 12" or standard 
DirectX11? Did you need to avoid the GC at all? I imagine the 
GC could ruin your framerate if you're not careful. Thanks for 
sharing and congrats on finishing (close enough) your game.


Plain old DX11. I've used DX12 in industry, and it basically 
amounts to opting in to writing 70% of the graphics driver along 
with your renderer :) I don't need to push AAA levels of 
performance or asset load for this game, so DX11 is fine.


Regarding the GC, copy-pasting my reply from Discord:

I don't have the GC fully disabled, but I make a point to avoid 
GC allocations in runtime code. I allow myself to use it for 
initialization, tooling, editor code, etc. For runtime code it 
really just acts as a fallback. If I messed something up, a 
memory leak just becomes a periodic hitch instead of an eventual 
crash.


I've also hacked some changes into druntime to help with this:
- I added a "scrapheap" GC implementation, which is a simple 
linear allocator that resets at the end of each frame. I have a 
mixin that makes a scope use the scrapheap instead of the regular 
GC, which is useful for allowing me to still use phobos or other 
libraries, as long as I'm okay with all allocated memory being 
discarded at the end of the frame. Each worker thread also gets 
one, which resets when a unit of work completes.
- I added a quick and dirty mode I can enable that logs the 
callstack of every GC allocation, to help me track down stray 
allocations that occur during runtime. @nogc is too restrictive, 
and doesn't understand that my scrapheap usage bypasses the GC.


Runtime allocations that need to stick around almost entirely use 
a structure I've internally called a GenerationalStorage. Pretty 
common idea in games, a fixed size object pool that hands out 
IDs, and IDs can be used to retrieve a pointer to the object. 
Each ID contains the object's index, along with a generation 
number that increments every allocation, letting you reliably 
catch and assert on any use-after-frees of IDs.


Re: How does one attach a manifest file to a D executable on Windows?

2024-05-24 Thread Ferhat Kurtulmuş via Digitalmars-d-learn

On Friday, 24 May 2024 at 21:04:53 UTC, Ferhat Kurtulmuş wrote:

On Friday, 24 May 2024 at 19:07:24 UTC, solidstate1991 wrote:
I have tried resource compiling, then using `dflags` in dug to 
add the resulting obj file, but I still get the issue of the 
old GUI style.


I did that before, but I don't remember now. Probably you will 
figure that out based on this.


https://gitlab.com/aferust/gtkdappcreator/-/tree/master/win_res?ref_type=heads


I think this is what you need

https://github.com/aferust/doitlater/tree/master/views/res



Re: How does one attach a manifest file to a D executable on Windows?

2024-05-24 Thread Ferhat Kurtulmuş via Digitalmars-d-learn

On Friday, 24 May 2024 at 19:07:24 UTC, solidstate1991 wrote:
I have tried resource compiling, then using `dflags` in dug to 
add the resulting obj file, but I still get the issue of the 
old GUI style.


I did that before, but I don't remember now. Probably you will 
figure that out based on this.


https://gitlab.com/aferust/gtkdappcreator/-/tree/master/win_res?ref_type=heads


Re: The D Programming Language and Its Role in Cybersecurity

2024-05-24 Thread Steven Schveighoffer via Digitalmars-d-announce

On Monday, 20 May 2024 at 21:21:24 UTC, aberba wrote:

Found this article by Raymond Andrè Hagen:

https://www.linkedin.com/pulse/d-programming-language-its-role-cybersecurity-raymond-andr%C3%A8-hagen-nfvgf/


My goodness this is a terrible article. Almost no substance. Is 
this AI generated?


-Steve


Re: Demo for The Art of Reflection released (a 3D game and engine fully written in D)

2024-05-24 Thread Jonathan Gerlach via Digitalmars-d-announce

On Friday, 24 May 2024 at 17:45:31 UTC, Lewis wrote:
Hello! Not sure if it's of interest, but I've been developing a 
3D game and engine in D for a few years, and finally have a 
demo up on Steam for anyone interested in poking around 
(Windows only unfortunately).


- All code (engine and game) written in D. Shaders in HLSL. 
External libraries used for some subsystems (eg. PhysX, FMOD)

- Custom 3D DX11 renderer using PBR + IBL
- Supports mirror rendering, with hundreds of simultaneous 
mirrors and recursive mirrors (passing seamlessly through 
mirrors is a core game mechanic)
- Asset burning/cooking system for textures, geometry, 
materials, and shaders. All asset types support hotswapping.
- Flexible code hotswapping, by putting 99% of the game and 
engine in a DLL
- Scrappy in-game level editor that supports editing during 
gameplay


Since I'm building the game as a commercial project I haven't 
released source code, but plan to open source it after the game 
releases. Happy though of course to answer any questions, share 
code snippets, techniques, general experiences, etc.


https://store.steampowered.com/app/2290770/The_Art_of_Reflection/


I'm impressed. Are you using DirectX "11 on 12" or standard 
DirectX11? Did you need to avoid the GC at all? I imagine the GC 
could ruin your framerate if you're not careful. Thanks for 
sharing and congrats on finishing (close enough) your game.


Demo for The Art of Reflection released (a 3D game and engine fully written in D)

2024-05-24 Thread Lewis via Digitalmars-d-announce
Hello! Not sure if it's of interest, but I've been developing a 
3D game and engine in D for a few years, and finally have a demo 
up on Steam for anyone interested in poking around (Windows only 
unfortunately).


- All code (engine and game) written in D. Shaders in HLSL. 
External libraries used for some subsystems (eg. PhysX, FMOD)

- Custom 3D DX11 renderer using PBR + IBL
- Supports mirror rendering, with hundreds of simultaneous 
mirrors and recursive mirrors (passing seamlessly through mirrors 
is a core game mechanic)
- Asset burning/cooking system for textures, geometry, materials, 
and shaders. All asset types support hotswapping.
- Flexible code hotswapping, by putting 99% of the game and 
engine in a DLL
- Scrappy in-game level editor that supports editing during 
gameplay


Since I'm building the game as a commercial project I haven't 
released source code, but plan to open source it after the game 
releases. Happy though of course to answer any questions, share 
code snippets, techniques, general experiences, etc.


https://store.steampowered.com/app/2290770/The_Art_of_Reflection/


Re: Recommendations on porting Python to D

2024-05-23 Thread mw via Digitalmars-d-learn

On Friday, 3 May 2024 at 17:53:41 UTC, mw wrote:

On Friday, 3 May 2024 at 17:38:10 UTC, Chris Piker wrote:

On Thursday, 25 April 2024 at 16:57:53 UTC, mw wrote:

[...]


Thanks for the suggestions.  I put the question aside for a 
bit, but yesterday ran across a python transpiler here:


  https://github.com/py2many/py2many

It already has support for C++, Go and others.  Since I have 
mountains of python code created over many years, maybe it 
would be worth contributing to this project out of self 
interest.


Can you take a look at py2many and see what you think about 
it?  Getting D on the support list might be good.


(Haven't checked its own implementation and output code 
quality.)


But it says has output for Kotlin, Dart, these two languages 
are similar to D syntactically, so will be a good start.


I took another quick look of the project, it uses the Python 
builtin `ast` module as parser, and visitor design pattern to 
implement the transcompiler, so I think it's of decent quality.


HTH.


The D Programming Language and Its Role in Cybersecurity

2024-05-20 Thread aberba via Digitalmars-d-announce

Found this article by Raymond Andrè Hagen:

https://www.linkedin.com/pulse/d-programming-language-its-role-cybersecurity-raymond-andr%C3%A8-hagen-nfvgf/


Re: D Language Foundation January 2024 Monthly Meeting Summary

2024-05-18 Thread Dukc via Digitalmars-d-announce

Mike Parker kirjoitti 14.5.2024 klo 16.23:
The D Language Foundation's monthly meeting for January 2024 was held on 
Friday the 12th. There were two things of particular note about this 
meeting.




Thanks for the write-up once again! Always nice to know what is cooking, 
even when the news come a bit late.


Re: My interest in contributing to the D language and participation in the Symmetry Autumn of code

2024-05-16 Thread Richard (Rikki) Andrew Cattermole via Digitalmars-d-announce

On 16/05/2024 11:43 PM, Dennis wrote:
just in case I've worked on an issue, how do I communicate with the 
community/mentors about it? Is there a discord/slack community I can join?


On the main website under Community there is an invite link to the 
community Discord.


Many people are there including Mike Parker and Razvan.


Re: My interest in contributing to the D language and participation in the Symmetry Autumn of code

2024-05-16 Thread Dennis via Digitalmars-d-announce

On Wednesday, 15 May 2024 at 14:23:32 UTC, RazvanN wrote:

On Tuesday, 14 May 2024 at 18:42:56 UTC, Dennis wrote:
Hello everyone, My name is Dennis and I’m from Nigeria and I 
want to contribute to the D language, perhaps engage in the 
upcoming Symmetry Autumn of code, and contribute immensely to 
the D language and beyond.
I’m open to anyone directing me on things to work on. I'd 
really appreciate that.


Hi Dennis!

We have a bunch of projects that you could work on, however, 
choosing the right project depends of what you are interested 
in and your experience with the concepts involved. Generally, 
we have multiple fronts that work could be done on: the 
compiler, the runtime library, the standard library, ecosystem 
tools etc. I suggest you pick one of the categories, get the 
code, try to fix the issues (you can find our list of issues 
here: https://issues.dlang.org/ - searching for the keywork 
"bootcamp" will list issues that are considered entry level, 
but note that some of those might be more complicated then you 
would expect at a first glance) and then we can have a hat on 
projects you can work on. How does that sound?


RazvanN


just in case I've worked on an issue, how do I communicate with 
the community/mentors about it? Is there a discord/slack 
community I can join?


Re: My interest in contributing to the D language and participation in the Symmetry Autumn of code

2024-05-15 Thread Dennis via Digitalmars-d-announce

On Wednesday, 15 May 2024 at 14:23:32 UTC, RazvanN wrote:

On Tuesday, 14 May 2024 at 18:42:56 UTC, Dennis wrote:
Hello everyone, My name is Dennis and I’m from Nigeria and I 
want to contribute to the D language, perhaps engage in the 
upcoming Symmetry Autumn of code, and contribute immensely to 
the D language and beyond.
I’m open to anyone directing me on things to work on. I'd 
really appreciate that.


Hi Dennis!

We have a bunch of projects that you could work on, however, 
choosing the right project depends of what you are interested 
in and your experience with the concepts involved. Generally, 
we have multiple fronts that work could be done on: the 
compiler, the runtime library, the standard library, ecosystem 
tools etc. I suggest you pick one of the categories, get the 
code, try to fix the issues (you can find our list of issues 
here: https://issues.dlang.org/ - searching for the keywork 
"bootcamp" will list issues that are considered entry level, 
but note that some of those might be more complicated then you 
would expect at a first glance) and then we can have a chat on 
projects you can work on. How does that sound?


RazvanN


That sounds great, looking forward to participate.


Re: My interest in contributing to the D language and participation in the Symmetry Autumn of code

2024-05-15 Thread RazvanN via Digitalmars-d-announce

On Tuesday, 14 May 2024 at 18:42:56 UTC, Dennis wrote:
Hello everyone, My name is Dennis and I’m from Nigeria and I 
want to contribute to the D language, perhaps engage in the 
upcoming Symmetry Autumn of code, and contribute immensely to 
the D language and beyond.
I’m open to anyone directing me on things to work on. I'd 
really appreciate that.


Hi Dennis!

We have a bunch of projects that you could work on, however, 
choosing the right project depends of what you are interested in 
and your experience with the concepts involved. Generally, we 
have multiple fronts that work could be done on: the compiler, 
the runtime library, the standard library, ecosystem tools etc. I 
suggest you pick one of the categories, get the code, try to fix 
the issues (you can find our list of issues here: 
https://issues.dlang.org/ - searching for the keywork "bootcamp" 
will list issues that are considered entry level, but note that 
some of those might be more complicated then you would expect at 
a first glance) and then we can have a chat on projects you can 
work on. How does that sound?


RazvanN


Re: My interest in contributing to the D language and participation in the Symmetry Autumn of code

2024-05-14 Thread Mike Parker via Digitalmars-d-announce

On Tuesday, 14 May 2024 at 18:42:56 UTC, Dennis wrote:
Hello everyone, My name is Dennis and I’m from Nigeria and I 
want to contribute to the D language, perhaps engage in the 
upcoming Symmetry Autumn of code, and contribute immensely to 
the D language and beyond.
I’m open to anyone directing me on things to work on. I'd 
really appreciate that.


Hi, Dennis. Nice to meet you.

I'll be making the announcement about SAOC 2024 in a few weeks. 
In the meantime, you can visit the SAOC page to learn everything 
you need to know about how to apply:


https://saoc.io

It's still got the info from last year, but very little will 
change for this year. The application deadline could be different 
this time, but the rest of the dates should be the same. It will 
run from September 15 of this year to January 14 of next year.


I'll leave it to Razvan Nitu and/or Dennis Korpel to help you 
with contributing.


Re: D Language Foundation January 2024 Monthly Meeting Summary

2024-05-14 Thread Richard (Rikki) Andrew Cattermole via Digitalmars-d-announce

Wow I see I was mentioned at a lot at this meeting!

In saying that I do have some points to add about Item 2 data structures.

Data structures come in one of two forms generally: owning and non-owning.

### Non-owning

Non-owning is the simplest, its an index.
It doesn't own any memory that isn't internal.

Takes in a single memory allocator for its internal state.

For its memory safety you are pretty limited to concerns surrounding 
read-only-ness of its internal state. Which only exist because the GC 
allocator might be in use.


You pass a value in, you get a value out. No references.

### Owning

Owning data structures come with two subsets which may be mixed to form 
a third combined subset.


 Cleans up

Takes in two memory allocators, one for its internal state, one for its 
deallocation of values.


Will deallocate any memory given to it, which also means that once 
memory is placed into it, it now owns it and is responsible for its cleanup.


As for memory safety you have only one (as long as you don't use 
references out).


Owner escape analysis, this is a DIP Walter has required for me to work 
on before reference counting. So its going in anyway.


 References out

I'll assume here that it does not clean up any memory passed in, that 
you handle this manually, that the data structure is merely an index.


In almost all ways its similar to non-owning, one memory allocator, 
still has the memory safety concerns of the owner.


An you also have to worry about borrows typically from a struct 
acting as a reference. Which once again is resolved with owner escape 
analysis (noticing a trend yet?).




What this tells us is that non-owning data structures can go in pretty 
much immediately, although there will need to be some remedial work once 
we get reference counting and with that a solution to read only memory.


But of course because Walter wants owner escape analysis first, it 
doesn't matter, both owning and non-owning will need to go together.


Note: concurrent data structures will need the read only memory solution 
due to the locks (notice a trend yet?) as well.


We'll likely want to use long names to differentiate all these behaviors 
unfortunately. As it could be quite desirable to have all the different 
variations.


Re: My interest in contributing to the D language and participation in the Symmetry Autumn of code

2024-05-14 Thread Sergey via Digitalmars-d-announce

On Tuesday, 14 May 2024 at 18:42:56 UTC, Dennis wrote:
Hello everyone, My name is Dennis and I’m from Nigeria and I 
want to contribute to the D language, perhaps engage in the 
upcoming Symmetry Autumn of code, and contribute immensely to 
the D language and beyond.
I’m open to anyone directing me on things to work on. I'd 
really appreciate that.


Hi Dennis, nice to hear that!

Razvan and Mike probably are good persons to ask such question.

There are some project milestones in GitHub repo..
But you can start with issues https://forum.dlang.org/group/issues


My interest in contributing to the D language and participation in the Symmetry Autumn of code

2024-05-14 Thread Dennis via Digitalmars-d-announce
Hello everyone, My name is Dennis and I’m from Nigeria and I want 
to contribute to the D language, perhaps engage in the upcoming 
Symmetry Autumn of code, and contribute immensely to the D 
language and beyond.
I’m open to anyone directing me on things to work on. I'd really 
appreciate that.


Re: Sokol now has official D bindings

2024-05-14 Thread Guillaume Piolat via Digitalmars-d-announce

On Tuesday, 14 May 2024 at 12:36:27 UTC, ryuukk_ wrote:


- float nan default



Complaints from C and C++ programmers could mention that at least 
stack variables gets initialized to something.


Re: D Language Foundation January 2024 Monthly Meeting Summary

2024-05-14 Thread jmh530 via Digitalmars-d-announce

On Tuesday, 14 May 2024 at 14:01:28 UTC, Hipreme wrote:

[snip]
### Item 8

There was a project which is basically rdmd but faster out 
there, done by Jonathan Marler.

- https://github.com/dragon-lang/rund
Sometime ago I thought about just pushing to d tools, but since 
no one cared about, I simply abandoned the idea, but there it 
is:


I was thinking the same thing! I had used it a few times, but I 
just don't use rdmd enough to want to use an alternative to it. 
If the improved functionality were built-in, then that would be a 
positive.


Re: D Language Foundation January 2024 Monthly Meeting Summary

2024-05-14 Thread Hipreme via Digitalmars-d-announce

On Tuesday, 14 May 2024 at 13:23:17 UTC, Mike Parker wrote:
The D Language Foundation's monthly meeting for January 2024 
was held on Friday the 12th. There were two things of 
particular note about this meeting.


[...]


I have some things to feedback on those points

### Item 6
I had done my DIP thinking mostly about intermediate values on 
mixin template. That would make the value not included in mixin 
template, but yes, static foreach also needs that, so a good 
solution would be one that solves them both.



### Item 7
Redub is a tool that is basically a dub clone which improves what 
dub is not doing very smartly: building. Recently I've done a 
simple, yet major UX improvement: if dmd is not found, it tries 
ldc.


But the apex of UX I've done is inside my engine, but I've shared 
a plenty of times: build selector.


This tool is focused into:

All the items ending with a `*` are optionally done by the user.

- Downloads a D compiler if none is found on the user system
- Downloads and installs git [only on Windows that is automatic. 
Other systems it shows an error requiring that to be done]
- [Windows] - Installs MSVC and vcruntime so D is able to build 
it on systems that doesn't have this option (I needed that when 
running with a VM).
- Download Android SDK/NDK [based on the user system], with the 
supported LDC compiler and sets up the DFLAGS required to build 
for Android.*
- Sets up a custom D runtime which supports building to WASM, 
sets up the DFLAGS required to build it. May also get a supported 
compiler.*

- Sets the DFLAGS required for being able to build for iOS.*

### Item 8

There was a project which is basically rdmd but faster out there, 
done by Jonathan Marler.

- https://github.com/dragon-lang/rund
Sometime ago I thought about just pushing to d tools, but since 
no one cared about, I simply abandoned the idea, but there it is:


D Language Foundation January 2024 Monthly Meeting Summary

2024-05-14 Thread Mike Parker via Digitalmars-d-announce
The D Language Foundation's monthly meeting for January 2024 was 
held on Friday the 12th. There were two things of particular note 
about this meeting.


First, Jonathan Davis joined us for the first time and is now a 
permanent member. We're very happy to have him aboard.


Second, this was the first meeting where we adopted a new format. 
Previously, we'd go around the "room" to give each participant a 
turn to say everything they needed to say or as much as they 
could say before we had to move on in the interest of time. 
Sometimes people had problems they wanted to solve, other times 
they just had status updates or progress reports. When our 
membership was small, it all worked well, but as the invitation 
list grew, we could end up with long meetings in which important 
topics got cut short because they didn't get brought up until 
later in the meeting.


For the new process, I ask everyone to send me any agenda items 
they'd like to discuss that are not progress reports or status 
updates. At the meetings, I'll go round-robin through the lists 
in the order I receive them: first item from each list, second 
item, etc, until either there are no more items or we've hit the 
hour-and-a-half mark. If we get through the items early, then 
I'll open the floor to anyone who has something to report. If we 
still have agenda items at the hour-and-a-half mark, I'll ask if 
we should continue for another 30 minutes or call it.


This new approach has worked well for us since. It's also going 
to change how I write the monthly summaries. Each section heading 
is a topic of discussion rather than a participant's name.


The only agenda items I received from the members for this 
meeting came from Timon. He had quite a list, and we went through 
pretty much the whole thing. But I did give the floor to Robert 
at the beginning for a very brief update. I also had one item 
that came in the form of a request on the Discord server.


## The Attendees

The following people attended the meeting:

* Andrei Alexandrescu
* Walter Bright
* John Colvin
* Jonathan M. Davis
* Timon Gehr
* Martin Kinkelin
* Dennis Korpel
* Mathais Lang
* Razvan Nitu
* Mike Parker
* Robert Schadek
* Steven Schveighoffer
* Adam Wilson

## The Summary

### Item 1: Bugzilla to GitHub migration
As I noted in the [November meeting 
summary](https://forum.dlang.org/post/lywqaaibghfinljxo...@forum.dlang.org), some potential issues had come up regarding the effect of the Bugzilla to GitHub migration on the dlang bot. Robert had said he'd investigate them.


As an update, he'd discovered some changes needed to be made to 
the changelog generator and had made good progress on that. He 
said Vladimir Panteleev had been working on some changes to the 
dlang bot related to how it closed solved issues. When that was 
all completed, they'd be able to test it. He wanted to put it 
through multiple tests to make sure it held up and worked as 
intended.


### Item 2: D data structures
Monkyyy asked me on the Discord server to bring his article on [D 
data 
structures](https://monkyyyscience.substack.com/p/d-data-structures?r=99zq_campaign=post_medium=web) to the meeting. I emailed a link to everyone before the meeting. I received a little bit of feedback in the email thread. In summary:


* Monkyyy's complaint that allocators are "unmerged" highlights 
why Átila wants them out of `std.experimental`.
* The article doesn't specify any specific data structures he'd 
like to see in the standard library.
* Any redesign of Phobos needs to consider containers at some 
point, but how comprehensive should it be? How high of a priority?
* Some simple containers can easily be built on top of arrays. 
Should we add that kind of thing to Phobos, or only more complex 
ones?
* Would it be better to have a comprehensive container library in 
the dub registry?


I asked if anyone had any more feedback that they hadn't raised 
in the email thread. Timon suggested that someone should do what 
Paul did with the sumtype package: write a container library and 
then we could put it in Phobos if it was good enough.


Adam said he'd been having discussions about containers with 
Rikki and others. He told us that Rikki felt that we needed to 
focus on allocators first, then once that was solved we could 
start looking at containers. Adam said he didn't know if that was 
necessary or not, but based on that and other conversations he'd 
had on Discord, he thought that was the point of the article.


Steve said he agreed with Timon: if we were going to have 
something that was going into Phobos, it should be put up on dub 
first to prove that it was worth including. There were so many 
different opinions around containers and their APIs that it 
wasn't something we should just say, "Here's some space in 
Phobos, now put them in." Put it in dub first, work out the API 
we wanted, make sure it all works, and then put it in Phobos.


Razvan wondered what the 

Re: Sokol now has official D bindings

2024-05-14 Thread evilrat via Digitalmars-d-announce

On Tuesday, 14 May 2024 at 12:36:27 UTC, ryuukk_ wrote:
It'll be interesting to know what the experience was for the 
maintainer to play around with D (for the first time?)


From what i could gather, problems encountered:

- rvalue ref params (wich led to someone telling him to use 
-preview=all wich led to other issues)


- attributes soup

- float nan default

- no warning on use of uninitialized floats


I think it is time to decide what to do with all these 
-previews, rvalue ref params should be a feature already imo




Yep, i think it was there long enough already so rvalue ref 
parameters should already be in.
Also what's with this `in` const parameters transition, it just 
like umm hanging in there for years?


Re: Sokol now has official D bindings

2024-05-14 Thread Hipreme via Digitalmars-d-announce

On Tuesday, 14 May 2024 at 12:46:13 UTC, ryuukk_ wrote:
LDC yet again is proving how essential it is for D, now that 
more OS are embracing ARM, having LDC available and maintained 
to support latest version of LLVM and all kind of platforms is 
a blessing


The maintainer is using macOS, and his library targets many 
platforms including the web with WASM, both supported by LDC 
out of the box


DMD for fast iteration time (on x86, hopefully ARM in the 
future)


And LDC for everything else

It's a deadly combo, thanks to everyone working hard on 
maintaining both projects


- On my work with redub, I've used dmd as a default. If it is not 
being able to find it, it will give an warning and try LDC 
instead.
- No need to change float default from nan to 0, excluding my own 
opinion, Walter concretely believes that nan is better than 0. I 
would like to at least get warnings on uninitialized floats, so 
it becomes 50-50 and no one will ever initialize float to nan 
again.
- Could we get official LDC full D support to WASM? I haven't 
been having much time to work with D. When I do have time, the 
last thing I want to do is updating my custom runtime again. 
Beyond that, people always get the wrong impression from the WASM 
status quo. I know we won't have a garbage collection, but 90% of 
the work will be done. Just send a warning for anyone using D 
wasm runtime that support is incomplete. D always done that 
nevertheless.


Re: Sokol now has official D bindings

2024-05-14 Thread ryuukk_ via Digitalmars-d-announce
LDC yet again is proving how essential it is for D, now that more 
OS are embracing ARM, having LDC available and maintained to 
support latest version of LLVM and all kind of platforms is a 
blessing


The maintainer is using macOS, and his library targets many 
platforms including the web with WASM, both supported by LDC out 
of the box


DMD for fast iteration time (on x86, hopefully ARM in the future)

And LDC for everything else

It's a deadly combo, thanks to everyone working hard on 
maintaining both projects


Re: Sokol now has official D bindings

2024-05-14 Thread ryuukk_ via Digitalmars-d-announce
It'll be interesting to know what the experience was for the 
maintainer to play around with D (for the first time?)


From what i could gather, problems encountered:

- rvalue ref params (wich led to someone telling him to use 
-preview=all wich led to other issues)


- attributes soup

- float nan default

- no warning on use of uninitialized floats


I think it is time to decide what to do with all these -previews, 
rvalue ref params should be a feature already imo


For float nan default, i personally think everything should be 
consistent therefore 0 initialized


Sokol now has official D bindings

2024-05-14 Thread ryuukk_ via Digitalmars-d-announce
I just saw this yesterday, and i haven't see anybody talk about 
it here, so i decided to share this great news for D here


Sokol is a popular gamedev library https://github.com/floooh/sokol

It now officially supports D, thanks to the work led by 
https://github.com/kassane


https://github.com/floooh/sokol/blob/master/CHANGELOG.md#13-may-2024

https://twitter.com/FlohOfWoe/status/1790043272385114421


Re: Find homography in D?

2024-05-13 Thread Ferhat Kurtulmuş via Digitalmars-d-learn

On Sunday, 21 April 2024 at 14:57:33 UTC, Paolo Invernizzi wrote:

Hi,

Someone can point me to a D implementation of the classical 
OpenCV find homography matrix?


Thank you,
Paolo


Now, we can do image stitching using DCV. It needs improvements 
though.


https://github.com/libmir/dcv/tree/master/examples/imagestitchinghomography


Re: How to load a DLL file in D?

2024-05-11 Thread Lance Bachmeier via Digitalmars-d-learn

On Saturday, 11 May 2024 at 20:04:38 UTC, Lance Bachmeier wrote:

On Saturday, 11 May 2024 at 19:33:03 UTC, solidstate1991 wrote:
I know that BindBC exists and otherwise would use it, but the 
bigger the library, the more extra hurdle it'll have. When I 
did a few bindings with it, I had to order the functions the 
right way, so I could do things much quicker with the 
Ctrl+Alt+Shift trick under VSCode, and even then having to 
write both a statically linked and dynamically linked version 
(the latter which required the functions to be loaded 
individually into function pointers).


Maybe I should write some automation tool...


You might find this package useful 
https://code.dlang.org/packages/dynamic


Also relevant if they're C functions: 
https://forum.dlang.org/post/qxctappnigkwvaqak...@forum.dlang.org


And this if you want to convert C headers to D code: 
https://forum.dlang.org/post/ugvc3o$5t3$1...@digitalmars.com


Re: How to load a DLL file in D?

2024-05-11 Thread Lance Bachmeier via Digitalmars-d-learn

On Saturday, 11 May 2024 at 19:33:03 UTC, solidstate1991 wrote:
I know that BindBC exists and otherwise would use it, but the 
bigger the library, the more extra hurdle it'll have. When I 
did a few bindings with it, I had to order the functions the 
right way, so I could do things much quicker with the 
Ctrl+Alt+Shift trick under VSCode, and even then having to 
write both a statically linked and dynamically linked version 
(the latter which required the functions to be loaded 
individually into function pointers).


Maybe I should write some automation tool...


You might find this package useful 
https://code.dlang.org/packages/dynamic


Re: D doesn't have weak references. So how can I make a associative array of objects without preventing their destruction?

2024-05-10 Thread evilrat via Digitalmars-d-learn

On Friday, 10 May 2024 at 13:27:40 UTC, Dukc wrote:

Steven Schveighoffer kirjoitti 10.5.2024 klo 16.01:

On Friday, 10 May 2024 at 11:05:28 UTC, Dukc wrote:
This also gets inferred as `pure` - meaning that if you use 
it twice for the same `WeakRef`, the compiler may reuse the 
result of the first dereference for the second call, without 
checking whether the referred value has changed!


This would be weak pure since the reference is mutable. This 
cannot be memoized.


The difference is the type. With a pointer parameter (both a 
bare one and one in a struct), the compiler can cache the 
result only when the pointed data is similar. However, here we 
have an integer parameter. It can be cached if it itself is 
similar to the one in the other function call. The compiler 
doesn't have to know, nor can know, when a `size_t` is a 
pointer in disguise.


This why I would just use ref counting if I were the topic 
author, trying to be smart will often comes back when one doesn't 
expect.


And as stated by previous author if the goal is to have 
self-clearable weak reference it will need some infrastructure 
anyway, so tbh this will greatly outweight any possible benefits 
of having weak refs.


Re: photon v0.9.0 with Go-style D-flavored channels!

2024-05-10 Thread Dmitry Olshansky via Digitalmars-d-announce

On Friday, 3 May 2024 at 17:12:40 UTC, Dmitry Olshansky wrote:
On Monday, 29 April 2024 at 20:50:59 UTC, Dmitry Olshansky 
wrote:
On Monday, 29 April 2024 at 20:50:24 UTC, Dmitry Olshansky 
wrote:
Photon is a minimalistic multi-threaded fiber scheduler and 
event loop that works transparently with traditional blocking 
I/O C/C++/D/Rust libraries w/o degrading performance.




And now we have Channels, gentelmen. The only missing bit is 
`select` function to multiplex on a bunch of channels.


And the wait is over! Now there is a select function to multiplex 
on read side of a bunch of channels. This also fixes a bug in the 
poll syscall override with multiple events on posix systems


https://github.com/DmitryOlshansky/photon/blob/master/examples/select.d

```d
module examples.select;

import std.range, std.datetime, std.stdio;

import photon;

void main() {
startloop();
auto first = channel!(int)(2);
auto second = channel!(string)(1);
go({
delay(500.msecs);
first.put(0);
first.put(1);
delay(500.msecs);
second.put("ping");
});
go({
foreach ( _; 0..3) {
select(
first, {
writefln("Got first %s", first.take(1));
},
second, {
writefln("Got second %s", second.take(1));
}
);
}
});
runFibers();
}

```


---
Dmitry Olshansky
CEO @ [Glow labs](https://glow-labs.pro)
https://olshansky.me/about/





Re: D doesn't have weak references. So how can I make a associative array of objects without preventing their destruction?

2024-05-10 Thread Dukc via Digitalmars-d-learn

Steven Schveighoffer kirjoitti 10.5.2024 klo 16.01:

On Friday, 10 May 2024 at 11:05:28 UTC, Dukc wrote:
This also gets inferred as `pure` - meaning that if you use it twice 
for the same `WeakRef`, the compiler may reuse the result of the first 
dereference for the second call, without checking whether the referred 
value has changed!


This would be weak pure since the reference is mutable. This cannot be 
memoized.


The difference is the type. With a pointer parameter (both a bare one 
and one in a struct), the compiler can cache the result only when the 
pointed data is similar. However, here we have an integer parameter. It 
can be cached if it itself is similar to the one in the other function 
call. The compiler doesn't have to know, nor can know, when a `size_t` 
is a pointer in disguise.


Re: D doesn't have weak references. So how can I make a associative array of objects without preventing their destruction?

2024-05-10 Thread Steven Schveighoffer via Digitalmars-d-learn

On Friday, 10 May 2024 at 11:05:28 UTC, Dukc wrote:



This also gets inferred as `pure` - meaning that if you use it 
twice for the same `WeakRef`, the compiler may reuse the result 
of the first dereference for the second call, without checking 
whether the referred value has changed!


This would be weak pure since the reference is mutable. This 
cannot be memoized.


-Steve


Re: D doesn't have weak references. So how can I make a associative array of objects without preventing their destruction?

2024-05-10 Thread Dukc via Digitalmars-d-learn

evilrat kirjoitti 9.5.2024 klo 18.19:

```d
struct WeakRef(T) {
     private size_t _handle; // same size as a pointer

     this(T* ptr) {
     _handle = cast(size_t) ptr;
     }

     T* getRef() {
     return cast(T*) _handle;
     }

     // do the rest ...
}
```

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


There is a hidden danger with using this struct. Since `getRef` is a 
template, it will be inferred as `pure`. Now, consider a function using it:


```D
auto derefer(WeakrefT)(WeakrefT wr) => *wr.getRef;
```

This also gets inferred as `pure` - meaning that if you use it twice for 
the same `WeakRef`, the compiler may reuse the result of the first 
dereference for the second call, without checking whether the referred 
value has changed!


You probably should add some never-executed dummy operation to `getRef` 
that prevents it from becoming `pure` if you go with this design.


Re: D doesn't have weak references. So how can I make a associative array of objects without preventing their destruction?

2024-05-09 Thread evilrat via Digitalmars-d-learn

On Thursday, 9 May 2024 at 00:39:49 UTC, Liam McGillivray wrote:


What's a good way I can achieve what I'm trying to do, using 
either reference counting or a garbage-collected object?


There is libraries like `automem`[1] that implements refcounting 
and more.
Without showing your code for ref counted struct we can't help 
you.


As for weak references, maybe you could "trick" the GC by using 
the fact that simple types are not scanned, i.e. do something 
like this but I have no idea if this is going to work at all, 
alternatively you can also try using `ubyte[size_t.sizeof]`.


Keep in mind that classes is already references so you don't need 
that extra pointer for classes, can be versioned with template 
specialization.


```d
struct WeakRef(T) {
private size_t _handle; // same size as a pointer

this(T* ptr) {
_handle = cast(size_t) ptr;
}

T* getRef() {
return cast(T*) _handle;
}

// do the rest ...
}
```

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


D doesn't have weak references. So how can I make a associative array of objects without preventing their destruction?

2024-05-08 Thread Liam McGillivray via Digitalmars-d-learn
A "weak reference" (in the sense that I'm referring to) is a 
feature in some programming languages for a reference to an 
object that doesn't prevent the GC from destroying that object.


My current understanding is that D doesn't have weak references, 
though I've found some posts in this forum from many years back 
that mention something called "weakref". So is weakref a real 
thing, or just a concept that never got implemented?


The functionality that I'm going to describe would be easy with 
weak references, but I don't know how I would implement it 
without it. If there is a way to implement it without it, I would 
like to know how. I am going to describe my specific example, but 
it may apply to any class that's initialized using contents of a 
file without any of that data being modified after.


In my particular case, the class I've created is a wrapper for 
the `Texture2D` struct in Raylib. This class holds an image that 
was loaded from a file.


```
Sprite[string] spritesByPath;

Sprite getSprite(string path) {
path = path.asAbsolutePath;

if (path !in spritesByPath) {
spritesByPath[path] = new Sprite(path);
}

return spritesByPath[path];
}

class Sprite
{
Texture2D texture;
alias this = texture;
string path;

this(string path) {
texture = LoadTexture(path.toStringz);
this.path = path;
}

~this() {
if (IsWindowReady) UnloadTexture(texture);
if (path in spritesByPath) spritesByName.remove(path);
}
}
```

Alternatively, `spritesByPath` and `getSprite` may be static 
members of `Sprite`.


If D had weak references, than `spritesByPath` would be made of 
weak references so that they don't prevent the destruction of 
`Sprite` objects, which should be destroyed whenever they don't 
have any references elsewhere.


I've considered making `Sprite` reference-counted, but I couldn't 
manage to figure out how to do it properly. I tried doing 
`SafeRefCounted!Sprite` but the compiler said it doesn't work on 
`Object` types. I then tried making my own struct for reference 
counting that would be placed in place of a direct reference to 
the `Sprite` object, but there was some bug in which sometimes it 
didn't increment the reference count, so it didn't work.


What's a good way I can achieve what I'm trying to do, using 
either reference counting or a garbage-collected object?


  1   2   3   4   5   6   7   8   9   10   >