Re: Vibe.d tutorial

2021-03-03 Thread aberba via Digitalmars-d-learn

On Monday, 1 March 2021 at 22:25:39 UTC, Rey Valeza wrote:
Hi, I wrote a tutorial on Vibe.d while trying to re-learn 
Vibe.d. I find that most of Kai Nacke's book need updating, so 
I wrote a tutorial while trying to re-learn it.


Here it is.

https://github.com/reyvaleza/vibed/commit/27ec3678f25d1dd414fae1390677397a7bc57721

I would be glad if you can give me some feedback so I can 
improve it.


Thanks!


Wow, that's a lot of hard work! Nice!


Re: Why many programmers don't like GC?

2021-01-18 Thread aberba via Digitalmars-d-learn

On Monday, 18 January 2021 at 13:14:16 UTC, Arafel wrote:

On 18/1/21 13:41, Ola Fosheim Grøstad wrote:
Yes, it is natural that the current D population don't mind 
the current GC. Otherwise they would be gone... but then you 
have to factor in all the people that go through the revolving 
door and does not stay. If they stayed the eco system would be 
better. So the fact that they don't... is effecting everyone 
in a negative way (also those that har happy with the runtime).


I must be in the minority here because one of the reasons why I 
started using D was precisely because it HAS a GC with full 
support. I wouldn't even have considered it if it hadn't.


For what I usually do (non-critical server-side unattended 
processing) latency is most obviously not an issue, and I for 
me not having to worry about memory management and being able 
to focus on the task at hand is a requirement.


1). You're not a minority at all. System programming is also vast 
so having a GC (especially D's special kind of GC) is nothing 
alien in System programming. If you look out there, you'd see 
most of the very important software (for the lack of a better 
word) written uses some form of GC.


2). I'm not sure anyone really know how many people use D, stay 
with D after first encounter or leave. So we're all guessing our 
biases. And I wouldn't look at just the core language as why 
someone will move to D or not.


From my experiencing freelancing, I've come to see that a large 
portion of clients' decision stems from other things like 
familiarity and ecosystem (packages, frameworks, vendor/cloud 
support, engineering hiring pool, consultants/support 
availability, tooling, marketing/popularity/fomo/community, 
etc)... including things that usually comes from the community 
and stakeholders. For D we don't really have any measure of 
community size. Only looking at the forum can be misleading.


3). Using GC doesn't mean you're writing scripts. A significant 
amonnt of very large D code I've read (including those from long 
time users) use GC... sometimes partially. So to think or assume 
GC is hurting D is an unmeasured bias.


I'm not saying those who are looking for nogc don't really matter 
(even though I hold the opinion that one can write nogc code in D 
just fine). dplug is written in D. What else couldn't?


Also maybe the GC and other complaints (genuine or not), which 
I'm also a culprit, might actually be a contributing to people's 
first impression of D when they visit the forums. I have a 
strongly suspicious of this.


Re: Why many programmers don't like GC?

2021-01-18 Thread aberba via Digitalmars-d-learn
On Monday, 18 January 2021 at 11:55:46 UTC, Ola Fosheim Grøstad 
wrote:

On Monday, 18 January 2021 at 11:43:20 UTC, aberba wrote:
Nevertheless, GC in D isn't going anywhere. And if the 
approach for writing nogc code in D doesn't cut it, then I'm 
not what else will.


As long as that attitude prevails, D will be going nowhere as 
well.


I meant it as this. English is not my native language so pardon 
my phrasing if it doesn't sound right.



I'm not aware of an alternative way of writing D code aside what 
already comes with it by default.


If you read the Origin of D book, you would see that the GC was a 
desire thing when D was designed probably due to how useful it is 
for ... as said, 90% or so of software development. So at this 
point, fighting the GC isn't (in my opinion) the right strategy.


I should also say that I notice your point about improving GC in 
D and making it more optional as much as possible for things that 
still rely on GC...ARC, etc. 



The OP was about why programmers don't "like" GC. I've been here 
long enough to see the GC being one of the most re-occurring 
issues for discussion (probably due to new users coming in). 
There's been official posts about how D's style of GC isn't like 
that of fully managed languages, how to write nogc code in D, how 
to minimize GC, among others.


Now if none of these work for you (for some special reason), then 
the long-term strategy might be an alternative runtime and or 
std. Which isn't a good answer that thought was worth it...so I 
didn't include that.


If none of these work, then I (as in my personal opinion), don't 
know what else is available.







Re: Why many programmers don't like GC?

2021-01-18 Thread aberba via Digitalmars-d-learn
On Monday, 18 January 2021 at 07:11:20 UTC, Ola Fosheim Grostad 
wrote:

On Monday, 18 January 2021 at 01:41:35 UTC, James Blachly wrote:
Those were not aberba's words, but the author of the first 
link, in which one does find a conceptual, high level 
description of GC.


I read it, it said nothing of relevance to the D collector. 
That is not TLDR informative.


It talks how the use of GC is desired even in a game engine like 
Unreal. Several AAA title's have been built on Unreal.


Apparently you can't convince people who have made up their mind 
about GC being a bad thing for D.


Nevertheless, GC in D isn't going anywhere. And if the approach 
for writing nogc code in D doesn't cut it, then I'm not what else 
will.


Re: Why many programmers don't like GC?

2021-01-15 Thread aberba via Digitalmars-d-learn
On Friday, 15 January 2021 at 19:49:34 UTC, Ola Fosheim Grøstad 
wrote:
On Friday, 15 January 2021 at 19:37:12 UTC, Guillaume Piolat 
wrote:

A small GC heap is sufficient.
There is this blog post where there was a quantitative measure 
of the sub-1ms D GC heap size.


That's ok for a small game, but not for applications that grow 
over time or projects where the requirement spec is written 
(and continually added to) by customers. But for enthusiast 
projects, that can work.


Many open source projects (and also some commercial ones) work 
ok for small datasets, but tank when you increase the dataset. 
So "match and mix" basically means use it for prototyping, but 
do-not-rely-on-it-if-you-can-avoid-it.


Switching to ARC looks more attractive, scales better and the 
overhead is more evenly distributed. But it probably won't 
happen.


Isn't it more theoretical/imaginary/hypothetical than something 
really measured from a real-world use case? Almost all large 
software use cases I've seen used mix and match.


(BTW ARC is also another form of GC)

Unreal game engine 
https://mikelis.net/garbage-collection-in-ue4-a-high-level-overview/


Unity (of course) 
https://docs.unity3d.com/Manual/UnderstandingAutomaticMemoryManagement.html


Legends have it that almost every major software project in ANY 
system language ends up writing custom allocators and 
containers.





Re: Why many programmers don't like GC?

2021-01-15 Thread aberba via Digitalmars-d-learn

On Friday, 15 January 2021 at 21:15:29 UTC, aberba wrote:
On Friday, 15 January 2021 at 19:49:34 UTC, Ola Fosheim Grøstad 
wrote:

[...]


Isn't it more theoretical/imaginary/hypothetical than something 
really measured from a real-world use case? Almost all large 
software use cases I've seen used mix and match.


(BTW ARC is also another form of GC)

Unreal game engine 
https://mikelis.net/garbage-collection-in-ue4-a-high-level-overview/


Unity (of course) 
https://docs.unity3d.com/Manual/UnderstandingAutomaticMemoryManagement.html



[...]



TL;DR:

In summation, the garbage collection system is a robust part of 
Unreal Engine that affords C++ programmers a lot of safety from 
memory leaks, as well as convenience. With this high-level 
discussion, I was aiming to introduce the system at a 
conceptual level, and I hope I have achieved that.


Re: Developing and running D GUI app on Android

2021-01-13 Thread aberba via Digitalmars-d-learn

On Wednesday, 13 January 2021 at 02:02:16 UTC, H. S. Teoh wrote:
On Sun, Jan 10, 2021 at 06:58:13PM +, aberba via 
Digitalmars-d-learn wrote:

[...]


First, you need a way to build an APK, and then transfer that 
to your Android device for testing.  Building an APK *can* be 
done manually (well, scripted), but I don't recommend it.  The 
simplest way is probably to install Android Studio and the 
Android SDK, and use Gradle to build your project.  Gradle 
takes care of the finicky details of how to build an APK, and 
the Android dev tools let you install to Android in debug mode 
without having to find your own way of transferring APKs.


[...]


So Adam's tool setup is pretty clear (talked to him). What 
remains is calling Java classes and interacting with the 
Android's API. I know a little bit of Java but not enough 
Android. Just the calling conversation part.


Do you have a sample of how that works?


Developing and running D GUI app on Android

2021-01-10 Thread aberba via Digitalmars-d-learn
I'm looking to explore running a D application on Android based 
on Adams previous foundation work. However, I'm not familiar with 
the Android + D integration so I need some help.


Has any of you successfully done that? Could use a sample code or 
anything I can use to figure out how to start.


Re: Socket handle leak and active handle warning with Vibe-D

2021-01-08 Thread aberba via Digitalmars-d-learn

On Friday, 1 January 2021 at 22:07:28 UTC, Selim Ozel wrote:


[2] https://github.com/SelimOzel/vibe_noLeaks


I don't see anything abnormal in this code though. Will trying it 
later today myself.


Could you show the actual socket code causing that leak?


Re: Socket handle leak and active handle warning with Vibe-D

2021-01-08 Thread aberba via Digitalmars-d-learn

On Tuesday, 5 January 2021 at 21:12:01 UTC, Selim Ozel wrote:
On Monday, 4 January 2021 at 17:17:10 UTC, Steven Schveighoffer 
wrote:

On 1/2/21 12:52 PM, Selim Ozel wrote:



After logging into to 127.0.0.1 for a single time in my 
browser, if I do a ctrl+c it still leaks two socket handles.


With connection Windows 10:

Running .\vibe_noleaks.exe
[main() INF] Listening for requests on http://[::1]:8080/
[main() INF] Listening for requests on 
http://127.0.0.1:8080/
[main() INF] Please open http://127.0.0.1:8080/ in your 
browser.

[() INF] Received signal 2. Shutting down.
[main() INF] Stopped to listen for HTTP^ requests on 
C::1:8080

[main(
) INFC:\Software\vibe_noLeaks>] Stopped to listen for HTTP 
requests on 127.0.0.1:8080

Warning: 2 socket handles leaked at driver shutdown.
Warning: 2 socket handles leaked at driver shutdown.


This is normal. The server uses keepalive connections, so that 
in case any more requests arrive on the same connection, the 
initial connection setup does not need to be established. 
Well, at least that is what I think is happening.


If you want a few seconds (I think 5 or so), then you won't 
get these.


It would be good if vibe-d could provide a way to shut down 
any keepalive connections when the server is shutting down.


-Steve


That's interesting. I actually started to dive deeper into 
those and tried to pinpoint the lines of code that result in 
additional open sockets upon new http connections; although my 
understanding of vibe-d is a bit too low at this point to 
figure out what's exactly happening.


I think from a user perspective having something a bit 
friendlier on warning side would be helpful.


Bausshf built a wrapper around vibe.d sockets called cheetah. 
Haven't used it myself but it looks more abstracted than than 
actual vibe.d code. Can't speak of the quality since I haven't 
used it myself.


Also it's got both a server and client abstraction but only the 
server example is shown. Still not low-level though.


https://github.com/bausshf/cheetah/wiki/Simple-Socket-Server-Example


I've used the very vibe.d example you referenced in the past and 
didn't have any trouble with it. So it could possibly be a bug or 
regression.


If you've have wsl2 installed on Windows, try running on the 
Linux side too.


