I know I haven't really written much in the past while but here goes.
For the past 4 months or so I've been working with D in windows and Linux on and off.
Now I've had people say why not use C++? or something more industry standard.
Well coming from a high level background of Java, Groovy, PHP it feels easier on me then C++ or C is.
This isn't because its a high level language either. The folks at Digital Mars have been very strict on what goes into the D syntax. Its quite small for a language like it. I have in fact done C++ in past on linux but to me I just don't like it.
I am aiming at moving to C++ after D however. Because of it being standard. For now just getting the grips on even having unsigned types is a big thing for me.
I will say this about D, it does miss a lot of libraries you would normally want. Like a way to work with databases. I solved this by using OpenDBX this is a cross platform C program. I wrote a bindings for it using the Derelict3 project. I also worked on contributing Lua5.2 bindings to it as well. Although only the later was accepted. Which was fair. The reason I used Derelict3 was because they had implemented SharedLibLoader basically what it does is manually get locations within a library binary and binds it to a variable. My extended version of Derelict3 can be found here.
The reason I use Derelict3's implementation of SharedLibLoader over Tango standard libraries is because I only need 1 class out of like a hundred that it provides. To put simply less code the better. I am quite happy to use the standard library so it will do fine.
Now all this didn't have to be an issue if it wasn't for OPTLINK. D's linker on windows. Its fine on linux as it uses LD but on windows it uses a weird old linker that doesn't even support COFF which is kinda standard for windows binaries.
To me D is a nice language to start learning the more low level stuff of programming.
I have done quite a bit of work learning C's headers and working with it form D. I have also had to learn about C++.
Currently I'm working on an IRC bot to work as a game. For this I've implemented OpenDBX as the backend for any information that the bot will store. Even though the standard libraries has Sqlite3 I would rather allow it one day easily also support others like Mysql for a bigger deployment. The main reason I choose OpenDBX wasn't because it was cross platform but because it had an ODBC backend. This enables much more flexibility then I may have had otherwise.
For this IRC bot I also implemented Lua for eventing. Most of the application will actually end up being written in Lua. All the structural stuff will be D like threading. About threading. D supports two types of threading paradigms, the first being the traditional mutexes method. The second being message passing. I choose the message passing paradigm. Now this may seem stupid as its far less used and has more overhead but I do like it for the reason that I can more or less isolate each function of the application from the get go.
How I interact with a thread is quite simple. I use a manager class. It handles all sending of information to a thread. There can be a lot of these but they require the thread id (its a struct) to be able to send it to it. This enabled me to one no manual sending of information to the threads all has already been checked. Two convenient way to send common tasks to each and only those I want to be public to any other thread.
Calling Lua from D is rather simple. The only thing that you must be aware of is some functions Lua expects 0 terminated strings as it is C based. Also ulong in D is not ulong in C so you must use another type which D defines and not imported by default.
Thats about all I can think of writing right now.
No comments:
Post a Comment