Code::Blocks D Thread Tutorial

Code::Blocks D Thread Tutorial

Code::Blocks D Thread Tutorial

The tutorial today is about a programming IDE called Code::Blocks, and it builds on Code::Blocks IDE D Primer Tutorial. For the tutorial today we are going to write a D program that spawns a thread and communicates with messages to and from that thread, the coding for which uses delegate functionality.

Code::Blocks can be an IDE for much more than D … it can supervise Matlab, Fortran, ARM, AVR, Direct/X, FLTK, GLFW, GLUT, GTK+, Irrlicht, Lightfeather, MCS51, Ogre, OpenGL, PowerPC, QT4, SDL, SFML, STL port, SmartWin, TriCore and wxWidgets projects. In coming days and weeks we’ll look at more.

In today’s tutorial we write a simple D program using a thread, and communicate with that thread with messages. We really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really hope you enjoy it.

Link to Code::Blocks “spiritual home” download page at Code::Blocks.

Link to D information … from Wikipedia … source of idea for the tutorial … merci.
Link to Digital Mars D download page … here.
Link to some downloadable D code … rename to SendReceive.d


Previous Code::Blocks IDE D Primer Tutorial of interest is shown below.

Code::Blocks IDE D Primer Tutorial

Code::Blocks IDE D Primer Tutorial

The tutorial today is about a programming IDE called Code::Blocks, and it builds on yesterday’s D Primer Tutorial as shown below.

Programming IDEs take a lot of the hard work out of tasks such as compiling and linking in languages such as D, Matlab, Fortran (Code::Blocks) or Java, C, C++, VB.Net and C# (NetBeans) … and please know that there are many other languages and many other IDEs. In the case of Code::Blocks IDE, which this blog introduces to you today (its customary to shake hands, and no Klingon is necessary), it can create a D code project environment. To cut a long story short, there aint nothin’ wrong with a good ol’ IDE, but beware of IDEs in March.

In saying that about IDEs, and how they make programming easier, often with Open Source programming, it is advantageous to know what goes on “under the hood” (or even “in the ‘hood” … chortle, chortle). So if you ever get an opportunity to get helped creating your own makefile (or make it yourself, even with the Sweet Green Icing … knew it could be worked in!) for something, take the opportunity to learn how to do this, as the Open Source world will become a little easier to navigate with such types of knowledge. You’ve got to admire those early designers of computer languages, and those days when all you had was this tiny bit of memory (64k or “into the heliosphere on 8,000 bytes of memory”) to play with to create your program.

In today’s tutorial we write a simple D program based on idea.d of yesterday, to do with a MovingAverage program, with some simple struct and class bits added on, all under the supervision of Code::Blocks IDE.

Code::Blocks can be an IDE for much more than D … it can supervise Matlab, Fortran, ARM, AVR, Direct/X, FLTK, GLFW, GLUT, GTK+, Irrlicht, Lightfeather, MCS51, Ogre, OpenGL, PowerPC, QT4, SDL, SFML, STL port, SmartWin, TriCore and wxWidgets projects. In coming days and weeks we’ll look at more.

So with the tutorial today we don’t do Hello World exactly, but it is pretty simple code to give a moving average of record (lengths) entered at the keyboard interactively, and show a rudimentary struct and class usage. By the way, if this had been written in C as hello.c and put into the right place, the compilation of this into a Digital Mars C program would have been as simple as … dmc hello.c … (and then … hello … to run … cute (and easy), huh?)

Link to Code::Blocks “spiritual home” download page at Code::Blocks.

Link to D information … from Wikipedia … source of quote above.
Link to Digital Mars D download page … here.
Link to some downloadable D code … rename to hello.d


Previous D Primer Tutorial is shown below.

D Primer Tutorial

D Primer Tutorial

Yes, there is a D … D comes after C … and that pans out to be true … but what if we find life on Mars … you heard it here.

Have been a fan of what Digital Mars do for a while, because if you are interested in programming languages you don’t want to interfere with various IDE programming language compilation arrangements, and the GCC/Xcode relationship, for example, is quite complex, and you probably don’t want to push its functionality in wrong directions, or you could break your environment … and we all know breaking up is hard to do.

Digital Mars C is like an independent voice (but in saying that, tomorrow’s tutorial shows it integrated into Code::Blocks IDE) and have been using it successfully on Windows for quite some time, especially for quick one off programs that need doing … though the “toast at breakfast even if you don’t want it” algorithm still needs work.

Am selling Digital Mars short to just stop at that. Take a look at the language D (it comes after C), and yes, with Digital Mars arrangements, please first install C (didn’t show you this with install, but “just do the Nike” on it).

Let’s look at Wikipedia view of D … will make it that it comes after C

The D programming language is an object-oriented, imperative, multi-paradigm system programming language created by Walter Bright of Digital Mars. Though it originated as a re-engineering of C++, D is a distinct language, having redesigned some core C++ features while also taking inspiration from other languages, notably Java, Python, Ruby, C#, and Eiffel.

D’s design goals attempt to combine the performance of compiled languages with the safety and expressive power of modern dynamic languages. Idiomatic D code is commonly as fast as equivalent C++ code, while being shorter and memory-safe. [7]

Type inference, automatic memory management and syntactic sugar for common types allow faster development, while bounds checking, design by contract features and a concurrency-aware type system help reduce the occurrence of bugs.[8]

… chortle … chortle

So with the tutorial today we don’t do Hello World exactly, but it is pretty simple code to give a moving average of record (lengths) entered at the keyboard interactively. By the way, if this had been written in C as idea.c and put into the right place , the compilation of this into a Digital Mars C program would have been as simple as … dmc idea.c … (and then … idea … to run … cute (and easy), huh?)

Link to D information … from Wikipedia … source of quote above.
Link to Digital Mars D download page … here.
Link to some downloadable D code … rename to idea.d

If this was interesting you may be interested in this too.


If this was interesting you may be interested in this too.


If this was interesting you may be interested in this too.

This entry was posted in Code::Blocks, eLearning, Tutorials and tagged , , , , , , , , . Bookmark the permalink.

6 Responses to Code::Blocks D Thread Tutorial

  1. Definitely believe that which you said. Your favorite reason seemed to be on the web the easiest thing to be aware of. I say to you, I definitely get annoyed while people think about worries that they just do not know about. You managed to hit the nail upon the top and also defined out the whole thing without having side-effects , people can take a signal. Will likely be back to get more. Thanks

  2. I’m absolutely agree with your declaration or the things that you have actually shared right here in this website.

  3. We would like to thank you just as before for the stunning suggestions you offered Jesse when preparing her own post-graduate research and, most importantly, regarding providing every among the concepts in 1 weblog post. In case we had been aware of your internet page a year ago, we may possibly have been saved the unwanted measures we were implementing. Thank you really significantly.

  4. This really is so excellent to see. We have do a lot more issues like this for the military families. They are protecting us and we need to have to support them in this way.

  5. HOME ADVISOR says:

    Very clean web site , thanks for this post.

  6. here says:

    Hi, of course this paragraph is in fact pleasant and I have learned lot of things from it on the topic of blogging. thanks.|

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>