Do you have any
suggestions in mind towards that? I have a bit of time this 
week and I could take a stab at it.


B





Re: Simple BeamUI project won't link

2021-01-03 Thread aberba via Digitalmars-d-learn

On Saturday, 2 January 2021 at 15:48:11 UTC, Kyle Ingraham wrote:
On Friday, 18 December 2020 at 19:14:25 UTC, Daren Scot Wilson 
wrote:
So maybe beamui isn't ready for the real world.  It's a 
one-off personal tool for image processing, maybe will go up 
on Github, so I don't need anything super-solid or well 
established. OTOH, if it's too much on the WIP side with lots 
of loose ends, it might be more work than my free time allows.


At least, beamui appears to be more workable than dlangui 
which seems to have fallen away.


Did you find a GUI library to work with? I'm in the same boat 
as you working on a tool for image processing in my free time.


I always recommend gtkd. Its pretty good. See gtkdcoding.com for 
examples.


Re: Socket handle leak and active handle warning with Vibe-D

2021-01-03 Thread aberba via Digitalmars-d-learn

On Friday, 1 January 2021 at 22:07:28 UTC, Selim Ozel wrote:
I created the simplest possible example as explained by the 
Vibe-D community in [1]. The exact source code of what I run is 
in [2].


On Windows I get a socket handle leak warning on shutdown with 
crtl+c from terminal after running the executable.



[...]


On Ubuntu 20.04 I get leaking drivers warning with the same 
process.

   [...]


I really don't know what this is all about but it is at the 
core of my Vibe-D development. So any pointers you might have 
would be very helpful to me.


Thanks in advance.

S

[1] 
https://vibed.org/blog/posts/a-scalable-chat-room-service-in-d

[2] https://github.com/SelimOzel/vibe_noLeaks


Add this to your dub.json file to fix it

"versions": [ "VibeHighEventPriority" ]


This issue should be fixed in next vibe.d release


Re: Getting started with graphqld

2020-12-23 Thread aberba via Digitalmars-d-learn

On Wednesday, 23 December 2020 at 08:33:21 UTC, Trustee wrote:

On Tuesday, 22 December 2020 at 23:49:12 UTC, aberba wrote:

On Friday, 18 December 2020 at 03:36:05 UTC, Trustee wrote:

[...]


Heres's a demo I put together 
https://github.com/aberba/graphqld-demo


A minimal example with only the essential APIs


Thank you for this. Between this and the test code I should 
have enough to get going with.


I did also begin working through the test code and it was 
beginning to make sense. Being pushed for time though, I did 
spin up a Prisma 2 based gateway server. This time with the 
intention to build out a D version in parallel as I learn the 
package.


This should speed things along.

I will keep you posted on any developments and I'll be sure to 
get in touch if I have any questions.


Thanks again.


I keep hearing about Prisma too... gotta learn myself.


Re: Getting started with graphqld

2020-12-22 Thread aberba via Digitalmars-d-learn

On Friday, 18 December 2020 at 03:36:05 UTC, Trustee wrote:

On Thursday, 17 December 2020 at 14:49:42 UTC, evilrat wrote:

On Tuesday, 15 December 2020 at 16:25:29 UTC, Trustee wrote:


connect a basic vibe-d app to a graphql backend.



umm, what?
Did you mean write graphql backend using vibe.d?


Vibe-d web app -> Vibe-d/GraphQL gateway server (a la Prisma 1) 
-> Vibe-d/GraphQL API server -> Data.


That's why I'm more interested in the workings of the package 
than a "How-To get a basic vibe-d/graphql server. I want to 
know which pieces are available OOTB to be put together to 
create the above, and which pieces need to be created.


Heres's a demo I put together 
https://github.com/aberba/graphqld-demo


A minimal example with only the essential APIs


Re: Getting started with graphqld

2020-12-20 Thread aberba via Digitalmars-d-learn

On Friday, 18 December 2020 at 02:46:32 UTC, Trustee wrote:

On Thursday, 17 December 2020 at 14:49:42 UTC, evilrat wrote:

On Tuesday, 15 December 2020 at 16:25:29 UTC, Trustee wrote:


connect a basic vibe-d app to a graphql backend.



umm, what?
Did you mean write graphql backend using vibe.d?


Yes. But more so, I want to learn the ins and outs of the 
graphqld package. What's contained, what isn't (in terms of 
what functionality available and/or possible - e.g. client 
gen???, xSQL gen), what to build to add to 
complement/contribute to the package. The first phase, docs.


I have already begun working through the code and it's 
beginning to make sense.


To be fair it's more about my fluency in D than the package 
itself. I haven't been coding for a while so it gets kinda 
rusty.
I'm also familiar with GraphQL in Node.js. The issue I find with 
graphqld package is their selection of terminologies (+ how the 
code is written). The code is also a test so it uses all the 
features of the package and not necessarily the essentials. So it 
will take some time to figure it out...including reading the 
original source code of the package.


My current understanding is it uses vibe.d to serve some static 
data. It does some validation of schema among other things and 
since the example meant as a development guinea pig, it uses all 
the API spread throughout the code.


I've not given it much time to filter those out myself. Will take 
a look once more after watching his DConf video about 
itsomething about all spreadsheets must die.



Any help would be appreciated though.

Hit me up in the dlang discord... @aberba



Re: Simple BeamUI project won't link

2020-12-19 Thread aberba via Digitalmars-d-learn
On Friday, 18 December 2020 at 19:15:16 UTC, Daren Scot Wilson 
wrote:
On Wednesday, 16 December 2020 at 07:45:50 UTC, Ferhat 
Kurtulmuş wrote:
On Wednesday, 16 December 2020 at 07:40:45 UTC, Ferhat 
Kurtulmuş wrote:


This may be not your issue, but I could manage it to work by 
adding this line:


subPackage "examples/myproject"

to the dub.sdl of the beamui. I simply put my project in 
examples/ folder.


And compile and run using:

dub run :myproject


The thought crossed my mind to try putting my source under 
examples/ but that's not a good way to organize a real project. 
I'd like it be under ~/projects/, naturally. What I want to 
make will involve a lot more than just a GUI.



When BeamUI is released, you wouldn't have to do that. It's still 
wip like you said.



I've been using GTKd on Windows and Linux... including CSS 
styling for getting a pretty looking UI. It works just fine and 
gtkdcoding.com is just the learning resource for getting started.




Re: Getting started with graphqld

2020-12-16 Thread aberba via Digitalmars-d-learn

On Tuesday, 15 December 2020 at 16:25:29 UTC, Trustee wrote:

Is there anyone willing to help me get started with GraphQLD.

I have some experience with graphql in node.

My D is intermediate at best but i can learn fast with guidance.

I am able to build and deploy vibe-d apps locally and on heroku.

Basically, I'm looking for someone to stand-in in lieu of the 
documentation (currently WIP) to help me connect a basic vibe-d 
app to a graphql backend.


I am willing to contribute to documentation (and produce 
premium quality video tutorials) once i am proficient using the 
package.


Thanks in advance.


I had wanted to do a written tutorial with it but since it isn't 
well documented, I've postpone it until I figure it out. It'll 
take a while to learn the API from code...and I kind of moved 
onto something else. (and I've raised this issue with D packages 
in a post I wrote)



It's quite unfortunately that folks spend months developing 
something but then don't invest few hrs to make it easy for 
others to use and contribute back.


I'm pretty sure they use it at Symmetry Investments though.


Re: Simple BeamUI project won't link

2020-12-16 Thread aberba via Digitalmars-d-learn
On Wednesday, 16 December 2020 at 07:02:11 UTC, Daren Scot Wilson 
wrote:
Trying out the beamui GUI package, obtained by git clone from 
github.  The "basic" example builds and runs.


[...]



When you look inside the examples folders, you'll see all the 
dependencies required to get it to work.


I know because I had a similar issue and the developer gave me 
heads up.


As already mentioned, beamUI isn't ready still work in 
progress.





Re: How to unit-test a phobos module?

2020-11-27 Thread aberba via Digitalmars-d-learn

On Friday, 27 November 2020 at 04:08:33 UTC, Q. Schroll wrote:
On Thursday, 26 November 2020 at 05:29:16 UTC, Mike Parker 
wrote:


