www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.announce - Call D code from C#

reply "anthony" <anthonyb panafonet.com> writes:
Hi to all here,

(another one here that wants to desperately use D in his work 
environment!)

So, I am a C# and C++ guy who is used to high quality tools and 
UI libraries. I discovered VisualD and I settled on using it, it 
is really awesome!

The only problem that concerns me is the lack of a UI library to 
use with the language. GTK+ is not an option for me. Qt is but I 
do not see any way to use it from D.

I am thinking about using D for the business logic of my programs 
(let's say on Windows, for start) and then C# for the UI stuff.

Is there a way to access D code from C# ? Some path I need to 
follow, some hint... ?

Thanks a lot for any help !

anthony
Jan 09 2014
next sibling parent "anthony" <anthonyb panafonet.com> writes:
Oopss...I think I posted on the wrong section of the forum and I 
do not see a way to put it on the correct one... :(
Jan 09 2014
prev sibling next sibling parent reply "John Colvin" <john.loughran.colvin gmail.com> writes:
On Thursday, 9 January 2014 at 15:58:20 UTC, anthony wrote:
 Hi to all here,

 (another one here that wants to desperately use D in his work 
 environment!)

 So, I am a C# and C++ guy who is used to high quality tools and 
 UI libraries. I discovered VisualD and I settled on using it, 
 it is really awesome!

 The only problem that concerns me is the lack of a UI library 
 to use with the language. GTK+ is not an option for me. Qt is 
 but I do not see any way to use it from D.

 I am thinking about using D for the business logic of my 
 programs (let's say on Windows, for start) and then C# for the 
 UI stuff.

 Is there a way to access D code from C# ? Some path I need to 
 follow, some hint... ?

 Thanks a lot for any help !

 anthony
C# should be able to call any D functions declared with extern(C) by compiling the D code as a shared library or dll and using C#'s PInvoke tool just like you would for C. Be aware that you will need to initialise the D runtime (core.runtime.rt_init). Also, loading multiple shared libs / dlls will cause pain.
Jan 09 2014
parent reply "anthony" <anthonyb panafonet.com> writes:
Thanks for the (ultra fast) reply!

I has that coming that P/Invoke is the only way, unfortunately. 
Are you aware of any other problems using this technique ?
Jan 09 2014
parent "evilrat" <evilrat666 gmail.com> writes:
On Thursday, 9 January 2014 at 16:09:11 UTC, anthony wrote:
 Thanks for the (ultra fast) reply!

 I has that coming that P/Invoke is the only way, unfortunately. 
 Are you aware of any other problems using this technique ?
why unfortunately? using this in visual studio allows me debug both C#/D code. all fine, but i never used it for anything complex than testing stuff though.
Jan 09 2014
prev sibling next sibling parent reply "bearophile" <bearophileHUGS lycos.com> writes:
anthony:

 The only problem that concerns me is the lack of a UI library 
 to use with the language. GTK+ is not an option for me. Qt is 
 but I do not see any way to use it from D.
Is QtD not good enough? Bye, bearophile
Jan 09 2014
next sibling parent "anthonyb" <anthony panafonet.com> writes:
QtD does not seem to be actively developed and i want something 
that is somewhat "future safe", if you can say that about our job!
Jan 09 2014
prev sibling parent reply "Adam D. Ruppe" <destructionator gmail.com> writes:
On Thursday, 9 January 2014 at 16:15:23 UTC, bearophile wrote:
 Is QtD not good enough?
When I tried it, a while ago, it was completely unusable - random runtime crashes.
Jan 09 2014
parent reply "anthonyb" <anthony panafonet.com> writes:
On Thursday, 9 January 2014 at 17:56:46 UTC, Adam D. Ruppe wrote:
 On Thursday, 9 January 2014 at 16:15:23 UTC, bearophile wrote:
 Is QtD not good enough?
When I tried it, a while ago, it was completely unusable - random runtime crashes.
Which i a real shame...If D was able to access a UI like Qt, it would give a tremendous push to the language. Not being able to use easily some UI from D is holding back many people. I think Qt is the only reason some people prefer C++ even now.
Jan 09 2014
next sibling parent reply "tc" <chalucha gmail.com> writes:
 Which i a real shame...If D was able to access a UI like Qt, it 
 would give a tremendous push to the language. Not being able to 
 use easily some UI from D is holding back many people. I think 
 Qt is the only reason some people prefer C++ even now.
I'm from C# world and this is exactly what will make a huge difference. Have a nice portable language with a nice portable UI toolkit. I would like to learn Qt, but for me C++ is a no go (I'm too much used to GC world simplicity/productivity). I like D, but i think much work is still needed to make it usable by masses. Still newb and learning, but for now what I observed that D is a productive language, comparable to C# and it can be really fast for many usecases. But I also observed from forum here: - no good UI capability - yes I really consider Qt as a must - not yet supported on arm/android/iOS,WP - why many Raspberry PI hackers are using python?? Would not this be a nice playground for D? - bad performance of GC (everyone arguing about this, specially for games) - small library (as compared to what you can do with standard java, .Net libs, this is just true) So what is actually a target audience of this language? I think that today its perfect for some backends, business layer logic infrastructure. For games? Well for some simple 2D/3D sure, but because of lacking GC its limited. Web development? Vibe.d is nice, but I think we need to have some complete framework to compete with ruby on rails, django for python, etc. Multiplatform UI apps? Without Qt, I'm not convinced. I like a progress the comunity is making (GDC, LDC2, vibe.d, dub, ...). If just there is a better GC, arm and mobile platforms support, decent UI framework as QT is, I think that that will make a huge step for D to be usable for a much wider userbase. I really dont get, why people should write portable UI apps in something like C or C++ if D is around. GC? I don't care about it in UI, it helps to make things implemented fast so for me its a must and performance critical blocks should be handled by backend anyway..
Jan 09 2014
next sibling parent reply "Rikki Cattermole" <alphaglosined gmail.com> writes:
On Thursday, 9 January 2014 at 22:09:14 UTC, tc wrote:
 Which i a real shame...If D was able to access a UI like Qt, 
 it would give a tremendous push to the language. Not being 
 able to use easily some UI from D is holding back many people. 
 I think Qt is the only reason some people prefer C++ even now.
I'm from C# world and this is exactly what will make a huge difference. Have a nice portable language with a nice portable UI toolkit. I would like to learn Qt, but for me C++ is a no go (I'm too much used to GC world simplicity/productivity). I like D, but i think much work is still needed to make it usable by masses. Still newb and learning, but for now what I observed that D is a productive language, comparable to C# and it can be really fast for many usecases. But I also observed from forum here: - no good UI capability - yes I really consider Qt as a must - not yet supported on arm/android/iOS,WP - why many Raspberry PI hackers are using python?? Would not this be a nice playground for D? - bad performance of GC (everyone arguing about this, specially for games) - small library (as compared to what you can do with standard java, .Net libs, this is just true) So what is actually a target audience of this language? I think that today its perfect for some backends, business layer logic infrastructure. For games? Well for some simple 2D/3D sure, but because of lacking GC its limited. Web development? Vibe.d is nice, but I think we need to have some complete framework to compete with ruby on rails, django for python, etc. Multiplatform UI apps? Without Qt, I'm not convinced. I like a progress the comunity is making (GDC, LDC2, vibe.d, dub, ...). If just there is a better GC, arm and mobile platforms support, decent UI framework as QT is, I think that that will make a huge step for D to be usable for a much wider userbase. I really dont get, why people should write portable UI apps in something like C or C++ if D is around. GC? I don't care about it in UI, it helps to make things implemented fast so for me its a must and performance critical blocks should be handled by backend anyway..
I would be interested to know what you think about my web service framework so far[0]. Blog post about why I did it here[1]. I was trying to sort our UI issues with DOOGLE[2]. But the latest talk about a new UI system basically killed my want to work on it altogether. It would have enabled building a GUI app and then very simply building it for a web as well. Without changing much code. Don't think any GUI toolkit exists that can do that. [0] https://github.com/rikkimax/Cmsed [1] http://alphaglosined.blogspot.com/2014/01/creating-competing-web-service.html [2] https://github.com/rikkimax/DOOGLE
Jan 09 2014
parent reply Rory McGuire <rjmcguire gmail.com> writes:
gtk has a web based backend available.


On Fri, Jan 10, 2014 at 7:31 AM, Rikki Cattermole
<alphaglosined gmail.com>wrote:

 ... It would have enabled building a GUI app and then very simply
 building it for a web as well. Without changing much code. Don't think any
 GUI toolkit exists that can do that.

 [0] https://github.com/rikkimax/Cmsed
 [1] http://alphaglosined.blogspot.com/2014/01/creating-
 competing-web-service.html
 [2] https://github.com/rikkimax/DOOGLE
Jan 10 2014
parent "Rikki Cattermole" <alphaglosined gmail.com> writes:
On Friday, 10 January 2014 at 15:02:18 UTC, Rory McGuire wrote:
 gtk has a web based backend available.
Awesome didn't know that thanks!
Jan 10 2014
prev sibling parent reply Jacob Carlborg <doob me.com> writes:
On 2014-01-09 23:09, tc wrote:

 I'm from C# world and this is exactly what will make a huge
 difference. Have a nice portable language with a nice portable UI
 toolkit.
 I would like to learn Qt, but for me C++ is a no go (I'm too much
 used to GC world simplicity/productivity).
Have a look at DWT: https://github.com/d-widget-toolkit/dwt -- /Jacob Carlborg
Jan 09 2014
parent reply "TC" <chalucha gmail.com> writes:
 Have a look at DWT: https://github.com/d-widget-toolkit/dwt
I looked at it and on the first sight it seems as a wrapper around GTK on linux side and native windows toolkit on windows. In this case I would probably rather use gtkd directly and hope for fewer problems. (but both should be tried and decided after that, DWT seems to be more OOP friendly so easier to use). If I understand it correctly, its backed up with GTK2 on linux? (SWT seems to get GTK3 support in october 2013, but don't know if its already released). My point is, that GTKD, DWT are for sure pretty usable. But they lack modern features and portability and if I will be in position to choose UI framework for multiplatform business app, I will end up with Qt 5.x for sure. It seems that D is advancing to be ARM ready, wouldn't it be nice to be able to write UI apps for Android, iOS, WinRT, whatever in D?
Jan 10 2014
next sibling parent reply "anthonyb" <anthony panafonet.com> writes:
On Friday, 10 January 2014 at 21:50:50 UTC, TC wrote:
 they lack modern features and portability and if I will be in 
 position to choose UI framework for multiplatform business app, 
 I will end up with Qt 5.x for sure.
C++ remains the best tool for that job (Qt 5.x). And unfortunately, i do not have many hopes that it will change soon.
Jan 11 2014
parent reply Paulo Pinto <pjmlp progtools.org> writes:
Am 11.01.2014 14:30, schrieb anthonyb:
 On Friday, 10 January 2014 at 21:50:50 UTC, TC wrote:
 they lack modern features and portability and if I will be in position
 to choose UI framework for multiplatform business app, I will end up
 with Qt 5.x for sure.
C++ remains the best tool for that job (Qt 5.x). And unfortunately, i do not have many hopes that it will change soon.
It will, but not in the direction most people would like. From what I can get from Qt conference videos since version 5 came out, QML is the way to go, with just performance critical parts still done in C++. -- Paulo
Jan 11 2014
parent reply Xavier Bigand <flamaros.xavier gmail.com> writes:
Le 11/01/2014 18:23, Paulo Pinto a écrit :
 Am 11.01.2014 14:30, schrieb anthonyb:
 On Friday, 10 January 2014 at 21:50:50 UTC, TC wrote:
 they lack modern features and portability and if I will be in position
 to choose UI framework for multiplatform business app, I will end up
 with Qt 5.x for sure.
C++ remains the best tool for that job (Qt 5.x). And unfortunately, i do not have many hopes that it will change soon.
It will, but not in the direction most people would like. From what I can get from Qt conference videos since version 5 came out, QML is the way to go, with just performance critical parts still done in C++. -- Paulo
I work every day on an application written in C++ with Qt and QML. The core of the application is written in C++ without Qt and only the GUI is in QML, some additionnal wrappers are necessary to inject data of the core application in QML. We have no performance issues with QML. Saddly for the moment I can't talk more about this application since it was not already released, but it's typically an application where performances are critical. Like with every script languages you need to do things with carefulness and avoid to put application logic in it. It's our experience give us the idea to do something similar in D, cause a lot of things can be better than with Qt and C++.
Jan 11 2014
parent Paulo Pinto <pjmlp progtools.org> writes:
On 11.01.2014 19:33, Xavier Bigand wrote:
 Le 11/01/2014 18:23, Paulo Pinto a écrit :
 Am 11.01.2014 14:30, schrieb anthonyb:
 On Friday, 10 January 2014 at 21:50:50 UTC, TC wrote:
 they lack modern features and portability and if I will be in position
 to choose UI framework for multiplatform business app, I will end up
 with Qt 5.x for sure.
C++ remains the best tool for that job (Qt 5.x). And unfortunately, i do not have many hopes that it will change soon.
It will, but not in the direction most people would like. From what I can get from Qt conference videos since version 5 came out, QML is the way to go, with just performance critical parts still done in C++. -- Paulo
I work every day on an application written in C++ with Qt and QML. The core of the application is written in C++ without Qt and only the GUI is in QML, some additionnal wrappers are necessary to inject data of the core application in QML. We have no performance issues with QML. Saddly for the moment I can't talk more about this application since it was not already released, but it's typically an application where performances are critical. Like with every script languages you need to do things with carefulness and avoid to put application logic in it. It's our experience give us the idea to do something similar in D, cause a lot of things can be better than with Qt and C++.
Thanks for sharing the information. At work I do mostly JVM/.NET stuff. Since 2006 I don't do any C++ at work, except when porting stuff to the former platforms. I just use Qt/C++ occasionally on hobby projects, so it is good to know from someone with experience on them, how the real situation is. -- Paulo
Jan 11 2014
prev sibling parent Jacob Carlborg <doob me.com> writes:
On 2014-01-10 22:50, TC wrote:

 I looked at it and on the first sight it seems as a wrapper around GTK
 on linux side and native windows toolkit on windows. In this case I
 would probably rather use gtkd directly and hope for fewer problems.
 (but both should be tried and decided after that, DWT seems to be more
 OOP friendly so easier to use).
It's quite a lot more than a wrapper. It's its own GUI toolkit. But yes, on Linux it uses GTK+.
 If I understand it correctly, its backed up with GTK2 on linux? (SWT
 seems to get GTK3 support in october 2013, but don't know if its already
 released).
Yes, it uses GTK+. DWT is quite an old port, 3.4 to be exact.
 My point is, that GTKD, DWT are for sure pretty usable. But they lack
 modern features and portability and if I will be in position to choose
 UI framework for multiplatform business app, I will end up with Qt 5.x
 for sure.
What do you mean lack portability? I'm currently working on the Mac OS X port.
 It seems that D is advancing to be ARM ready, wouldn't it be nice to be
 able to write UI apps for Android, iOS, WinRT, whatever in D?
Yeah, of course. The advantage of DWT is that is uses the native toolkit on each platform (Linux doesn't really have one). No additional libraries are required except for the system libraries. -- /Jacob Carlborg
Jan 11 2014
prev sibling parent reply Jim Hewes <jimhewes gmail.com> writes:
On 1/9/2014 10:38 AM, anthonyb wrote:
 On Thursday, 9 January 2014 at 17:56:46 UTC, Adam D. Ruppe wrote:
 On Thursday, 9 January 2014 at 16:15:23 UTC, bearophile wrote:
 Is QtD not good enough?
When I tried it, a while ago, it was completely unusable - random runtime crashes.
Which i a real shame...If D was able to access a UI like Qt, it would give a tremendous push to the language. Not being able to use easily some UI from D is holding back many people. I think Qt is the only reason some people prefer C++ even now.
I agree UI is an issue. It's kind of a showstopper for me. If I were writing programs for other programmers it wouldn't matter as much, but I write them for normal people and so it has to have a GUI. I realize the first priority is having a standard library, but UI is right up there. I always run into two problems with volunteer open source projects. One, it was probably abandoned some years ago because the developers lost interest and it no longer works. Two, you have to first install the developer's three or four favorite tools before you can build it, some of which may have their own dependencies. Coming from the Windows side this is annoying. I'd prefer to use wxWidgets. Not long ago I spent a day trying to get it to work by just pulling the code into a Visual Studio project (with Visual D) and fixing compilation errors. I got the sample program to run which was encouraging, but it crashed after exit in what looked like the GC so I gave up for now. I may consider doing what you're doing and use C#/.Net framework for UI. Jim
Jan 12 2014
parent "MGW" <mgw yandex.ru> writes:
I'm testing with the ability to connect to Qt

https://github.com/MGWL/QtE-Qt_for_Dlang_and_Forth
Jan 17 2014
prev sibling next sibling parent reply "Radu" <void space.lo> writes:
On Thursday, 9 January 2014 at 15:58:20 UTC, anthony wrote:
 Hi to all here,

 (another one here that wants to desperately use D in his work 
 environment!)

 So, I am a C# and C++ guy who is used to high quality tools and 
 UI libraries. I discovered VisualD and I settled on using it, 
 it is really awesome!

 The only problem that concerns me is the lack of a UI library 
 to use with the language. GTK+ is not an option for me. Qt is 
 but I do not see any way to use it from D.

 I am thinking about using D for the business logic of my 
 programs (let's say on Windows, for start) and then C# for the 
 UI stuff.

 Is there a way to access D code from C# ? Some path I need to 
 follow, some hint... ?

 Thanks a lot for any help !

 anthony
You can expose D code as COM objects and use them from C# this way. http://dlang.org/dll.html#com
Jan 09 2014
parent "anthonyb" <anthony panafonet.com> writes:
Hhmm...It sounds interesting! Looking at it right now... Thanks!

 You can expose D code as COM objects and use them from C# this 
 way.
 http://dlang.org/dll.html#com
Jan 09 2014
prev sibling next sibling parent Jacob Carlborg <doob me.com> writes:
On 2014-01-09 16:58, anthony wrote:

 The only problem that concerns me is the lack of a UI library to use
 with the language. GTK+ is not an option for me. Qt is but I do not see
 any way to use it from D.
Have a look at DWT: https://github.com/d-widget-toolkit/dwt -- /Jacob Carlborg
Jan 09 2014
prev sibling parent reply "Dejan Lekic" <dejan.lekic gmail.com> writes:
On Thursday, 9 January 2014 at 15:58:20 UTC, anthony wrote:
 Hi to all here,

 (another one here that wants to desperately use D in his work 
 environment!)

 So, I am a C# and C++ guy who is used to high quality tools and 
 UI libraries. I discovered VisualD and I settled on using it, 
 it is really awesome!

 The only problem that concerns me is the lack of a UI library 
 to use with the language. GTK+ is not an option for me. Qt is 
 but I do not see any way to use it from D.

 I am thinking about using D for the business logic of my 
 programs (let's say on Windows, for start) and then C# for the 
 UI stuff.

 Is there a way to access D code from C# ? Some path I need to 
 follow, some hint... ?

 Thanks a lot for any help !

 anthony
May I ask why is GtkD not an option? Do not get me wrong, I am not a GTK advocate, I am myself a FLTK user/developer. However, GTK would probably be my second choice after FLTK, if I ever had to chose another GUI toolkit for my C++ projects.
Jan 09 2014
next sibling parent "tc" <chalucha gmail.com> writes:
 May I ask why is GtkD not an option? Do not get me wrong, I am 
 not a GTK advocate, I am myself a FLTK user/developer. However, 
 GTK would probably be my second choice after FLTK, if I ever 
 had to chose another GUI toolkit for my
 C++ projects.
Look at this comparison: http://bit.ly/KFbLbs In short, QT has much more to offer and was built with OOP in mind. Its more portable. QtQuick. MVC, MVVM patterns. But unfortunatelly much harder to use with D :( Even Ubuntu's Unity is being rewriten to Qt (from GTK). I think that something like SIP (for python) is needed to make the bindings possible and maintainable. Don't know if swig will be enough alone?
Jan 09 2014
prev sibling parent reply "anthony" <anthonyb panafonet.com> writes:
Hi Dejan,

GTK is not an option for me mainly because I do not like the way 
programs written with appears on the screen. It is a 
little...ugly! Qt does a lot better in that field, it also has 
(QT) better documentation, better tools etc etc.

This is why I first looked for Qt binding for D.


On Thursday, 9 January 2014 at 21:29:36 UTC, Dejan Lekic wrote:
 On Thursday, 9 January 2014 at 15:58:20 UTC, anthony wrote:
 Hi to all here,

 (another one here that wants to desperately use D in his work 
 environment!)

 So, I am a C# and C++ guy who is used to high quality tools 
 and UI libraries. I discovered VisualD and I settled on using 
 it, it is really awesome!

 The only problem that concerns me is the lack of a UI library 
 to use with the language. GTK+ is not an option for me. Qt is 
 but I do not see any way to use it from D.

 I am thinking about using D for the business logic of my 
 programs (let's say on Windows, for start) and then C# for the 
 UI stuff.

 Is there a way to access D code from C# ? Some path I need to 
 follow, some hint... ?

 Thanks a lot for any help !

 anthony
May I ask why is GtkD not an option? Do not get me wrong, I am not a GTK advocate, I am myself a FLTK user/developer. However, GTK would probably be my second choice after FLTK, if I ever had to chose another GUI toolkit for my C++ projects.
Jan 10 2014
parent reply "evilrat" <evilrat666 gmail.com> writes:
On Friday, 10 January 2014 at 09:54:27 UTC, anthony wrote:
 Hi Dejan,

 GTK is not an option for me mainly because I do not like the 
 way programs written with appears on the screen. It is a 
 little...ugly! Qt does a lot better in that field, it also has 
 (QT) better documentation, better tools etc etc.

 This is why I first looked for Qt binding for D.
isn't they actually has same method for building ui visuals? i mean by using CSS-like styles, so it is just style, not the Gtk or Qt itself...
Jan 10 2014
parent "Dicebot" <public dicebot.lv> writes:
On Friday, 10 January 2014 at 12:55:35 UTC, evilrat wrote:
 On Friday, 10 January 2014 at 09:54:27 UTC, anthony wrote:
 Hi Dejan,

 GTK is not an option for me mainly because I do not like the 
 way programs written with appears on the screen. It is a 
 little...ugly! Qt does a lot better in that field, it also has 
 (QT) better documentation, better tools etc etc.

 This is why I first looked for Qt binding for D.
isn't they actually has same method for building ui visuals? i mean by using CSS-like styles, so it is just style, not the Gtk or Qt itself...
Yes and there are styles available to make Qt and GTK apps look relatively uniform.
Jan 10 2014