Thread overview | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
January 28, 2017 Aerospike wrapper/driver for vibe.d ? | ||||
---|---|---|---|---|
| ||||
I'm new to the D language, but I really enjoy its execution speed and ease of programming, and I'd like to implement the web server of my next project in D instead of C++ or Go. Unfortunately my server needs to communicate with an Aerospike database (an ultra-fast open-source distributed database). Aerospike provides a client API for plenty of languages (C, C++, Go, JS, Ruby, Python, etc) but unfortunately not for D. So I'd like to know if anybody has already begun to build a wrapper around Aerospike's C API, preferably one that automatically converts class fields to record bins (and inversely). I'm trying to implement this by myself, but honestly it's not easy for a newcomer like me... That's really sad, because IMHO, this driver could definitely help D in becoming THE mainstream language for high-performance web servers, outperforming even C++ and Go, as obviously the Dlang/Aerospike combination feels really optimal for this kind of development. |
January 28, 2017 Re: Aerospike wrapper/driver for vibe.d ? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Rico Decho | On 28/01/2017 10:15 PM, Rico Decho wrote:
> I'm new to the D language, but I really enjoy its execution speed and
> ease of programming, and I'd like to implement the web server of my next
> project in D instead of C++ or Go.
>
> Unfortunately my server needs to communicate with an Aerospike database
> (an ultra-fast open-source distributed database).
>
> Aerospike provides a client API for plenty of languages (C, C++, Go, JS,
> Ruby, Python, etc) but unfortunately not for D.
>
> So I'd like to know if anybody has already begun to build a wrapper
> around Aerospike's C API, preferably one that automatically converts
> class fields to record bins (and inversely).
>
> I'm trying to implement this by myself, but honestly it's not easy for a
> newcomer like me...
>
> That's really sad, because IMHO, this driver could definitely help D in
> becoming THE mainstream language for high-performance web servers,
> outperforming even C++ and Go, as obviously the Dlang/Aerospike
> combination feels really optimal for this kind of development.
I wouldn't worry about writing a wrapper just yet.
Get a binding going first.
If you would like some interactive help jump on to #D on Freenode (IRC).
|
January 28, 2017 Re: Aerospike wrapper/driver for vibe.d ? | ||||
---|---|---|---|---|
| ||||
Posted in reply to rikki cattermole | I agree, one step at a time... Anyway, as I've never used D's type introspection and compile-time code generation, my options are quite limited at the moment :( |
January 28, 2017 Re: Aerospike wrapper/driver for vibe.d ? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Rico Decho | On Saturday, 28 January 2017 at 09:59:10 UTC, Rico Decho wrote: > I agree, one step at a time... > > Anyway, as I've never used D's type introspection and compile-time code generation, my options are quite limited at the moment :( You shouldn't need any of that to create a binding to a C API. You can manually translate the headers or use a tool like DStep [1] to get you most of the way there. [1] https://github.com/jacob-carlborg/dstep |
January 28, 2017 Re: Aerospike wrapper/driver for vibe.d ? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Rico Decho | On Saturday, 28 January 2017 at 09:59:10 UTC, Rico Decho wrote:
> I agree, one step at a time...
>
> Anyway, as I've never used D's type introspection and compile-time code generation, my options are quite limited at the moment :(
Binding to C is really, really easy for most cases. E.g. for a library
called fancyLib with a C header fancyLib.h
// fancyLib.h, just for reference
struct S
{
int a, b;
}
char const *fancyCFunction(int a, long b, struct S s);
//fancyLib.d
import core.stdc.config : c_long;
struct S
{
int a, b;
}
extern(C) const(char)* fancyCFunction(int a, c_long b, S s);
//myCode.d
import fancyLib;
void main()
{
auto res = fancyCFunction(4, 53, S(1, 1));
}
compile with:
dmd fancyLib.d myCode.d -L-lfancyLib
or add fancyLib to "libs" if you use dub.
|
January 28, 2017 Re: Aerospike wrapper/driver for vibe.d ? | ||||
---|---|---|---|---|
| ||||
Posted in reply to John Colvin | This afternoon I'll first try using dstep to generate the binding automatically. If that doesn't work as expected, I'll try to bind the main functions manually as detailed in the "fancylib" example... In both cases, at least now I'm confident that I know precisely how to proceed, so thanks guys for the tips :) |
January 28, 2017 Re: Aerospike wrapper/driver for vibe.d ? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Rico Decho | On Saturday, 28 January 2017 at 12:34:21 UTC, Rico Decho wrote: > This afternoon I'll first try using dstep to generate the binding automatically. > > If that doesn't work as expected, I'll try to bind the main functions manually as detailed in the "fancylib" example... > > In both cases, at least now I'm confident that I know precisely how to proceed, so thanks guys for the tips :) Be sure to pay a visit to the Wiki for some help: http://wiki.dlang.org/Bind_D_to_C |
January 28, 2017 Re: Aerospike wrapper/driver for vibe.d ? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Mike Parker | Actually I think that John's explanations are much more concrete and useful than what's in the official docs. Why not integrate it into D's wiki ? |
January 28, 2017 Re: Aerospike wrapper/driver for vibe.d ? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Rico Decho | On Saturday, 28 January 2017 at 15:01:00 UTC, Rico Decho wrote:
> Actually I think that John's explanations are much more concrete and useful than what's in the official docs.
>
> Why not integrate it into D's wiki ?
Simply because no one has bothered to do it? The Wiki page links to some stuff I wrote over at gamedev.net that covers most of the common cases and fills in some stuff I didn't. I also devoted an entire chapter to it, where I covered more cases, in Learning D.
If anyone wants to take all of that and combine it into a Wiki page, it's fine by me.
|
January 28, 2017 Re: Aerospike wrapper/driver for vibe.d ? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Mike Parker | Thanks for proposing it ! I've just added John's sample code to the wiki (hoping that he doesn't mind). |
Copyright © 1999-2021 by the D Language Foundation