Tomorrow, I'll try setting up a dual boot and give it a shot 
there. (Not the dub experience  but following 
https://wiki.dlang.org/Building_under_Posix)


Have you heard about WSL...WSL2? You don't need dual boot 
anymore. Read https://docs.microsoft.com/en-us/windows/wsl/about


Re: Automatic update system

2020-11-27 Thread aberba via Digitalmars-d-learn

On Friday, 27 November 2020 at 20:00:22 UTC, aberba wrote:

On Thursday, 26 November 2020 at 12:13:59 UTC, vnr wrote:

On Linux, both Flatpak and Snap all provide suck functionality.

Such* was what I meant .

On Flatpak, it's not really a pure auto-update...but users get to 
up update from the store. Cus some folks are skeptical about 
auto-updates.


1. 
https://docs.microsoft.com/en-us/windows/msix/desktop/desktop-to-uwp-packaging-dot-net#:~:text=%20Setup%20the%20Windows%20Application%20Packaging%20Project%20in,make%20sure%20to%20set%20the%20Minimum...%20More%20





Re: Automatic update system

2020-11-27 Thread aberba via Digitalmars-d-learn

On Thursday, 26 November 2020 at 12:13:59 UTC, vnr wrote:

Hello,

I have a program written in D which is open-source on GitHub.

I would appreciate it if, when I release a new version, users 
would be notified by the program and that it offers an 
automatic update, i.e. the user doesn't have to reinstall the 
whole repository himself, but that it is updated automatically.


I haven't found any packages that directly meet my needs, but 
in the meantime I imagine that I will have to use the GitHub 
API, as well as Curl to make such a system.


Do you have any resources or suggestions as to how I could 
implement this? Thank you!


Auto-updates of an installed app (.ie. if that's what you want) 
is done from the app's installation side of things... App Store 
(with a few exceptions of course). On Windows, Microsoft's new 
packaging stack supports that [1]. You can even set it up with 
your CI/CD pipelines...e.g. GitHub Actions.


On Linux, both Flatpak and Snap all provide suck functionality.

1. 
https://docs.microsoft.com/en-us/windows/msix/desktop/desktop-to-uwp-packaging-dot-net#:~:text=%20Setup%20the%20Windows%20Application%20Packaging%20Project%20in,make%20sure%20to%20set%20the%20Minimum...%20More%20


Re: Reflection on the book D web development.

2020-11-21 Thread aberba via Digitalmars-d-learn

On Friday, 20 November 2020 at 19:12:38 UTC, Alaindevos wrote:

I bought the book "D Web Development".
I understand only 20% of the book,the other 80% is way above my 
head.
Compare, I own a book on flask development, and I understand 
100% of it.
Which means I can use dlang for anything except QT and serious 
web development ...


How would you like this to be improved? I'm personally interested 
in making vibe.d more accessible.





Re: Print int[string] sorted by Value

2020-10-28 Thread aberba via Digitalmars-d-learn

On Wednesday, 28 October 2020 at 15:15:40 UTC, Paul wrote:

per the D sample wc2.d
size_t[string] dictionary;  <-is printed by...
.
foreach (word1; dictionary.keys.sort) writef etc

I want to print the dictionary sorted by value not key.  I can 
write an algorithm but is there a library method(s) I can use 
to iterate through the array sorted by decreasing values?


Thanks for your time.


Have you tries .values() function? dictionary.values.sort()


Re: mysql-native Help required

2020-10-23 Thread aberba via Digitalmars-d-learn
On Thursday, 22 October 2020 at 18:43:40 UTC, Steven 
Schveighoffer wrote:

On 10/22/20 11:00 AM, Vino wrote:

[...]


Different error:

 Row[] data = conn.query("SELECT * FROM hostlog").array;

This is trying to call mysql-native's UFCS query function on 
Connections, which isn't valid. You need to call it on 
conn.conn.


But there's no access to the private Connection conn inside the 
Connections class. I'm not sure what the class is for anyway, 
so it's hard for me to suggest a proper alternative. Are you 
just trying to encapsulate the connection string? I'd suggest 
instead of a whole class, just a factory function:


Connection getConnection()
{
   return new Connection("...");
}

-Steve


Was about to say that. Part of why I think some people hate 
OOP...due to misuse.


All my MySQL projects have this getConnection() function.


IRe: GtkD CRUD Application

2020-10-17 Thread aberba via Digitalmars-d-learn

On Saturday, 17 October 2020 at 14:53:35 UTC, Alaindevos wrote:

I've written the beginning but dont know how to end.
What is the way to add functionality for the add,edit,delete 
button ?

//==
import gtk.Button;
import gtk.Box;
import gtk.Label;
import gtk.Entry;
import gtk.Grid;
import gtk.Main;
import gtk.MainWindow;
import gtk.Widget;
import gdk.Event: Event;
import std.array: assocArray;
import std.conv: to;
import std.format : format;
import std.range: iota, retro, drop, zip;
import std.stdio: writeln;

[...]




I haven't used GTK in d myself in a long time. But gtkdcoding.com 
is s great place to see some code. You might want to start from 
the first post


Re: vibe.d / experience / feedback

2020-10-17 Thread aberba via Digitalmars-d-learn

On Wednesday, 14 October 2020 at 15:11:29 UTC, Alaindevos wrote:
Is there an example just more functional then skeleton http 
server ?

Sending data to the server and back .


If you're having vibe.d trouble and can't get a quick response, 
jump in the discord. We're there to help?


Re: How do I use translation module in vibe.d?

2020-10-17 Thread aberba via Digitalmars-d-learn

On Tuesday, 13 October 2020 at 17:02:54 UTC, Jack wrote:

On Tuesday, 13 October 2020 at 08:07:17 UTC, aberba wrote:

On Friday, 9 October 2020 at 21:07:28 UTC, jack wrote:

[...]


https://www.github.com/vibe-d/vibe.d/tree/master/examples%2Fweb-i18n

There's also an example here


My dub.json file and folder structure is exactly this one, as 
the tutorial told to do yet I get the compilation error. I 
guess the library was updated but the documentation didn't


I'll have to try that. I haven't really used vibe.d translation 
myself beyond learning... and that was a long time ago.


Re: vibe.d / experience / feedback

2020-10-13 Thread aberba via Digitalmars-d-learn

On Tuesday, 13 October 2020 at 15:02:08 UTC, Alaindevos wrote:
What is weird is that rails is THE ruby application , that 
flask is the python application, and that dlang can't have 
something like that in their standard library.

An opportunity missed.
On the other hand I don't understand the interest in Java/swing 
when there is a good working gtkd which is a good working and 
beautiful framework.


What exactly do you want to do with vibe.d that it can't anyway?


Re: How do I use translation module in vibe.d?

2020-10-13 Thread aberba via Digitalmars-d-learn

On Friday, 9 October 2020 at 21:07:28 UTC, jack wrote:
Documentation[1] tells to use 
@translationModule!TranslationContext on class, like this:



@translationModule!TranslationContext
class WebInterface {
...


but it return the error:

Error: template instance 
translationModule!(TranslationContext) does not match template

 declaration translationModule(string FILENAME)


it seems that construtor was removed[2] but I can't find the 
replacement anywhere. Could someone help with that?


[1]: see "location" section: https://vibed.org/docs#Localization
[2]: https://vibed.org/api/search?q=translationModule


D dlang discord is a great place to also reach out. There's a 
dlang webdev channel.


Re: How do I use translation module in vibe.d?

2020-10-13 Thread aberba via Digitalmars-d-learn

On Friday, 9 October 2020 at 21:07:28 UTC, jack wrote:
Documentation[1] tells to use 
@translationModule!TranslationContext on class, like this:



@translationModule!TranslationContext
class WebInterface {
...


but it return the error:

Error: template instance 
translationModule!(TranslationContext) does not match template

 declaration translationModule(string FILENAME)


it seems that construtor was removed[2] but I can't find the 
replacement anywhere. Could someone help with that?


[1]: see "location" section: https://vibed.org/docs#Localization
[2]: https://vibed.org/api/search?q=translationModule


https://www.github.com/vibe-d/vibe.d/tree/master/examples%2Fweb-i18n

There's also an example here


Re: How do I use translation module in vibe.d?

2020-10-13 Thread aberba via Digitalmars-d-learn

On Friday, 9 October 2020 at 21:07:28 UTC, jack wrote:
Documentation[1] tells to use 
@translationModule!TranslationContext on class, like this:



[...]


but it return the error:


 [...]


it seems that construtor was removed[2] but I can't find the 
replacement anywhere. Could someone help with that?


[1]: see "location" section: https://vibed.org/docs#Localization
[2]: https://vibed.org/api/search?q=translationModule



Did you do this?

Using GNU gettext compatible .po translation files, it's 
possible to localize Diet templates at compile time. This just 
requires putting the translation files with the naming scheme 
..po into a path that is registered in the 
"stringImportPaths" field of the dub.json.  must be a 
language identifier of the form en_US.


Re: vibe.d / experience / feedback

2020-10-13 Thread aberba via Digitalmars-d-learn
On Saturday, 3 October 2020 at 11:31:27 UTC, Robert M. Münch 
wrote:
On 3 Oct 2020 at 13:14:57 CEST, "0xEAB"  
wrote:



On Saturday, 3 October 2020 at 07:54:58 UTC, Martin wrote:

 On Friday, 2 October 2020 at 09:46:09 UTC, Denis Feklushkin
 wrote:

 Because standard implementation worse?


 What do you mean with "worse"?


It's said to be pretty slow…


Well, then it should be fixed... it doesn't make sense to 
spread N version because everyone things, A or B is not fitting 
for such a code framework.


And, this argument sounds like pre-mature optimization. Who has 
a real life use-case where the std lib JSON thing is too slow? 
By how much?



The community discord is a great place to get help BTW. Wherever 
issue it is, I'm sure you'll find solution there.




Re: vibe.d / experience / feedback

2020-10-13 Thread aberba via Digitalmars-d-learn

On Monday, 12 October 2020 at 11:06:55 UTC, Robert M. Münch wrote:
On 11 Oct 2020 at 16:46:13 CEST, "Ola Fosheim Grøstad" 
 wrote:



Ada, Java, Eiffel are supposed to.


Yes... beside Java, the other two are already in the exotic 
department...


I'm not sure if Go is a success in that department either. I 
suspect it tanks when programs get large.


Go seems to be kept as simple as possible, even if you have to 
write more code. Which is, in the long run, the cheaper and 
smaller burden. No tricks, no surprises... that has a lot of 
merits.


Aside all the issues with the D ecosystem... which requires 
writing certain stuff yourself. And things like vibe.d not well 
documented, here's one thing that D gives that I don't get 
anywhere else.


D is a great language that is capable of solving any problem 
easier than what it'll take to do in equivalent languages.


D's ecosystem is not currently where I would want it to be... 
simply not enough dub packages and alternatives.


Vibe.d for instance is great but it's currently moving at slow 
pace because Sonke isn't able to work on it as much as he used 
to. Personally I think it should just focus on the core base and 
let others extend on it.


But it's only a matter of time. Certain things are very doable in 
vibe.d but I guess there's not enough blog posts on vibe.d.



D is a language you learn once and use every. Just hope the 
ecosystem gets better to meet business needs... getting things 
done.




Re: question on dub and postgresql

2020-10-07 Thread aberba via Digitalmars-d-learn

On Monday, 5 October 2020 at 09:05:16 UTC, Alaindevos wrote:

On Monday, 5 October 2020 at 08:54:39 UTC, Daniel Kozak wrote:
On Mon, Oct 5, 2020 at 10:25 AM Alaindevos via 
Digitalmars-d-learn < digitalmars-d-learn@puremagic.com> wrote:



[...]


Yes and no. Dub is Dlang dependency solution but it is not 
installer as pip is




[...]


Yes if you want to use any of dub packages you need to add it 
as a dependency to your dub.json (dub.sdl)


A name dependency solution is at least vage.
How do I install ,
https://github.com/denizzzka/dpq2
on unix so in the code i write the .d files of that library and 
after compilation linked to the libary shared objects. For that 
shared object must be installed. How ?


It seems the D ecosystem is not immediately obvious to some 
people. Dub, compilers, and IDEs are recurring issues.


Re: vibe.d / experience / feedback

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


[...]



I've been in a similar position once... when it slows you down. 
Vibe could stay simple and break things down into separate 
packages.


The docs is also a major issue. But try filling issues like these 
on the repo.


Re: vibe.de multiple ports.

2020-09-30 Thread aberba via Digitalmars-d-learn

On Wednesday, 30 September 2020 at 12:38:10 UTC, seany wrote:
On Wednesday, 30 September 2020 at 12:29:06 UTC, Daniel Kozak 
wrote:
Dne st 30. 9. 2020 13:25 uživatel seany via 
Digitalmars-d-learn < digitalmars-d-learn@puremagic.com> 
napsal:



Hello

I am trying to use this example for a iot application: 
https://aberba.com/2018/using-vibe-d-web-interface/


The code i use is:

ushort port   =   5504;

void main(char[][] args)
{

 auto router = new URLRouter;
 router.post("/archive", );
 router.get("/archive", );

 auto settings = new HTTPServerSettings;
 settings.port = port;
 settings.bindAddresses = ["::1", "0.0.0.0"];
 listenHTTP(settings, router);

 runApplication();
}


This is fine. But now that we have ~ 100 IoT devices in the 
field, I would like to assign each a new port.




Why? I do not see any reason for that.


to separate the messages from the IoT responses quickly and 
forward them to different programs, and to have the capability 
in hand, so that when later i have an idea to exploit the 
capability, I can also do it.


What you are doing, if I understand you well, is a way of scaling 
the server to handle high amount of traffic.


If that's right, then I'm not sure how the number of PORT is the 
issue. Irrespective of the port, the server resources remains the 
same.


And if that's the case, then you might need a load balancer (or 
use nginx or any of the options I've used in my projects). In 
that case, you run multiple versions of the server in stateless 
environments... scaled up or down on demand.




Been a long while since I wrote some vibe.d tutorials though :)


Re: DDoc generation

2020-09-21 Thread aberba via Digitalmars-d-learn
On Saturday, 19 September 2020 at 11:39:45 UTC, Jacob Carlborg 
wrote:
On Saturday, 19 September 2020 at 07:43:24 UTC, Russel Winder 
wrote:


Doesn't that then make the whole DDoc system fairly useless, 
despite it's use in Phobos?


Yes.  The problem is that most things in D are compared with C 
or C++. People are praising that the built-in support for unit 
tests and Ddoc are the best things that have happened since 
sliced bread. But if you compare with C or C++ the bar isn't 
very high.


--
/Jacob Carlborg


+1.

Couldn't agree more.


Re: Building LDC runtime for a microcontroller

2020-09-19 Thread aberba via Digitalmars-d-learn

On Friday, 18 September 2020 at 07:44:50 UTC, Dylan Graham wrote:

On Monday, 7 September 2020 at 19:12:59 UTC, aberba wrote:

[...]


I use D in an automotive environment (it controls parts of the 
powertrain, so yeah there are cars running around on D) on 
various types of ARM Cortex M CPUs, I think this will be the 
best way to extend D to those platforms.


Wow. Happy to hear this.

Do you attend our monthly D online meetups?



The existing runtime is PC-oriented. Embedded stuff doesn't 
need a GC or some of the more advanced features, but having 
things like classes, interfaces, dynamic arrays would make the 
development workload a lot easier.

+1




A lot of embedded stuff is done with RTOSs now that provide 
memory management and threading support, so having a flexible 
lightweight runtime with a generic backend (mem allocation, 
threads) that I can hook to the RTOS' libraries would be great.


I think Ali was also working on or at least talked about that OS 
(if I remember correctly) at Dconf, right?


Re: vibe.d: How to get the conent of a file upload ?

2020-09-19 Thread aberba via Digitalmars-d-learn

On Saturday, 19 September 2020 at 20:17:06 UTC, aberba wrote:

On Friday, 18 September 2020 at 22:31:09 UTC, mw wrote:

On Friday, 18 September 2020 at 00:07:12 UTC, wjoe wrote:

Are there other frameworks besides vibe that can do what I 
want?


Personally I use vibe.d for basic side projects. Looking to use 
it more going forward. But that's how I see it.


This is my personal collection of D web development packages. Let 
me know if I'm missing something.


https://gist.github.com/aberba/dcaf9102b35205080ad99a2af2c21142



Re: vibe.d: How to get the conent of a file upload ?

2020-09-19 Thread aberba via Digitalmars-d-learn

On Friday, 18 September 2020 at 22:31:09 UTC, mw wrote:

On Friday, 18 September 2020 at 00:07:12 UTC, wjoe wrote:

Are there other frameworks besides vibe that can do what I 
want?


Just FYI, there is also:

https://code.dlang.org/packages/hunt-framework


I never used myself, you need to investigate.


Yeah, I'm aware of hunt too. Its like laravel in php whilst 
vibe.d feels more like express in nodejs. Infact I believe Sonke 
wrote vibe.d after using express or similar framework by design.



And yes, almost all frameworks work in a certain way. Arsd cgi.d 
might be what you want if you want to it your way as its more 
low-level interface-wise.


I personally (and many others in the industry... judging by 
popularity of express (node.js) and the plentiful third-party 
libraries,..do prefer the router.get() design. Also having 
everything abstracted in a convenient and consistent way...is 
very desirable. vibe.d's web interface API is something I've 
always praised and thanks to how powerful D is compare to say 
JavaScript. Diet templates is also an example.


However that power is not tapped in enough (yet) to favour using 
D conveniently over node (js). And web developers are interested 
in getting things done (at least my kind of web devs) rather than 
getting it our way...or squeezing every bit of efficiency out of 
it. Part of why v8 is fast by default (for us).


Unike express (which is a thing layer with interface for 
third-parties to hook in and extend with libs), vibe.d became a 
monolith with everything included... making it harder to maintain 
and extend in other ways. Plus too much hard-coding by default 
currently. Unfortunately Sonke doesn't work on it like he used 
to...and its quite an huge accomplishment...the work he's done 
for D.



I wish vibe.d could be positioned and sponsored officially or by 
community cus its the killer app.


Staying lean and being extensible will open up for more 
innovation around it. Eg. a form handler for files library that 
works like how Ikod suggested...a customizable stream.



Unless you're doing usual routing and database things, using 
vibe.d for a full stack projects can lead to a dead end unless 
you're positioned to write your own stuff to supplement. Of 
course its only a matter of time before this change for the good.


Personally I use vibe.d for basic side projects. Looking to use 
it more going forward. But that's how I see it.


Re: vibe.d: How to get the conent of a file upload ?

2020-09-18 Thread aberba via Digitalmars-d-learn

On Friday, 18 September 2020 at 00:07:12 UTC, wjoe wrote:
On Thursday, 17 September 2020 at 22:33:46 UTC, Steven 
Schveighoffer wrote:

On 9/17/20 6:13 PM, aberba wrote:
On Thursday, 17 September 2020 at 21:57:37 UTC, Steven 
Schveighoffer wrote:

On 9/17/20 1:08 PM, wjoe wrote:

[...]


the `files` property actually does the processing only when 
you call it.


If you access the `bodyReader` property directly, you can 
process that data yourself. You can even register a web 
interface function with an `InputStream` parameter type, and 
it will be bound to the body data.


I'm not sure I understand how to do this and parser the files 
in memory.


So an HTTP request with form data will come in with the 
headers parsed, but the data is still on the network stream.


The first time you access `files`, it processes the stream 
data, and splits it into form data and file data, saves the 
files, and then gives you back the file dictionary so you can 
use them.


If instead, you access `bodyReader`, YOU get to process the 
form data and file data.




I've done this with my REST interface, though that's not 
form data.


That's not a great API, though. I would love to see vibe.d 
allow a direct call to vibe.inet.webform.parseFormData with 
a specific handler for files and form data.
Can we file an issue for this? Because I'm very interested in 
having this resolved


You can always file an issue! 
https://github.com/vibe-d/vibe.d/issues


There may already be one in there.

There's potential to results in out of memory condition. Its 
a know issues. A complete parser (like multer in nodejs) 
allowance you to limit file size as well for error handling.


Meh, this is D :) we should be able to just process the data 
and do whatever we want with it. What I would like to see is 
vibe provide the parsing of form data, and just give me the 
data as it comes (kind of like a SAX parser). Maybe just a 
property in the HTTPServerRequest that I can set that says 
"use this callback when you get Form File data".


I've done this with my REST interface, though that's not 
form data.


Can you share your code for this?


Heh, this is not form data, it's just file data, raw on the 
stream. So I have a function like:


```
class FileRestImpl
{
@path(":cat/:id/:uuid/upload")
@getAuth
void postUpload(HTTPServerResponse res, string _cat, int 
_id, string _uuid, InputStream stream, Nullable!string md5sum, 
NRMAuthInfo _authInfo)

{
...
}
}
```

You can see, I take an InputStream as a parameter -- the data 
comes in there. I just read it and save it to a file (in the 
correct location) anyway, verifying the md5sum is valid.


-Steve


Not a reply to this post in particular but to all the ones I've 
read so far.


If I understand correctly. Vibe parses the form data and writes 
all files to disk. Where to ?
Can I configure it ? I don't want libraries to just write data 
to my file systems without me setting this up. Nowhere did I 
find this behavior described in the docs.
And if not, how is data processed with a 10mb file upload 
followed by a few number fields ?
It needs to read all of the file data to get to the other data 
fields, doesn't it ?


I'm sorry this is completely counter intuitive. I can 
understand the memory/security risks and all but I have no 
intention to hack, DOS or however else disrupt my private 
server in my private network with garbage data. I just want to 
get the data in a byte[].


That's what I was trying to answer. When Steve said meh, he 
probably didn't get what I said. Probably its because of my typos.


This sort of convenience and productivity benefit is part of why 
I use Node.Js in the job when I need to get things doneand 
not D yet. There are several pieces and bits you can't write 
yourself when working on projects.


In this case you want to get the file(s) in memory...in the form 
of bytes (or buffer) and probably set a file size limit. Its all 
doable through a library but such a library doesn't exist in D 
yet. At least not that I know of.


Its why I mentioned that multer[1] in Node.Js able to do 
that...hence the advantage. Its built for the express 
framework...meaning such library can be built to work with 
vibe.d. Not everything can be built into vibe.d..and I think 
that'll even make it bloated for other uses case. Its need an 
ecosystem of third-party libraries.


In the case of the vibe.d form, data and files are handled using 
this implementation[2] so its a reference to such a form parser 
implementation...with support for a storage parameter for either 
a MemoryStore or SessionStore. Multer does it pretty cleanly.


1. Multer: https://www.npmjs.com/package/multer
2. 
https://github.com/vibe-d/vibe.d/blob/ebebfa827f568cc9bced4bec2b66edc043a8adf7/inet/vibe/inet/webform.d





Why does the lib not simply reject files that are unreasonably 
(configurable) big ?
Writing files to disk in order to then needing to copy them 
somewhere else or to read 

Re: vibe.d: How to get the conent of a file upload ?

2020-09-17 Thread aberba via Digitalmars-d-learn
On Thursday, 17 September 2020 at 21:57:37 UTC, Steven 
Schveighoffer wrote:

On 9/17/20 1:08 PM, wjoe wrote:

[...]


the `files` property actually does the processing only when you 
call it.


If you access the `bodyReader` property directly, you can 
process that data yourself. You can even register a web 
interface function with an `InputStream` parameter type, and it 
will be bound to the body data.


I'm not sure I understand how to do this and parser the files in 
memory.




I've done this with my REST interface, though that's not form 
data.


That's not a great API, though. I would love to see vibe.d 
allow a direct call to vibe.inet.webform.parseFormData with a 
specific handler for files and form data.
Can we file an issue for this? Because I'm very interested in 
having this resolved




I think you can agree that it's not feasible to store arbitrary 
sized file contents in memory. But it certainly can provide a 
mechanism to handle it as it's read.


-Steve


There's potential to results in out of memory condition. Its a 
know issues. A complete parser (like multer in nodejs) allowance 
you to limit file size as well for error handling.


I've done this with my REST interface, though that's not form 
data.


Can you share your code for this?


Re: vibe.d: How to get the conent of a file upload ?

2020-09-17 Thread aberba via Digitalmars-d-learn

On Thursday, 17 September 2020 at 16:32:55 UTC, WebFreak001 wrote:

On Thursday, 17 September 2020 at 16:00:33 UTC, wjoe wrote:
I found this [1] but unfortunately the post this refers to is 
a dead link and the content, unfortunately, didn't tell me 
anything that I didn't already find in the docs.


What I can get from the form is the form fields with content, 
the field name for the file upload and the file name. But the 
file name is useless to me because I need the file content.


Where is it stored ?

[1] https://aberba.com/2017/multiple-file-upload-in-vibe-d/


hi, you can access HTTPServerRequest.files which contains the 
uploaded file.


Example in real code: 
https://github.com/WebFreak001/ImageUploader/blob/master/source/app.d#L141-L159


Documentation: https://vibed.org/api/vibe.inet.webform/FilePart

Note: the file is only downloaded from the client / stored on 
disk once you access the files or the form property, though 
this isn't documented.


I don't believe the temp file behavior is customizable as it is 
hardcoded here to write to a temporary file (which is called on 
form parsing): 
https://github.com/vibe-d/vibe.d/blob/ebebfa827f568cc9bced4bec2b66edc043a8adf7/inet/vibe/inet/webform.d#L311


However if you really wanted to (but I'd advise against it) you 
could parse the form data from the HTTPServerRequest.bodyReader 
yourself



Yeah I think what he wants is a way to write the file into an 
in-memory buffer. This is especially necessary it some 
environments where you can write to disk at all.



How that's done, even in node.js is to use a middleware for 
parsing library to parse the headers in such way. I often use 
multer (which is also based on busybody) to do that in nodejs.


Unfortunately I haven't used D to that extent to need such a 
thing... I in never hit that problem.


I wonder if using a psuedo file handler will work for the 
in-memory buffer thing.




Re: Building LDC runtime for a microcontroller

2020-09-07 Thread aberba via Digitalmars-d-learn

On Monday, 7 September 2020 at 16:18:00 UTC, IGotD- wrote:
On Monday, 7 September 2020 at 15:23:28 UTC, Severin Teona 
wrote:

[...]


Use betterC, which is much better suited for microcontrollers 
than the full D. The disadvantage is that many great features 
are disabled in betterC.


[...]


How about an alternative runtime + standard library for embedded 
systems...with a least bare minimum. I've seen a number of 
efforts to get D to run in those environments but almost none of 
them is packaged for others to consume.


Re: Master Thesis using D Programming language.

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

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

Hello everyone,

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

Academic don't know innovation. Only history :)



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


Metaprogramming as suggested sounds interesting upon second 
thought. On Wikipedia, only D and C++ seems to have sufficient 
implementation among mainstream languages. With D's being 
exceptionally capable.


So you might want to do something around that...and how it 
impacts software development.




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


Yep. Its does. Metaprogramming really has a very significant 
benefit in practice. And disign by introspection is one way it 
can be used.




Re: Master Thesis using D Programming language.

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

On Tuesday, 25 August 2020 at 16:52:17 UTC, aberba wrote:

On Monday, 24 August 2020 at 19:56:49 UTC, Tariq Siddiqui wrote:
Academic don't know innovation. Only history :)


Academia*


Re: vibe.d and my first web service

2020-08-21 Thread aberba via Digitalmars-d-learn

On Friday, 21 August 2020 at 09:50:38 UTC, ddcovery wrote:

On Friday, 21 August 2020 at 08:48:34 UTC, ddcovery wrote:

On Thursday, 20 August 2020 at 21:36:04 UTC, Andre Pany wrote:

[...]

Thanks a lot Andre,

I opened immediately the issues to receive some feedback:

[...]


EDIT: 23 days ago new vibe.d (0.9.0) was released... Testing 
with it memory problem has disappeared!!!


+1 to vibe.d :-)


I'm glad you came around.


Re: BetterC + WASM Update

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

On Wednesday, 19 August 2020 at 21:24:23 UTC, Mike Brown wrote:

Hi all,

I'd like to make a WASM project, and looking into options.


It's scattered in several places including
https://gist.github.com/skoppe/7617ceba6afd67b2e20c6be4f922725d

Are you aware of Spasm?
https://github.com/skoppe/spasm



Re: vibe.d and my first web service

2020-08-17 Thread aberba via Digitalmars-d-learn

On Thursday, 13 August 2020 at 09:54:06 UTC, Mr. Backup wrote:
On Wednesday, 12 August 2020 at 13:46:06 UTC, James Blachly 
wrote:


Unfortunately the problem still occurs with Vibe.d 0.9.0

IMO **this is the single most important problem to fix** for 
vibe.d -- if the most basic of examples (indeed, supplied by 
dub itself) fails so spectacularly, the casual new user will 
not spend the time to find out why this is happening, but 
instead move on. The ctrl-C non-termination bug has existed 
since at least 2015 from what I can tell from the forums.




As a casual new novice, I really like dlang as such, and I 
think it should be the most widespread and popular language in 
the world. And as soon as I came across it, I wanted to use it 
in my project. But it has many packages for the same things, 
but these packages are unfinished. Everyone creates their own. 
You start comparing them and don't know what to choose for your 
job and then you find out that you should have chosen another 
and then find out that you should have written it yourself. And 
then I finally done it in golang in a while. I think the dlang 
community should focus on creating a quality standard library.


We live in the 21st century where there are web technologies 
everywhere around us, so I think that the http package should 
be part of a standard library.



It takes time. I was comparing packages available in D compared 
to say nodejs which I've been using for a while.


Very few important ones are missing. The others too lack some 
documentation. Other than that, you get pretty much what you 
need. Except cloud sdks.


also using vibe.d has some missing pieces on how to do certain 
things... that I agree we Users need to do writing about them.


You're also right that people keep rolling their own 
implementations. Most people here are really good and can roll 
their own so its quite tempting...plus reading someone's code and 
implementation can be a lil...sometimes. except rolling your own 
means it'll be half baked and undocumented.


Also I suspect lot of community members primary don't do web 
stuff primarily.


If you ask me, I'll say vibe.d is the most solid and feature 
complete web framework at the moment...code, docs, libraries. 
It's not perfect but its never been a blocker. That's if you know 
your way around it. Sonke is a pretty cool guy.


Will be nice if he had a GitHub sponsor or something for vibe.d

Hunt framework is also your laravel D alternative.






Re: Autodecode?

2020-08-16 Thread aberba via Digitalmars-d-learn

On Sunday, 16 August 2020 at 20:53:41 UTC, JN wrote:
Related to this thread: 
https://forum.dlang.org/post/xtjzhkvszdiwvrmry...@forum.dlang.org


I don't want to hijack it with my newbie questions. What is 
autodecode and why is it such a big deal? From what I've seen 
it's related to handling Unicode characters? And D has the 
wrong defaults?


https://forum.dlang.org/thread/qitnkf$2736$1...@digitalmars.com?page=1


Re: I just discovered an alternative use of the `in`-operator

2020-08-07 Thread aberba via Digitalmars-d-learn

On Friday, 7 August 2020 at 21:02:03 UTC, Per Nordlöw wrote:

On Thursday, 6 August 2020 at 22:24:43 UTC, Paul Backus wrote:

[1] https://dlang.org/spec/expression.html#is_expression


I bet there a several places in Phobos where this feature isn't 
but could be used.


I feel same. That there's a clever use of certain D features 
waiting to be discovered.


How does D's templated functions implementation differ from generics in C#/Java?

2020-08-07 Thread aberba via Digitalmars-d-learn
Syntactically they look the same (although D's can do more 
things) so I'm trying to understand how why in D it's called 
template but in languages like C#/Java they're generics.



I guess I have fair understanding of D's code generation but 
isn't it same as what what is available in those languages too? 
How are the implementation different?


Re: How do I convert a Base64 image url string to a png/jpg image file?

2020-07-30 Thread aberba via Digitalmars-d-learn

On Thursday, 30 July 2020 at 12:28:08 UTC, Adam D. Ruppe wrote:

On Thursday, 30 July 2020 at 12:22:46 UTC, aberba wrote:

[...]


I don't think I wrote it as a library yet, but the idea is 
pretty simple: they all start with "data:" so you look for that.


Then there's a type after that, so you read the string until 
the next ; character. It will be like image/png or image/jpeg.


Then there's the semicolon and the string "base64,".

After that, the rest of the string is base64 data.

```
import std.base64;
ubyte[] data = Base64.decode(rest_of_string);
```

And now that you have the data you can write it to a file:


⅞iii> import std.file;

std.file.write("filename.png", data);
```

And that should make the file you want.


Thank Adam.


How do I convert a Base64 image url string to a png/jpg image file?

2020-07-30 Thread aberba via Digitalmars-d-learn
So I have a base64 image url string and I'm trying to generate a 
png,jpg image file from it.


I'm able to decode it to a buffer but the trouble is getting it 
from buffer to an actual image file. Any library function 
combination I can use?


Re: Contributing to D wiki

2020-07-27 Thread aberba via Digitalmars-d-learn

On Monday, 27 July 2020 at 11:39:32 UTC, John Burton wrote:

On Wednesday, 15 July 2020 at 22:18:47 UTC, H. S. Teoh wrote:
On Wed, Jul 15, 2020 at 09:27:22PM +, tastyminerals via 
Digitalmars-d-learn wrote: [...]

[...]


Why not?  It's a *wiki*.  Wikis are intended for the user 
community (i.e. you & me) to go and edit.  That's the whole 
point of a wiki.  If that wasn't the intention we wouldn't 
have set up a wiki in the first place.


I tried looking there for information and examples of getting 
glfw3
statically linked into my program using LDC and didn't really 
find anything.


I wonder if adding a page for static linking tips would be 
useful as it seems to be problematic and compiler and 
environment dependent? Perhaps I should go ahead and see if I 
can make a page and see if anyone objects :P


I believe it'll be a useful addition. Please do that.


Re: How DerelictCL works

2020-07-21 Thread aberba via Digitalmars-d-learn

On Tuesday, 21 July 2020 at 12:00:03 UTC, bioinfornatics wrote:

Dear,

I would like to use OpenCL in D. Thus I try to use DerelictCL.
But I fail to use it I encounter this error message:
--
/opt/jonathan/jonathan-dlang_ldc2092/root/usr/include/d/derelict/opencl/constants.di(835):
 Error: genCLVectorTypes cannot be interpreted at compile time, because it has 
no available source code
/opt/jonathan/jonathan-dlang_ldc2092/root/usr/include/d/derelict/opencl/constants.di-mixin-835(835):
 Error: declaration expected, not <
--

[...]



Have you install the libopencl** dev dependencies?


Re: How Install and Configure DCD (D Completion Daemon) on Sublime Text?

2020-07-20 Thread aberba via Digitalmars-d-learn

On Monday, 20 July 2020 at 18:08:02 UTC, Marcone wrote:
How Install and Configure DCD (D Completion Daemon) on Sublime 
Text?

I need auto complete for the Dlang in Sublime Text.


Recently tried sublime myself for D since its quite lightweight 
compared to VS code for when I need to write something quick. 
Turns out most of the packages are outdated as everyone moved 
from it to something else...VS Code.


See https://wiki.dlang.org/IDEs if you want alternatives.


Re: How can I get Phobos Runtime Library docummentation in PDF?

2020-07-18 Thread aberba via Digitalmars-d-learn

On Saturday, 18 July 2020 at 00:23:22 UTC, Marcone wrote:
I need full Phobos Runtime Library docummentation in only one 
PDF file.


I'm not sure how to generate docs in a single html page but 
there's external services or tools to terms HTML files into PDF 
and much it all into one. This can be automated with a script.


Ddoc generates a docs folder containing HTML pages.

wkhtmltopdf is one command line tool you can use on Linux to 
generate PDF from html.


For combining PDFs, see some options at 
https://stackoverflow.com/questions/2507766/merge-convert-multiple-pdf-files-into-one-pdf


For now I'm not aware of an all-in-one tool to do that.


Re: How to generate ddoc html?

2020-07-18 Thread aberba via Digitalmars-d-learn
On Wednesday, 29 January 2020 at 20:50:14 UTC, Pavel Shkadzko 
wrote:
I've been skimming through https://dlang.org/spec/ddoc.html in 
order to understand how can one use ddoc to generate nice 
htmls. [...]


This post contains information on how to do that.

https://dlang.org/blog/2017/03/08/editable-and-runnable-doc-examples-on-dlang-org/



Re: How to generate ddoc html?

2020-07-18 Thread aberba via Digitalmars-d-learn
On Wednesday, 29 January 2020 at 20:50:14 UTC, Pavel Shkadzko 
wrote:
I've been skimming through https://dlang.org/spec/ddoc.html in 
order to understand how can one use ddoc to generate nice 
htmls. I tend to use markdown to log some daily work or copy 
down code examples. For learning purposes I wanted to try ddoc 
for this but could not find any information on ddoc.html page 
on how to actually generate the html page. I guessed that dmd 
should have a switch to generate docs and was correct: dmd 
mylogs.dd -D would generate mylogs.html.


[...]


Yeah, I figured the ddoc documentation doesn't help much with 
this. And its true we need to document that part.


Re: D Wiki: run.dlang.io integration?

2020-07-16 Thread aberba via Digitalmars-d-learn

On Thursday, 16 July 2020 at 14:17:10 UTC, WebFreak001 wrote:

On Thursday, 16 July 2020 at 13:54:56 UTC, aberba wrote:

On Thursday, 16 July 2020 at 13:41:31 UTC, aberba wrote:

On Thursday, 16 July 2020 at 09:47:02 UTC, WebFreak001 wrote:

[...]


Since its based on WikiMedia, searched an came up with this 
[1] to embed in iframe


1. https://www.mediawiki.org/wiki/Extension:Iframe


Also the D Tour uses codemirror [1] which has an extension for 
wikimedia [2]


1. https://codemirror.net/index.html
2. https://www.mediawiki.org/wiki/Extension:CodeMirror


Yeah an extension combining CodeMirror and adding another tab 
or splitting the container for the output, executed by 
run.dlang.io would be a cool addition to the wiki and would not 
be blocked as easily as iframes.


From my quick lookup, its seems after embedded in your WikiMedia 
instances, it exposes a JavaScript API to monitor change and then 
execute the code. If run.dlang.io has a rest API of some kind, 
have to look up how it's done in tour, then its a matter of 
showing the code in a bottom div.


Not familiar with the WikiMedia extension system but having it as 
a reusable component will be the ideal approach.




I rather we go for a modernized wiki platform.




Re: D Wiki: run.dlang.io integration?

2020-07-16 Thread aberba via Digitalmars-d-learn

On Thursday, 16 July 2020 at 13:41:31 UTC, aberba wrote:

On Thursday, 16 July 2020 at 09:47:02 UTC, WebFreak001 wrote:

[...]


Since its based on WikiMedia, searched an came up with this [1] 
to embed in iframe


1. https://www.mediawiki.org/wiki/Extension:Iframe


Also the D Tour uses codemirror [1] which has an extension for 
wikimedia [2]


1. https://codemirror.net/index.html
2. https://www.mediawiki.org/wiki/Extension:CodeMirror


Re: D Wiki: run.dlang.io integration?

2020-07-16 Thread aberba via Digitalmars-d-learn

On Thursday, 16 July 2020 at 09:47:02 UTC, WebFreak001 wrote:
Is there a way to integrate some kind of "run this source code" 
button into the D wiki using run.dlang.io?


If there isn't, it would be nice to add this kind of thing as 
plugin with the possibility of also including the editor so you 
never need to leave the wiki. (like on the D Tour)


Since its based on WikiMedia, searched an came up with this [1] 
to embed in iframe


1. https://www.mediawiki.org/wiki/Extension:Iframe


Re: Vibe.d and NodeJs with Express

2020-07-15 Thread aberba via Digitalmars-d-learn

On Wednesday, 15 July 2020 at 04:19:57 UTC, bauss wrote:

On Sunday, 12 July 2020 at 19:16:32 UTC, aberba wrote:
3) packages, now it might be better though. But I've always 
felt that there's not a lot of people using D for complete web 
dev projects...



I implement most things I need myself;


That's when you have time and compelling reason to do that. Most 
at times I don't. And dub packages mostly works fine...why I like 
it when there's several options to choose from.


Contributing to D wiki

2020-07-15 Thread aberba via Digitalmars-d-learn
So I'm looking to make changes to the D wiki but I'm not sure who 
to talk to about such changes.


Currently: Move all other IDEs low-quality down (maybe to Others) 
and focus on just the few that really works (IntelliJ, Visual 
Studio Code and Visual Studio). Instead of many options that 
don't work, why not focus on they few that works?





Re: Error: `std.uni.isUpper` conflicts with `std.ascii.isUpper`

2020-07-15 Thread aberba via Digitalmars-d-learn

On Wednesday, 15 July 2020 at 07:01:34 UTC, WebFreak001 wrote:

On Tuesday, 14 July 2020 at 20:37:53 UTC, Marcone wrote:

[...]


Additionally to the other answers telling you how to fix it, 
it's important to know why it happens in the first place:


[...]


Without reading this very explanation, how would one know whilst 
reading docs?


Re: How can I make executeShell ask for Admin Elevation?

2020-07-13 Thread aberba via Digitalmars-d-learn

On Monday, 13 July 2020 at 00:57:02 UTC, Marcone wrote:

On Sunday, 12 July 2020 at 02:10:11 UTC, Marcone wrote:
I don't want start program with admin elevation, but ask user 
for admin permission when some function is called.


alias runas = compose!(x => to!bool((cast(int) x) > 32), x => 
ShellExecute(null, "runas", "cmd", cast(wchar*) "/c \"cd /d %s 
&& %s\"".format(getcwd(), x).to!wstring, null, 
SW_HIDE).WaitForSingleObject(WAIT_TIMEOUT));


runas("netsh winhttp set proxy 127.0.0.1:9666")


Can you put it into a small dub package?


Re: Vibe.d and NodeJs with Express

2020-07-12 Thread aberba via Digitalmars-d-learn

On Sunday, 12 July 2020 at 10:01:54 UTC, greatsam4sure wrote:
I am thinking of building an App with Vibe. D or NodeJS but my 
topmost priority is speed and ease of development due to third 
party libraries integration. I know Vibe. D is faster than 
NodeJS and I love to use Dlang. My question is can I eat my 
cake and have it if I go with Dlang and Vibe. D. I have being 
able to use jQuery and bootstrap with vibe. D and it work well. 
My believe is that most JavaScript library will work with Vibe. 
D out of the box. The application with use database heavily, 
can I work easily with database in vibe. D. For me I would love 
to use D for it raw power and speed.


Please this is a post to criticize D but to encourage me to use 
it. I need pros and cons


It depends. Most cases nodejs will work just fine for performance 
reasons.


Im my last major side project I tried to use vibe.d and even 
though I enjoy using D, I was slowed down by...


1) figuring vibe.d APIs out,

2) compilation speed (considering using something like nodemom, 
the nodejs express server just restarts on save)... I believe 
there's a way to do that in vibe.d by using a program that 
monitors file changes but wasn't a low hanging fruit so I just 
recompiled manual. Was very annoying but something like LDC or 
GDC would have made it worst. Compilation speed is very important 
for quick iterations... something you'll be doing 1000s of times.


3) packages, now it might be better though. But I've always felt 
that there's not a lot of people using D for complete web dev 
projects... packages was lacking. When doing a full stack job you 
then realise having packages for just about everything you need, 
gets the job done. Honestly was my main major issue. Yeah, main 
major :) Tried to build "sanival" for form data validation 
server-side (like validator.js) but gave up as project idea fell 
apart. Was very early stage...not much code was written then.  
Since then I haven't had chance to use D for such.


4. Help resources and people to ask for help. Now community is 
increasing so I'm sure it shouldn't be an issue. D community is 
very welcoming and helpful. That I really appreciate. However 
there's not a lot people doing web or stuff to Google. I did 
start blogging about D for web dev on my website to improve this. 
Random people actually liked it... considering my stuff are meh :)



That was about two yrs ago. New packages are now in dub. Even 
then every language suffers from sdks for interfacing with cloud 
services. AWS S3, Google services etc. Frankly something that 
makes nodejs very compelling cus there's packages for just about 
everything.



D is enjoyable to use nevertheless. I'm looking at doing another 
side project when time permits...or even continue my blog series 
(aberba.com)



So for me...its not mostly about the language itself but how I'm 
able to get things done.



I'm looking to improve resources discovery and availability in D 
for beginners too. Something I keep thinking about. Will 
hopefully share something soon.


Re: D Plugin for Visual Studio Code [was Re: Visual D 1.0.0 released]

2020-07-04 Thread aberba via Digitalmars-d-learn

On Saturday, 4 July 2020 at 19:52:42 UTC, Arafel wrote:

On 4/7/20 19:58, Paul Backus wrote:


You're looking for code-d:

https://github.com/Pure-D/code-d


Thanks! I'm trying it, although at least with VSCodium and 
Linux I had to build from sources, it didn't show by searching 
in the marketplace.


It DOES appear in the marketplace, its what I'm using. Just  
search for D programming or something. Its the most popular one 
there.


 One would assume such information is obvious to find but it is 
not. Unless you're already familiar with the ecosystem.


Re: How to implement Canceleable spawn() from parent

2020-07-01 Thread aberba via Digitalmars-d-learn
On Tuesday, 30 June 2020 at 14:43:40 UTC, Steven Schveighoffer 
wrote:

On 6/30/20 10:15 AM, Simen Kjærås wrote:

[...]


My thinking is I don't want regular consumers using the package 
to think about the technicality of thread_joinAll() at all.


Thinking about putting it in a mixin like:

mixin KeepRunning;

Or something


Re: How to implement Canceleable spawn() from parent

2020-06-30 Thread aberba via Digitalmars-d-learn

On Tuesday, 30 June 2020 at 12:48:32 UTC, Simen Kjærås wrote:

On Tuesday, 30 June 2020 at 08:15:54 UTC, aberba wrote:

On Tuesday, 30 June 2020 at 00:33:41 UTC, Ali Çehreli wrote:

On 6/29/20 4:34 PM, aberba wrote:

> So with this, without the Thread.sleep() to block main from
exiting, the
> spawned thread  will terminate immediately.

You can call core.thread.thread_joinAll at the end of main.
So I tried that initially but my (){ writeln(...) } wasn't 
printing anything in console. Could that be related to stdout 
buffering? The program kept running though.






So I guess the error is elsewhere, but I'm not sure where and 
how.


Yeah, you're right. I changed receiveTimeout() to receive() to 
try something and forgot to change it back.


Jeez, I hate myself.

Thanks.


So how can I now hide the core.thread.thread_joinAll so the 
library user doesn't have to type it themselves in main() ? I 
don't see how that can be done.




Re: How to implement Canceleable spawn() from parent

2020-06-30 Thread aberba via Digitalmars-d-learn

On Tuesday, 30 June 2020 at 00:33:41 UTC, Ali Çehreli wrote:

On 6/29/20 4:34 PM, aberba wrote:

> So with this, without the Thread.sleep() to block main from
exiting, the
> spawned thread  will terminate immediately.

You can call core.thread.thread_joinAll at the end of main.
So I tried that initially but my (){ writeln(...) } wasn't 
printing anything in console. Could that be related to stdout 
buffering? The program kept running though.





Another way would be to wait for a worker's exit by looking for 
LinkTerminated but you need to start the thread with 
spawnLinked:


Read that too, but doesn't seem like the desired behavior I want.


So here's the thing, unlike JavaScript, the D behavior seems to 
be like a while(bool){} has to be placed directly within the 
scope of main. Was thinking as long my while loop in 
setInterval() was running, spawn() will be kept alive.


It seem both vibe.d and arsd have a similar setInterval() 
implementation and they both require using their event loop to 
keep the program alive.


In my case, wanted setInterval() to behave like it's own event 
loop without placing it in a while(bool){} loop in main()




Re: How to implement Canceleable spawn() from parent

2020-06-29 Thread aberba via Digitalmars-d-learn

On Sunday, 28 June 2020 at 14:23:01 UTC, Stanislav Blinov wrote:

On Sunday, 28 June 2020 at 13:29:08 UTC, aberba wrote:


   [...]



The error you're getting is because you're passing a pointer to 
a delegate instead of a delegate.


[...]


So with this, without the Thread.sleep() to block main from 
exiting, the spawned thread  will terminate immediately. How do I 
keep it from happening? Keep it running continuously?


From the docs, it says OwnerTerminated exception gets thrown when 
the sending thread (e.i. main) is terminated.


Thrown on calls to receive if the thread that spawned the 
receiving thread has terminated and no more messages exist.




Re: How to implement Canceleable spawn() from parent

2020-06-28 Thread aberba via Digitalmars-d-learn

On Sunday, 28 June 2020 at 23:39:07 UTC, Stanislav Blinov wrote:

On Sunday, 28 June 2020 at 23:02:26 UTC, aberba wrote:


I believe this:

StopWatch sw;
sw.start;

works becuse D structs are initialized by default, right?
I've never actually done it this way. Little details.


Yup. You can also do a

auto sw = StopWatch(AutoStart.yes);

and not have to call `start` explicitly.


Interesting. I should look into Phobos more.


Re: How to implement Canceleable spawn() from parent

2020-06-28 Thread aberba via Digitalmars-d-learn

On Sunday, 28 June 2020 at 23:02:26 UTC, aberba wrote:

On Sunday, 28 June 2020 at 14:23:01 UTC, Stanislav Blinov wrote:

On Sunday, 28 June 2020 at 13:29:08 UTC, aberba wrote:

 Thanks.

I believe this:

StopWatch sw;
sw.start;


works becuse D structs are initialized by default, right?
I've never actually done it this way. Little details.


So I checked receiveTimeout() when I was looking for what I could 
use. I wish there was an example in the docs.


https://dlang.org/library/std/concurrency/receive_timeout.html


Re: How to implement Canceleable spawn() from parent

2020-06-28 Thread aberba via Digitalmars-d-learn

On Sunday, 28 June 2020 at 14:23:01 UTC, Stanislav Blinov wrote:

On Sunday, 28 June 2020 at 13:29:08 UTC, aberba wrote:

 Thanks.

I believe this:

StopWatch sw;
sw.start;


works becuse D structs are initialized by default, right?
I've never actually done it this way. Little details.


How to implement Canceleable spawn() from parent

2020-06-28 Thread aberba via Digitalmars-d-learn

Trying to implement a setInterval() that I can cancel using:

Tid tid = setInterval(2000, (){ writeln("hello");})

And then I can do:

stopInterval(tid);


With something like this:

stopInterval(Tid tid) {
send(tid, "cancel");
}

import std.stdio : writeln;
import std.concurrency : receive, spawn, thisTid, Tid;

auto setInterval(long milliseconds, void delegate() callback)
{
auto worker(long mls, void delegate() cb)
{
import core.thread.osthread : Thread;
import std.datetime : seconds, msecs;

writeln("Starting ", thisTid, "...");

bool done = false;

receive((string text) {
   writeln("Received string: ", text);
   done = true;
});

do
{
// or receive() comes here?

Thread.sleep(mls.msecs);
cb();
}
while (!done);
}

// I guess issue is with the callback
Tid id = spawn(, milliseconds, );

return id;
}



Getting error:

Error: template std.concurrency.spawn cannot deduce function from 
argument types !()(void delegate(Tid id) @system, Tid), 
candidates are:
/usr/include/dmd/phobos/std/concurrency.d(460,5):spawn(F, 
T...)(F fn, T args)

  with F = void delegate(Tid) @system,
   T = (Tid)
  must satisfy the following constraint:
   isSpawnable!(F, T)


Am I even using the right tool here?


Re: Light-weight runtime

2020-06-28 Thread aberba via Digitalmars-d-learn

On Sunday, 28 June 2020 at 07:09:53 UTC, Виталий Фадеев wrote:

I want light-weight runtime !

How to ?


If you have access to Google translate or any equivalent tool, 
you may use it to write in Russian language and copy+paste the 
English here. I think that'll really help.


I always give deep respect to people with different native 
languages who're trying really well to write English here. 
Considering someone of us learnt and wrote English in school but 
still suck at it. My biggest problem is typos.



--;;::
Now I think your question was discussed recently here 
https://forum.dlang.org/thread/gxtgbthyytukmqmzp...@forum.dlang.org


Re: How to work Get & Set text in clipboard in Windows ?

2020-06-22 Thread aberba via Digitalmars-d-learn

On Saturday, 20 June 2020 at 19:39:56 UTC, Vinod K Chandran wrote:

On Saturday, 20 June 2020 at 13:46:05 UTC, Dennis wrote:



Thanks a lot. Well, i thought it should be a one liner like-
Clipboard.SetText(sText)
But after reading your reply, i realized that this is D, not a 
scripting language. :)


It would be a one-liner if it was an api. Such utility APIs are 
quite missing in D.


How about putting them together into a package?


Re: Arduino and MCU Support

2020-06-19 Thread aberba via Digitalmars-d-learn

On Friday, 19 June 2020 at 11:57:01 UTC, frasdoge wrote:
I am looking to use D for microcontroller programming due to 
its benefits over C in workflow and general language features.


I was wondering what the current state of this is, especially 
with regards to AVR. An example of the MCUs I would like to 
develop with include anything from 8 bit ATmega328p to 32 bit 
ESP32.


The ESP32 can be programmed in C, C++, micropython and Lua, so 
I'm hoping there's at least some compatibility there.


Once you get it to work, please document something for use by 
others. Its quite unfortunate this is not well documented.


Re: Why is there no std.stream anymore?

2020-06-18 Thread aberba via Digitalmars-d-learn
On Thursday, 18 June 2020 at 15:03:38 UTC, Steven Schveighoffer 
wrote:

On 6/18/20 10:53 AM, aberba wrote:
On Tuesday, 12 December 2017 at 20:51:30 UTC, Steven 
Schveighoffer wrote:

On 12/11/17 6:33 PM, Seb wrote:

[...]
Since iopipe was mentioned several times, I will say a couple 
things:


[...]



I should really try iopipe this time round. I think I avoided 
toying with it because the making conventions put me off. 
Don't remember about the docs and available examples though.


I have made some updates that are probably not reflected yet in 
the docs. But let me know if there are any stumbling blocks. I 
intend to make the iopipe + std.io (from Martin) a more 
user-friendly library in the near future.


-Steve


Will discuss in the GH issue


Re: Why is there no std.stream anymore?

2020-06-18 Thread aberba via Digitalmars-d-learn
On Tuesday, 12 December 2017 at 20:51:30 UTC, Steven 
Schveighoffer wrote:

On 12/11/17 6:33 PM, Seb wrote:

[...]
Since iopipe was mentioned several times, I will say a couple 
things:


[...]



I should really try iopipe this time round. I think I avoided 
toying with it because the making conventions put me off. Don't 
remember about the docs and available examples though.


Re: Alpine support for D

2020-06-09 Thread aberba via Digitalmars-d-learn

On Wednesday, 10 June 2020 at 01:06:30 UTC, aberba wrote:

On Tuesday, 9 June 2020 at 14:23:34 UTC, Jesse Phillips wrote:
I notice that in the new release for Alpine Linux it mentions 
support for D.


I was curious what was meant by this and thought someone here 
would know. Just high level, like druntime was ported or 
packages added to the repo?


Tradionally you'd run D on something like Ubuntu, etc but 
Alpine is lightweight which is a good thing when building 
docker containers. Alpine uses a different C runtime musl?? 
among other things whilst D uses use libc. So I believe we now 
have bindings musl too to get D to work on Alpine.


https://en.m.wikipedia.org/wiki/Musl


Re: Alpine support for D

2020-06-09 Thread aberba via Digitalmars-d-learn

On Tuesday, 9 June 2020 at 14:23:34 UTC, Jesse Phillips wrote:
I notice that in the new release for Alpine Linux it mentions 
support for D.


I was curious what was meant by this and thought someone here 
would know. Just high level, like druntime was ported or 
packages added to the repo?


Tradionally you'd run D on something like Ubuntu, etc but Alpine 
is lightweight which is a good thing when building docker 
containers. Alpine uses a different C runtime musl?? among other 
things whilst D uses use libc. So I believe we now have bindings 
musl too to get D to work on Alpine.


Re: Control flushing to stdout... core.osthread.Thread + arsd.terminal

2020-06-05 Thread aberba via Digitalmars-d-learn

On Friday, 5 June 2020 at 12:28:17 UTC, Adam D. Ruppe wrote:

On Friday, 5 June 2020 at 11:45:31 UTC, aberba wrote:
How can I make Thread.sleep() only run AFTER "Wait, signing 
you in ..." is written (force flushed) to stdout?


just use explicit `terminal.flush();` any time you want the 
output to appear immediately.


Terminal does its own aggressive buffering internally (which I 
kinda regret) and only flushes with 1) it is full or 2) you ask 
for input, unless you call that flush function.


Ooop. Forgot to say thanks. Thanks, works as expected now.

Didn't come to mind to lookup from terminal docs. Thought it was 
a Dlang/OS problem.


Re: Control flushing to stdout... core.osthread.Thread + arsd.terminal

2020-06-05 Thread aberba via Digitalmars-d-learn

On Friday, 5 June 2020 at 12:28:17 UTC, Adam D. Ruppe wrote:

On Friday, 5 June 2020 at 11:45:31 UTC, aberba wrote:
How can I make Thread.sleep() only run AFTER "Wait, signing 
you in ..." is written (force flushed) to stdout?


just use explicit `terminal.flush();` any time you want the 
output to appear immediately.


Terminal does its own aggressive buffering internally (which I 
kinda regret) and only flushes with 1) it is full or 2) you ask 
for input, unless you call that flush function.


Why was the initial decision to handle buffering that way in 
terminal?


Control flushing to stdout... core.osthread.Thread + arsd.terminal

2020-06-05 Thread aberba via Digitalmars-d-learn
I have this code which take two inputs. I expect "Wait, signing 
you in ..." to be written to stdout before Thread.sleep() kicks 
in but it somehow doesn't follow that sequence. I believe its a 
normal stdout behaviour since its buffered.


How can I make Thread.sleep() only run AFTER "Wait, signing you 
in ..." is written (force flushed) to stdout?


import core.thread.osthread, std.datetime;
import arsd.terminal;

void main()
{
auto terminal = Terminal(ConsoleOutputType.linear);
terminal.setTitle("App");

// this is possible too but you MUST have an indexed png 
which might be hard to make if you aren't ready for it.

// terminal.changeWindowIcon("assets/icon.png");

terminal.writeln("hi");

auto got = terminal.getline("Username: ");
auto code = terminal.getline("Password: ");

const timeInSeconds = 5;
terminal.writeln("Wait, signing you in ...");


Thread.sleep(timeInSeconds.seconds);


terminal.writeln("username is ", got);
terminal.writeln("code is ", code);
}



Re: Is there a list of things which are slow to compile?

2020-06-05 Thread aberba via Digitalmars-d-learn

On Wednesday, 3 June 2020 at 17:02:35 UTC, H. S. Teoh wrote:
On Wed, Jun 03, 2020 at 09:36:52AM +, drathier via 
Digitalmars-d-learn wrote:
I'm wondering if there's a place that lists things which are 
slower/faster to compile? DMD is pretty famed for compiling 
quickly, but I'm not seeing particularly high speed at all, 
and I want to fix that.


The two usual culprits are:
- Recursive/chained templates
- Excessive CTFE

Note that while the current CTFE engine is slow, it's still 
reasonably fast for short computations. Just don't write nested 
loops or loops with a huge number of iterations inside your 
CTFE code, and you should be fine. And on that note, even 
running std.format with all of its complexity inside CTFE is 
reasonably fast, as long as you don't do it too often; so 
generally you won't see a problem here unless you have loop 
with too many iterations or too deeply-nested loops running in 
CTFE.


Templates are generally reasonably OK, until you use too many 
recursive templates. Or if you chain too many of them together, 
like if you have excessively long UFCS chains with Phobos 
algorithms. Short chains are generally OK, but once they start 
getting long they will generate large symbols and large numbers 
of instantiations. Large symbols used to be a big problem, but 
ever since Rainer's fix they have generally been a lot tamer. 
But still, it's something to avoid unless you can't help it.


Recursive templates are generally bad because they tend to 
produce a super-linear number of instantiations, which consume 
lots of compiler memory and also slow things down. Use too many 
of them, and things will quickly slow to a crawl.


Worst is if you combine both deeply-nested templates and CTFE, 
like std.regex does. Similarly, std.format (which includes 
writefln & co) tends to add 1-2 seconds to compile time.


Another is if you have an excessively long function body, IIRC 
there are some O(n^2) algorithms in the compiler w.r.t. the 
length of the function body. But I don't expect normal code to 
reach the point where this begins to matter; generally you 
won't run into this unless your code is *really* poorly written 
(like the entire application inside main()), or you're using 
excessive code generation (like the mixin of a huge 
procedurally generated string).


Identifier lengths are generally no problem unless you're 
talking about 100KB-long identifiers, which used to be a 
problem until Rainer implemented backreferences in the 
mangling. But I don't expect normal code to generate symbols of 
this order of magnitude unless you're using excessively-long 
UFCS chains with nested templates. Identifier length generally 
doesn't even register on the radar unless they're ridiculously 
long, like tens or hundreds of KB long -- not something a human 
would type. What humans would consider a long identifier, like 
Java-style names that span 50 characters, are mere round-off 
error and probably don't even make a measurable difference. The 
problem really only begins to surface when you have 10,000 
characters in your identifier or larger.


Comments are not even a blip on the radar: lexing is the 
fastest part of the compilation process.  Similarly, aliases 
are extremely cheap, it's not even on the radar. Delegates have 
only a runtime cost; they are similarly unnoticeably cheap 
during compilation.  As are Variants, unless you're running 
Variants inside CTFE (which I don't think even works).



T


I'm thinking about a resource hub for D with information like 
these. Can I use this information? ...of course I'll reference 
this thread and you can always call for changes.


Re: I want Sublime 3 D auto import !

2020-06-03 Thread aberba via Digitalmars-d-learn

On Monday, 1 June 2020 at 17:28:16 UTC, Johannes Loher wrote:

On Monday, 1 June 2020 at 16:18:44 UTC, Виталий Фадеев wrote:

[...]


Demanding stuff usually doesn't work in this community. The 
usual answer is something like this: If you care about this, 
implement it yourself or pay somebody to do it.


Depends on how you interpret it.


Re: Best way to learn 2d games with D?

2020-03-16 Thread aberba via Digitalmars-d-learn

On Tuesday, 17 March 2020 at 03:13:02 UTC, aberba wrote:
On Sunday, 15 March 2020 at 17:58:58 UTC, Steven Schveighoffer 
wrote:
I want to try and learn how to write 2d games. I'd prefer to 
do it with D.


I've found a ton of tutorials on learning 2d gaming with other 
languages. Is there a place to look that uses D for learning? 
Should I just start with another language and then migrate to 
D later? Anyone recommend any specific tutorial/book?


-Steve


https://github.com/DerelictOrg/DerelictSFML2 is the most up to 
date D binding to SFML library. Now that the maintainer is 
saying bindbc is better, I'm not sure the way to go.


Will we ever get a bindbc-sfml?


By the way, the maintainer of DSFML went very far by creating a 
great website with docs and tutorials at http://www.dsfml.com/


You can still use DSFML with an older compiler by installing and 
using with something like DVM 
(https://code.dlang.org/packages/dvm)


Re: Best way to learn 2d games with D?

2020-03-16 Thread aberba via Digitalmars-d-learn
On Sunday, 15 March 2020 at 17:58:58 UTC, Steven Schveighoffer 
wrote:
I want to try and learn how to write 2d games. I'd prefer to do 
it with D.


I've found a ton of tutorials on learning 2d gaming with other 
languages. Is there a place to look that uses D for learning? 
Should I just start with another language and then migrate to D 
later? Anyone recommend any specific tutorial/book?


-Steve


https://github.com/DerelictOrg/DerelictSFML2 is the most up to 
date D binding to SFML library. Now that the maintainer is saying 
bindbc is better, I'm not sure the way to go.


Will we ever get a bindbc-sfml?


By the way, the maintainer of DSFML went very far by creating a 
great website with docs and tutorials at http://www.dsfml.com/





Re: Best way to learn 2d games with D?

2020-03-16 Thread aberba via Digitalmars-d-learn
On Sunday, 15 March 2020 at 17:58:58 UTC, Steven Schveighoffer 
wrote:
I want to try and learn how to write 2d games. I'd prefer to do 
it with D.


I've found a ton of tutorials on learning 2d gaming with other 
languages. Is there a place to look that uses D for learning? 
Should I just start with another language and then migrate to D 
later? Anyone recommend any specific tutorial/book?


-Steve


Its sad we still don't have a really great framework/engine for 
developing 2d games in D...even with many options in C available. 
It seems the casual game community/fan is missing here.


Re: Best way to learn 2d games with D?

2020-03-16 Thread aberba via Digitalmars-d-learn
On Sunday, 15 March 2020 at 17:58:58 UTC, Steven Schveighoffer 
wrote:
I want to try and learn how to write 2d games. I'd prefer to do 
it with D.


I've found a ton of tutorials on learning 2d gaming with other 
languages. Is there a place to look that uses D for learning? 
Should I just start with another language and then migrate to D 
later? Anyone recommend any specific tutorial/book?


-Steve


Over the years, I've seen so many 2d game frameworks/engine get 
started and abandoned here. I would recommend DSFML if you can 
get it to work. I really like the SFML API design. With that 
said, here are some I looked at:


https://code.dlang.org/packages/d2dgame (based on SDL2 by 
WebFreak001, not sure how mature it is though, see a demo at 
https://github.com/WebFreak001/D2DGame/blob/master/example/source/app.d)



https://code.dlang.org/packages/dagon (Mostly 3d, but can do 
3d/2d games too. The most advanced of any D game 
engine/framework. Tonne of work poured into it)


https://code.dlang.org/packages/pixelperfectengine (retro games, 
I have seen several YouTube demos by the dev)


https://code.dlang.org/packages/godot-d (Godot is quite 
popular..used in commercial game. Not sure how good and easy to 
use this binding is though)


https://themindofmurilomiranda.blogspot.com/2020/01/space-invaders-game-example-to-learn.html
 (Murilo Miranda has this tutorial he pulled together after working tirelessly 
and asking many question on using Adam's arsd package here, I like this guy's 
tenacity)



Re: Using D for Raspberry Pi expirements

2019-09-29 Thread aberba via Digitalmars-d-learn

On Sunday, 29 September 2019 at 16:26:48 UTC, Aldo wrote:

On Sunday, 29 September 2019 at 11:36:00 UTC, aberba wrote:
On Thursday, 26 September 2019 at 00:09:30 UTC, Mike Franklin 
wrote:

[...]


I have no idea how to do that from D. Any help/resources on 
that?


Maybe you can use this dub package? 
http://code.dlang.org/packages/dgpio


I'm using a D app on a raspberry Pi to open my house portal for 
1 year now. It works perfectly. The "hardest" part is the 
compilation.


I tried this guide yesterday: 
https://wiki.dlang.org/Programming_in_D_tutorial_on_Embedded_Linux_ARM_devices and it worked perfectly fine. I compiled my app from Windows with a Debian (from the windows store) and uploaded my executable compiled with ARM target.


Thanks. Appreciate.


Re: Packaging and Distributing Dlang Applications with GtkD Dependency?

2019-09-29 Thread aberba via Digitalmars-d-learn

On Thursday, 26 September 2019 at 16:30:39 UTC, Andre Pany wrote:
On Wednesday, 25 September 2019 at 17:03:51 UTC, Ron Tarrant 
wrote:
On Wednesday, 25 September 2019 at 13:52:48 UTC, 
bioinfornatics wrote:


I think I misunderstood your need but are lo looking for dub 
tool with its repository https://code.dlang.org/


I don't think so, but I could be wrong. I tried reading up on 
dub, but got lost in the docs, so I really don't understand 
what all it can do.


Dub is a tool for developers, I understand your requirements 
that you want target end customers of your applications. 
Therefore dub is the wrong tool for this job.


To be more precise, gtkd is a wrapper for GTK. Gtkd is not 
interesting in this context, but the dependency on gtk. On 
windows you have the possibility to either publish your 
application with GTK dlls or to run gtk setup routine as part 
of your application setup routine or just say in your readme 
that the customer needs to run GTK setup on there own.


On posix (linus, macos) of course you can also say in your 
readme that the customer should run apt-get ... to install gtk 
(here I do not have much knowledge on packaging).


Kind regards
Andre


I will immediately abandon any app that provides this sort of 
incomplete experience to use unless I have my developer hats 
on...or I really have not other choice.


Re: Using D for Raspberry Pi expirements

2019-09-29 Thread aberba via Digitalmars-d-learn
On Thursday, 26 September 2019 at 00:09:30 UTC, Mike Franklin 
wrote:

On Wednesday, 25 September 2019 at 23:56:45 UTC, aberba wrote:
I'm looking for resources on using D for basic Raspberry Pi 
programming...stuff like turning on and off an LED light. I 
believe it requires being able to call the Raspberry OS core 
APIs from D as available in Python.


Anyone here tried something like that using D?


I haven't tried with D yet, but I use C# and mono calling into 
the pigpio C library (http://abyz.me.uk/rpi/pigpio/pdif2.html) 
and it workes great.  You should be able to do the same with D.


Mike


I have no idea how to do that from D. Any help/resources on that?


Re: Using D for Raspberry Pi expirements

2019-09-29 Thread aberba via Digitalmars-d-learn
On Thursday, 26 September 2019 at 17:26:25 UTC, Dave Chapman 
wrote:

On Thursday, 26 September 2019 at 00:10:40 UTC, aberba wrote:

[...]


I've been using 
https://git.kernel.org/pub/scm/libs/libgpiod/libgpiod.git/ . It 
is a C library written by Bartosz Golaszewski. He is actively 
working on it. The latest update is a week old. It has the 
advantage that you don't have to use sudo to access the gpio 
pins. It comes with a set of tools written in C that I have 
been converting to D. Since my knowledge of both D and C is 
weak it has taken me some time to get things going. I have a 
hand written D bindings file that is incomplete and of amateur 
quality. So far I have converted 2 of the 6 command line tools 
that Bartosz Golaszewski provided to to work with the library.


David Chapman


your code... can you push it to GitHub so I can check it out?


Re: Using D for Raspberry Pi expirements

2019-09-25 Thread aberba via Digitalmars-d-learn

On Wednesday, 25 September 2019 at 23:56:45 UTC, aberba wrote:
I'm looking for resources on using D for basic Raspberry Pi 
programming...stuff like turning on and off an LED light. I 
believe it requires being able to call the Raspberry OS core 
APIs from D as available in Python.


Just found this package dating back from May 2016...let's see 
what it can do 
(https://github.com/fgheorghe/D-Lang-Raspbian-GPIO-Module)




Anyone here tried something like that using D?





Using D for Raspberry Pi expirements

2019-09-25 Thread aberba via Digitalmars-d-learn
I'm looking for resources on using D for basic Raspberry Pi 
programming...stuff like turning on and off an LED light. I 
believe it requires being able to call the Raspberry OS core APIs 
from D as available in Python.


Anyone here tried something like that using D?


Re: gtkDcoding Blog Post for 2019-03-29 - Grid

2019-03-29 Thread aberba via Digitalmars-d-learn

On Friday, 29 March 2019 at 14:25:16 UTC, Ron Tarrant wrote:

I'm having trouble replying to the thread I usually use, so...

There's a new tutorial for using a GTK Grid. You can find it 
here: http://gtkdcoding.com/2019/03/29/0022-grids.html


Have shared gtkdcoding.com with some folks and they like it, keep 
it coming!!




  1   2   >