https://wiki.dlang.org/api.php?action=feedcontributions&user=Laeeth&feedformat=atomD Wiki - User contributions [en]2024-03-29T05:11:18ZUser contributionsMediaWiki 1.31.2https://wiki.dlang.org/?title=Get_involved&diff=8649Get involved2017-10-23T11:48:27Z<p>Laeeth: add dub pull requests</p>
<hr />
<div>== File a bug report ==<br />
<br />
The simplest way to participate is to [https://issues.dlang.org/enter_bug.cgi?product=D file bug reports] at the [http://dlang.org/bugstats.html bug tracker].<br />
<br />
If you find any problems with the D language, please file a bug report. Problems that are not filed will not get fixed, because the developers wouldn't know the problem existed. If you're not sure if something is a bug or by design, please ask in the forums (see below).<br />
<br />
Ideally, bug reports should be accompanied by a [http://sscce.org/ small, self-contained example] which demonstrates the problem, and makes it easy to reproduce it. If you find it difficult to manually extract a small example from your source code, [https://github.com/CyberShadow/DustMite DustMite] can help with automatically extracting one. See [https://github.com/CyberShadow/DustMite/wiki the project wiki] for more information.<br />
<br />
If a piece of code worked in an older version of a compiler but no longer works in a newer version, please file a regression (by setting the "Severity" field to "Regression"). Regression bugs are examined before all others. You can use [https://github.com/CyberShadow/Digger Digger] to find the pull request that introduced the change which broke your code. [https://github.com/CyberShadow/DustMite/wiki/Reducing-a-regression-between-two-D-versions DustMite can also be helpful] in creating a minimal example.<br />
<br />
Note that compiler internal errors (crashes, assertion failures, etc.) should ''always'' be filed. No matter how wrong your input is, the compiler should give an appropriate error message and abort compilation; it should ''never'' crash. Such crashes are ''always'' bugs.<br />
<br />
== Discuss in the forums ==<br />
<br />
You can also join in the discussion at the [http://forum.dlang.org/ D forums], which can be accessed via the [http://forum.dlang.org/ web interface], the [http://lists.puremagic.com/mailman/listinfo mailing list interface], or the [news://news.digitalmars.com NNTP server].<br />
<br />
The main D forum is for general discussion on the D language, feature requests and discussions, etc.. Newcomers should start with the [http://forum.dlang.org/group/digitalmars.D.learn D.learn] forum, which is intended for learners to ask more basic questions about programming in D.<br />
<br />
== Write blog posts, articles and documentation ==<br />
<br />
D doesn't have a dedicated outreach team. All blog posts about the language's awesome features, standard library, or a third-party DUB packages are very welcome.<br />
If you have an idea for a post on [http://blog.dlang.org D's official blog], please give [https://github.com/mdparker @mdparker] a ping.<br />
You may also consider improving the [https://tour.dlang.org DLang Tour], or [https://tour.dlang.org/tour/en/welcome/languages work on a translation].<br />
The source code for the DTour repos can be found [https://github.com/dlang-tour on GitHub].<br />
<br />
== Alpha-test the development version of D ==<br />
<br />
If you're feeling adventurous, or crave the bleeding-edge features of D, you may want to try a [https://nightlies.dlang.org/dmd-nightly/ nightly build of DMD], or learn [[Building DMD|how to build git master]].<br />
<br />
== Contribute to the source code ==<br />
<br />
=== Contributing to the Phobos source code ===<br />
<br />
==== Easy tasks ====<br />
<br />
* Make sure every function in Phobos has an example -> <code>has_public_example</code> DScanner check (see [https://github.com/dlang/phobos/pull/5581 phobos/5581] for an example)<br />
* Make sure every function in Phobos has Params: and Returns: sections -> <code>properly_documented_public_functions</code> DScanner check<br />
* Improve code coverage<br />
** CodeCov provides an [https://codecov.io/gh/dlang/phobos/tree/master/std excellent overview]<br />
** e.g. <code>make -f std/ascii.test</code> yields a <code>std-ascii.lst</code> with the coverage information<br />
* Fix [https://issues.dlang.org/buglist.cgi?component=phobos&keywords=trivial%2C%20&keywords_type=anywords&list_id=215848&product=D&query_format=advanced&resolution=--- trivial issues at Phobos]<br />
<br />
==== More tricky tasks ====<br />
<br />
* Make more functions/module <code>@safe</code><br />
** grep for <code>@system unittest</code>)<br />
** Guide: http://dlang.org/blog/2016/09/28/how-to-write-trusted-code-in-d<br />
** Another good resource for finding instances that could be <code>@safe</code> is grepping [https://github.com/rejectedsoftware/vibe.d vibe.d] for <code>@trusted</code> (or see [https://github.com/rejectedsoftware/vibe.d/pull/1618 vibe.d/1618])<br />
* Eliminate all gratuitous use of gc<br />
* Review all Phobos modules for compatibility with ranges (std.zip, for example, was done before ranges and does not work with them)<br />
* [https://issues.dlang.org/buglist.cgi?component=phobos&keywords=bootcamp%2C%20preapproved&keywords_type=anywords&list_id=215846&product=D&query_format=advanced&resolution=--- Fix preapproved or bootcamp issues at Phobos]<br />
<br />
==== Hard tasks ====<br />
<br />
* [https://issues.dlang.org/buglist.cgi?component=phobos&list_id=215849&product=D&resolution=--- Fix open issues at Phobos]<br />
* Remove autodecode from Phobos ([https://github.com/dlang/phobos/pull/5513 #5513 could help])<br />
* [[Wish_list|Add a new module]]<br />
<br />
=== Contribute to the DMD and DRuntime ===<br />
<br />
The source code for the D website, compiler, runtime library, and Phobos (the standard library), are all available on [https://github.com/dlang GitHub]. Contributions to the source code are done via [[Pull Requests|pull requests]]. Please note that contributions to DMD source code will only be accepted if the author agrees to have the copyright of the code assigned to the D Language Foundation.<br />
<br />
To find something to work on, you can [http://d.puremagic.com/issues/query.cgi search] the bug list for issues that you can help fix, or on one [https://issues.dlang.org/buglist.cgi?columnlist=votes%2Cbug_severity%2Cpriority%2Cop_sys%2Cassigned_to_realname%2Cbug_status%2Cshort_desc&field0-0-0=votes&order=votes%20DESC&resolution=--- that has been voted for a lot] or [https://issues.dlang.org/buglist.cgi?keywords=preapproved&resolution=--- preapproved].<br />
<br />
There is a pre-filtered list of [https://issues.dlang.org/buglist.cgi?keywords=trivial&resolution=--- trivial] issues which is a good starting points for beginners.<br />
Improving [https://issues.dlang.org/buglist.cgi?keywords=diagnostic&resolution=--- compiler error messages] is also often easy and a good way to become familiar with the DMD source code.<br />
<br />
=== Contribute to the documentation and dlang.org ===<br />
<br />
To contribute to the documentation, start by reading [https://github.com/dlang/dlang.org/blob/master/CONTRIBUTING.md How to Fork and Build dlang.org]. Additional information on improving the documentation can be found in [http://www.digitalmars.com/d/archives/digitalmars/D/Phobos_Documentation_-_call_to_action_258777.html this thread] started by Walter Bright.<br />
<br />
== Review pull requests ==<br />
<br />
The sheer amount of code being written for the D compiler, standard library and related project is often too great for the core developers to keep up. Even if you're not a "hardcore" D developer you can help lessen this load by reviewing the changes in pull requests at GitHub for [https://github.com/dlang/dmd/pulls DMD], [https://github.com/dlang/phobos/pulls Phobos], [https://github.com/dlang/druntime/pulls DRuntime], the [https://github.com/dlang/dlang.org/pulls D website], and the [https://github.com/dlang/dub/pulls dub package manager].<br />
<br />
Various "easy" things to look for: <br />
<br />
* Missing or hard to understand comments<br />
* Unintuitive documentation<br />
* Unchecked edge cases in the code (missing assert, enforce, template constraints)<br />
* Inconsistencies with the [http://dlang.org/dstyle.html D style]<br />
* API inconvenient for use cases the author didn't think of<br />
* Missing/inadequate unittests<br />
* Poor code coverage (install the [https://github.com/codecov/browser-extension CodeCov browser extension] or check <code>dmd -cov -unittest -main std/filename.d</code>)<br />
* More/better code examples in documentation. Look at answers in [http://forum.dlang.org/group/digitalmars.D.learn D.learn] and [http://stackoverflow.com/questions/tagged/d stack overflow] for ideas.<br />
* Missing overflow checks when calculating storage sizes<br />
<br />
Please avoid:<br />
<br />
* Drifting off topic, i.e. anything other than the PR being reviewed.<br />
<br />
To run the unittests of a single file on Posix:<br />
<syntaxhighlight lang=bash><br />
make -f posix.mak std/file.test <br />
</syntaxhighlight><br />
<br />
Also, it is often helpful to review old pull requests (e.g. sort by least recently updated on GitHub). Commenting on an old pull request that seems OK but was for some reason forgotten may bring some attention to it. If you think a pull request is OK to be merged, write "LGTM" (looks good to merge) in your comment.<br />
<br />
If a pull you're interested in has been languishing in the queue for a long time with no attention, commenting "ping" may help prod things along. Especially if the author needs to rebase the pull due to a merge conflict, autotester failure, or other such maintenance problem.<br />
<br />
Citing Andrei Alexandrescu:<br />
<br />
:"If you see [Pull request] you care about, review it even if you don't have rights yet. A simple message such as "I reviewed this and LGTM, any holdup?" would be sufficient to attract attention."<br />
<br />
== Write a DIP about a language change ==<br />
<br />
A [https://github.com/dlang/DIPs D Improvement Proposal (DIP)] is a formal document that details a potential feature or enhancement to the language, or the official tooling, and the rationale behind it.<br />
If you feel strongly about missing feature or would like to change a behavior, you should consider writing a [https://github.com/dlang/DIPs DIP].<br />
<br />
== Google Summer of Code ideas ==<br />
<br />
Some of the past ideas may still be interesting:<br />
<br />
* [https://wiki.dlang.org/GSOC_2016_Ideas 2016]<br />
* [https://wiki.dlang.org/GSOC_2015_Ideas 2015]<br />
* [https://wiki.dlang.org/GSOC_2014_Ideas 2014]<br />
* [https://wiki.dlang.org/GSOC_2013_Ideas 2013]<br />
* [https://www.prowiki.org/wiki4d/wiki.cgi?GSOC_2012_Ideas 2012]<br />
* [https://www.prowiki.org/wiki4d/wiki.cgi?GSOC_2011_Ideas 2011]<br />
<br />
== Other D-related projects ==<br />
<br />
* [https://github.com/dlang-tour Help with a translation of the Dlang Tour to your language]<br />
* [http://wiki.dlang.org/LDC_project_ideas LDC project ideas]<br />
* [http://wiki.dlang.org/GDC/ProjectIdeas GDC project ideas]<br />
* [http://stackoverflow.com/documentation/d Extend the Stackoverflow D documentation]<br />
<br />
== How to better promote your own D projects ==<br />
<br />
<blockquote><br />
I hate the movie "Field of Dreams" where they push the idiotic idea of "Build it and they will come." No, they won't. There's a blizzard of stuff competing for their attention out there, why should they invest the time looking at your stuff? You need to tell them why!<br />
<br />
Here's the frustrating typical pattern I've seen here for years:<br />
<br />
# spend hundreds if not thousands of hours developing something really cool<br />
# spend 2 minutes posting a link to the repository on D.announce<br />
# someone posts it to reddit. Ignore it<br />
# get frustrated that nobody looks at it<br />
# get bitter and quit<br />
<br />
Here's the pattern that works a lot better:<br />
<br />
# spend hundreds if not thousands of hours developing something really cool<br />
# spend 10 minutes writing the announcement to D.announce. Be sure to include:<br />
#: who, what, where, when, why, and how<br />
# someone posts it to reddit<br />
# post the who, what, where, when, why and how on reddit AS SOON AS POSSIBLE after the reddit link appears. Stuff on reddit has a VERY SHORT shelf life. If it doesn't get action within a couple hours, it fades into oblivion. Identify yourself as the author, say AMA. The first one to post a comment tends to spark and set the tone for the discussion.<br />
# check back on reddit once an hour or so for the next day, answer questions<br />
# *****<br />
# profit!<br />
<br />
Walter Bright<br />
</blockquote><br />
<br />
== Contribute to this wiki ==<br />
<br />
* [http://wiki.dlang.org/Coming_From D as a second language] sections should be completed <br />
* add more examples of how to shift idiom to speak fluent D<br />
* flesh out the Python page<br />
* review empty sections <br />
* update C and C++ transition guides <br />
<br />
<blockquote><br />
One note about Walter's older C/C++ transition articles. They have good information on transition technicalities (e.g. "how do I do this thing in D that I used to do in C++?") but not a lot about the changes in coding style - making object copying not arbitrarily expensive, choosing struct vs. class, preferring pipelines and lazy to eager computation, etc. From what I see some folks come from C++, write their first D program in a stilted C++ idiom, and are left with the impression that the work is not worth the trouble.<br />
<br />
Andrei<br />
</blockquote><br />
<br />
== See also ==<br />
<br />
* [[Starting as a Contributor]]<br />
* [[Contributing to Phobos]]<br />
* [[Bugzilla]]<br />
* [[Pull Requests]], [[Review process]], [http://dlang.org/dstyle.html Phobos style guidelines]<br />
* [[Building DMD]], [[Build DMD for Android]]<br />
* [[DMD Source Guide]]<br />
* [[Release Process]]<br />
* [[Git Commit Tester]]<br />
* [[Using Git on Windows]]<br />
<br />
[[Category: Contribution Guidelines]]</div>Laeethhttps://wiki.dlang.org/?title=COM_Programming&diff=8039COM Programming2016-10-28T05:54:28Z<p>Laeeth: </p>
<hr />
<div>COM interfaces are all derived from '''std.c.windows.com.IUnknown'''.<br />
<br />
<br />
Many Windows API interfaces are in terms of COM (Common Object Model) objects (also called OLE or ActiveX objects). A COM object is an object who's first field is a pointer to a vtbl[], and the first 3 entries in that vtbl[] are for QueryInterface(), AddRef(), and Release().<br />
<br />
For understanding COM, Kraig Brockshmidt's [http://www.amazon.com/exec/obidos/ASIN/1556158432/classicempire Inside OLE] is an indispensible resource.<br />
<br />
For a complete D solution with sample code and some wrapping to make working with COM easier, see Adam D Ruppe's [https://github.com/adamdruppe/com/ COM helper] repository. Note that the Phobos Windows headers are now more up to date than when the README for his repository was authored, and it is possible that it may not be necessary to use the version from Andrej Mitrovic that he suggests. Also note that for accessing a COM object from scripting languages, it may be necessary to [https://msdn.microsoft.com/en-us/library/windows/desktop/aa367091(v=vs.85).aspx create a type library using MIDL], which should then be registered with Windows by standard means.<br />
<br />
<br />
==Exporting==<br />
<br />
To create objects in D that can be consumed by COM applications the following should be used.<br />
<br />
COM objects are analogous to D interfaces. Any COM object can be expressed as a D interface, and every D object with an interface X can be exposed as a COM object X. This means that D is compatible with COM objects implemented in other languages.<br />
<br />
While not strictly necessary, the Phobos library provides an Object useful as a super class for all D COM objects, called ComObject. ComObject provides a default implementation for QueryInterface(), AddRef(), and Release().<br />
<br />
Windows COM objects use the Windows calling convention, which is not the default for D, so COM functions need to have the attribute extern (Windows).<br />
<br />
So, to write a COM object:<br />
<br />
<syntaxhighlight lang="D"><br />
import std.c.windows.com;<br />
<br />
class MyCOMobject : ComObject<br />
{<br />
extern (Windows):<br />
...<br />
}<br />
</syntaxhighlight><br />
<br />
The sample code includes an example COM client program and server DLL.<br />
<br />
==Importing==<br />
<br />
To use COM objects within D programs the following can be used.<br />
<br />
<syntaxhighlight lang="D"><br />
import core.sys.windows.com;<br />
<br />
void main()<br />
{<br />
auto hr = CoInitialize(null);<br />
<br />
auto CLSID_DOMDocument60 = GUID(0x88d96a05,0xf192,0x11d4,[0xa6,0x5f,0x00,0x40,0x96,0x32,0x51,0xe5]);<br />
auto iid = IID_IUnknown;<br />
<br />
void* pUnk;<br />
hr = CoCreateInstance(&CLSID_DOMDocument60, null, CLSCTX_ALL, &iid, &pUnk);<br />
if (FAILED(hr))<br />
throw new Exception(...);<br />
<br />
...<br />
}<br />
</syntaxhighlight><br />
<br />
[[Category:HowTo]]</div>Laeethhttps://wiki.dlang.org/?title=Why_program_in_D&diff=8038Why program in D2016-10-28T05:53:41Z<p>Laeeth: </p>
<hr />
<div><blockquote><br />
[Many] of D's improvements appear to be small, but the aggregate is large enough that once you write a project<br/><br />
in D, you'll find it pretty hard to go back to another language. <br/><br />
-- Walter Bright <br/> <br/><br />
</blockquote><br />
<br />
<blockquote><br />
Often, programming teams will resort to a hybrid approach, where they will mix Python and C++, trying to get <br/><br />
the productivity of Python and the performance of C++. The frequency of this approach indicates that there <br/><br />
is a large unmet need in the programming language department.<br/><br />
<br />
D intends to fill that need. It combines the ability to do low-level manipulation of the machine with the <br/><br />
latest technologies in building reliable, maintainable, portable, high-level code. D has moved well ahead of <br/><br />
any other language in its abilities to support and integrate multiple paradigms like imperative, OOP, and <br/><br />
generic programming.<br />
<br />
-- Walter Bright <br/> <br/><br />
</blockquote><br />
<br />
<blockquote><br />
Should one choose C over D for maximum performance? <br/><br />
<br />
My answer is an emphatic no, and I bring as evidence the fact that warp is significantly faster than the <br/><br />
preprocessor in my own older Digital Mars C/C++ compiler tool chain, which was already the fastest on the <br/><br />
market, and on which I've spared no effort optimizing and tuning over months and years. Modern compiler <br/><br />
technology working in concert with D language fundamentals (white-box templates, simple object models) takes <br/><br />
high-level compositions of templated code and optimizes it down to code that is virtually indistinguishable <br/><br />
from what a C programmer would write for maximum efficiency. <br/><br />
<br />
The neato thing about D is that by separating the code into ranges and algorithms, it becomes easy to keep <br/><br />
trying different range implementations and different algorithms. I tried all sorts of things. Like breeding <br/><br />
racehorses, I kept the profile winners and culled the losers, step by step, through the code. That would have <br/><br />
been a lot more difficult to do in other languages. <br/><br />
<br />
[https://code.facebook.com/posts/476987592402291/under-the-hood-warp-a-fast-c-and-c-preprocessor/ -- Facebook's warp C/C++ preprocessor written by Walter Bright] <br/> <br/><br />
</blockquote><br />
<br />
The detailed [http://dlang.org/overview.html overview] of the language should give you the big picture.<br />
<br />
Now if you are looking for reasons to start using D you are probably also looking for reasons not to use it. This was pointed out by Andrei Alexandrescu in [http://www.ddj.com/hpc-high-performance-computing/217801225 The Case for D], "Trying to find quick reasons to avoid [learning a new language] is a survival instinct." And like any language there are reasons not to use D, but you might find that they don't apply to you or that the benefits are greater.<br />
<br />
* [[MoreLinks#DBuzz | D Buzz]]<br />
* [[PerfectD | Imperfect C++ and More Perfect D]]<br />
* [http://dlang.org/faq.html FAQ]<br />
<br />
<p></p><br />
<br />
== Videos - language ==<br />
W. Bright: [http://channel9.msdn.com/Events/Lang-NEXT/Lang-NEXT-2012/The-D-Programming-Language The D Programming Language] (2012)<br />
<br />
A. Alexandrescu: [http://channel9.msdn.com/Events/Lang-NEXT/Lang-NEXT-2012/Three-Unlikely-Successful-Features-of-D Three Unlikely Successful Features of D] (2012)<br />
<br />
A. Alexandrescu: [http://www.infoq.com/presentations/Generic-Programming-Galore-Using-D Generic Programming Galore Using D] (2012)<br />
<br />
A. Alexandrescu: [http://www.youtube.com/watch?v=RlVpPstLPEc Three Cool Things About D - The Case for the D Programing Language] (2010)<br />
<br />
W. Bright: [http://vimeo.com/4333802 Metaprogramming in D] (2009)<br />
<br />
<br />
== Videos - D users ==<br />
<br />
[http://dconf.org/2016/talks/zvibel.html Weka.io: Using D for implementing a large scale primary storage system] (2016)<br />
<br />
[http://dconf.org/2016/talks/watson.html Quantum Break: AAA Gaming with Some D Code] (2016)<br />
<br />
[http://dconf.org/2014/talks/clugston.html Sociomantic: Real-Time Big Data in D] (2014)<br />
<br />
[http://dconf.org/2015/talks/smith.html Large Hedge Fund: Using D in production in finance] (2014)<br />
<br />
[http://dconf.org/2014/talks/crapuchettes.html EMSI: economic modelling at scale using D] (2014)<br />
<br />
[http://dconf.org/2014/talks/simpkins.html Facebook: Experience Report - Using D at Facebook and Beyond](2014)<br />
<br />
<br />
Here is a full list of [[Videos | videos]] relating to D.<br />
Here is a list of [http://dlang.org/orgs-using-d.html organisations using D]<br />
<br />
== Articles ==<br />
You will find in the main website more than a dozen articles discussing several design decisions for the language and its library. Don't forget to have a look there.<br />
A few examples<br />
* D. Clugston [http://dlang.org/d-floating-point.html Real Close to the Machine: Floating Point in D]<br />
* S. Schweighoffer [http://dlang.org/d-array-article.html D Slices]<br />
* B. Mileswski [http://dlang.org/safed.html Safe D]<br />
<br />
Until that journal's untimely demise, Walter Bright regularly wrote enlightening [http://www.drdobbs.com/author/6839 columns in Dr Dobb's]. Many were directly related to D (access is free, but it may require registering if you read more than a couple articles/day).<br />
<br />
* [http://www.drdobbs.com/blogs/cpp/232700394 Uniform function call syntax] (2012)<br />
* [http://www.drdobbs.com/blogs/cpp/232601305 Inheriting purity] (2012)<br />
* [http://www.drdobbs.com/blogs/cpp/231902461 Type Qualifiers and Wild Cards] (2011)<br />
* [http://www.drdobbs.com/blogs/cpp/231600610 Member function pointers] (2011)<br />
<br />
A. Alexandrescu wrote several equally important articles :<br />
* [http://www.informit.com/articles/article.aspx?p=1621867 Interview part 1] [http://www.informit.com/articles/article.aspx?p=1622265 part 2] [http://www.informit.com/articles/article.aspx?p=1623791 part 3] (2010)<br />
* [http://www.informit.com/articles/article.aspx?p=1609144 Concurrency in the D Programming Language](2010) (from ''The D Programming Language'' book)<br />
* [http://www.informit.com/articles/article.aspx?p=1407357 On iteration] (2009)<br />
* [http://www.ddj.com/hpc-high-performance-computing/217801225 Case For D] (2009)<br />
<br />
* N. Sabalausky [https://www.semitwist.com/articles/article/view/combine-coroutines-and-input-ranges-for-dead-simple-d-iteration Combine Coroutines and Input Ranges for Dead-Simple D Iteration]<br />
<br />
<br />
You can find more articles in the [[Articles | articles section]].<br />
<br />
See also the [https://dlang.org/blog/ official D blog] and [http://arsdnet.net/this-week-in-d/ This Week in D], the summary of what is going on in the D community.<br />
<br />
<br />
== Application Developers ==<br />
<br />
Each language has a preferred application domain. D has a high degree of versatility as a language - it does have a sweet spot in high performance desktop and server side applications, but it can nonetheless be used where a scripting language would be the traditional choice: it provides the performance of low-level languages (of the order of C++) with the safety and ease of expression reminiscent of languages like Java and Python.<br />
<br />
In fact, nearly everywhere Java is suitable, D could replace it, bringing in more expressive power, better performance and better memory management. Although its [https://code.dlang.org/ current libraries] are nowhere near as extensive as the Java libraries, most fundamental bricks are already here, and D has native interfacing to both C and C++, with library solutions for other languages such as Python,R and Lua. You may want to have a look at [http://dlang.org/phobos/index.html Phobos] and [https://github.com/D-Programming-Deimos Deimos] libraries, as well as third-party libraries to make your own opinion on that matter. A very nice port of Java's SWT library has been created under the name [https://github.com/d-widget-toolkit/dwt DWT] (with older but more complete documentation available at the [http://www.dsource.org/projects/dwt legacy dsource site]). There are also [http://gtkd.org/ bindings for GTK], and [https://github.com/buggins/dlangui a cross-platform idiomatic D GUI].<br />
<br />
<br />
== Embedded Developers ==<br />
<br />
Being targeted at 32 bit and 64 bit machines, D is not designed for embedded development on small devices. However, with the advent of Android and iOS smartphones which embed powerful CPUs and large amounts of RAM, D may be suitable for such development. The GCC and LLVM compiler backends being able to target these devices, the community is making progress.<br />
<br />
Find out more at StackOverflow:<br />
* [http://stackoverflow.com/questions/1207958/getting-embedded-with-d-the-programming-language Getting Embedded with D (the programming language)]<br />
* [http://stackoverflow.com/questions/1113938/how-would-you-approach-using-d-in-a-embedded-real-time-environment How would you approach using D in a embedded real-time environment?]<br />
<br />
== Numerical programmers ==<br />
<br />
D provides high precision floating point, NaN, and complex/imaginary numbers. There are also a number of mathematical and scientific libraries in development, e.g. SciD. Notably the [https://github.com/libmir/mir Mir] and [https://github.com/libmir/mir-glas Mir-GLAS] projects provide an implementation of numerical libraries that offer performance comparable to Intel MKL, and better than Eigen and OpenBLAS without the use of assembler and implemented in a way that makes porting to new platforms very simple.<br />
<br />
<br />
== Script Fan ==<br />
<br />
Since D provides type inference, high-level constructs, and fast compile-time it is a great language for writing scripts. The first line of the file is ignored if it begins with #! ('shebang') and combining this with [https://dlang.org/rdmd.html rdmd] which handles dependency resolution, D becomes a leader in native-code scripting languages. <br />
<br />
<syntaxhighlight lang="D"><br />
#!/usr/bin/env rdmd<br />
<br />
void main() {<br />
import std.stdio : writeln;<br />
writeln("Hello, World!");<br />
}<br />
</syntaxhighlight><br />
<br />
Scripts with library dependencies can also be written using a shebang with the [https://code.dlang.org/getting_started dub package manager]. The example below uses the [http://vibed.org/tutorials async fiber-based framework vibe.d]<br />
<br />
<syntaxhighlight lang="D"><br />
#!/usr/bin/env rdmd<br />
/+ dub.sdl:<br />
name "hello"<br />
version "~master"<br />
dependency "vibe-d" version="~master"<br />
+/<br />
import vibe.core.log;<br />
import vibe.mail.smtp;<br />
<br />
void main()<br />
{<br />
auto settings = new SMTPClientSettings("smtp.example.com", 25);<br />
settings.connectionType = SMTPConnectionType.startTLS;<br />
settings.authType = SMTPAuthType.plain;<br />
settings.username = "username";<br />
settings.password = "secret";<br />
<br />
auto mail = new Mail;<br />
mail.headers["From"] = "<user@isp.com>";<br />
mail.headers["To"] = "<recipient@domain.com>";<br />
mail.headers["Subject"] = "Testmail";<br />
mail.bodyText = "Hello, World!";<br />
<br />
logInfo("Sending mail...");<br />
sendMail(settings, mail);<br />
logInfo("done.");<br />
}<br />
</syntaxhighlight><br />
<br />
== Language Lover ==<br />
<br />
Walter, Andrei and the D community work to make D a practical language that combines native code efficiency and control with the modeling power, safety, and productivity found in high-level languages and those that stick strictly to a single paradigm. If you enjoy languages D is interesting in the way it combines many paradigms in a C-like syntax, and yet D is also a language [http://dlang.org/orgs-using-d.html used in production at scale] in industry and academe.<br />
<br />
== Related ==<br />
* [[Coming_From | Learning D as a second language]]<br />
* [http://dlang.org/spec.html Language Specification]<br />
* [[D__Tutorial/StartingWithD | Setting up an environment to compile programs]]<br />
* [[Development_With_D | Development with D]]<br />
* [http://dlang.org/faq.html FAQ]<br />
* [[Current D Use | Current uses of D]]</div>Laeethhttps://wiki.dlang.org/?title=Why_program_in_D&diff=8037Why program in D2016-10-28T05:46:04Z<p>Laeeth: refined some of the language; brought videos up to date and added examples of industrial users to add credibility; gave example of scripting</p>
<hr />
<div><blockquote><br />
[Many] of D's improvements appear to be small, but the aggregate is large enough that once you write a project<br/><br />
in D, you'll find it pretty hard to go back to another language. <br/><br />
-- Walter Bright <br/> <br/><br />
</blockquote><br />
<br />
<blockquote><br />
Often, programming teams will resort to a hybrid approach, where they will mix Python and C++, trying to get <br/><br />
the productivity of Python and the performance of C++. The frequency of this approach indicates that there <br/><br />
is a large unmet need in the programming language department.<br/><br />
<br />
D intends to fill that need. It combines the ability to do low-level manipulation of the machine with the <br/><br />
latest technologies in building reliable, maintainable, portable, high-level code. D has moved well ahead of <br/><br />
any other language in its abilities to support and integrate multiple paradigms like imperative, OOP, and <br/><br />
generic programming.<br />
<br />
-- Walter Bright <br/> <br/><br />
</blockquote><br />
<br />
<blockquote><br />
Should one choose C over D for maximum performance? <br/><br />
<br />
My answer is an emphatic no, and I bring as evidence the fact that warp is significantly faster than the <br/><br />
preprocessor in my own older Digital Mars C/C++ compiler tool chain, which was already the fastest on the <br/><br />
market, and on which I've spared no effort optimizing and tuning over months and years. Modern compiler <br/><br />
technology working in concert with D language fundamentals (white-box templates, simple object models) takes <br/><br />
high-level compositions of templated code and optimizes it down to code that is virtually indistinguishable <br/><br />
from what a C programmer would write for maximum efficiency. <br/><br />
<br />
The neato thing about D is that by separating the code into ranges and algorithms, it becomes easy to keep <br/><br />
trying different range implementations and different algorithms. I tried all sorts of things. Like breeding <br/><br />
racehorses, I kept the profile winners and culled the losers, step by step, through the code. That would have <br/><br />
been a lot more difficult to do in other languages. <br/><br />
<br />
[https://code.facebook.com/posts/476987592402291/under-the-hood-warp-a-fast-c-and-c-preprocessor/ -- Facebook's warp C/C++ preprocessor written by Walter Bright] <br/> <br/><br />
</blockquote><br />
<br />
The detailed [http://dlang.org/overview.html overview] of the language should give you the big picture.<br />
<br />
Now if you are looking for reasons to start using D you are probably also looking for reasons not to use it. This was pointed out by Andrei Alexandrescu in [http://www.ddj.com/hpc-high-performance-computing/217801225 The Case for D], "Trying to find quick reasons to avoid [learning a new language] is a survival instinct." And like any language there are reasons not to use D, but you might find that they don't apply to you or that the benefits are greater.<br />
<br />
* [[MoreLinks#DBuzz | D Buzz]]<br />
* [[PerfectD | Imperfect C++ and More Perfect D]]<br />
* [http://dlang.org/faq.html FAQ]<br />
<br />
<p></p><br />
<br />
== Videos - language ==<br />
W. Bright: [http://channel9.msdn.com/Events/Lang-NEXT/Lang-NEXT-2012/The-D-Programming-Language The D Programming Language] (2012)<br />
<br />
A. Alexandrescu: [http://channel9.msdn.com/Events/Lang-NEXT/Lang-NEXT-2012/Three-Unlikely-Successful-Features-of-D Three Unlikely Successful Features of D] (2012)<br />
<br />
A. Alexandrescu: [http://www.infoq.com/presentations/Generic-Programming-Galore-Using-D Generic Programming Galore Using D] (2012)<br />
<br />
A. Alexandrescu: [http://www.youtube.com/watch?v=RlVpPstLPEc Three Cool Things About D - The Case for the D Programing Language] (2010)<br />
<br />
W. Bright: [http://vimeo.com/4333802 Metaprogramming in D] (2009)<br />
<br />
<br />
== Videos - D users ==<br />
<br />
[http://dconf.org/2016/talks/zvibel.html Weka.io: Using D for implementing a large scale primary storage system] (2016)<br />
<br />
[http://dconf.org/2016/talks/watson.html Quantum Break: AAA Gaming with Some D Code] (2016)<br />
<br />
[http://dconf.org/2014/talks/clugston.html Sociomantic: Real-Time Big Data in D] (2014)<br />
<br />
[http://dconf.org/2015/talks/smith.html Large Hedge Fund: Using D in production in finance] (2014)<br />
<br />
[http://dconf.org/2014/talks/crapuchettes.html EMSI: economic modelling at scale using D] (2014)<br />
<br />
[http://dconf.org/2014/talks/simpkins.html Facebook: Experience Report - Using D at Facebook and Beyond](2014)<br />
<br />
<br />
Here is a full list of [[Videos | videos]] relating to D.<br />
Here is a list of [http://dlang.org/orgs-using-d.html organisations using D]<br />
<br />
== Articles ==<br />
You will find in the main website more than a dozen articles discussing several design decisions for the language and its library. Don't forget to have a look there.<br />
A few examples<br />
* D. Clugston [http://dlang.org/d-floating-point.html Real Close to the Machine: Floating Point in D]<br />
* S. Schweighoffer [http://dlang.org/d-array-article.html D Slices]<br />
* B. Mileswski [http://dlang.org/safed.html Safe D]<br />
<br />
Until that journal's untimely demise, Walter Bright regularly wrote enlightening [http://www.drdobbs.com/author/6839 columns in Dr Dobb's]. Many were directly related to D (access is free, but it may require registering if you read more than a couple articles/day).<br />
<br />
* [http://www.drdobbs.com/blogs/cpp/232700394 Uniform function call syntax] (2012)<br />
* [http://www.drdobbs.com/blogs/cpp/232601305 Inheriting purity] (2012)<br />
* [http://www.drdobbs.com/blogs/cpp/231902461 Type Qualifiers and Wild Cards] (2011)<br />
* [http://www.drdobbs.com/blogs/cpp/231600610 Member function pointers] (2011)<br />
<br />
A. Alexandrescu wrote several equally important articles :<br />
* [http://www.informit.com/articles/article.aspx?p=1621867 Interview part 1] [http://www.informit.com/articles/article.aspx?p=1622265 part 2] [http://www.informit.com/articles/article.aspx?p=1623791 part 3] (2010)<br />
* [http://www.informit.com/articles/article.aspx?p=1609144 Concurrency in the D Programming Language](2010) (from ''The D Programming Language'' book)<br />
* [http://www.informit.com/articles/article.aspx?p=1407357 On iteration] (2009)<br />
* [http://www.ddj.com/hpc-high-performance-computing/217801225 Case For D] (2009)<br />
<br />
* N. Sabalausky [https://www.semitwist.com/articles/article/view/combine-coroutines-and-input-ranges-for-dead-simple-d-iteration Combine Coroutines and Input Ranges for Dead-Simple D Iteration]<br />
<br />
<br />
You can find more articles in the [[Articles | articles section]].<br />
<br />
See also the [https://dlang.org/blog/ official D blog] and [http://arsdnet.net/this-week-in-d/ This Week in D], the summary of what is going on in the D community.<br />
<br />
<br />
== Application Developers ==<br />
<br />
Each language has a preferred application domain. D has a high degree of versatility as a language - it does have a sweet spot in high performance desktop and server side applications, but it can nonetheless be used where a scripting language would be the traditional choice: it provides the performance of low-level languages (of the order of C++) with the safety and ease of expression reminiscent of languages like Java and Python.<br />
<br />
In fact, nearly everywhere Java is suitable, D could replace it, bringing in more expressive power, better performance and better memory management. Although its [https://code.dlang.org/ current libraries] are nowhere near as extensive as the Java libraries, most fundamental bricks are already here, and D has native interfacing to both C and C++, with library solutions for other languages such as Python,R and Lua. You may want to have a look at [http://dlang.org/phobos/index.html Phobos] and [https://github.com/D-Programming-Deimos Deimos] libraries, as well as third-party libraries to make your own opinion on that matter. A very nice port of Java's SWT library has been created under the name [https://github.com/d-widget-toolkit/dwt DWT] (with older but more complete documentation available at the [http://www.dsource.org/projects/dwt legacy dsource site]). There are also [http://gtkd.org/ bindings for GTK], and [https://github.com/buggins/dlangui a cross-platform idiomatic D GUI].<br />
<br />
<br />
== Embedded Developers ==<br />
<br />
Being targeted at 32 bit and 64 bit machines, D is not designed for embedded development on small devices. However, with the advent of Android and iOS smartphones which embed powerful CPUs and large amounts of RAM, D may be suitable for such development. The GCC and LLVM compiler backends being able to target these devices, the community is making progress.<br />
<br />
Find out more at StackOverflow:<br />
* [http://stackoverflow.com/questions/1207958/getting-embedded-with-d-the-programming-language Getting Embedded with D (the programming language)]<br />
* [http://stackoverflow.com/questions/1113938/how-would-you-approach-using-d-in-a-embedded-real-time-environment How would you approach using D in a embedded real-time environment?]<br />
<br />
== Numerical programmers ==<br />
<br />
D provides high precision floating point, NaN, and complex/imaginary numbers. There are also a number of mathematical and scientific libraries in development, e.g. SciD. Notably the [https://github.com/libmir/mir Mir] and [https://github.com/libmir/mir-glas Mir-GLAS] projects provide an implementation of numerical libraries that offer performance comparable to Intel MKL, and better than Eigen and OpenBLAS without the use of assembler and implemented in a way that makes porting to new platforms very simple.<br />
<br />
<br />
== Script Fan ==<br />
<br />
Since D provides type inference, high-level constructs, and fast compile-time it is a great language for writing scripts. The first line of the file is ignored if it begins with #! ('shebang') and combining this with [https://dlang.org/rdmd.html rdmd] which handles dependency resolution, D becomes a leader in native-code scripting languages. Scripts with library dependencies can also be written using a shebang with the dub package manager:<br />
<br />
<code>[https://code.dlang.org/getting_started Getting Started with Dub]<br />
<nowiki><br />
#!/usr/bin/env rdmd<br />
<br />
void main() {<br />
import std.stdio : writeln;<br />
writeln("Hello, World!");<br />
}<br />
</nowiki><br />
</code><br />
<br />
<code>[http://vibed.org/tutorials Sample application using the async fiber-based framework vibe.d]<br />
<nowiki><br />
#!/usr/bin/env rdmd<br />
/+ dub.sdl:<br />
name "hello"<br />
version "~master"<br />
dependency "vibe-d" version&#x3d;"~master"<br />
+/<br />
import vibe.core.log;<br />
import vibe.mail.smtp;<br />
<br />
void main()<br />
{<br />
auto settings = new SMTPClientSettings("smtp.example.com", 25);<br />
settings.connectionType = SMTPConnectionType.startTLS;<br />
settings.authType = SMTPAuthType.plain;<br />
settings.username = "username";<br />
settings.password = "secret";<br />
<br />
auto mail = new Mail;<br />
mail.headers["From"] = "<user@isp.com>";<br />
mail.headers["To"] = "<recipient@domain.com>";<br />
mail.headers["Subject"] = "Testmail";<br />
mail.bodyText = "Hello, World!";<br />
<br />
logInfo("Sending mail...");<br />
sendMail(settings, mail);<br />
logInfo("done.");<br />
}<br />
</nowiki><br />
</code><br />
<br />
== Language Lover ==<br />
<br />
Walter, Andrei and the D community work to make D a practical language that combines native code efficiency and control with the modeling power, safety, and productivity found in high-level languages and those that stick strictly to a single paradigm. If you enjoy languages D is interesting in the way it combines many paradigms in a C-like syntax, and yet D is also a language [http://dlang.org/orgs-using-d.html used in production at scale] in industry and academe.<br />
<br />
== Related ==<br />
* [[Coming_From | Learning D as a second language]]<br />
* [http://dlang.org/spec.html Language Specification]<br />
* [[D__Tutorial/StartingWithD | Setting up an environment to compile programs]]<br />
* [[Development_With_D | Development with D]]<br />
* [http://dlang.org/faq.html FAQ]<br />
* [[Current D Use | Current uses of D]]</div>Laeethhttps://wiki.dlang.org/?title=Current_D_Use&diff=7563Current D Use2016-05-28T17:41:22Z<p>Laeeth: /* Organizations */</p>
<hr />
<div>Organizations and notable projects using D:<br />
<br />
== Organizations ==<br />
<br />
* [https://www.facebook.com/facebook/info Facebook] - See [http://forum.dlang.org/post/l37h5s$2gd8$1@digitalmars.com announcement] in the forums.<br />
* [https://www.putao.com/ putao.com] - From China's largest children's science and technology company. Large scale use of D programming language (distributed systems and cloud storage).<br />
* [http://weka.io/ weka.io] - Storage startup (stealth mode) - Talk [http://dconf.org/2015/talks/zvibel.html here]<br />
* [https://www.sociomantic.com/ Sociomantic] - real-time bidding for eCommerce. [http://dconf.org/talks/clugston.html DConf 2013 talk]. Historically based on D1 / Tango but from their public comments code is being migrated to D2. [http://dconf.org/2015/talks/strasuns.html Talk]<br />
* [http://remedygames.com/ Remedy Games] - game development. [http://dconf.org/talks/evans_1.html DConf 2013 talk].<br />
* [http://www.funkwerk-itk.com/funkwerk_itk_en/ Funkwerk Aktiengesellschaft] - passenger information systems. [http://dconf.org/talks/rohe.html DConf 2013 talk]. Uses D2 / Phobos.<br />
* [http://www.economicmodeling.com/ EMSI] - economic modeling. [http://dconf.org/2014/talks/crapuchettes.html Talk] [http://forum.dlang.org/post/kpnb4n$24t0$1@digitalmars.com Discussion]. [https://github.com/economicmodeling Github]<br />
* [http://www.randomstorm.com/ RandomStorm] - network security products and services. Uses D2 / Phobos.<br />
* [http://2night.it 2night.it] - italian website about nightlife. Uses D2/phobos for webservice (ios/android app) and for language parsing.<br />
* [http://www.srlabs.it SR Labs] - Eye Tracking Systems Integrator<br />
* [http://www.funatics.de/en Funatics Software GmbH] - MMO Game Developer (See [http://forum.dlang.org/post/kghpblrtxuzzgpnzasxc@forum.dlang.org Newsgroup announcement]).<br />
* [http://www.infognition.com/ Infognition] - mostly video processing technologies and products. Uses D2, Phobos and DFL. (have a post [http://www.infognition.com/blog/2014/why_d.html Why D?])<br />
* [http://www.auburnsounds.com/ Auburn Sounds] - audio plugins. ([http://forum.dlang.org/post/hbmbztydvyfwemfnerwb@forum.dlang.org announce])<br />
* [http://socialmagnetics.com Social Magnetics] - Distributed Storage, Processing & Messaging PaaS (stealth mode)<br />
* [http://dconf.org/2015/talks/smith.html Large Hedge Fund] D is a core part of the production trading system - receiving market data, electronic trading, processing large text files<br />
* [http://tech.adroll.com/blog/data/2014/11/17/d-is-for-data-science.html Adroll: big data marketing]<br />
* [https://github.com/eBay/tsv-utils-dlang Ebay's command line utilities for tab-separated value files]<br />
* [https://www.tripaneer.com Tripaneer.com] - Themed vacation websites. All infrastructure is in D<br />
* [https://kaleidicassociates.com] - Kaleidic Associates. Developing tools for the hedge fund industry - almost all back-end work is written in D. Low public profile but you can reach the owner, Laeeth Isharc, on LinkedIn.<br />
<br />
== Notable projects ==<br />
<br />
=== Video games ===<br />
<br />
* [http://www.asahi-net.or.jp/~cs8k-cyu/games/index.html#windows ABA Games] (2004-2005). Written in D 0.x, includes source code.<br />
* [http://www.inventivedingo.com/mayhemig Mayhem Intergalactic] - the first commercial video game written in D (2007). [http://forum.dlang.org/post/fjakft$cv4$1@digitalmars.com Newsgroup announcement].<br />
* [http://www.stack4.de STACK4] (2013-2014). Gameserver Backend written in D 2. See [http://forum.dlang.org/post/dxcruptyfxsaauihzknw@forum.dlang.org Newsgroup announcement].<br />
<br />
=== Other ===<br />
<br />
* [http://www.xomb.org Xomb] - an exokernel operating system written in D.<br />
* [http://deoma-cmd.ru/en/Products/Geometry/GInMA.aspx GInMA] - a 2D and 3D dynamic geometry system (DGS) written in D1 (2010).<br />
<br />
== Publications ==<br />
<br />
=== Programming languages ===<br />
<br />
* [http://www.cs.berkeley.edu/~daw/papers/pure-ccs08.pdf Verifiable Functional Purity in Java] (2008). Praises D's approach to purity.<br />
<br />
=== Other ===<br />
<br />
* [http://dl.acm.org/citation.cfm?doid=1377980.1377993 Rigid shape interpolation using normal equations] (2008). [http://forum.dlang.org/post/mailman.174.1221513302.19733.digitalmars-d-announce@puremagic.com Discussion].</div>Laeethhttps://wiki.dlang.org/?title=Programming_in_D_for_CSharp_Programmers&diff=7389Programming in D for CSharp Programmers2016-03-26T14:26:46Z<p>Laeeth: </p>
<hr />
<div>= Introduction: Hello world=<br />
<br />
''The C# Way''<br />
<br />
using System;<br />
class Hello {<br />
static void Main(string[] args) {<br />
Console.WriteLine(&quot;Hello world!&quot;);<br />
}<br />
}<br />
<br />
''The D Way''<br />
<br />
import std.stdio;<br />
void main(string[] args) {<br />
writeln(&quot;Hello world&quot;);<br />
}<br />
<br />
Things we learnt so far:<br />
<br />
* standard file extension for D source code files is <code>.d</code><br />
* we <code>import</code> a module instead of <code>using</code> a namespace;<br />
* static methods can be declared outside a class;<br />
* we can call directly any method even if it’s not declared in a class (<code>writeln</code>);<br />
* <code>writeln</code> is D equivalent for C# <code>System.Console.WriteLine</code>;<br />
* syntax is exactly the same as in C# (method definitions, string qualifiers, array declarations, comments)<br />
* many of the keywords are exactly the same (<code>void,string</code>);<br />
<br />
= Documentation Comments =<br />
''The C# Way''<br />
/// <summary><br />
/// Documentation comment<br />
/// </summary><br />
/// <param name="foo">...</param><br />
/// <param name="bar">...</param><br />
/// <returns>...</returns><br />
<br />
''The D Way''<br />
/**<br />
* Documentation comment<br />
*<br />
* Params: foo = param description<br />
* bar = param description<br />
*<br />
* Returns: return value<br />
*<br />
* Throws: Exception <br />
*/<br />
<br />
= Compilation = <br />
== Simple compilation ==<br />
<br />
''The C# Way''<br />
<br />
With [http://www.mono-project.com/docs/about-mono/languages/csharp/ mcs] mono compiler:<br />
$ mcs source1.cs source2.cs -out:program.exe<br />
<br />
''The D Way''<br />
<br />
With [[DMD]] Digital Mars compiler:<br />
$ dmd source1.d source2.d -ofprogram<br />
<br />
== Conditional Compilation Directives ==<br />
''The C# Way''<br />
<br />
Defines one or more conditional symbols (short: -d)<br />
<br />
-define:S1[;S2]<br />
<br />
// compile with: /define:xx<br />
// or uncomment the next line:<br />
//#define xx<br />
<br />
[Test] public void define_test() {<br />
int x = 0;<br />
#if (xx)<br />
x = 5;<br />
#else<br />
x = 1;<br />
#endif<br />
Assert.AreEqual(x, 5);<br />
}<br />
<br />
''The D Way''<br />
<br />
'''TO DO'''<br />
<br />
= Coding styles =<br />
<br />
* D programmers prefer to use the camelCase notation instead of PascalCase for method names, variable names and enum members<br />
* Module names (C# namespaces) are always in lowercase due to cross-platform compatibility regarding file names.<br />
* If there are conflicts between a named entity and a keyword, in C# you can use verbatim identifiers (@while). D does not have verbatim identifiers, but the convention is to add an underscore at the end of the entity (while_).<br />
<br />
<br />
{| class="wikitable"<br />
! Type<br />
! C# Way<br />
! D Way<br />
|-<br />
|Class<br />
|PascalCase<br />
|PascalCase<br />
|-<br />
|Struct<br />
|PascalCase<br />
|PascalCase<br />
|-<br />
|class method<br />
|PascalCase<br />
|camelCase<br />
|-<br />
|class property<br />
|PascalCase<br />
|camelCase<br />
|-<br />
|enum declaration<br />
|PascalCase<br />
|PascalCase<br />
|-<br />
|enum value<br />
|PascalCase<br />
|camelCase<br />
|-<br />
|const<br />
|UPPER_CASE<br />
| -<br />
|-<br />
|local variable<br />
|camelCase<br />
|camelCase<br />
|}<br />
<br />
= Type system =<br />
<br />
== Built-in types ==<br />
<br />
Basic type names are very similar in both languages with the following differences: <br />
* The 8 bit signed integer from C# <code>sbyte</code> is written in D as <code>byte</code>; <br />
* The 8 bit unsigned integer from C# <code>byte</code> is written in D as <code>ubyte</code>; <br />
* There is no type equivalence for <code>decimal</code><br />
* There are three types of char in D: <code>char</code>, <code>wchar</code> and <code>dchar</code>, each of them corresponding to an UTF encoding : UTF-8, UTF-16 and UTF-32. Since C# is using internally UTF-16 chars, the direct equivalent of C# <code>char</code> is D <code>wchar</code>.<br />
* There are also three types of string in D: <code>string</code>, <code>wstring</code> and <code>dstring</code>. The direct equivalent of C# <code>string</code> is in fact D <code>wstring</code>. These are not keywords in D, they are in fact declared as aliases to immutable char arrays. <br />
* There is another floating point type in D: <code>real</code> with no type equivalence in C#.<br />
* Complex floating point types <code>Complex&lt;T&gt;</code> are keywords in D: <code>cfloat, cdouble, creal</code> and they imaginary counterparts are <code>ifloat</code>, <code>idouble</code>, <code>ireal</code>;<br />
<br />
== Literals ==<br />
'''TO DO'''<br />
<br />
== Arrays ==<br />
<br />
Arrays in D are not too different than the ones form C# (for D see [https://github.com/ilmanzo/DLangKoans/blob/master/source/07_about_arrays.d D Koans] and [http://dlang.org/arrays.html#static-arrays dlang])<br />
<br />
=== Static array ===<br />
==== Initialize with a literal ====<br />
''The C# Way''<br />
string[] fruits = {"banana", "mango", "apple", "orange"};<br />
// or long mode<br />
string[] longFruits = new string[4]{"banana", "mango", "apple", "orange"};<br />
Assert.AreEqual(fruits[0], "banana");<br />
Assert.AreEqual(fruits.Length, 4);<br />
<br />
''The D Way''<br />
string[4] fruits = ["banana", "mango", "apple", "orange"];<br />
assertEquals(fruits[0], "banana");<br />
assertEquals(fruits.length, 4);<br />
<br />
==== Initialize with same value ====<br />
''The C# Way''<br />
// no short way<br />
int[] b = { 1, 1, 1}; // 3 elements with same value 1<br />
<br />
''The D Way''<br />
int[3] b = 1; // 3 elements with same value 1<br />
<br />
=== Dynamic array ===<br />
For D see [https://github.com/ilmanzo/DLangKoans/blob/master/source/07_about_arrays.d D Koans] and [http://dlang.org/arrays.html#static-arrays dlang]<br />
<br />
''The C# Way''<br />
<br />
List<T> works very similarly to a dynamic array<br />
using System.Collections.Generic;<br />
...<br />
List<string> fruits = new List<string>{"banana", "mango"};<br />
Assert.AreEqual(fruits.Count, 2);<br />
<br />
fruits.Add("strawberry");<br />
Assert.AreEqual(fruits.Count, 3);<br />
Assert.AreEqual(fruits[2], "strawberry");<br />
<br />
<br />
''The D Way''<br />
string[] fruits = ["banana", "mango"];<br />
assertEquals(fruits.length, 2);<br />
<br />
fruits ~= "strawberry";<br />
assertEquals(fruits.length, 3);<br />
assertEquals(fruits[2], "strawberry");<br />
<br />
== Pointers ==<br />
Since D is not a managed language, you are free to use pointers anywhere in the code, without encompassing them in an unsafe context. On the contrary, D code is by default unsafe, but you can force the safe context using the <code>@safe</code> keyword:<br />
<br />
''The C# Way''<br />
int value;<br />
// here you can't use pointers<br />
unsafe {<br />
int* p = &amp;value<br />
}<br />
<br />
''The D Way''<br />
<br />
int value;<br />
int* p = &amp;value<br />
@safe {<br />
//here you can't use pointers<br />
}<br />
<br />
== Delegates ==<br />
<br />
Delegates in D are declared with the same keyword, but the return type precedes the declaration:<br />
<br />
''The C# Way''<br />
delegate int F<br />
<br />
''The D Way''<br />
int delegate(int x) Foo;<br />
int function(int x) Foo;<br />
<br />
Since D doesn't need to declare methods inside a class, you can declare also a function, equivalent to a delegate without class context. A notable difference between C# and D is the fact that '''delegates are not multicast in D''', therefore you cannot join or remove them.<br />
<br />
== Enums == <br />
<br />
There is no difference between enum declarations, except that so called C# flags enums are not necessarely decorated with the [Flags] attribute:<br />
<br />
''The C# Way''<br />
enum Option { <br />
Option1, <br />
Option2<br />
}<br />
<br />
[Flags]<br />
enum Permission {<br />
read,<br />
write,<br />
all = read | wite<br />
}<br />
<br />
''The D Way''<br />
<br />
The members of enums should be camelCased, so their first letter is lowercase. (see [http://dlang.org/dstyle.html D Style]<br />
enum Color { <br />
red, <br />
green, <br />
blue<br />
}<br />
<br />
enum Permission {<br />
read,<br />
write,<br />
all = read | wite<br />
}<br />
<br />
== Struct ==<br />
Struct are declared exactly the same way in D except:<br />
<br />
* There is no explicit layout in D. Nevertheless, there is a solution in the standard library.<br />
* Structs cannot implement interfaces<br />
<br />
''The C# Way''<br />
public struct TimeOfDay {<br />
public int hour;<br />
public int minute;<br />
public TimeOfDay(int h, int m) {<br />
hour = h;<br />
minute = m;<br />
}<br />
}<br />
...<br />
<br />
var t1 = new TimeOfDay(8, 30);<br />
Assert.AreEqual(t1.minute, 30);<br />
<br />
// Declare a struct object without "new.<br />
TimeOfDay t2;<br />
t2.minute = 10;<br />
Assert.AreEqual(t2.minute, 10);<br />
<br />
''The D Way''<br />
struct TimeOfDay {<br />
int hour;<br />
int minute;<br />
}<br />
... <br />
<br />
// preferred syntax<br />
auto t1 = TimeOfDay(8, 30); <br />
assertEquals(t1.minute, 30);<br />
<br />
// alternate C syntax<br />
TimeOfDay t2 = {9, 45}; <br />
assertEquals(t2.hour, 9);<br />
<br />
auto t3 = TimeOfDay(10); // not all members need to be specified<br />
assertEquals(t3.minute, 0);<br />
<br />
== Union ==<br />
D has unions, the equivalent of a C# struct with explicit layout where all fields offsets are 0<br />
<br />
''The C# Way''<br />
<br />
[StructLayout(LayoutKind.Explicit)]<br />
struct MyUnion {<br />
[FieldOffset(0)]<br />
int someInt;<br />
[FieldOffset(0)]<br />
float someFloat;<br />
}<br />
<br />
''The D Way''<br />
<br />
union MyUnion {<br />
int someInt;<br />
float someFloat;<br />
}<br />
<br />
<br />
== Interfaces ==<br />
<br />
Interfaces are declared in the same way as in C#, the only difference being that interfaces in D can have final methods, equivalent to C# abstract class<br />
<br />
''The C# Way''<br />
<br />
interface I {<br />
void Method();<br />
}<br />
<br />
abstract class C {<br />
void Method() {<br />
Console.WriteLine("hello");<br />
}<br />
}<br />
<br />
''The D Way''<br />
interface I {<br />
void method();<br />
}<br />
<br />
interface C {<br />
final void method() {<br />
writeln("hello");<br />
}<br />
}<br />
<br />
<br />
== Classes ==<br />
''The C# Way''<br />
class A {<br />
private int myValue; // not accessible from outside<br />
<br />
public A(int startValue) { // constructor<br />
myValue = startValue;<br />
}<br />
public int Value {<br />
get { return myValue; }<br />
}<br />
<br />
}<br />
<br />
class B: A {<br />
public B(): base(3) {}<br />
<br />
public int GetDoubleValue() {<br />
//return myValue * 2; // Error: myValue is inaccessible due to its protection level<br />
return this.Value * 2;<br />
}<br />
}<br />
<br />
[TestFixture] public class AboutClasses {<br />
[Test]public void inheritance() {<br />
B instance = new B();<br />
Assert.AreEqual(instance.GetDoubleValue(), 6);<br />
}<br />
}<br />
<br />
<br />
''The D Way''<br />
class A {<br />
private int myValue; // not accessible from outside<br />
<br />
this(int startValue) { // constructor<br />
myValue = startValue;<br />
}<br />
}<br />
<br />
class B: A {<br />
this() {<br />
super(3); // what happens here ?<br />
} <br />
<br />
auto getDoubleValue() {<br />
return myValue * 2; // B doesn't have this field but..<br />
}<br />
}<br />
<br />
class AboutClasses {<br />
<br />
@Test public void inheritance() {<br />
auto instance = new B;<br />
assertEquals(instance.getDoubleValue(), 6);<br />
}<br />
}<br />
<br />
== Generic Types ==<br />
<br />
D is not using generics, instead it has a more powerful concept named templates.<br />
<br />
''The C# Way''<br />
<br />
public class A {<br />
public void Foo<T>(T arg) {}<br />
}<br />
// use<br />
A a = new A();<br />
a.Foo<int>(1);<br />
<br />
<br />
public class C<T> where T: class { }<br />
... <br />
C<A> c = new C<A>();<br />
// C<int> i = new C<int>(); compiler error: int isn't a class<br />
<br />
<br />
public class X { }<br />
public class D<T> where T: X {}<br />
<br />
D<X> d = new D<X>();<br />
//D<A> d = new D<A>();compiler error: A isn't X<br />
<br />
<br />
''The D Way''<br />
<br />
void foo(T)(T arg) {}<br />
// use<br />
foo!int(3);<br />
foo!string("bar");<br />
<br />
class X {} <br />
class C(T) if is(T == class) {}<br />
<br />
// use<br />
C c = new C!X;<br />
// C c = new C!int; compiler error: int isn't a class<br />
<br />
<br />
class D(T) if is(T : X) {}<br />
auto d = new D!X;<br />
//auto d = new D!(A);compiler error: A isn't X<br />
<br />
=== Constraints ===<br />
There are no direct equivalents of other generic constraints, but the D template system is so versatile that you can create your own.<br />
<br />
''The C# Way''<br />
<br />
class C<T> where T: new() {}<br />
<br />
''The D Way''<br />
<br />
class C(T) if (is(typeof(new T()) == T))<br />
<br />
The template constraint will be read as if the result of expression <code>new T()</code> is of type T. If the T class has no contructor or is some other type, the <code>new T()</code> expression will result in an error or some other type, therefore the constraint will not be satisfied.<br />
<br />
== Events ==<br />
<br />
There is no such concept in D language, but D programmers prefer to use [http://dlang.org/phobos/std_signals.html signals and slots] instead of events. <br />
<br />
If you are keen to use events in D, a quick and dirty way to implement them can be found below:<br />
<br />
'''TO DO'''<br />
<br />
== Dynamic Types ==<br />
<br />
There is no such concept in D language. All types must be known at compile time but the same semantics can be simulated by forwarding.<br />
<br />
== Boxing ==<br />
<br />
<cite>Boxing, otherwise known as wrapping, is the process of placing a primitive type within an object so that the primitive can be used as a reference object</cite> ([https://en.wikipedia.org/wiki/Object_type_%28object-oriented_programming%29#Boxing wikipedia])<br />
<br />
Value types in D are not boxed or unboxed automatically and do not inherit from ValueType. Also, you cannot implement interfaces for value types. <br />
Depending on your purpose, there are alternatives to boxing in D:<br />
<br />
* if you just want to have a container for several types you can use [http://dlang.org/phobos/std_variant.html std.variant]<br />
* if you want to write general purpose method with object parameters, use generics<br />
<br />
''The C# Way''<br />
<br />
[Test]public void boxing_test() {<br />
int a = 1;<br />
float b = 19.64f;<br />
<br />
object o = a;<br />
Assert.AreEqual(o, 1);<br />
Assert.AreEqual(tos(o), "1");<br />
<br />
o = b;<br />
Assert.AreEqual(o, 19.64f);<br />
<br />
b = (float)o;<br />
Assert.AreEqual(b, 19.64f);<br />
Assert.AreEqual(tos(o), "19.64");<br />
}<br />
private string tos(object obj) {<br />
return obj.ToString();<br />
}<br />
<br />
<br />
''The D Way''<br />
@Test void boxing_test() {<br />
int a = 1; <br />
float b = 19.64f;<br />
<br />
Variant o = a;<br />
assert(o.type == typeid(int));<br />
assert(tos(o) == "1");<br />
<br />
v = b;<br />
auto x = v.get!(float);<br />
assert(x == 19.64f);<br />
}<br />
<br />
string tos(T)(T obj) {<br />
return to!string(obj);<br />
}<br />
<br />
== Nullable types ==<br />
Value types are not nullable in D language. <br />
There are solutions in the standard library to simulate this behaviour<br />
<br />
''[https://msdn.microsoft.com/en-us/library/vstudio/1t3y8s4s%28v=vs.110%29.aspx The C# Way]''<br />
int? num = null;<br />
if (num.HasValue) {<br />
System.Console.WriteLine("num = " + num.Value);<br />
} else {<br />
System.Console.WriteLine("num = Null");<br />
}<br />
<br />
''[http://dlang.org/phobos/std_typecons.html#.Nullable The D Way]'' <br />
<br />
Nullable!int num = 10;<br />
if (num.isNull) {<br />
writeln(num.get());<br />
}<br />
int y = num.get();<br />
int z = num.isNull ? int.init : num.get();<br />
num.nullify();<br />
<br />
== Enumerable types ==<br />
In C#, a type can be considered enumerable if implements the [https://msdn.microsoft.com/en-us/library/system.collections.ienumerable.aspx IEnumerable] interface. <br />
In D, a type is considered enumerable (Range is more used as the concept in D) if:<br />
<br />
* implements three methods named popFront, empty and front or,<br />
* implements a special operator named opApply;<br />
<br />
''The C# Way''<br />
class Prime: IEnumerable {<br />
object[] items = {1, 3, 5, 7};<br />
<br />
public IEnumerator GetEnumerator() {<br />
foreach (object o in items) {<br />
// Return the current element and then on next function call<br />
// resume from next element rather than starting all over again;<br />
yield return o;<br />
}<br />
}<br />
}<br />
<br />
[TestFixture] public class TestIterator {<br />
[Test] public void prime_test() {<br />
Prime primes = new Prime();<br />
int[] expected = {1, 3, 5, 7};<br />
int i = 0;<br />
<br />
foreach (object p in primes) {<br />
Assert.AreEqual(p, expected[i++]);<br />
}<br />
}<br />
}<br />
<br />
''The D Way (front, popFront, empty)''<br />
<br />
class Prime {<br />
private int[] p = [1, 3, 5, 7];<br />
@property bool empty() {<br />
return p.length == 0;<br />
}<br />
@property int front() {<br />
return p[0];<br />
}<br />
void popFront() {<br />
p = p[1..$];<br />
}<br />
} <br />
<br />
class TestIterator {<br />
mixin UnitTest;<br />
<br />
@Test prime() {<br />
Prime primes = new Prime();<br />
int[] expected = [1, 3, 5, 7];<br />
int i;<br />
for (; !primes.empty; primes.popFront()) {<br />
assert(primes.front == expected[i++]);<br />
}<br />
}<br />
}<br />
<br />
''The D Way (opApply)''<br />
<br />
'''TO DO'''<br />
<br />
== Code Attributes ==<br />
=== Property ===<br />
''The C# Way''<br />
<br />
class Person {<br />
public Person() {<br />
Name = "Default Name";<br />
}<br />
public string Name { get; set; }<br />
}<br />
<br />
''The D Way''<br />
class Person {<br />
private string _name;<br />
this() {<br />
_name = "Default Name";<br />
}<br />
<br />
@property string name() {<br />
return _name;<br />
}<br />
@property void name(string n) {<br />
_name = n;<br />
}<br />
}<br />
<br />
= Statements =<br />
<br />
== Declaring variables ==<br />
''The C# Way''<br />
<br />
int x;<br />
string text = "abc";<br />
const double PI = 3.14;<br />
<br />
''The D Way''<br />
<br />
int x;<br />
string text = "abc";<br />
enum double PI = 3.14;<br />
<br />
<br />
== Expressions ==<br />
''The C# Way''<br />
<br />
double average = (a + b) / 2; // assignment expression<br />
foo.Bar(); // method call<br />
<br />
SomeClass c = new SomeClass(); // class initialization<br />
SomeStruct s = new SomeStruct(); //struct initialization<br />
<br />
List<int> list = new List<int>();<br />
Dictionary<string, int> = new Dictionary<string, int>();<br />
<br />
''The D Way''<br />
<br />
double average = (a + b) / 2; // assignment expression<br />
foo.bar(); // method call<br />
<br />
SomeClass c = new SomeClass(); // class initialization<br />
SomeStruct s = SomeStruct(); //struct initialization<br />
<br />
List!int list = new List!int();<br />
Dictionary!(string, int) = new Dictionary!(string, int);<br />
<br />
Differences:<br />
* Structs in D are initialized without the <code>new</code> keyword.<br />
* Generic types in D are initialized using <code>!</code> and by specifing types between parantheses. If there is only one specialisation, parantheses can be omitted.<br />
<br />
== Using namespaces ==<br />
<br />
D is importing modules instead of using namespaces. A collection of modules in D in named `package`. There is one-to-one correspondence between D modules and filenames and one-to-one correspondence between packages and folders.<br />
<br />
''The C# Way''<br />
<br />
using System;<br />
using System.Collections;<br />
<br />
''The D Way''<br />
<br />
import system;<br />
//this will try to import 'system.d' from the current folder. <br />
//if 'system' is a folder name, it will try to import a special file named 'package.d'<br />
import system.collections;<br />
//this will import the file 'collections.d' from a folder named 'system'.<br />
<br />
if you are creating your own namespaces, the closest match for simulating C# namespaces is a trick used to import C++ code in D:<br />
<br />
''The D Way''<br />
extern (C++, MyNamespace) {<br />
class MyClass { ...}<br />
}<br />
//Fully qualified name of MyClass is MyNamespace.MyClass <br />
<br />
<br />
== if Statement ==<br />
The <code>if else</code> statement has the same structure as in C#:<br />
<br />
''The C# Way''<br />
<br />
bool b; <br />
if (b) { ... }<br />
<br />
int a;<br />
if (a == 10) { .... } else { ... }<br />
<br />
SomeClass c;<br />
if (c == null) { ... }<br />
void* p;<br />
if (p != IntPtr.Zero) { ... }<br />
<br />
string s = string.Empty;<br />
if (string.IsNullOrEmpty(s)) { ... }<br />
<br />
<br />
''The D Way''<br />
bool b; <br />
if (b) { ... }<br />
<br />
int a;<br />
if (a == 10) { .... } else { ... }<br />
if (a) { ... }<br />
<br />
SomeClass c;<br />
if (c is null) { ... }<br />
if (!c) { ... }<br />
<br />
void* p;<br />
if (p) { ... }<br />
<br />
string s = "";<br />
if(s.length == 0) { ... }<br />
<br />
<br />
Differences:<br />
<br />
* null values are compared using is operator. The is operator has a very different meaning in D.<br />
* In D, the conditional expression can be any other type than bool<br />
<br />
<br />
== switch Statement ==<br />
The <code>switch</code> case statement has exactly the same structure as in C#, except that D provides a final switch statement intended to use with enum types<br />
''The C# Way''<br />
<br />
enum Color { Blue, Red, Green }<br />
<br />
Color c;<br />
switch (c) {<br />
case Color.Blue: ... break;<br />
case Color.Red: ... break;<br />
default: ... break;<br />
}<br />
<br />
''The D Way''<br />
enum Color { Blue, Red, Green }<br />
<br />
Color c;<br />
final switch (c) {<br />
case Color.Blue: ... break;<br />
case Color.Red: ... break;<br />
//compilation error if the switch statement does not treat all members of Color.<br />
}<br />
<br />
or [http://p0nce.github.io/d-idioms/#Qualified-switch-using-with using with] <br />
<br />
''The D Way''<br />
<br />
// The members of enums should be camelCased<br />
enum Color { blue, red, green }<br />
<br />
Color c;<br />
<br />
final switch() with (Color){<br />
case blue: ... break;<br />
case red: ... break;<br />
case green: ... break;<br />
//compilation error if the switch statement does not treat all members of Color.<br />
}<br />
<br />
== Iteration statements ==<br />
'''TO DO'''<br />
<br />
== Jump statements ==<br />
'''TO DO'''<br />
<br />
= Exception handling =<br />
<br />
'''TO DO'''<br />
<br />
= Argument Checking =<br />
'''TO DO'''<br />
<br />
= Resources =<br />
* [http://www.youtube.com/watch?v=6_xdfSVRrKo C# to D video-presentation]<br />
* [https://github.com/rumbu13/sharp/blob/master/cstod.md Original article] <br />
* [https://github.com/ilmanzo/DLangKoans/ D Koans]<br />
* [https://github.com/taylorh140/Calling-NET-from-D Calling .NET from D]<br />
[[Category:Languages versus D]]</div>Laeethhttps://wiki.dlang.org/?title=Coming_From&diff=7002Coming From2015-11-30T21:33:16Z<p>Laeeth: /* Porting */</p>
<hr />
<div>When coming from another language it is good to find out where D stands in relation to it. There is the [[DigitalMars:d/2.0/comparison.html | feature list]] which states if a feature exists or not and possibly an explanation. For a side-by-side comparison of many languages: [[Languages_Versus_D | Languages vs D]] or you can look at code snippets of from [http://rosettacode.org/wiki/Category:D Rosetta Code].<br />
<br />
A very superficial way to find out the popularity of D in relation to other languages can is at the [http://www.tiobe.com/tiobe_index/index.htm Tiobe Index] website.<br />
<br />
For information about syntactical differences or gotchas when coming from another language choose your language below.<br />
<br />
<br />
== General Comparison ==<br />
* [[Languages Versus D | Languages vs. D]]<br />
* [http://en.wikibooks.org/wiki/D_Transition_Guide D Transition Guide]<br />
* [http://dlang.org/comparison.html Feature List]<br />
* [http://rosettacode.org/wiki/Category:D Rosetta Code: D category]<br />
* [https://p0nce.github.io/d-idioms/ Idioms for D]<br />
* [http://www.programming-idioms.org/ programming-idioms]<br />
<br />
== Specific Language ==<br />
<br />
* [http://dlang.org/ctod.html Programming in D for C Programmers]<br />
* [https://p0nce.github.io/d-idioms/#Porting-from-C-gotchas Porting from C gotchas]<br />
* [http://dlang.org/cpptod.html Programming in D for C++ Programmers]<br />
* [https://p0nce.github.io/d-idioms/#How-does-D-improve-on-C++17? How does D improve on C++ 17?]<br />
* [[Programming in D for C++ Programmers | C++]]<br />
* [[Programming in D for CSharp Programmers | C#]]<br />
* [[Programming in D for Delphi Programmers | Delphi or Pascal]]<br />
* [[Programming in D for Eiffel Programmers | Eiffel]]<br />
* [[Programming in D for Java Programmers | Java]]<br />
* [[Programming in D for Python Programmers | Python]]<br />
* [[Programming in D for Ruby Programmers | Ruby]]<br />
* [[Programming in D for Basic Programmers | Basic]]<br />
* [http://beza1e1.tuxen.de/stuff/FunctionalD.pdf Functional Languages]<br />
* [[Scientific Programming in D | Fortran, Matlab, R, and other languages for scientific programming]]<br />
<br />
== Porting ==<br />
If you are interested in converting your code to D start by looking at the [[PortingOverview | Porting Overview]].<br />
<br />
Walter Bright has observed that when you first start writing D you tend to write it like the existing languages you are familiar with. In time you may choose to make use of the higher-level features of D that make writing D code a pleasure rather than a chore. But programming is about using a tool to solve a problem, and there is no dogma in D that there is only one way to do it. Very often you don't need to make use of advanced D features like metaprogramming, templates, and compile time function execution to achieve a useful result quickly.<br />
<br />
Converting C code with explicit memory allocation and resource management? Make use of the scope(exit) feature to automatically free pointers and close files when your function or code block finishes (whether successfully or on error).<br />
<br />
From Adam Ruppe "D this Week"<br />
<blockquote><br />
Don't be afraid to do things the C way.<br />
<br />
I've observed a lot of D programmers worrying about doing things the "D way", including asking how to convert working C standard library code to D or lamenting the lack of a D library to replace some C code.<br />
<br />
There's value in this: D can do a lot of things C can't. The "D way" can often be safer, less bug-prone, more beautiful, or more efficient than C code and libraries.<br />
<br />
However, D is also a language for practical programmers and sometimes code that works today is more important than ideal code that might be written at some point later. This is why D gives full access to C facilities, so you can use them!<br />
<br />
If you know how to do something with scanf, you can still use it in D, even while mixing with std.stdio's functions. Simply import core.stdc.stdio; and you can use all your familiar C functions.<br />
<br />
Want to do memory management the C way? Simply import core.stdc.stdlib; and use malloc and free. Combined with D features like scope(exit) to help with freeing and struct semantics to manage ownership you can rest assured that using D will offer advantages over C where needed, without tying your hands when you want to do things the old, familiar way.<br />
<br />
If you have a third-party C API, you don't have to reimplement that functionality in D to take advantage of it (though, there are times you do want to, to leverage D's unique offers). You can simple write an extern(C) function declaration and call the function directly from D, or you can also use dynamic library loading in D, the same way as in C, e.g. with dlopen or LoadLibrary.<br />
<br />
If you know how to solve a problem with pointers, structs, loops, and procedures as in C, you can use them in D too. Yes, the standard library offers a number of excellent range-based algorithms and help for coding in a functional programming style, and learning these is worth the investment. But, if you already know how to do it in C and need it done now, don't let Phobos' allure be an enemy to your productivity. You can still do your work with familiar language features.<br />
<br />
Moving to D opens up a whole new world of superior programming. But it doesn't shut you out of the old world. D aims to be a practical language for working programmers - remember that as you work with it. The new features will still be there to try tomorrow.<br />
<br />
</blockquote><br />
<br />
== Related ==<br />
* [[Language_Specification | Language Specification]]<br />
* [[D_Tutorial/Starting_With_D | Setting up an environment to compile programs]]<br />
* [[Neighbourhood | Seeking help using D]]<br />
* [[Development_with_D | Development with D]]<br />
* [[FAQ | Frequently Asked Questions]]<br />
<br />
[[Category:Languages versus D]]</div>Laeethhttps://wiki.dlang.org/?title=DWiki:Current_events&diff=7001DWiki:Current events2015-11-30T21:32:29Z<p>Laeeth: Created page with "For now, the best places to follow news on upcoming D events is the announce forum, and Adam Ruppe's D This Week newsletter: *[http://forum.dlang.org/group/announce announce..."</p>
<hr />
<div>For now, the best places to follow news on upcoming D events is the announce forum, and Adam Ruppe's D This Week newsletter:<br />
<br />
*[http://forum.dlang.org/group/announce announce forum]<br />
*[http://forum.dlang.org/search?q=talk&scope=group%3AdigitalmarsDannounce search for talks in announce forum]<br />
*[http://arsdnet.net/this-week-in-d/ This week in D]<br />
<br />
<br />
Don't forget the upcoming DConf 2016, which will be held in May 4-6 2016 in Berlin, hosted by Sociomantic, a prominent D corporate user:<br />
<br />
*[http://dconf.org/2016/index.html dconf]<br />
<br />
<br />
There are regular meetup groups in London, Silicon Valley, and other locations - please check the forums.</div>Laeethhttps://wiki.dlang.org/?title=User:Laeeth&diff=6673User:Laeeth2015-09-22T18:25:14Z<p>Laeeth: </p>
<hr />
<div>*[[vibed faq addition]]<br />
*[[useful D snippets]]<br />
*[[User narratives on switching to D]]<br />
*[[Use of IDEs]]</div>Laeethhttps://wiki.dlang.org/?title=User:Laeeth&diff=6672User:Laeeth2015-09-22T18:24:56Z<p>Laeeth: </p>
<hr />
<div>*[[vibed faq addition]]<br />
*[[useful D snippets]]<br />
*[[User narratives on switching to D]]<br />
*[[IDEs]]</div>Laeethhttps://wiki.dlang.org/?title=Bind_D_to_C&diff=6597Bind D to C2015-09-08T12:35:55Z<p>Laeeth: </p>
<hr />
<div><br />
== Introduction ==<br />
[http://www.gamedev.net/page/resources/_/technical/game-programming/binding-d-to-c-r3122 Article] and [http://www.gamedev.net/blog/1140/entry-2254003-binding-d-to-c/ Series] on creating bindings to C libraries for the D programming language.<br />
<br />
See [[C++ interop]] for information on interoperability between D and C++. More can be done than is currently described in the official documentation.<br />
<br />
<br />
== Response to the article / more information ==<br />
=== Global variables ===<br />
<br />
Global variables need to have an extra <code>extern</code> and the <code>__gshared</code> storage.<br />
<br />
''Example in C:''<br />
<br />
int a;<br />
<br />
''Translated to D:''<br />
<br />
extern (C) extern __gshared int a;<br />
<br />
For TLS variables __gshared is not used.<br />
<br />
=== Typedefs ===<br />
<br />
When I do a binding I'm trying to figure out why they used a typedef in the first place.<br />
<br />
There's a couple of reasons:<br />
<br />
* To get a fixed type on all platforms. In the C language there are no fixed types, it's just relations between the sizes of the types. I.e. long => int => short => char, or something like that. In this case, use the native D type. In D a given type has a fixed size on all platforms (except for real). Examples of these can be: "int8_t", "uint16_t", "uint32_t" and so on.<br />
<br />
* To get different sizes on different platforms. For example, a 32bit value of 32bit platforms and a 64bit value of 64bit platforms. In this case you're basically forced to use an alias.<br />
<br />
* Opaque types. Perhaps the API is hiding the actual type behind a void* or for other reasons uses a void*. Then it uses a tyepdef on top of that to give it an idea of what type we're dealing with. In this case use the typedef.<br />
<br />
* The typedef is well known in the API. Examples of this would be GLint. I don't remember why they use typedefs but if I recall correctly GLint is used in all examples, tutorials, books and so on. In this case it's best to the typedef.<br />
<br />
* Hiding a complex type. An example of this could be function pointers. In this case use the typedef.<br />
<br />
=== Function pointers ===<br />
<br />
With function pointers there are (at least) two cases where an alias have to be used, instead of a function pointer. <br />
<br />
* When declaring function parameters with a specific linkage.<br />
<br />
The following is syntactically invalid in D:<br />
<br />
void foo (extern(C) void function () callback);<br />
<br />
Use an alias:<br />
<br />
alias extern (C) void function () Callback; <br />
void foo (Callback callback);<br />
<br />
* When using a cast with a specific linkage. You won't see this in a binding, if you're not converting inline functions.<br />
<br />
This is invalid in D as well:<br />
<br />
void* foo;<br />
...<br />
auto bar = cast(extern (C) void function ()) foo;<br />
<br />
Use the same approach as above.<br />
<br />
=== Structs/Unions ===<br />
<br />
You actually didn't mention unions at all but basically all the same rules that apply when translating structs apply to unions as well. Two other things that you didn't mention was nested structs and anonymous structs.<br />
<br />
=== Structs ===<br />
<br />
* For named structs in typedefs I feel a bit undecided of how I want to have it. You can either just use the name of the typedef in D when declaring the struct. Or you can use the real name of the struct and then use an alias as well. In some cases the actual name of the struct could be used, i.e. "struct foo".<br />
<br />
=== Anonymous Structs ===<br />
<br />
* If an anonymous struct is used directly to declare a variable you're forced to invent a name for the struct in D, since D doesn't support anonymous structs. Example:<br />
<br />
struct<br />
{<br />
int a;<br />
int b;<br />
} c; <br />
<br />
Translate to:<br />
<br />
struct _AnonymousStruct1<br />
{<br />
int a;<br />
int b;<br />
}<br />
<br />
_AnonymousStruct1 c;<br />
<br />
Any name can be used in this case. In my tool, DStep, for automatically generating bindings I'm using names similar to above.<br />
<br />
* If an anonymous struct is used in a typedef just use the name of the typedef. No alias is required in the D code in this case. I actual noticed now that you have this example.<br />
<br />
=== Nested structs ===<br />
<br />
I always fail to remember how these should be translated to D.<br />
<br />
* For nested structs that are named. Example:<br />
<br />
struct Foo<br />
{<br />
int a;<br />
struct Bar<br />
{<br />
int b;<br />
} bar;<br />
}<br />
<br />
In this case translate it to a named struct in D as well:<br />
<br />
struct Foo<br />
{<br />
int a;<br />
struct Bar<br />
{<br />
int b;<br />
}<br />
Bar bar;<br />
}<br />
<br />
* For nested struct that are anonymous. Example:<br />
<br />
struct Foo<br />
{<br />
int a;<br />
struct<br />
{<br />
int b;<br />
} bar;<br />
}<br />
<br />
In this case you could translate it to an anonymous struct in D as well:<br />
<br />
struct Foo<br />
{<br />
int a;<br />
struct<br />
{<br />
int b;<br />
}<br />
}<br />
<br />
The problem with this is that the API changes. Instead of accessing "b" like this:<br />
<br />
struct Foo foo;<br />
foo.bar.b = 1;<br />
<br />
You would do like this:<br />
<br />
Foo foo;<br />
foo.b = 1;<br />
<br />
I actually looked at the documentation now and see that this example is not used anymore:<br />
<br />
[http://dlang.org/interfaceToC.html http://dlang.org/interfaceToC.html]<br><br />
[http://dlang.org/htod.html http://dlang.org/htod.html]<br />
<br />
It's still on the D1 page:<br />
<br />
[http://digitalmars.com/d/1.0/htomodule.html http://digitalmars.com/d/1.0/htomodule.html]<br />
<br />
== See also ==<br />
<br />
* [[D binding for C]]<br />
* [[Binding generators]]<br />
* [[Bindings]]<br />
* [http://p0nce.github.io/d-idioms/#Porting-from-C-gotchas Porting from C gotchas]<br />
<br />
<br />
<br />
[[Category:Binding]]<br />
[[Category:HowTo]]</div>Laeethhttps://wiki.dlang.org/?title=How_You_Can_Help&diff=6586How You Can Help2015-09-05T13:29:46Z<p>Laeeth: </p>
<hr />
<div>== Documentation ==<br />
<br />
* std.algorithm - see forum<br />
<br />
== Wiki ==<br />
<br />
* We need [http://wiki.dlang.org/Coming_From D as a second language] sections completed <br />
* C and C++ need updating <br />
* we need more examples of how to shift idiom to speak fluent D<br />
* the Python page is started but needs fleshing out<br />
* and most of the other sections are empty.<br />
<br />
<blockquote><br />
One note about Walter's older C/C++ transition articles. They have good information on transition technicalities (e.g. "how do I do this thing in D that I used to do in C++?") but not a lot about the changes in coding style - making object copying not arbitrarily expensive, choosing struct vs. class, preferring pipelines and lazy to eager computation, etc. From what I see some folks come from C++, write their first D program in a stilted C++ idiom, and are left with the impression that the work is not worth the trouble.<br />
<br />
Andrei<br />
</blockquote><br />
<br />
== Past GSOC ideas ==<br />
<br />
Some of these may still be interesting.<br />
* [http://wiki.dlang.org/GSOC_2015_Ideas 2015]<br />
* [http://wiki.dlang.org/GSOC_2014_Ideas 2014]<br />
* [http://wiki.dlang.org/GSOC_2013_Ideas 2013]<br />
* [http://www.prowiki.org/wiki4d/wiki.cgi?GSOC_2012_Ideas 2012]<br />
* [http://www.prowiki.org/wiki4d/wiki.cgi?GSOC_2011_Ideas 2011]<br />
<br />
== how to better promote your own D projects ==<br />
<br />
<blockquote><br />
I hate the movie "Field of Dreams" where they push the idiotic idea of "Build it and they will come." No, they won't. There's a blizzard of stuff competing for their attention out there, why should they invest the time looking at your stuff? You need to tell them why!<br />
<br />
Here's the frustrating typical pattern I've seen here for years:<br />
<br />
# spend hundreds if not thousands of hours developing something really cool<br />
# spend 2 minutes posting a link to the repository on D.announce<br />
# someone posts it to reddit. Ignore it<br />
# get frustrated that nobody looks at it<br />
# get bitter and quit<br />
<br />
Here's the pattern that works a lot better:<br />
<br />
# spend hundreds if not thousands of hours developing something really cool<br />
# spend 10 minutes writing the announcement to D.announce. Be sure to include:<br />
#: who, what, where, when, why, and how<br />
# someone posts it to reddit<br />
# post the who, what, where, when, why and how on reddit AS SOON AS POSSIBLE after the reddit link appears. Stuff on reddit has a VERY SHORT shelf life. If it doesn't get action within a couple hours, it fades into oblivion. Identify yourself as the author, say AMA. The first one to post a comment tends to spark and set the tone for the discussion.<br />
# check back on reddit once an hour or so for the next day, answer questions<br />
# *****<br />
# profit!<br />
<br />
Walter Bright<br />
</blockquote><br />
<br />
<br />
<br />
== Compiler Project List ==<br />
* DMD (TBA)<br />
* [http://wiki.dlang.org/LDC_project_ideas LDC]<br />
* [http://wiki.dlang.org/GDC/ProjectIdeas GDC]</div>Laeethhttps://wiki.dlang.org/?title=How_You_Can_Help&diff=6585How You Can Help2015-09-05T13:26:44Z<p>Laeeth: </p>
<hr />
<div>== Documentation ==<br />
<br />
* std.algorithm - see forum<br />
<br />
== Wiki ==<br />
<br />
* We need [http://wiki.dlang.org/Coming_From D as a second language] sections completed <br />
* C and C++ need updating <br />
* we need more examples of how to shift idiom to speak fluent D<br />
* the Python page is started but needs fleshing out<br />
* and most of the other sections are empty.<br />
<br />
<blockquote><br />
One note about Walter's older C/C++ transition articles. They have good information on transition technicalities (e.g. "how do I do this thing in D that I used to do in C++?") but not a lot about the changes in coding style - making object copying not arbitrarily expensive, choosing struct vs. class, preferring pipelines and lazy to eager computation, etc. From what I see some folks come from C++, write their first D program in a stilted C++ idiom, and are left with the impression that the work is not worth the trouble.<br />
<br />
Andrei<br />
</blockquote><br />
<br />
== Past GSOC ideas ==<br />
<br />
Some of these may still be interesting.<br />
* [http://wiki.dlang.org/GSOC_2015_Ideas 2015]<br />
* [http://wiki.dlang.org/GSOC_2014_Ideas 2014]<br />
* [http://wiki.dlang.org/GSOC_2013_Ideas 2013]<br />
* [http://www.prowiki.org/wiki4d/wiki.cgi?GSOC_2012_Ideas 2012]<br />
* [http://www.prowiki.org/wiki4d/wiki.cgi?GSOC_2011_Ideas 2011]<br />
<br />
== how to better promote your own D projects ==<br />
<br />
<blockquote><br />
I hate the movie "Field of Dreams" where they push the idiotic idea of "Build it and they will come." No, they won't. There's a blizzard of stuff competing for their attention out there, why should they invest the time looking at your stuff? You need to tell them why!<br />
<br />
Here's the frustrating typical pattern I've seen here for years:<br />
<br />
# spend hundreds if not thousands of hours developing something really cool<br />
# spend 2 minutes posting a link to the repository on D.announce<br />
# someone posts it to reddit. Ignore it<br />
# get frustrated that nobody looks at it<br />
# get bitter and quit<br />
<br />
Here's the pattern that works a lot better:<br />
<br />
# spend hundreds if not thousands of hours developing something really cool<br />
# spend 10 minutes writing the announcement to D.announce. Be sure to include:<br />
#: who, what, where, when, why, and how<br />
# someone posts it to reddit<br />
# post the who, what, where, when, why and how on reddit AS SOON AS POSSIBLE after the reddit link appears. Stuff on reddit has a VERY SHORT shelf life. If it doesn't get action within a couple hours, it fades into oblivion. Identify yourself as the author, say AMA. The first one to post a comment tends to spark and set the tone for the discussion.<br />
# check back on reddit once an hour or so for the next day, answer questions<br />
# *****<br />
# profit!<br />
<br />
Walter Bright<br />
</blockquote></div>Laeethhttps://wiki.dlang.org/?title=Current_D_Use&diff=6584Current D Use2015-09-04T20:35:41Z<p>Laeeth: /* Organizations */</p>
<hr />
<div>Organizations and notable projects using D:<br />
<br />
== Organizations ==<br />
<br />
* [https://www.facebook.com/facebook/info Facebook] - See [http://forum.dlang.org/post/l37h5s$2gd8$1@digitalmars.com announcement] in the forums.<br />
* [http://weka.io/ weka.io] - Storage startup (stealth mode) - Talk [http://dconf.org/2015/talks/zvibel.html here]<br />
* [https://www.sociomantic.com/ Sociomantic] - real-time bidding for eCommerce. [http://dconf.org/talks/clugston.html DConf 2013 talk]. Historically based on D1 / Tango but from their public comments code is being migrated to D2. [http://dconf.org/2015/talks/strasuns.html Talk]<br />
* [http://remedygames.com/ Remedy Games] - game development. [http://dconf.org/talks/evans_1.html DConf 2013 talk].<br />
* [http://www.funkwerk-itk.com/funkwerk_itk_en/ Funkwerk Aktiengesellschaft] - passenger information systems. [http://dconf.org/talks/rohe.html DConf 2013 talk]. Uses D2 / Phobos.<br />
* [http://www.economicmodeling.com/ EMSI] - economic modeling. [http://dconf.org/2014/talks/crapuchettes.html Talk] [http://forum.dlang.org/post/kpnb4n$24t0$1@digitalmars.com Discussion]. [https://github.com/economicmodeling Github]<br />
* [http://www.randomstorm.com/ RandomStorm] - network security products and services. Uses D2 / Phobos.<br />
* [http://2night.it 2night.it] - italian website about nightlife. Uses D2/phobos for webservice (ios/android app) and for language parsing.<br />
* [http://www.srlabs.it SR Labs] - Eye Tracking Systems Integrator<br />
* [http://www.funatics.de/en Funatics Software GmbH] - MMO Game Developer (See [http://forum.dlang.org/post/kghpblrtxuzzgpnzasxc@forum.dlang.org Newsgroup announcement]).<br />
* [http://www.infognition.com/ Infognition] - mostly video processing technologies and products. Uses D2, Phobos and DFL. (have a post [http://www.infognition.com/blog/2014/why_d.html Why D?])<br />
* [https://socialmagnetics.com Social Magnetics] - Distributed Storage, Processing & Messaging PaaS (stealth mode)<br />
* [http://dconf.org/2015/talks/smith.html Large Hedge Fund] D is a core part of the production trading system - receiving market data, electronic trading, processing large text files<br />
* [http://tech.adroll.com/blog/data/2014/11/17/d-is-for-data-science.html Adroll: big data marketing]<br />
<br />
== Notable projects ==<br />
<br />
=== Video games ===<br />
<br />
* [http://www.asahi-net.or.jp/~cs8k-cyu/games/index.html#windows ABA Games] (2004-2005). Written in D 0.x, includes source code.<br />
* [http://www.inventivedingo.com/mayhemig Mayhem Intergalactic] - the first commercial video game written in D (2007). [http://forum.dlang.org/post/fjakft$cv4$1@digitalmars.com Newsgroup announcement].<br />
* [http://www.stack4.de STACK4] (2013-2014). Gameserver Backend written in D 2. See [http://forum.dlang.org/post/dxcruptyfxsaauihzknw@forum.dlang.org Newsgroup announcement].<br />
<br />
=== Other ===<br />
<br />
* [http://www.xomb.org Xomb] - an exokernel operating system written in D.<br />
* [http://deoma-cmd.ru/en/Products/Geometry/GInMA.aspx GInMA] - a 2D and 3D dynamic geometry system (DGS) written in D1 (2010).<br />
<br />
== Publications ==<br />
<br />
=== Programming languages ===<br />
<br />
* [http://www.cs.berkeley.edu/~daw/papers/pure-ccs08.pdf Verifiable Functional Purity in Java] (2008). Praises D's approach to purity.<br />
<br />
=== Other ===<br />
<br />
* [http://dl.acm.org/citation.cfm?doid=1377980.1377993 Rigid shape interpolation using normal equations] (2008). [http://forum.dlang.org/post/mailman.174.1221513302.19733.digitalmars-d-announce@puremagic.com Discussion].</div>Laeethhttps://wiki.dlang.org/?title=Current_D_Use&diff=6583Current D Use2015-09-04T20:18:41Z<p>Laeeth: /* Organizations */</p>
<hr />
<div>Organizations and notable projects using D:<br />
<br />
== Organizations ==<br />
<br />
* [https://www.facebook.com/facebook/info Facebook] - See [http://forum.dlang.org/post/l37h5s$2gd8$1@digitalmars.com announcement] in the forums.<br />
* [http://weka.io/ weka.io] - Storage startup (stealth mode)<br />
* [https://www.sociomantic.com/ Sociomantic] - real-time bidding for eCommerce. [http://dconf.org/talks/clugston.html DConf 2013 talk]. Historically based on D1 / Tango but from their public comments code is being migrated to D2.<br />
* [http://remedygames.com/ Remedy Games] - game development. [http://dconf.org/talks/evans_1.html DConf 2013 talk].<br />
* [http://www.funkwerk-itk.com/funkwerk_itk_en/ Funkwerk Aktiengesellschaft] - passenger information systems. [http://dconf.org/talks/rohe.html DConf 2013 talk]. Uses D2 / Phobos.<br />
* [http://www.economicmodeling.com/ EMSI] - economic modeling. [http://forum.dlang.org/post/kpnb4n$24t0$1@digitalmars.com Discussion]. [https://github.com/economicmodeling Github]<br />
* [http://www.randomstorm.com/ RandomStorm] - network security products and services. Uses D2 / Phobos.<br />
* [http://2night.it 2night.it] - italian website about nightlife. Uses D2/phobos for webservice (ios/android app) and for language parsing.<br />
* [http://www.srlabs.it SR Labs] - Eye Tracking Systems Integrator<br />
* [http://www.funatics.de/en Funatics Software GmbH] - MMO Game Developer (See [http://forum.dlang.org/post/kghpblrtxuzzgpnzasxc@forum.dlang.org Newsgroup announcement]).<br />
* [http://www.infognition.com/ Infognition] - mostly video processing technologies and products. Uses D2, Phobos and DFL. (have a post [http://www.infognition.com/blog/2014/why_d.html Why D?])<br />
* [https://socialmagnetics.com Social Magnetics] - Distributed Storage, Processing & Messaging PaaS (stealth mode)<br />
* [http://dconf.org/2015/talks/smith.html Large Hedge Fund] D is a core part of the production trading system - receiving market data, electronic trading, processing large text files<br />
* [http://tech.adroll.com/blog/data/2014/11/17/d-is-for-data-science.html Adroll: big data marketing]<br />
<br />
== Notable projects ==<br />
<br />
=== Video games ===<br />
<br />
* [http://www.asahi-net.or.jp/~cs8k-cyu/games/index.html#windows ABA Games] (2004-2005). Written in D 0.x, includes source code.<br />
* [http://www.inventivedingo.com/mayhemig Mayhem Intergalactic] - the first commercial video game written in D (2007). [http://forum.dlang.org/post/fjakft$cv4$1@digitalmars.com Newsgroup announcement].<br />
* [http://www.stack4.de STACK4] (2013-2014). Gameserver Backend written in D 2. See [http://forum.dlang.org/post/dxcruptyfxsaauihzknw@forum.dlang.org Newsgroup announcement].<br />
<br />
=== Other ===<br />
<br />
* [http://www.xomb.org Xomb] - an exokernel operating system written in D.<br />
* [http://deoma-cmd.ru/en/Products/Geometry/GInMA.aspx GInMA] - a 2D and 3D dynamic geometry system (DGS) written in D1 (2010).<br />
<br />
== Publications ==<br />
<br />
=== Programming languages ===<br />
<br />
* [http://www.cs.berkeley.edu/~daw/papers/pure-ccs08.pdf Verifiable Functional Purity in Java] (2008). Praises D's approach to purity.<br />
<br />
=== Other ===<br />
<br />
* [http://dl.acm.org/citation.cfm?doid=1377980.1377993 Rigid shape interpolation using normal equations] (2008). [http://forum.dlang.org/post/mailman.174.1221513302.19733.digitalmars-d-announce@puremagic.com Discussion].</div>Laeethhttps://wiki.dlang.org/?title=Get_involved&diff=6472Get involved2015-08-19T20:32:55Z<p>Laeeth: /* See also */</p>
<hr />
<div>== File a bug report ==<br />
<br />
The simplest way to participate is to [https://issues.dlang.org/enter_bug.cgi?product=D file bug reports] at the [http://issues.dlang.org/ bug tracker].<br />
<br />
If you find any problems with the D language, please file a bug report. Problems that are not filed will not get fixed, because the developers wouldn't know the problem existed. If you're not sure if something is a bug or by design, please ask in the forums (see below).<br />
<br />
Ideally, bug reports should be accompanied by a [http://sscce.org/ small, self-contained example] which demonstrates the problem, and makes it easy to reproduce it. If you find it difficult to manually extract a small example from your source code, [https://github.com/CyberShadow/DustMite DustMite] can help with automatically extracting one. See [https://github.com/CyberShadow/DustMite/wiki the project wiki] for more information.<br />
<br />
If a piece of code worked in an older version of a compiler but no longer works in a newer version, please file a regression (by setting the "Severity" field to "Regression"). Regression bugs are examined before all others. You can use [https://github.com/CyberShadow/Digger Digger] to find the pull request that introduced the change which broke your code. [https://github.com/CyberShadow/DustMite/wiki/Reducing-a-regression-between-two-D-versions DustMite can also be helpful] in creating a minimal example.<br />
<br />
Note that compiler internal errors (crashes, assertion failures, etc.) should ''always'' be filed. No matter how wrong your input is, the compiler should give an appropriate error message and abort compilation; it should ''never'' crash. Such crashes are ''always'' bugs.<br />
<br />
== Discuss in the forums ==<br />
<br />
You can also join in the discussion at the [http://forum.dlang.org/ D forums], which can be accessed via the [http://forum.dlang.org/ web interface], the [http://lists.puremagic.com/mailman/listinfo mailing list interface], or the [news://news.digitalmars.com NNTP server].<br />
<br />
The main D forum is for general discussion on the D language, feature requests and discussions, etc.. Newcomers should start with the [http://forum.dlang.org/group/digitalmars.D.learn D.learn] forum, which is intended for learners to ask more basic questions about programming in D.<br />
<br />
== Alpha-test the development version of D ==<br />
<br />
If you're feeling adventurous, or crave the bleeding-edge features of D, you may want to learn [[Building DMD|how to build git master]].<br />
<br />
== Contribute to the source code and documentation ==<br />
<br />
The source code for the D website, compiler, runtime library, and Phobos (the standard library), are all available on [https://github.com/D-Programming-Language GitHub]. Contributions to the source code are done via [[Pull Requests|pull requests]]. Please note that contributions to DMD source code will only be accepted if the author agrees to have the copyright of the code assigned to Digital Mars.<br />
<br />
To find something to work on, you can [http://d.puremagic.com/issues/query.cgi search] the bug list for issues that you can help fix, or on one [https://issues.dlang.org/buglist.cgi?columnlist=votes%2Cbug_severity%2Cpriority%2Cop_sys%2Cassigned_to_realname%2Cbug_status%2Cshort_desc&field0-0-0=votes&order=votes%20DESC&resolution=--- that has been voted for a lot] or [https://issues.dlang.org/buglist.cgi?keywords=preapproved&resolution=--- preapproved].<br />
<br />
To contribute to the documentation, start by reading [https://github.com/D-Programming-Language/dlang.org/blob/master/CONTRIBUTING.md How to Fork and Build dlang.org]. Additional information on improving the documentation can be found in [http://www.digitalmars.com/d/archives/digitalmars/D/Phobos_Documentation_-_call_to_action_258777.html this thread] started by Walter Bright.<br />
<br />
== Review pull requests ==<br />
<br />
The sheer amount of code being written for the D compiler, standard library and related project is often too great for the core developers to keep up. Even if you're not a "hardcore" D developer you can help lessen this load by reviewing the changes in pull requests at GitHub for [https://github.com/D-Programming-Language/dmd/pulls DMD], [https://github.com/D-Programming-Language/phobos/pulls Phobos], [https://github.com/D-Programming-Language/druntime/pulls DRuntime] and the [https://github.com/D-Programming-Language/dlang.org/pulls D website].<br />
<br />
Various "easy" things to look for: <br />
<br />
* Missing or hard to understand comments<br />
* Unintuitive documentation<br />
* Unchecked edge cases in the code (missing assert, enforce, template constraints)<br />
* Inconsistencies with the [http://dlang.org/dstyle.html D style]<br />
* API inconvenient for use cases the author didn't think of<br />
* Missing/inadequate unittests<br />
* Poor code coverage (check with `dmd -cov -unittest -main std/filename.d`)<br />
* More/better code examples in documentation. Look at answers in [http://forum.dlang.org/group/digitalmars.D.learn D.learn] and [http://stackoverflow.com/questions/tagged/d stack overflow] for ideas.<br />
<br />
To run the unittests of a single file on posix:<br />
<syntaxhighlight lang=bash><br />
make -f posix.mak DMD=../dmd/src/dmd std/*.test <br />
</syntaxhighlight><br />
Adding "-cov" to the "%.test" target inside posix.mak will generate a coverage analysis. <br />
<br />
Also, it is often helpful to review old pull requests (e.g. sort by least recently updated on GitHub). Commenting on an old pull request that seems OK but was for some reason forgotten may bring some attention to it. If you think a pull request is OK to be merged, write "LGTM" (looks good to merge) in your comment.<br />
<br />
If a pull you're interested in has been languishing in the queue for a long time with no attention, commenting "ping" may help prod things along. Especially if the author needs to rebase the pull due to a merge conflict, autotester failure, or other such maintenance problem.<br />
<br />
Citing Andrei Alexandrescu:<br />
<br />
:"If you see [Pull request] you care about, review it even if you don't have rights yet. A simple message such as "I reviewed this and LGTM, any holdup?" would be sufficient to attract attention."<br />
<br />
== See also ==<br />
<br />
* [[Bugzilla]]<br />
* [[Pull Requests]], [[Review process]], [http://dlang.org/dstyle.html Phobos style guidelines]<br />
* [[Building DMD]], [[Build DMD for Android]]<br />
* [[DMD Source Guide]]<br />
* [[Unit Testing Phobos modules]]<br />
* [[Release Process]]<br />
* [[History Of Development Model For D]]<br />
* [[Phobos]]<br />
* [[Libraries]]<br />
* [[Git Commit Tester]]<br />
* [[Using Git on Windows]]<br />
* [[Container Ideas]]<br />
* [[How_You_Can_Help]]</div>Laeethhttps://wiki.dlang.org/?title=Coming_From&diff=6471Coming From2015-08-19T20:31:13Z<p>Laeeth: /* Specific Language */</p>
<hr />
<div>When coming from another language it is good to find out where D stands in relation to it. There is the [[DigitalMars:d/2.0/comparison.html | feature list]] which states if a feature exists or not and possibly an explanation. For a side-by-side comparison of many languages: [[Languages_Versus_D | Languages vs D]] or you can look at code snippets of from [http://rosettacode.org/wiki/Category:D Rosetta Code].<br />
<br />
A very superficial way to find out the popularity of D in relation to other languages can is at the [http://www.tiobe.com/tiobe_index/index.htm Tiobe Index] website.<br />
<br />
For information about syntactical differences or gotchas when coming from another language choose your language below.<br />
<br />
<br />
== General Comparison ==<br />
* [[Languages Versus D | Languages vs. D]]<br />
* [http://en.wikibooks.org/wiki/D_Transition_Guide D Transition Guide]<br />
* [http://dlang.org/comparison.html Feature List]<br />
* [http://rosettacode.org/wiki/Category:D Rosetta Code: D category]<br />
* [https://p0nce.github.io/d-idioms/ Idioms for D]<br />
<br />
== Specific Language ==<br />
<br />
* [http://dlang.org/ctod.html Programming in D for C Programmers]<br />
* [https://p0nce.github.io/d-idioms/#Porting-from-C-gotchas Porting from C gotchas]<br />
* [http://dlang.org/cpptod.html Programming in D for C++ Programmers]<br />
* [https://p0nce.github.io/d-idioms/#How-does-D-improve-on-C++17? How does D improve on C++ 17?]<br />
* [[Programming in D for C++ Programmers | C++]]<br />
* [[Programming in D for CSharp Programmers | C#]]<br />
* [[Programming in D for Delphi Programmers | Delphi or Pascal]]<br />
* [[Programming in D for Eiffel Programmers | Eiffel]]<br />
* [[Programming in D for Java Programmers | Java]]<br />
* [[Programming in D for Python Programmers | Python]]<br />
* [[Programming in D for Ruby Programmers | Ruby]]<br />
* [[Programming in D for Basic Programmers | Basic]]<br />
* [http://beza1e1.tuxen.de/stuff/FunctionalD.pdf Functional Languages]<br />
<br />
== Porting ==<br />
If you are interested in converting your code to D start by looking at the [[PortingOverview | Porting Overview]].<br />
<br />
Walter Bright has observed that when you first start writing D you tend to write it like the existing languages you are familiar with. In time you may choose to make use of the higher-level features of D that make writing D code a pleasure rather than a chore. But programming is about using a tool to solve a problem, and there is no dogma in D that there is only one way to do it. Very often you don't need to make use of advanced D features like metaprogramming, templates, and compiler time function execution to achieve a useful result quickly.<br />
<br />
Converting C code with explicit memory allocation and resource management? Make use of the scope(exit) feature to automatically free pointers and close files when your function or code block finishes (whether successfully or on error).<br />
<br />
From Adam Ruppe "D this Week"<br />
<blockquote><br />
Don't be afraid to do things the C way.<br />
<br />
I've observed a lot of D programmers worrying about doing things the "D way", including asking how to convert working C standard library code to D or lamenting the lack of a D library to replace some C code.<br />
<br />
There's value in this: D can do a lot of things C can't. The "D way" can often be safer, less bug-prone, more beautiful, or more efficient than C code and libraries.<br />
<br />
However, D is also a language for practical programmers and sometimes code that works today is more important than ideal code that might be written at some point later. This is why D gives full access to C facilities, so you can use them!<br />
<br />
If you know how to do something with scanf, you can still use it in D, even while mixing with std.stdio's functions. Simply import core.stdc.stdio; and you can use all your familiar C functions.<br />
<br />
Want to do memory management the C way? Simply import core.stdc.stdlib; and use malloc and free. Combined with D features like scope(exit) to help with freeing and struct semantics to manage ownership you can rest assured that using D will offer advantages over C where needed, without tying your hands when you want to do things the old, familiar way.<br />
<br />
If you have a third-party C API, you don't have to reimplement that functionality in D to take advantage of it (though, there are times you do want to, to leverage D's unique offers). You can simple write an extern(C) function declaration and call the function directly from D, or you can also use dynamic library loading in D, the same way as in C, e.g. with dlopen or LoadLibrary.<br />
<br />
If you know how to solve a problem with pointers, structs, loops, and procedures as in C, you can use them in D too. Yes, the standard library offers a number of excellent range-based algorithms and help for coding in a functional programming style, and learning these is worth the investment. But, if you already know how to do it in C and need it done now, don't let Phobos' allure be an enemy to your productivity. You can still do your work with familiar language features.<br />
<br />
Moving to D opens up a whole new world of superior programming. But it doesn't shut you out of the old world. D aims to be a practical language for working programmers - remember that as you work with it. The new features will still be there to try tomorrow.<br />
<br />
</blockquote><br />
<br />
== Related ==<br />
* [[Language_Specification | Language Specification]]<br />
* [[D_Tutorial/Starting_With_D | Setting up an environment to compile programs]]<br />
* [[Neighbourhood | Seeking help using D]]<br />
* [[Development_with_D | Development with D]]<br />
* [[FAQ | Frequently Asked Questions]]<br />
<br />
[[Category:Languages versus D]]</div>Laeethhttps://wiki.dlang.org/?title=Coming_From&diff=6470Coming From2015-08-19T20:30:50Z<p>Laeeth: /* Specific Language */</p>
<hr />
<div>When coming from another language it is good to find out where D stands in relation to it. There is the [[DigitalMars:d/2.0/comparison.html | feature list]] which states if a feature exists or not and possibly an explanation. For a side-by-side comparison of many languages: [[Languages_Versus_D | Languages vs D]] or you can look at code snippets of from [http://rosettacode.org/wiki/Category:D Rosetta Code].<br />
<br />
A very superficial way to find out the popularity of D in relation to other languages can is at the [http://www.tiobe.com/tiobe_index/index.htm Tiobe Index] website.<br />
<br />
For information about syntactical differences or gotchas when coming from another language choose your language below.<br />
<br />
<br />
== General Comparison ==<br />
* [[Languages Versus D | Languages vs. D]]<br />
* [http://en.wikibooks.org/wiki/D_Transition_Guide D Transition Guide]<br />
* [http://dlang.org/comparison.html Feature List]<br />
* [http://rosettacode.org/wiki/Category:D Rosetta Code: D category]<br />
* [https://p0nce.github.io/d-idioms/ Idioms for D]<br />
<br />
== Specific Language ==<br />
<br />
* [http://dlang.org/ctod.html Programming in D for C Programmers]<br />
* [https://p0nce.github.io/d-idioms/#Porting-from-C-gotchas Porting from C gotchas]<br />
* [http://dlang.org/cpptod.html Programming in D for C++ Programmers]<br />
* [https://p0nce.github.io/d-idioms/#How-does-D-improve-on-C++17? How does D improve on C++ 17?]<br />
* [[Programming in D for C++ Programmers | C++]]<br />
* [[Programming in D for CSharp Programmers | C#]]<br />
* [[Programming in D for Delphi Programmers | Delphi or Pascal]]<br />
* [[Programming in D for Eiffel Programmers | Eiffel]]<br />
* [[Programming in D for Java Programmers | Java]]<br />
* [[Programming in D for Python Programmers | Python]]<br />
* [[Programming in D for Ruby Programmers | Ruby]]<br />
* [[Programming in D for Basic Programmers | Basic]]<br />
* [[http://beza1e1.tuxen.de/stuff/FunctionalD.pdf | FunctionalLanguages]]<br />
<br />
== Porting ==<br />
If you are interested in converting your code to D start by looking at the [[PortingOverview | Porting Overview]].<br />
<br />
Walter Bright has observed that when you first start writing D you tend to write it like the existing languages you are familiar with. In time you may choose to make use of the higher-level features of D that make writing D code a pleasure rather than a chore. But programming is about using a tool to solve a problem, and there is no dogma in D that there is only one way to do it. Very often you don't need to make use of advanced D features like metaprogramming, templates, and compiler time function execution to achieve a useful result quickly.<br />
<br />
Converting C code with explicit memory allocation and resource management? Make use of the scope(exit) feature to automatically free pointers and close files when your function or code block finishes (whether successfully or on error).<br />
<br />
From Adam Ruppe "D this Week"<br />
<blockquote><br />
Don't be afraid to do things the C way.<br />
<br />
I've observed a lot of D programmers worrying about doing things the "D way", including asking how to convert working C standard library code to D or lamenting the lack of a D library to replace some C code.<br />
<br />
There's value in this: D can do a lot of things C can't. The "D way" can often be safer, less bug-prone, more beautiful, or more efficient than C code and libraries.<br />
<br />
However, D is also a language for practical programmers and sometimes code that works today is more important than ideal code that might be written at some point later. This is why D gives full access to C facilities, so you can use them!<br />
<br />
If you know how to do something with scanf, you can still use it in D, even while mixing with std.stdio's functions. Simply import core.stdc.stdio; and you can use all your familiar C functions.<br />
<br />
Want to do memory management the C way? Simply import core.stdc.stdlib; and use malloc and free. Combined with D features like scope(exit) to help with freeing and struct semantics to manage ownership you can rest assured that using D will offer advantages over C where needed, without tying your hands when you want to do things the old, familiar way.<br />
<br />
If you have a third-party C API, you don't have to reimplement that functionality in D to take advantage of it (though, there are times you do want to, to leverage D's unique offers). You can simple write an extern(C) function declaration and call the function directly from D, or you can also use dynamic library loading in D, the same way as in C, e.g. with dlopen or LoadLibrary.<br />
<br />
If you know how to solve a problem with pointers, structs, loops, and procedures as in C, you can use them in D too. Yes, the standard library offers a number of excellent range-based algorithms and help for coding in a functional programming style, and learning these is worth the investment. But, if you already know how to do it in C and need it done now, don't let Phobos' allure be an enemy to your productivity. You can still do your work with familiar language features.<br />
<br />
Moving to D opens up a whole new world of superior programming. But it doesn't shut you out of the old world. D aims to be a practical language for working programmers - remember that as you work with it. The new features will still be there to try tomorrow.<br />
<br />
</blockquote><br />
<br />
== Related ==<br />
* [[Language_Specification | Language Specification]]<br />
* [[D_Tutorial/Starting_With_D | Setting up an environment to compile programs]]<br />
* [[Neighbourhood | Seeking help using D]]<br />
* [[Development_with_D | Development with D]]<br />
* [[FAQ | Frequently Asked Questions]]<br />
<br />
[[Category:Languages versus D]]</div>Laeethhttps://wiki.dlang.org/?title=Coming_From&diff=6469Coming From2015-08-19T20:30:09Z<p>Laeeth: /* Specific Language */</p>
<hr />
<div>When coming from another language it is good to find out where D stands in relation to it. There is the [[DigitalMars:d/2.0/comparison.html | feature list]] which states if a feature exists or not and possibly an explanation. For a side-by-side comparison of many languages: [[Languages_Versus_D | Languages vs D]] or you can look at code snippets of from [http://rosettacode.org/wiki/Category:D Rosetta Code].<br />
<br />
A very superficial way to find out the popularity of D in relation to other languages can is at the [http://www.tiobe.com/tiobe_index/index.htm Tiobe Index] website.<br />
<br />
For information about syntactical differences or gotchas when coming from another language choose your language below.<br />
<br />
<br />
== General Comparison ==<br />
* [[Languages Versus D | Languages vs. D]]<br />
* [http://en.wikibooks.org/wiki/D_Transition_Guide D Transition Guide]<br />
* [http://dlang.org/comparison.html Feature List]<br />
* [http://rosettacode.org/wiki/Category:D Rosetta Code: D category]<br />
* [https://p0nce.github.io/d-idioms/ Idioms for D]<br />
<br />
== Specific Language ==<br />
<br />
* [http://dlang.org/ctod.html Programming in D for C Programmers]<br />
* [https://p0nce.github.io/d-idioms/#Porting-from-C-gotchas Porting from C gotchas]<br />
* [http://dlang.org/cpptod.html Programming in D for C++ Programmers]<br />
* [https://p0nce.github.io/d-idioms/#How-does-D-improve-on-C++17? How does D improve on C++ 17?]<br />
* [[Programming in D for C++ Programmers | C++]]<br />
* [[Programming in D for CSharp Programmers | C#]]<br />
* [[Programming in D for Delphi Programmers | Delphi or Pascal]]<br />
* [[Programming in D for Eiffel Programmers | Eiffel]]<br />
* [[Programming in D for Java Programmers | Java]]<br />
* [[Programming in D for Python Programmers | Python]]<br />
* [[Programming in D for Ruby Programmers | Ruby]]<br />
* [[Programming in D for Basic Programmers | Basic]]<br />
* [[Programming in D for functional programmers | ComingFromFunctional]]<br />
<br />
== Porting ==<br />
If you are interested in converting your code to D start by looking at the [[PortingOverview | Porting Overview]].<br />
<br />
Walter Bright has observed that when you first start writing D you tend to write it like the existing languages you are familiar with. In time you may choose to make use of the higher-level features of D that make writing D code a pleasure rather than a chore. But programming is about using a tool to solve a problem, and there is no dogma in D that there is only one way to do it. Very often you don't need to make use of advanced D features like metaprogramming, templates, and compiler time function execution to achieve a useful result quickly.<br />
<br />
Converting C code with explicit memory allocation and resource management? Make use of the scope(exit) feature to automatically free pointers and close files when your function or code block finishes (whether successfully or on error).<br />
<br />
From Adam Ruppe "D this Week"<br />
<blockquote><br />
Don't be afraid to do things the C way.<br />
<br />
I've observed a lot of D programmers worrying about doing things the "D way", including asking how to convert working C standard library code to D or lamenting the lack of a D library to replace some C code.<br />
<br />
There's value in this: D can do a lot of things C can't. The "D way" can often be safer, less bug-prone, more beautiful, or more efficient than C code and libraries.<br />
<br />
However, D is also a language for practical programmers and sometimes code that works today is more important than ideal code that might be written at some point later. This is why D gives full access to C facilities, so you can use them!<br />
<br />
If you know how to do something with scanf, you can still use it in D, even while mixing with std.stdio's functions. Simply import core.stdc.stdio; and you can use all your familiar C functions.<br />
<br />
Want to do memory management the C way? Simply import core.stdc.stdlib; and use malloc and free. Combined with D features like scope(exit) to help with freeing and struct semantics to manage ownership you can rest assured that using D will offer advantages over C where needed, without tying your hands when you want to do things the old, familiar way.<br />
<br />
If you have a third-party C API, you don't have to reimplement that functionality in D to take advantage of it (though, there are times you do want to, to leverage D's unique offers). You can simple write an extern(C) function declaration and call the function directly from D, or you can also use dynamic library loading in D, the same way as in C, e.g. with dlopen or LoadLibrary.<br />
<br />
If you know how to solve a problem with pointers, structs, loops, and procedures as in C, you can use them in D too. Yes, the standard library offers a number of excellent range-based algorithms and help for coding in a functional programming style, and learning these is worth the investment. But, if you already know how to do it in C and need it done now, don't let Phobos' allure be an enemy to your productivity. You can still do your work with familiar language features.<br />
<br />
Moving to D opens up a whole new world of superior programming. But it doesn't shut you out of the old world. D aims to be a practical language for working programmers - remember that as you work with it. The new features will still be there to try tomorrow.<br />
<br />
</blockquote><br />
<br />
== Related ==<br />
* [[Language_Specification | Language Specification]]<br />
* [[D_Tutorial/Starting_With_D | Setting up an environment to compile programs]]<br />
* [[Neighbourhood | Seeking help using D]]<br />
* [[Development_with_D | Development with D]]<br />
* [[FAQ | Frequently Asked Questions]]<br />
<br />
[[Category:Languages versus D]]</div>Laeethhttps://wiki.dlang.org/?title=Coming_From&diff=6468Coming From2015-08-19T20:29:54Z<p>Laeeth: /* Specific Language */</p>
<hr />
<div>When coming from another language it is good to find out where D stands in relation to it. There is the [[DigitalMars:d/2.0/comparison.html | feature list]] which states if a feature exists or not and possibly an explanation. For a side-by-side comparison of many languages: [[Languages_Versus_D | Languages vs D]] or you can look at code snippets of from [http://rosettacode.org/wiki/Category:D Rosetta Code].<br />
<br />
A very superficial way to find out the popularity of D in relation to other languages can is at the [http://www.tiobe.com/tiobe_index/index.htm Tiobe Index] website.<br />
<br />
For information about syntactical differences or gotchas when coming from another language choose your language below.<br />
<br />
<br />
== General Comparison ==<br />
* [[Languages Versus D | Languages vs. D]]<br />
* [http://en.wikibooks.org/wiki/D_Transition_Guide D Transition Guide]<br />
* [http://dlang.org/comparison.html Feature List]<br />
* [http://rosettacode.org/wiki/Category:D Rosetta Code: D category]<br />
* [https://p0nce.github.io/d-idioms/ Idioms for D]<br />
<br />
== Specific Language ==<br />
<br />
* [http://dlang.org/ctod.html Programming in D for C Programmers]<br />
* [https://p0nce.github.io/d-idioms/#Porting-from-C-gotchas Porting from C gotchas]<br />
* [http://dlang.org/cpptod.html Programming in D for C++ Programmers]<br />
* [https://p0nce.github.io/d-idioms/#How-does-D-improve-on-C++17? How does D improve on C++ 17?]<br />
* [[Programming in D for C++ Programmers | C++]]<br />
* [[Programming in D for CSharp Programmers | C#]]<br />
* [[Programming in D for Delphi Programmers | Delphi or Pascal]]<br />
* [[Programming in D for Eiffel Programmers | Eiffel]]<br />
* [[Programming in D for Java Programmers | Java]]<br />
* [[Programming in D for Python Programmers | Python]]<br />
* [[Programming in D for Ruby Programmers | Ruby]]<br />
* [[Programming in D for Basic Programmers | Basic]]<br />
* [[Programming in D for functional programmers | ComingFromFunctional<br />
<br />
== Porting ==<br />
If you are interested in converting your code to D start by looking at the [[PortingOverview | Porting Overview]].<br />
<br />
Walter Bright has observed that when you first start writing D you tend to write it like the existing languages you are familiar with. In time you may choose to make use of the higher-level features of D that make writing D code a pleasure rather than a chore. But programming is about using a tool to solve a problem, and there is no dogma in D that there is only one way to do it. Very often you don't need to make use of advanced D features like metaprogramming, templates, and compiler time function execution to achieve a useful result quickly.<br />
<br />
Converting C code with explicit memory allocation and resource management? Make use of the scope(exit) feature to automatically free pointers and close files when your function or code block finishes (whether successfully or on error).<br />
<br />
From Adam Ruppe "D this Week"<br />
<blockquote><br />
Don't be afraid to do things the C way.<br />
<br />
I've observed a lot of D programmers worrying about doing things the "D way", including asking how to convert working C standard library code to D or lamenting the lack of a D library to replace some C code.<br />
<br />
There's value in this: D can do a lot of things C can't. The "D way" can often be safer, less bug-prone, more beautiful, or more efficient than C code and libraries.<br />
<br />
However, D is also a language for practical programmers and sometimes code that works today is more important than ideal code that might be written at some point later. This is why D gives full access to C facilities, so you can use them!<br />
<br />
If you know how to do something with scanf, you can still use it in D, even while mixing with std.stdio's functions. Simply import core.stdc.stdio; and you can use all your familiar C functions.<br />
<br />
Want to do memory management the C way? Simply import core.stdc.stdlib; and use malloc and free. Combined with D features like scope(exit) to help with freeing and struct semantics to manage ownership you can rest assured that using D will offer advantages over C where needed, without tying your hands when you want to do things the old, familiar way.<br />
<br />
If you have a third-party C API, you don't have to reimplement that functionality in D to take advantage of it (though, there are times you do want to, to leverage D's unique offers). You can simple write an extern(C) function declaration and call the function directly from D, or you can also use dynamic library loading in D, the same way as in C, e.g. with dlopen or LoadLibrary.<br />
<br />
If you know how to solve a problem with pointers, structs, loops, and procedures as in C, you can use them in D too. Yes, the standard library offers a number of excellent range-based algorithms and help for coding in a functional programming style, and learning these is worth the investment. But, if you already know how to do it in C and need it done now, don't let Phobos' allure be an enemy to your productivity. You can still do your work with familiar language features.<br />
<br />
Moving to D opens up a whole new world of superior programming. But it doesn't shut you out of the old world. D aims to be a practical language for working programmers - remember that as you work with it. The new features will still be there to try tomorrow.<br />
<br />
</blockquote><br />
<br />
== Related ==<br />
* [[Language_Specification | Language Specification]]<br />
* [[D_Tutorial/Starting_With_D | Setting up an environment to compile programs]]<br />
* [[Neighbourhood | Seeking help using D]]<br />
* [[Development_with_D | Development with D]]<br />
* [[FAQ | Frequently Asked Questions]]<br />
<br />
[[Category:Languages versus D]]</div>Laeethhttps://wiki.dlang.org/?title=How_You_Can_Help&diff=6460How You Can Help2015-08-19T07:56:48Z<p>Laeeth: </p>
<hr />
<div>== Documentation ==<br />
<br />
* std.algorithm - see forum<br />
<br />
== Wiki ==<br />
<br />
* We need [http://wiki.dlang.org/Coming_From D as a second language] sections completed <br />
* C and C++ need updating <br />
* we need more examples of how to shift idiom to speak fluent D<br />
* the Python page is started but needs fleshing out<br />
* and most of the other sections are empty.<br />
<br />
<blockquote><br />
One note about Walter's older C/C++ transition articles. They have good information on transition technicalities (e.g. "how do I do this thing in D that I used to do in C++?") but not a lot about the changes in coding style - making object copying not arbitrarily expensive, choosing struct vs. class, preferring pipelines and lazy to eager computation, etc. From what I see some folks come from C++, write their first D program in a stilted C++ idiom, and are left with the impression that the work is not worth the trouble.<br />
<br />
Andrei<br />
</blockquote><br />
<br />
<br />
== how to better promote your own D projects ==<br />
<br />
<blockquote><br />
I hate the movie "Field of Dreams" where they push the idiotic idea of "Build it and they will come." No, they won't. There's a blizzard of stuff competing for their attention out there, why should they invest the time looking at your stuff? You need to tell them why!<br />
<br />
Here's the frustrating typical pattern I've seen here for years:<br />
<br />
1. spend hundreds if not thousands of hours developing something really cool<br />
2. spend 2 minutes posting a link to the repository on D.announce<br />
3. someone posts it to reddit. Ignore it<br />
4. get frustrated that nobody looks at it<br />
5. get bitter and quit<br />
<br />
Here's the pattern that works a lot better:<br />
<br />
1. spend hundreds if not thousands of hours developing something really cool<br />
2. spend 10 minutes writing the announcement to D.announce. Be sure to include:<br />
who, what, where, when, why, and how<br />
3. someone posts it to reddit<br />
4. post the who, what, where, when, why and how on reddit AS SOON AS POSSIBLE after the reddit link appears. Stuff on reddit has a VERY SHORT shelf life. If it doesn't get action within a couple hours, it fades into oblivion. Identify yourself as the author, say AMA. The first one to post a comment tends to spark and set the tone for the discussion.<br />
5. check back on reddit once an hour or so for the next day, answer questions<br />
6. *****<br />
7. profit!<br />
<br />
Walter Bright<br />
</blockquote></div>Laeethhttps://wiki.dlang.org/?title=Transforming_slice_of_structs_into_struct_of_slices&diff=6343Transforming slice of structs into struct of slices2015-07-07T08:47:00Z<p>Laeeth: </p>
<hr />
<div>=== {{{A simple application of metaprogramming: turning an array/slice of structs into a struct of arrays/slices|}}} ===<br />
<br />
In some applications it is a common requirement to transform an array/slice of structs into a struct of arrays/slices. This may be for cache efficiency (see data-driven design) or in order to present data to an API that requires a different format than the standard internal representation of client code. If the struct design is fixed then this can be done in a few lines of code, but in cases where the struct design may change over time, or the struct itself is constructed via metaprogramming or CTFE then it may be helpful to create the new struct definition in code.<br />
<br />
This is not intended to be a complete or definitive solution to the problem, but here are three approaches presented by experienced users on the D forum. I hope that this explanation will be filled out by others in time.<br />
<br />
http://forum.dlang.org/post/mzpwjelelctwvxzbsijh@forum.dlang.org<br />
<br />
Array of structs<br />
<code><br />
<nowiki><br />
struct PriceBar<br />
{<br />
DateTime date;<br />
double open;<br />
double high;<br />
double low;<br />
double close;<br />
}<br />
<br />
PriceBar[] priceBar;<br />
</nowiki><br />
</code><br />
<br />
Desired - struct of arrays:<br />
<br />
<code><br />
<nowiki><br />
struct PriceBars<br />
{<br />
DateTime[] dates;<br />
double[] opens;<br />
double[] highs;<br />
double[] lows;<br />
double[] closes;<br />
}<br />
</nowiki><br />
</code><br />
<br />
First solution - from Economic Modeling, a Moscow, Idaho (USA) based company that uses D to support their big data analysis of economic fundamental developments. Code from https://github.com/economicmodeling/soa:<br />
<code><br />
<nowiki><br />
<br />
struct SOA(A : T[], T) if (is(T == struct))<br />
{<br />
mixin CommonImpl;<br />
<br />
private static string getMemberDecls() @property pure<br />
{<br />
string ret;<br />
foreach (name; Fields)<br />
ret ~= `typeof(U.`~name~`)[] `~name~`;`;<br />
return ret;<br />
}<br />
<br />
// Actual storage<br />
mixin(getMemberDecls);<br />
<br />
/// Array lengths<br />
auto length() @property const<br />
{<br />
// We expect all arrays to have the same length<br />
static enum FirstMember = Fields[0];<br />
return __traits(getMember, this, FirstMember).length;<br />
}<br />
<br />
///<br />
void length(size_t newLen) @property<br />
{<br />
auto oldLen = length;<br />
foreach (Name; Fields)<br />
{<br />
__traits(getMember, this, Name).length = newLen;<br />
if (oldLen < newLen)<br />
{<br />
// initialize new values<br />
foreach (ref e; __traits(getMember, this, Name)[oldLen .. newLen])<br />
e = __traits(getMember, initValues, Name);<br />
}<br />
}<br />
}<br />
}<br />
</nowiki><br />
</code><br />
<br />
Solution from John Colvin, organizer of the Scientific Computing portal for D, DlangScience:<br />
<code><br />
<nowiki><br />
<br />
import std.typetuple;<br />
import std.typecons;<br />
import std.traits;<br />
<br />
struct Pack(TL...)<br />
{<br />
alias expand = TL;<br />
enum length = TL.length;<br />
@disable this();<br />
}<br />
<br />
enum isPack(T) = is(T == Pack!Args, Args...);<br />
<br />
template EqualLength(Packs ...)<br />
if(allSatisfy!(isPack, Packs) && Packs.length != 0)<br />
{<br />
static if (Packs.length == 1) enum EqualLength = true;<br />
else<br />
{<br />
template EqualLengthTo(size_t len)<br />
{<br />
enum EqualLengthTo(T) = len == T.length;<br />
}<br />
enum EqualLength = Filter!(EqualLengthTo!(Packs[0].length), Packs[1 .. $]).length == Packs.length - 1;<br />
}<br />
}<br />
<br />
template Alias(alias a)<br />
{<br />
static if (__traits(compiles, { alias x = a; }))<br />
alias Alias = a;<br />
else static if (__traits(compiles, { enum x = a; }))<br />
enum Alias = a;<br />
else<br />
static assert(0, "Cannot alias " ~ a.stringof);<br />
}<br />
<br />
template Alias(a...)<br />
{<br />
alias Alias = a;<br />
}<br />
<br />
template Head(Pack)<br />
if(isPack!Pack)<br />
{<br />
alias Head = Alias!(Pack.expand[0]);<br />
}<br />
<br />
template Tail(Pack)<br />
if(isPack!Pack)<br />
{<br />
alias Tail = Pack!(Pack.expand[1 .. $]);<br />
}<br />
<br />
template TemplAppender(string suffix)<br />
{<br />
enum TemplAppender(string s) = s ~ suffix;<br />
}<br />
<br />
template RoundRobin(Args ...)<br />
if(Args.length >= 2 && allSatisfy!(isPack, Args) && EqualLength!Args)<br />
{<br />
static if (Args[0].length == 0)<br />
alias RoundRobin = TypeTuple!();<br />
else<br />
alias RoundRobin = TypeTuple!(staticMap!(Head, Args), RoundRobin!(staticMap!(Tail, Args)));<br />
}<br />
<br />
alias SliceOf(T) = T[];<br />
<br />
alias TransformMembers(alias TypeTransform, alias NameTransform, T) = Tuple!(<br />
RoundRobin!(Pack!(staticMap!(TypeTransform, FieldTypeTuple!T)),<br />
Pack!(staticMap!(NameTransform, FieldNameTuple!T))));<br />
<br />
import std.datetime;<br />
<br />
struct PriceBar<br />
{<br />
DateTime date;<br />
double open;<br />
double high;<br />
double low;<br />
double close;<br />
}<br />
<br />
alias PriceBars = TransformMembers!(SliceOf, TemplAppender!"s", PriceBar);<br />
</nowiki><br />
</code><br />
<br />
<br />
Solution from Artur Skawina on the forum:<br />
The simplest solution is something like the following. You will need to adjust to your requirements (eg drop the '"~LENGTH.stringof~"' part to get a struct-of-slices, which is what your example above shows).<br />
<code><br />
<nowiki><br />
<br />
<br />
<br />
template SOA(Struct, size_t LENGTH) {<br />
struct SOA {<br />
enum MEMBERNAME(size_t N) = __traits(identifier, Struct.tupleof[N]);<br />
<br />
static __gentypes() {<br />
string ret;<br />
foreach (I, TYPE; typeof(Struct.tupleof))<br />
ret ~= "align(16) typeof(Struct.tupleof["~I.stringof~"])["~LENGTH.stringof~"] "<br />
~ MEMBERNAME!I ~ ";";<br />
return ret;<br />
}<br />
mixin(__gentypes());<br />
}<br />
}<br />
<br />
alias PriceBars = SOA!(PriceBar, 8);<br />
</nowiki><br />
</code></div>Laeethhttps://wiki.dlang.org/?title=Transforming_slice_of_structs_into_struct_of_slices&diff=6340Transforming slice of structs into struct of slices2015-07-05T00:07:03Z<p>Laeeth: Created page with "=== {{{A simple application of metaprogramming: turning an array/slice of structs into a struct of arrays/slices|}}} === In some applications it is a common requirement to tr..."</p>
<hr />
<div>=== {{{A simple application of metaprogramming: turning an array/slice of structs into a struct of arrays/slices|}}} ===<br />
<br />
In some applications it is a common requirement to transform an array/slice of structs into a struct of arrays/slices. This may be for cache efficiency (see data-driven design) or in order to present data to an API that requires a different format than the standard internal representation of client code. If the struct design is fixed then this can be done in a few lines of code, but in cases where the struct design may change over time, or the struct itself is constructed via metaprogramming or CTFE then it may be helpful to create the new struct definition in code.<br />
<br />
This is not intended to be a complete or definitive solution to the problem, but here are three approaches presented by experienced users on the D forum. I hope that this explanation will be filled out by others in time.<br />
<br />
http://forum.dlang.org/post/mzpwjelelctwvxzbsijh@forum.dlang.org<br />
<br />
<code>Array of structs<br />
<nowiki><br />
struct PriceBar<br />
{<br />
DateTime date;<br />
double open;<br />
double high;<br />
double low;<br />
double close;<br />
}<br />
<br />
PriceBar[] priceBar;<br />
<br />
Desired - struct of arrays:<br />
<br />
struct PriceBars<br />
{<br />
DateTime[] dates;<br />
double[] opens;<br />
double[] highs;<br />
double[] lows;<br />
double[] closes;<br />
}<br />
</nowiki><br />
</code><br />
<br />
<code>First solution - from Economic Modeling, a Moscow, Idaho (USA) based company that uses D to support their big data analysis of economic fundamental developments:<br />
<nowiki><br />
https://github.com/economicmodeling/soa<br />
<br />
<br />
struct SOA(A : T[], T) if (is(T == struct))<br />
{<br />
mixin CommonImpl;<br />
<br />
private static string getMemberDecls() @property pure<br />
{<br />
string ret;<br />
foreach (name; Fields)<br />
ret ~= `typeof(U.`~name~`)[] `~name~`;`;<br />
return ret;<br />
}<br />
<br />
// Actual storage<br />
mixin(getMemberDecls);<br />
<br />
/// Array lengths<br />
auto length() @property const<br />
{<br />
// We expect all arrays to have the same length<br />
static enum FirstMember = Fields[0];<br />
return __traits(getMember, this, FirstMember).length;<br />
}<br />
<br />
///<br />
void length(size_t newLen) @property<br />
{<br />
auto oldLen = length;<br />
foreach (Name; Fields)<br />
{<br />
__traits(getMember, this, Name).length = newLen;<br />
if (oldLen < newLen)<br />
{<br />
// initialize new values<br />
foreach (ref e; __traits(getMember, this, Name)[oldLen .. newLen])<br />
e = __traits(getMember, initValues, Name);<br />
}<br />
}<br />
}<br />
}<br />
</nowiki><br />
</code><br />
<br />
<code>Solution from John Colvin, organizer of the Scientific Computing portal for D:<br />
<nowiki><br />
<br />
import std.typetuple;<br />
import std.typecons;<br />
import std.traits;<br />
<br />
struct Pack(TL...)<br />
{<br />
alias expand = TL;<br />
enum length = TL.length;<br />
@disable this();<br />
}<br />
<br />
enum isPack(T) = is(T == Pack!Args, Args...);<br />
<br />
template EqualLength(Packs ...)<br />
if(allSatisfy!(isPack, Packs) && Packs.length != 0)<br />
{<br />
static if (Packs.length == 1) enum EqualLength = true;<br />
else<br />
{<br />
template EqualLengthTo(size_t len)<br />
{<br />
enum EqualLengthTo(T) = len == T.length;<br />
}<br />
enum EqualLength = Filter!(EqualLengthTo!(Packs[0].length), Packs[1 .. $]).length == Packs.length - 1;<br />
}<br />
}<br />
<br />
template Alias(alias a)<br />
{<br />
static if (__traits(compiles, { alias x = a; }))<br />
alias Alias = a;<br />
else static if (__traits(compiles, { enum x = a; }))<br />
enum Alias = a;<br />
else<br />
static assert(0, "Cannot alias " ~ a.stringof);<br />
}<br />
<br />
template Alias(a...)<br />
{<br />
alias Alias = a;<br />
}<br />
<br />
template Head(Pack)<br />
if(isPack!Pack)<br />
{<br />
alias Head = Alias!(Pack.expand[0]);<br />
}<br />
<br />
template Tail(Pack)<br />
if(isPack!Pack)<br />
{<br />
alias Tail = Pack!(Pack.expand[1 .. $]);<br />
}<br />
<br />
template TemplAppender(string suffix)<br />
{<br />
enum TemplAppender(string s) = s ~ suffix;<br />
}<br />
<br />
template RoundRobin(Args ...)<br />
if(Args.length >= 2 && allSatisfy!(isPack, Args) && EqualLength!Args)<br />
{<br />
static if (Args[0].length == 0)<br />
alias RoundRobin = TypeTuple!();<br />
else<br />
alias RoundRobin = TypeTuple!(staticMap!(Head, Args), RoundRobin!(staticMap!(Tail, Args)));<br />
}<br />
<br />
alias SliceOf(T) = T[];<br />
<br />
alias TransformMembers(alias TypeTransform, alias NameTransform, T) = Tuple!(<br />
RoundRobin!(Pack!(staticMap!(TypeTransform, FieldTypeTuple!PriceBar)),<br />
Pack!(staticMap!(NameTransform, FieldNameTuple!PriceBar))));<br />
<br />
import std.datetime;<br />
<br />
struct PriceBar<br />
{<br />
DateTime date;<br />
double open;<br />
double high;<br />
double low;<br />
double close;<br />
}<br />
<br />
alias PriceBars = TransformMembers!(SliceOf, TemplAppender!"s", PriceBar);<br />
</nowiki><br />
</code><br />
<br />
<code>Solution from Artur Skawina on the forum:<br />
The simplest solution is something like the following. You will need to adjust to your requirements (eg drop the '"~LENGTH.stringof~"' part to get a struct-of-slices, which is what your example above shows).<br />
<nowiki><br />
<br />
<br />
<br />
template SOA(Struct, size_t LENGTH) {<br />
struct SOA {<br />
enum MEMBERNAME(size_t N) = __traits(identifier, Struct.tupleof[N]);<br />
<br />
static __gentypes() {<br />
string ret;<br />
foreach (I, TYPE; typeof(Struct.tupleof))<br />
ret ~= "align(16) typeof(Struct.tupleof["~I.stringof~"])["~LENGTH.stringof~"] "<br />
~ MEMBERNAME!I ~ ";";<br />
return ret;<br />
}<br />
mixin(__gentypes());<br />
}<br />
}<br />
<br />
alias PriceBars = SOA!(PriceBar, 8);<br />
</nowiki><br />
</code></div>Laeethhttps://wiki.dlang.org/?title=Articles&diff=6339Articles2015-07-05T00:06:40Z<p>Laeeth: </p>
<hr />
<div>{{Article Group<br />
| Name = Beginning<br />
| Articles =<br />
<br />
{{Article<br />
| name = Dispelling Common D Myths<br />
| url = http://semitwist.com/articles/article/view/dispelling-common-d-myths<br />
| author = Nicholas Sabalausky<br />
}}<br />
<br />
{{Article<br />
| name = "D"iving Into the D Programming Language<br />
| url = http://www.informit.com/articles/article.aspx?p=1381876<br />
| author = Andrei Alexandrescu<br />
}}<br />
<br />
{{Article<br />
| name = D: A Newbie-Oriented Tutorial<br />
| url = http://compsci.ca/v3/viewtopic.php?t=9518<br />
| author = Andrei Alexandrescu<br />
}}<br />
<br />
{{Article<br />
| name = Getting Started with the D Programming Language<br />
| url = http://www.gamedev.net/page/resources/_/technical/general-programming/getting-started-with-the-d-programming-language-r3306<br />
| author = Mike "Aldacron" Parker<br />
}}<br />
<br />
}}<br />
<br />
<br />
{{Article Group<br />
| Name = General<br />
| Articles =<br />
<br />
{{Article<br />
| name = Functional image processing in D<br />
| url = http://blog.thecybershadow.net/2014/03/21/functional-image-processing-in-d/<br />
| author = Vladimir Panteleev<br />
| published = Mar 21 2014<br />
}}<br />
<br />
{{Article<br />
| name = Implementing Pure Functions<br />
| url = http://www.drdobbs.com/tools/implementing-pure-functions/230700070#<br />
| author = Walter Bright<br />
| published = June 15, 2011<br />
}}<br />
<br />
{{Article<br />
| name = NaNs Just Don't Get No Respect<br />
| url = http://www.drdobbs.com/cpp/nans-just-dont-get-no-respect/240005723<br />
| author = Walter Bright<br />
| published = Aug 16 2012<br />
}}<br />
<br />
{{Article<br />
| name = Voldemort Types In D<br />
| url = http://www.drdobbs.com/cpp/voldemort-types-in-d/232901591<br />
| author = Walter Bright<br />
| published = May 07 2012<br />
}}<br />
<br />
{{Article<br />
| name = Uniform Function Call Syntax<br />
| url = http://www.drdobbs.com/cpp/uniform-function-call-syntax/232700394<br />
| author = Walter Bright<br />
| published = Mar 28 2012<br />
}}<br />
<br />
{{Article<br />
| name = Real World Comparison, GC vs. Manual Memory Management<br />
| url = http://3d.benjamin-thaut.de/?p=20<br />
| author = Benjamin Thaut<br />
}}<br />
<br />
{{Article<br />
| name = Increasing Compiler Speed by Over 75%<br />
| url = http://www.drdobbs.com/cpp/increasing-compiler-speed-by-over-75/240158941#<br />
| author = Walter Bright<br />
| published = July 25 2013<br />
}}<br />
<br />
{{Article<br />
| name = Memory Management<br />
}}<br />
<br />
{{Article<br />
| name = Useful Workarounds<br />
}}<br />
<br />
}}<br />
<br />
<br />
{{Article Group<br />
| Name = Features<br />
| Articles =<br />
<br />
{{Article<br />
| name = Introduction to D templates<br />
}}<br />
<br />
{{Article<br />
| name = Templates in D Explained<br />
| url = http://nomad.so/2013/07/templates-in-d-explained/<br />
| author = Gary Willoughby<br />
}}<br />
<br />
{{Article<br />
| name = Templates Primer, In D<br />
| url = https://semitwist.com/articles/article/view/template-primer-in-d<br />
| author = Nicholas Sabalausky<br />
}}<br />
<br />
{{Article<br />
| name = Understanding Templates in D2 (PDF)<br />
| url = https://github.com/PhilippeSigaud/D-templates-tutorial/blob/master/D-templates-tutorial.pdf?raw=true<br />
| alt1 = [https://github.com/PhilippeSigaud/D-templates-tutorial/blob/master/D-templates-tutorial.epub?raw=true EPUB]<br />
| author = Philippe Sigaud<br />
}}<br />
<br />
{{Article<br />
| name = Purity in D<br />
| url = http://klickverbot.at/blog/2012/05/purity-in-d/<br />
| author = David Nadlinger<br />
}}<br />
<br />
{{Article<br />
| name = Inheriting Purity<br />
| url = http://www.drdobbs.com/cpp/inheriting-purity/232601305<br />
| author = Walter Bright<br />
| published = Feb 22 2012<br />
}}<br />
<br />
{{Article<br />
| name = Defining custom print format specifiers<br />
}}<br />
<br />
}}<br />
<br />
<br />
{{Article Group<br />
| Name = Architecture and Design<br />
| Articles =<br />
<br />
{{Article<br />
| name = Component Programming in D<br />
| url = http://www.drdobbs.com/architecture-and-design/component-programming-in-d/240008321<br />
| author = Walter Bright<br />
| published = Oct 02 2012<br />
}}<br />
<br />
{{Article<br />
| name = Component Programming with Ranges<br />
| url = http://wiki.dlang.org/Component_programming_with_ranges<br />
| author = H. S. Teoh<br />
| published = Aug 06 2013<br />
}}<br />
<br />
}}<br />
<br />
<br />
{{Article Group<br />
| Name = Concurrency<br />
| Articles =<br />
<br />
{{Article<br />
| name = Getting more fiber in your diet<br />
| url = http://octarineparrot.com/article/view/getting-more-fiber-in-your-diet<br />
| author = OctarineParrot DevLog<br />
}}<br />
<br />
}}<br />
<br />
<br />
<br />
{{Article Group<br />
| Name = Operating System Development<br />
| Articles =<br />
<br />
{{Article<br />
| name = D Bare Bones<br />
| url = http://wiki.osdev.org/D_Bare_Bones<br />
| author = Unknown<br />
}}<br />
<br />
}}<br />
<br />
<br />
<br />
{{Article Group<br />
| Name = Metaprogramming<br />
| Articles =<br />
<br />
{{Article<br />
| name = Have Your Efficiency, and Flexibility Too - Metaprogramming Techniques For No-Compromise Code<br />
| url = http://www.semitwist.com/articles/EfficientAndFlexible/SinglePage/<br />
| author = Nicholas Sabalausky<br />
}}<br />
<br />
{{Article<br />
| name = Transforming an array/slice of structs into a struct of arrays/slices using metaprogramming<br />
| url = http://wiki.dlang.org/Transforming_slice_of_structs_into_struct_of_slices<br />
| author = Laeeth Isharc for the D forums<br />
}}<br />
<br />
}}<br />
<br />
<br />
{{Article Group<br />
| Name = Windows Specific<br />
| Articles =<br />
<br />
{{Article<br />
| name = Compiling and linking with DMD on Windows<br />
}}<br />
<br />
{{Article<br />
| name = Linking With Unilink<br />
}}<br />
<br />
{{Article<br />
| name = Using Windows Resource Files with D2<br />
}}<br />
<br />
{{Article<br />
| name = Programming Windows code samples translated to D2<br />
| url = https://github.com/AndrejMitrovic/DWinProgramming<br />
| author = Andrej Mitrovic<br />
}}<br />
<br />
<br />
}}<br />
<br />
<br />
{{Article Group<br />
| Name = Interfacing to C<br />
| Articles =<br />
<br />
{{Article<br />
| name = D Exceptions and C Callbacks<br />
| url = http://www.gamedev.net/page/resources/_/technical/general-programming/d-exceptions-and-c-callbacks-r3323<br />
| author = Mike "Aldacron" Parker<br />
}}<br />
<br />
{{Article<br />
| name = Binding D to C Part 1<br />
| url = http://www.gamedev.net/blog/1140/entry-2254003-binding-d-to-c/<br />
| author = Mike "Aldacron" Parker<br />
}}<br />
<br />
{{Article<br />
| name = Binding D to C Part 2<br />
| url = http://www.gamedev.net/blog/1140/entry-2254108-binding-d-to-c-part-two/<br />
| author = Mike "Aldacron" Parker<br />
}}<br />
<br />
{{Article<br />
| name = Binding D to C Part 3<br />
| url = http://www.gamedev.net/blog/1140/entry-2254632-binding-d-to-c-part-three/<br />
| author = Mike "Aldacron" Parker<br />
}}<br />
<br />
{{Article<br />
| name = Binding D to C Part 4<br />
| url = http://www.gamedev.net/blog/1140/entry-2254910-binding-d-to-c-part-four/<br />
| author = Mike "Aldacron" Parker<br />
}}<br />
<br />
{{Article<br />
| name = Binding D to C Part 5<br />
| url = http://www.gamedev.net/blog/1140/entry-2255632-binding-d-to-c-part-five/<br />
| author = Mike "Aldacron" Parker<br />
}}<br />
<br />
}}</div>Laeethhttps://wiki.dlang.org/?title=Articles&diff=6338Articles2015-07-05T00:05:36Z<p>Laeeth: </p>
<hr />
<div>{{Article Group<br />
| Name = Beginning<br />
| Articles =<br />
<br />
{{Article<br />
| name = Dispelling Common D Myths<br />
| url = http://semitwist.com/articles/article/view/dispelling-common-d-myths<br />
| author = Nicholas Sabalausky<br />
}}<br />
<br />
{{Article<br />
| name = "D"iving Into the D Programming Language<br />
| url = http://www.informit.com/articles/article.aspx?p=1381876<br />
| author = Andrei Alexandrescu<br />
}}<br />
<br />
{{Article<br />
| name = D: A Newbie-Oriented Tutorial<br />
| url = http://compsci.ca/v3/viewtopic.php?t=9518<br />
| author = Andrei Alexandrescu<br />
}}<br />
<br />
{{Article<br />
| name = Getting Started with the D Programming Language<br />
| url = http://www.gamedev.net/page/resources/_/technical/general-programming/getting-started-with-the-d-programming-language-r3306<br />
| author = Mike "Aldacron" Parker<br />
}}<br />
<br />
}}<br />
<br />
<br />
{{Article Group<br />
| Name = General<br />
| Articles =<br />
<br />
{{Article<br />
| name = Functional image processing in D<br />
| url = http://blog.thecybershadow.net/2014/03/21/functional-image-processing-in-d/<br />
| author = Vladimir Panteleev<br />
| published = Mar 21 2014<br />
}}<br />
<br />
{{Article<br />
| name = Implementing Pure Functions<br />
| url = http://www.drdobbs.com/tools/implementing-pure-functions/230700070#<br />
| author = Walter Bright<br />
| published = June 15, 2011<br />
}}<br />
<br />
{{Article<br />
| name = NaNs Just Don't Get No Respect<br />
| url = http://www.drdobbs.com/cpp/nans-just-dont-get-no-respect/240005723<br />
| author = Walter Bright<br />
| published = Aug 16 2012<br />
}}<br />
<br />
{{Article<br />
| name = Voldemort Types In D<br />
| url = http://www.drdobbs.com/cpp/voldemort-types-in-d/232901591<br />
| author = Walter Bright<br />
| published = May 07 2012<br />
}}<br />
<br />
{{Article<br />
| name = Uniform Function Call Syntax<br />
| url = http://www.drdobbs.com/cpp/uniform-function-call-syntax/232700394<br />
| author = Walter Bright<br />
| published = Mar 28 2012<br />
}}<br />
<br />
{{Article<br />
| name = Real World Comparison, GC vs. Manual Memory Management<br />
| url = http://3d.benjamin-thaut.de/?p=20<br />
| author = Benjamin Thaut<br />
}}<br />
<br />
{{Article<br />
| name = Increasing Compiler Speed by Over 75%<br />
| url = http://www.drdobbs.com/cpp/increasing-compiler-speed-by-over-75/240158941#<br />
| author = Walter Bright<br />
| published = July 25 2013<br />
}}<br />
<br />
{{Article<br />
| name = Memory Management<br />
}}<br />
<br />
{{Article<br />
| name = Useful Workarounds<br />
}}<br />
<br />
}}<br />
<br />
<br />
{{Article Group<br />
| Name = Features<br />
| Articles =<br />
<br />
{{Article<br />
| name = Introduction to D templates<br />
}}<br />
<br />
{{Article<br />
| name = Templates in D Explained<br />
| url = http://nomad.so/2013/07/templates-in-d-explained/<br />
| author = Gary Willoughby<br />
}}<br />
<br />
{{Article<br />
| name = Templates Primer, In D<br />
| url = https://semitwist.com/articles/article/view/template-primer-in-d<br />
| author = Nicholas Sabalausky<br />
}}<br />
<br />
{{Article<br />
| name = Understanding Templates in D2 (PDF)<br />
| url = https://github.com/PhilippeSigaud/D-templates-tutorial/blob/master/D-templates-tutorial.pdf?raw=true<br />
| alt1 = [https://github.com/PhilippeSigaud/D-templates-tutorial/blob/master/D-templates-tutorial.epub?raw=true EPUB]<br />
| author = Philippe Sigaud<br />
}}<br />
<br />
{{Article<br />
| name = Purity in D<br />
| url = http://klickverbot.at/blog/2012/05/purity-in-d/<br />
| author = David Nadlinger<br />
}}<br />
<br />
{{Article<br />
| name = Inheriting Purity<br />
| url = http://www.drdobbs.com/cpp/inheriting-purity/232601305<br />
| author = Walter Bright<br />
| published = Feb 22 2012<br />
}}<br />
<br />
{{Article<br />
| name = Defining custom print format specifiers<br />
}}<br />
<br />
}}<br />
<br />
<br />
{{Article Group<br />
| Name = Architecture and Design<br />
| Articles =<br />
<br />
{{Article<br />
| name = Component Programming in D<br />
| url = http://www.drdobbs.com/architecture-and-design/component-programming-in-d/240008321<br />
| author = Walter Bright<br />
| published = Oct 02 2012<br />
}}<br />
<br />
{{Article<br />
| name = Component Programming with Ranges<br />
| url = http://wiki.dlang.org/Component_programming_with_ranges<br />
| author = H. S. Teoh<br />
| published = Aug 06 2013<br />
}}<br />
<br />
}}<br />
<br />
<br />
{{Article Group<br />
| Name = Concurrency<br />
| Articles =<br />
<br />
{{Article<br />
| name = Getting more fiber in your diet<br />
| url = http://octarineparrot.com/article/view/getting-more-fiber-in-your-diet<br />
| author = OctarineParrot DevLog<br />
}}<br />
<br />
}}<br />
<br />
<br />
<br />
{{Article Group<br />
| Name = Operating System Development<br />
| Articles =<br />
<br />
{{Article<br />
| name = D Bare Bones<br />
| url = http://wiki.osdev.org/D_Bare_Bones<br />
| author = Unknown<br />
}}<br />
<br />
}}<br />
<br />
<br />
<br />
{{Article Group<br />
| Name = Metaprogramming<br />
| Articles =<br />
<br />
{{Article<br />
| name = Have Your Efficiency, and Flexibility Too - Metaprogramming Techniques For No-Compromise Code<br />
| url = http://www.semitwist.com/articles/EfficientAndFlexible/SinglePage/<br />
| author = Nicholas Sabalausky<br />
}}<br />
<br />
{{Article<br />
| name = Transforming an array/slice of structs into a struct of arrays/slices using metaprogramming<br />
| url = http://wiki.dlang.org/Component_programming_with_ranges/<br />
| author = Laeeth Isharc for the D forums<br />
}}<br />
<br />
}}<br />
<br />
<br />
{{Article Group<br />
| Name = Windows Specific<br />
| Articles =<br />
<br />
{{Article<br />
| name = Compiling and linking with DMD on Windows<br />
}}<br />
<br />
{{Article<br />
| name = Linking With Unilink<br />
}}<br />
<br />
{{Article<br />
| name = Using Windows Resource Files with D2<br />
}}<br />
<br />
{{Article<br />
| name = Programming Windows code samples translated to D2<br />
| url = https://github.com/AndrejMitrovic/DWinProgramming<br />
| author = Andrej Mitrovic<br />
}}<br />
<br />
<br />
}}<br />
<br />
<br />
{{Article Group<br />
| Name = Interfacing to C<br />
| Articles =<br />
<br />
{{Article<br />
| name = D Exceptions and C Callbacks<br />
| url = http://www.gamedev.net/page/resources/_/technical/general-programming/d-exceptions-and-c-callbacks-r3323<br />
| author = Mike "Aldacron" Parker<br />
}}<br />
<br />
{{Article<br />
| name = Binding D to C Part 1<br />
| url = http://www.gamedev.net/blog/1140/entry-2254003-binding-d-to-c/<br />
| author = Mike "Aldacron" Parker<br />
}}<br />
<br />
{{Article<br />
| name = Binding D to C Part 2<br />
| url = http://www.gamedev.net/blog/1140/entry-2254108-binding-d-to-c-part-two/<br />
| author = Mike "Aldacron" Parker<br />
}}<br />
<br />
{{Article<br />
| name = Binding D to C Part 3<br />
| url = http://www.gamedev.net/blog/1140/entry-2254632-binding-d-to-c-part-three/<br />
| author = Mike "Aldacron" Parker<br />
}}<br />
<br />
{{Article<br />
| name = Binding D to C Part 4<br />
| url = http://www.gamedev.net/blog/1140/entry-2254910-binding-d-to-c-part-four/<br />
| author = Mike "Aldacron" Parker<br />
}}<br />
<br />
{{Article<br />
| name = Binding D to C Part 5<br />
| url = http://www.gamedev.net/blog/1140/entry-2255632-binding-d-to-c-part-five/<br />
| author = Mike "Aldacron" Parker<br />
}}<br />
<br />
}}</div>Laeethhttps://wiki.dlang.org/?title=Template:Article_Group&diff=6337Template:Article Group2015-07-05T00:01:55Z<p>Laeeth: Undo revision 6336 by Laeeth (talk)</p>
<hr />
<div>=== {{{Name|}}} ===<br />
{{{Articles|}}}</div>Laeethhttps://wiki.dlang.org/?title=Template:Article_Group&diff=6336Template:Article Group2015-07-04T23:59:20Z<p>Laeeth: /* {{{Name|}}} */</p>
<hr />
<div>=== {{{A simple application of metaprogramming: turning an array/slice of structs into a struct of arrays/slices|}}} ===<br />
<br />
In some applications it is a common requirement to transform an array/slice of structs into a struct of arrays/slices. This may be for cache efficiency (see data-driven design) or in order to present data to an API that requires a different format than the standard internal representation of client code. If the struct design is fixed then this can be done in a few lines of code, but in cases where the struct design may change over time, or the struct itself is constructed via metaprogramming or CTFE then it may be helpful to create the new struct definition in code.<br />
<br />
This is not intended to be a complete or definitive solution to the problem, but here are three approaches presented by experienced users on the D forum. I hope that this explanation will be filled out by others in time.<br />
<br />
http://forum.dlang.org/post/mzpwjelelctwvxzbsijh@forum.dlang.org<br />
<br />
<code>Array of structs<br />
<nowiki><br />
struct PriceBar<br />
{<br />
DateTime date;<br />
double open;<br />
double high;<br />
double low;<br />
double close;<br />
}<br />
<br />
PriceBar[] priceBar;<br />
<br />
Desired - struct of arrays:<br />
<br />
struct PriceBars<br />
{<br />
DateTime[] dates;<br />
double[] opens;<br />
double[] highs;<br />
double[] lows;<br />
double[] closes;<br />
}<br />
</nowiki><br />
</code><br />
<br />
<code>First solution - from Economic Modeling, a Moscow, Idaho (USA) based company that uses D to support their big data analysis of economic fundamental developments:<br />
<nowiki><br />
https://github.com/economicmodeling/soa<br />
<br />
<br />
struct SOA(A : T[], T) if (is(T == struct))<br />
{<br />
mixin CommonImpl;<br />
<br />
private static string getMemberDecls() @property pure<br />
{<br />
string ret;<br />
foreach (name; Fields)<br />
ret ~= `typeof(U.`~name~`)[] `~name~`;`;<br />
return ret;<br />
}<br />
<br />
// Actual storage<br />
mixin(getMemberDecls);<br />
<br />
/// Array lengths<br />
auto length() @property const<br />
{<br />
// We expect all arrays to have the same length<br />
static enum FirstMember = Fields[0];<br />
return __traits(getMember, this, FirstMember).length;<br />
}<br />
<br />
///<br />
void length(size_t newLen) @property<br />
{<br />
auto oldLen = length;<br />
foreach (Name; Fields)<br />
{<br />
__traits(getMember, this, Name).length = newLen;<br />
if (oldLen < newLen)<br />
{<br />
// initialize new values<br />
foreach (ref e; __traits(getMember, this, Name)[oldLen .. newLen])<br />
e = __traits(getMember, initValues, Name);<br />
}<br />
}<br />
}<br />
}<br />
</nowiki><br />
</code><br />
<br />
<code>Solution from John Colvin, organizer of the Scientific Computing portal for D:<br />
<nowiki><br />
<br />
import std.typetuple;<br />
import std.typecons;<br />
import std.traits;<br />
<br />
struct Pack(TL...)<br />
{<br />
alias expand = TL;<br />
enum length = TL.length;<br />
@disable this();<br />
}<br />
<br />
enum isPack(T) = is(T == Pack!Args, Args...);<br />
<br />
template EqualLength(Packs ...)<br />
if(allSatisfy!(isPack, Packs) && Packs.length != 0)<br />
{<br />
static if (Packs.length == 1) enum EqualLength = true;<br />
else<br />
{<br />
template EqualLengthTo(size_t len)<br />
{<br />
enum EqualLengthTo(T) = len == T.length;<br />
}<br />
enum EqualLength = Filter!(EqualLengthTo!(Packs[0].length), Packs[1 .. $]).length == Packs.length - 1;<br />
}<br />
}<br />
<br />
template Alias(alias a)<br />
{<br />
static if (__traits(compiles, { alias x = a; }))<br />
alias Alias = a;<br />
else static if (__traits(compiles, { enum x = a; }))<br />
enum Alias = a;<br />
else<br />
static assert(0, "Cannot alias " ~ a.stringof);<br />
}<br />
<br />
template Alias(a...)<br />
{<br />
alias Alias = a;<br />
}<br />
<br />
template Head(Pack)<br />
if(isPack!Pack)<br />
{<br />
alias Head = Alias!(Pack.expand[0]);<br />
}<br />
<br />
template Tail(Pack)<br />
if(isPack!Pack)<br />
{<br />
alias Tail = Pack!(Pack.expand[1 .. $]);<br />
}<br />
<br />
template TemplAppender(string suffix)<br />
{<br />
enum TemplAppender(string s) = s ~ suffix;<br />
}<br />
<br />
template RoundRobin(Args ...)<br />
if(Args.length >= 2 && allSatisfy!(isPack, Args) && EqualLength!Args)<br />
{<br />
static if (Args[0].length == 0)<br />
alias RoundRobin = TypeTuple!();<br />
else<br />
alias RoundRobin = TypeTuple!(staticMap!(Head, Args), RoundRobin!(staticMap!(Tail, Args)));<br />
}<br />
<br />
alias SliceOf(T) = T[];<br />
<br />
alias TransformMembers(alias TypeTransform, alias NameTransform, T) = Tuple!(<br />
RoundRobin!(Pack!(staticMap!(TypeTransform, FieldTypeTuple!PriceBar)),<br />
Pack!(staticMap!(NameTransform, FieldNameTuple!PriceBar))));<br />
<br />
import std.datetime;<br />
<br />
struct PriceBar<br />
{<br />
DateTime date;<br />
double open;<br />
double high;<br />
double low;<br />
double close;<br />
}<br />
<br />
alias PriceBars = TransformMembers!(SliceOf, TemplAppender!"s", PriceBar);<br />
</nowiki><br />
</code><br />
<br />
<code>Solution from Artur Skawina on the forum:<br />
The simplest solution is something like the following. You will need to adjust to your requirements (eg drop the '"~LENGTH.stringof~"' part to get a struct-of-slices, which is what your example above shows).<br />
<nowiki><br />
<br />
<br />
<br />
template SOA(Struct, size_t LENGTH) {<br />
struct SOA {<br />
enum MEMBERNAME(size_t N) = __traits(identifier, Struct.tupleof[N]);<br />
<br />
static __gentypes() {<br />
string ret;<br />
foreach (I, TYPE; typeof(Struct.tupleof))<br />
ret ~= "align(16) typeof(Struct.tupleof["~I.stringof~"])["~LENGTH.stringof~"] "<br />
~ MEMBERNAME!I ~ ";";<br />
return ret;<br />
}<br />
mixin(__gentypes());<br />
}<br />
}<br />
<br />
alias PriceBars = SOA!(PriceBar, 8);<br />
</nowiki><br />
</code></div>Laeethhttps://wiki.dlang.org/?title=User_narratives_on_switching_to_D&diff=6307User narratives on switching to D2015-06-18T07:41:27Z<p>Laeeth: </p>
<hr />
<div>[We can clean up formatting later. I am not so good with wiki].<br />
<br />
Story 1: please state your agreement to use your name if you don't mind it being included. (It would make the account more vivid if so):<br />
<br />
Before I was mainly using C++ for my work(and dabbled in Rust, <br />
but never ended up switching to it)<br />
D's C-like syntax inspires familiarity to the point where I truly <br />
believe that D is easier to port C code to than C++ because you <br />
can write D in a "cleaned up" C for the most part, and slowly <br />
turn it into D whereas C++ is essentially a completely different <br />
style. Not too many languages can really claim this, and IMO it's <br />
a huge boon.<br />
<br />
D provides native performance directly on comparison with C/C++ <br />
while being much easier to jump in and bash out a few quick <br />
ideas(Phobos helps a lot with this.)<br />
<br />
Phobos offers far more than the C++ standard library as well. <br />
It's nice not to have to go hunting for libraries, C++11 helped <br />
with this a little I guess but it just feels like "it's there," <br />
whereas Andrei/Walter seem to actively be working towards "you <br />
should always be using Phobos or it should be fixed."<br />
<br />
Also, D's metaprogramming system is actually usable. I use CTFE <br />
to do a ton of precomputations at compiletime, I even recently <br />
learned that the compiler can unroll foreach loops in switches(! <br />
that's cool - D has a lot of neat tricks that nobody really seems <br />
to discuss,) I feel like I'm always learning new tricks in D, and <br />
not in the C++ way.<br />
<br />
The ability to use C libraries with barely any fuss(!), I ported <br />
a C's library's headers to D in about 10 minutes using htod and a <br />
bit of manual touchup. This is a `killer feature` in my opinion.<br />
<br />
Ranges/functional programming in general, C++ really has nothing <br />
on this. I think C++17 might be getting ranges but when I <br />
reviewed the paper they seemed far uglier and an <br />
afterthought(like most of C++), I've written large parts of my <br />
programs in purely functional style and LDC optimizes it to the <br />
equivalent imperative code.<br />
<br />
D's operator overloading is extremely well designed IMO,(it just <br />
goes with the rest of the 'make D work the way you want it to' <br />
feeling of the rest of the language)<br />
<br />
D(md) compiles pretty fast, I think it used to have a bigger <br />
advantage here over C++ before Clang became popular but it's <br />
still pretty darn fast and makes for python-esque edit-run-debug <br />
editing style. I went from compiling my projects on the <br />
university servers to my home desktop(and it compiles faster.)<br />
<br />
<br />
I think D's best quality is probably how approachable it is for <br />
C/C++ programmers compared to i.e, Rust which has a (weird) ML <br />
influence. I wouldn't be surprised if you could get a C or C++ <br />
programmer up to speed in D in an afternoon, at least enough to <br />
be efficient in it.<br />
<br />
D is of course not all roses, shared still feels half implemented <br />
and left to rot(D's memory model in general.) TDPL is aging, and <br />
there's not too much other literature on D - but Ali's book is <br />
very good. The compiler situation feels odd, LDC and GDC have <br />
very few contributors despite being better than dmd at optimizing <br />
and providing a lot of extra perks - i.e, LDC lets you use all of <br />
the LLVM sanitizers like the thread, memory, etc. ones, and LDC <br />
provides in-depth optimization analysis thanks to LLVM.<br />
<br />
But comparatively, this list is not so bad.<br />
<br />
I feel like I could write a book on why I use D, so I'm going to <br />
stop now : )<br />
<br />
====<br />
Story 2<br />
"In D, if you have a bug, you are 100% certain that you can resolve it yourself. You have all the C/C++ tools available to go all the way down to the memory and debug anything you want. You have statically typed language that allows huge projects to breathe very healthy and increment features at low cost.<br />
<br />
Nothing beats D in my opinion. It's 20 years ahead of everything out there. All you need to do, is know how to use it and understand it enough to resolve any bugs you come up with."<br />
<br />
Natively compiled: Moore's law predicts that the burden in advancements in computing speed will migrate into software. This may be enough to rule out increasingly the use of managed language for developments where cost is important and more than 1 server will be needed. Compiling vs interpreting can make all the difference between requiring 1000 servers vs 10 servers.<br />
<br />
Template metaprogramming: This is the first reason I've chosen to use D in the first place. The idea that I could write code that writes code, and make it statically typed and safe. C++ has this but the errors are insane, the static if is not there, CTFE is just starting to pick up, there's no traits or very limited compile-time reflection (ie. static if(__traits(compiles, { some_operation(); })). The compile time is also much slower, there's simply too many legacy features in the language that have made it suffer in the long run. Even a package manager like dub is something nobody can agree on, because the community is so divided.<br />
<br />
Overall, it would take decades for the most powerful language C++ to reach the current state of D in terms of compile-time capabilities. This is important because preprocessors are the only alternatives and they suck for larger projects.<br />
<br />
I started off as a C, C#, Javascript & PHP programmer with 6 years of experience, building mostly e-commerce and information systems on a contractual basis. One day, I decided I had enough and wanted to invest my time in a faster web engine because I was tired of seeing all those slow and bloated libraries that can barely serve 10 requests per second when they're put to any practical use.<br />
<br />
I decided to go for C++ and learn everything I could about writing an integrated solution. I found interesting libraries but everytime I wanted to add a feature, I'd have to import another library and it again became bloated but in terms of code base. Nothing seemed to work together (Qt & Boost?).<br />
<br />
The D programming language came up frequently in search results when looking for C++-related concepts, and I saw everything I needed in Phobos. The language features seemed similar at first but I quickly realized how much more convenient the language was as a whole and it felt much like a managed language overall.<br />
<br />
Even the vibe.d library was much more advanced than what I could find with an open source license that allowed static compilation at the time (1 yr 1/2 ago), so I went forward with that and worked my way through. The most interesting part is that everytime I had a problem, I never had to google the error from the compiler because it was quite straightforward. I did have to debug the memory a lot but all the tools from C/C++ work for that.<br />
<br />
So now I can build a full web application/server executable in less than 2mb packed, and it runs faster than anything out there. It's standalone, works cross-platform, etc. I really have to put the blame on the language for the speed at which this very large project was finished. I completed the STL-equivalent memory library, TLS/crypto security library, the low-level async TCP library, the HTTP/2 implementation and the integration of everything in a web application framework within about 10 months. I learned the language for about 6 months through that coming from a background more familiar with managed languages. I can't say D isn't meant for large projects, it's a really fucking solid language that was built for the future."<br />
===<br />
Story 3 (hedge fund guy)<br />
<br />
Coming back from lunch, the first speaker was Andy Smith, talking about using D in the world of financial software. Download his slides here.<br />
<br />
He got interested in D because of Walter and Andrei's names and took a look. He said he wrote a bit of code that didn't work and asked for help on the #d IRC channel on freenode and was surprised to find that somebody on IRC actually meant it when he said he'd help rewrite the example so it works and explain it - Andy said this left him with a good impression of the community.<br />
<br />
After this experience, he started using D at work. His company wanted to rewrite their infrastructure to take advantage of new computer hardware and he was going to use D for the prototype, but it ended up working well right into production.<br />
<br />
D scores highly on all requirements they had: it was correct, testable, reliable, modifable, productive, and performant.<br />
<br />
Among other wins in the language were: fast builds, easy testing, C syntax is easy learning, low level functions, the standard library, the module system helps with changes Editor's note: I'd also point out how much static typing helps in modifying code, and he found no nasty language surprises.<br />
<br />
In Phobos, he loved having the modules for: getopt, json, DateTime, atomics, bitops, csv (he specifically called out how nice the Struct[] population functions are) and loved how well they worked and that they were easy to use.<br />
<br />
====<br />
Story 4 (Sonke Ludwig/vibed)<br />
http://arsdnet.net/this-week-in-d/mar-15.html<br />
Sönke Ludwig is the primary developer behind DUB, the D package manager, and the vibe.d web framework, which was recently chosen to be bundled alongside the reference dmd compiler.<br />
<br />
- How did you first come to start the vibe.d project and why? Was it your first D project or were there other attempts before?<br />
<br />
- I first heard about D, I think, in a magazine article around maybe 2005 and got all ears immediately. My growing dislike for C++ (lacking an overall better alternative) grew over the years and the cleaned-up syntax and the module system of D alone were huge selling points. However, things were still too unstable back then: platform support was lacking and I didn't feel ready to ditch the concept of "const" (which didn't exist before D 2.x), so that the starting shot for me was when the first 2.000 alpha of DMD was released back in 2007.<br />
<br />
My first large D project was the conversion of my C++ game engine and GUI framework to D. Bit for bit, going over the course of multiple years, finally the D version had more features than the old C++ code base - at about half the number of code lines and those were also much shorter on average! This framework also forms the basis of most of my current commercial projects. I'd like to publish parts of it one day, maybe using some kind of dual-licensing scheme, when I have enough time to properly maintain it.<br />
<br />
Vibe.d was born later, in 2012, when a few friends and I wanted to start a project that was partially web based. In terms of scalability, node.js was the hip new thing and one of us already had experience with it, so we first went with that. However, using JavaScript meant that we had to rewrite and maintain parts of the D code in JavaScript, and more importantly, programming with node.js was really awful due to the callback-based API.<br />
<br />
Then I remembered D's "Fiber" class, which was inherited from Tango's runtime during the D1->D2 transition. This was the missing piece of the puzzle to an I/O system in D that could be made better in almost every aspect. So we decided that we'd put some concentrated effort into this to make the development of the project more bearable. Two months later, the first public alpha version was born.<br />
<br />
- Could you talk about your experiences with D in building vibe.d, ie things you liked about D when writing vibe.d and things you had to work around?<br />
<br />
- In general, D has always been very pleasant to work with, including when developing vibe.d. I have never experienced this level of productiveness for medium to large scale projects with any other language so far. However, hitting compiler bugs and regressions of all sorts was common, and finding workarounds/reproducible cases and reporting bugs at times diminished a lot of the productivity gains. However, although there is still something that breaks with almost any new beta release of DMD, this has gotten much better over time and isn't so much of an issue today anymore. It can still be a little difficult to maintain compatibility with a range of D compilers (vibe.d tries to support 2.065-2.067 ATM), especially since using new language features can be very tempting!<br />
<br />
Speaking of which, one of the most useful additions to D would be things like proper "scope" and isolated (a.k.a. "unique") references. Those would enable the memory-safe use of faster programming paradigms, such as using stack-allocated classes, or accessing objects from different threads without the need for costly locks or atomic operations. These are things that vibe.d could greatly benefit from, but memory safety is too important for network services to go this route without language-based verification.<br />
<br />
- Please tell us a bit about yourself: who you are, what programming languages you used before D, and your experience first discovering and using D.<br />
<br />
I grew up and still live in northern Germany near the city of Lübeck, which is also where I graduated in bioinformatics a few years ago. My first programming experiences began in my early teenager times when I got my first 386DX, running DOS/Windows 3.1. I discovered qbasic.exe soon after playing around with some simple batch files and began creating all kinds of little GUI and 3D-Graphics based DOS applications.<br />
<br />
The experience of the direct feedback back then got me hooked. After some tinkering with TurboBasic - boy, was that fast - and another BASIC based Windows IDE (CA Realizer) around '95, a friend of mine gave me a CD with Borland C++ 5.0, which I then discovered step by step in a completely naive and trial/error based way (What is a "pointer"? Why does it crash now?). The next thing I remember are some bad memories involving Visual C++ 6 and tons of cross compiler compatibility macros, and discovering all of the details of the C++ standard that I wouldn't ever have wanted to know about.<br />
<br />
In these times, I created a big number of small programs, discovering the darkest corners of the Windows API, network protocols, hardware interfaces, OpenGL and other random things. I also tried out a lot of other programming languages, including most of the popular scripting languages and a short trip to OCaml, but I've mainly stuck to C and C++ for actual projects (still preferring C over C++ due to many factors). W32DASM was also one of my favorite tools at the time, without going into details of what kind of 1337 things that was used for, but it also helped me learn the details of x86 assembly.<br />
<br />
Then, during my time at the university, I worked for Nik Software, a former company which specialized in software for professional photographers, later bought out by Google. There I managed the creation of the company-wide cross-platform core library, providing higher level concepts needed for almost all products. This included an image-filtering framework capable of transparently using multi-core CPUs and GPUs to filter images of arbitrary sizes and a custom GUI framework, which allowed us to maintain a single code base for all platforms, while having the ability to implement advanced GUI concepts that were more or less impossible with other GUI frameworks at the time.<br />
<br />
For my masters thesis back in 2011, I created a compiler in D for an image filtering-specific DSL, which was able to translate to GPU shader code (GLSL or HSL), to C++ code and, thanks to LLVM, directly to machine code at runtime. It was then integrated into the company's core library to form the basis for new filters. This was the fist piece of software in the company which was written in D (controlled through an extern(C) interface). The language made this a very pleasant and an extremely efficient endeavor (apart from some friction caused by the C interfaces to the host application and to the LLVM libraries). I intentionally tried to keep the D code simple, without excessive use of advanced meta-programming and other "bleeding edge" features, so that the chance of running into compiler bugs was as low as possible (there have still been quite some of these, and getting 64-bit builds to work on Windows also still was a challenge at the time).<br />
<br />
What do you love and/or hate about D? This is more general than the specific vibe.d-related question above.<br />
<br />
- I basically love the initial (D1) design choices - the clean and easy to parse syntax (field access, templates, slices, foreach etc.), the module system and the low compile times. Also D's meta-programming abilities, including CTFE and the more recent support for user-defined attributes, are superb and, I'm sure other D programmers know this feeling as well, it's sometimes really hard for me now to force myself into doing things with certain other languages that could have been done much more efficiently in D, even when talking just about a few lines of code more or less.</div>Laeethhttps://wiki.dlang.org/?title=User_narratives_on_switching_to_D&diff=6306User narratives on switching to D2015-06-18T07:41:00Z<p>Laeeth: </p>
<hr />
<div>[We can clean up formatting later. I am not so good with wiki].<br />
<br />
Story 1: please state your agreement to use your name if you don't mind it being included. (It would make the account more vivid if so):<br />
<br />
Before I was mainly using C++ for my work(and dabbled in Rust, <br />
but never ended up switching to it)<br />
D's C-like syntax inspires familiarity to the point where I truly <br />
believe that D is easier to port C code to than C++ because you <br />
can write D in a "cleaned up" C for the most part, and slowly <br />
turn it into D whereas C++ is essentially a completely different <br />
style. Not too many languages can really claim this, and IMO it's <br />
a huge boon.<br />
<br />
D provides native performance directly on comparison with C/C++ <br />
while being much easier to jump in and bash out a few quick <br />
ideas(Phobos helps a lot with this.)<br />
<br />
Phobos offers far more than the C++ standard library as well. <br />
It's nice not to have to go hunting for libraries, C++11 helped <br />
with this a little I guess but it just feels like "it's there," <br />
whereas Andrei/Walter seem to actively be working towards "you <br />
should always be using Phobos or it should be fixed."<br />
<br />
Also, D's metaprogramming system is actually usable. I use CTFE <br />
to do a ton of precomputations at compiletime, I even recently <br />
learned that the compiler can unroll foreach loops in switches(! <br />
that's cool - D has a lot of neat tricks that nobody really seems <br />
to discuss,) I feel like I'm always learning new tricks in D, and <br />
not in the C++ way.<br />
<br />
The ability to use C libraries with barely any fuss(!), I ported <br />
a C's library's headers to D in about 10 minutes using htod and a <br />
bit of manual touchup. This is a `killer feature` in my opinion.<br />
<br />
Ranges/functional programming in general, C++ really has nothing <br />
on this. I think C++17 might be getting ranges but when I <br />
reviewed the paper they seemed far uglier and an <br />
afterthought(like most of C++), I've written large parts of my <br />
programs in purely functional style and LDC optimizes it to the <br />
equivalent imperative code.<br />
<br />
D's operator overloading is extremely well designed IMO,(it just <br />
goes with the rest of the 'make D work the way you want it to' <br />
feeling of the rest of the language)<br />
<br />
D(md) compiles pretty fast, I think it used to have a bigger <br />
advantage here over C++ before Clang became popular but it's <br />
still pretty darn fast and makes for python-esque edit-run-debug <br />
editing style. I went from compiling my projects on the <br />
university servers to my home desktop(and it compiles faster.)<br />
<br />
<br />
I think D's best quality is probably how approachable it is for <br />
C/C++ programmers compared to i.e, Rust which has a (weird) ML <br />
influence. I wouldn't be surprised if you could get a C or C++ <br />
programmer up to speed in D in an afternoon, at least enough to <br />
be efficient in it.<br />
<br />
D is of course not all roses, shared still feels half implemented <br />
and left to rot(D's memory model in general.) TDPL is aging, and <br />
there's not too much other literature on D - but Ali's book is <br />
very good. The compiler situation feels odd, LDC and GDC have <br />
very few contributors despite being better than dmd at optimizing <br />
and providing a lot of extra perks - i.e, LDC lets you use all of <br />
the LLVM sanitizers like the thread, memory, etc. ones, and LDC <br />
provides in-depth optimization analysis thanks to LLVM.<br />
<br />
But comparatively, this list is not so bad.<br />
<br />
I feel like I could write a book on why I use D, so I'm going to <br />
stop now : )<br />
<br />
====<br />
Story 2<br />
"In D, if you have a bug, you are 100% certain that you can resolve it yourself. You have all the C/C++ tools available to go all the way down to the memory and debug anything you want. You have statically typed language that allows huge projects to breathe very healthy and increment features at low cost.<br />
<br />
Nothing beats D in my opinion. It's 20 years ahead of everything out there. All you need to do, is know how to use it and understand it enough to resolve any bugs you come up with."<br />
<br />
Natively compiled: Moore's law predicts that the burden in advancements in computing speed will migrate into software. This may be enough to rule out increasingly the use of managed language for developments where cost is important and more than 1 server will be needed. Compiling vs interpreting can make all the difference between requiring 1000 servers vs 10 servers.<br />
<br />
Template metaprogramming: This is the first reason I've chosen to use D in the first place. The idea that I could write code that writes code, and make it statically typed and safe. C++ has this but the errors are insane, the static if is not there, CTFE is just starting to pick up, there's no traits or very limited compile-time reflection (ie. static if(__traits(compiles, { some_operation(); })). The compile time is also much slower, there's simply too many legacy features in the language that have made it suffer in the long run. Even a package manager like dub is something nobody can agree on, because the community is so divided.<br />
<br />
Overall, it would take decades for the most powerful language C++ to reach the current state of D in terms of compile-time capabilities. This is important because preprocessors are the only alternatives and they suck for larger projects.<br />
<br />
I started off as a C, C#, Javascript & PHP programmer with 6 years of experience, building mostly e-commerce and information systems on a contractual basis. One day, I decided I had enough and wanted to invest my time in a faster web engine because I was tired of seeing all those slow and bloated libraries that can barely serve 10 requests per second when they're put to any practical use.<br />
<br />
I decided to go for C++ and learn everything I could about writing an integrated solution. I found interesting libraries but everytime I wanted to add a feature, I'd have to import another library and it again became bloated but in terms of code base. Nothing seemed to work together (Qt & Boost?).<br />
<br />
The D programming language came up frequently in search results when looking for C++-related concepts, and I saw everything I needed in Phobos. The language features seemed similar at first but I quickly realized how much more convenient the language was as a whole and it felt much like a managed language overall.<br />
<br />
Even the vibe.d library was much more advanced than what I could find with an open source license that allowed static compilation at the time (1 yr 1/2 ago), so I went forward with that and worked my way through. The most interesting part is that everytime I had a problem, I never had to google the error from the compiler because it was quite straightforward. I did have to debug the memory a lot but all the tools from C/C++ work for that.<br />
<br />
So now I can build a full web application/server executable in less than 2mb packed, and it runs faster than anything out there. It's standalone, works cross-platform, etc. I really have to put the blame on the language for the speed at which this very large project was finished. I completed the STL-equivalent memory library, TLS/crypto security library, the low-level async TCP library, the HTTP/2 implementation and the integration of everything in a web application framework within about 10 months. I learned the language for about 6 months through that coming from a background more familiar with managed languages. I can't say D isn't meant for large projects, it's a really fucking solid language that was built for the future."<br />
===<br />
Story 3 (hedge fund guy)<br />
<br />
Coming back from lunch, the first speaker was Andy Smith, talking about using D in the world of financial software. Download his slides here.<br />
<br />
He got interested in D because of Walter and Andrei's names and took a look. He said he wrote a bit of code that didn't work and asked for help on the #d IRC channel on freenode and was surprised to find that somebody on IRC actually meant it when he said he'd help rewrite the example so it works and explain it - Andy said this left him with a good impression of the community.<br />
<br />
After this experience, he started using D at work. His company wanted to rewrite their infrastructure to take advantage of new computer hardware and he was going to use D for the prototype, but it ended up working well right into production.<br />
<br />
D scores highly on all requirements they had: it was correct, testable, reliable, modifable, productive, and performant.<br />
<br />
Among other wins in the language were: fast builds, easy testing, C syntax is easy learning, low level functions, the standard library, the module system helps with changes Editor's note: I'd also point out how much static typing helps in modifying code, and he found no nasty language surprises.<br />
<br />
In Phobos, he loved having the modules for: getopt, json, DateTime, atomics, bitops, csv (he specifically called out how nice the Struct[] population functions are) and loved how well they worked and that they were easy to use.<br />
<br />
====<br />
Story 3 (Sonke Ludwig/vibed)<br />
http://arsdnet.net/this-week-in-d/mar-15.html<br />
Sönke Ludwig is the primary developer behind DUB, the D package manager, and the vibe.d web framework, which was recently chosen to be bundled alongside the reference dmd compiler.<br />
<br />
- How did you first come to start the vibe.d project and why? Was it your first D project or were there other attempts before?<br />
<br />
- I first heard about D, I think, in a magazine article around maybe 2005 and got all ears immediately. My growing dislike for C++ (lacking an overall better alternative) grew over the years and the cleaned-up syntax and the module system of D alone were huge selling points. However, things were still too unstable back then: platform support was lacking and I didn't feel ready to ditch the concept of "const" (which didn't exist before D 2.x), so that the starting shot for me was when the first 2.000 alpha of DMD was released back in 2007.<br />
<br />
My first large D project was the conversion of my C++ game engine and GUI framework to D. Bit for bit, going over the course of multiple years, finally the D version had more features than the old C++ code base - at about half the number of code lines and those were also much shorter on average! This framework also forms the basis of most of my current commercial projects. I'd like to publish parts of it one day, maybe using some kind of dual-licensing scheme, when I have enough time to properly maintain it.<br />
<br />
Vibe.d was born later, in 2012, when a few friends and I wanted to start a project that was partially web based. In terms of scalability, node.js was the hip new thing and one of us already had experience with it, so we first went with that. However, using JavaScript meant that we had to rewrite and maintain parts of the D code in JavaScript, and more importantly, programming with node.js was really awful due to the callback-based API.<br />
<br />
Then I remembered D's "Fiber" class, which was inherited from Tango's runtime during the D1->D2 transition. This was the missing piece of the puzzle to an I/O system in D that could be made better in almost every aspect. So we decided that we'd put some concentrated effort into this to make the development of the project more bearable. Two months later, the first public alpha version was born.<br />
<br />
- Could you talk about your experiences with D in building vibe.d, ie things you liked about D when writing vibe.d and things you had to work around?<br />
<br />
- In general, D has always been very pleasant to work with, including when developing vibe.d. I have never experienced this level of productiveness for medium to large scale projects with any other language so far. However, hitting compiler bugs and regressions of all sorts was common, and finding workarounds/reproducible cases and reporting bugs at times diminished a lot of the productivity gains. However, although there is still something that breaks with almost any new beta release of DMD, this has gotten much better over time and isn't so much of an issue today anymore. It can still be a little difficult to maintain compatibility with a range of D compilers (vibe.d tries to support 2.065-2.067 ATM), especially since using new language features can be very tempting!<br />
<br />
Speaking of which, one of the most useful additions to D would be things like proper "scope" and isolated (a.k.a. "unique") references. Those would enable the memory-safe use of faster programming paradigms, such as using stack-allocated classes, or accessing objects from different threads without the need for costly locks or atomic operations. These are things that vibe.d could greatly benefit from, but memory safety is too important for network services to go this route without language-based verification.<br />
<br />
- Please tell us a bit about yourself: who you are, what programming languages you used before D, and your experience first discovering and using D.<br />
<br />
I grew up and still live in northern Germany near the city of Lübeck, which is also where I graduated in bioinformatics a few years ago. My first programming experiences began in my early teenager times when I got my first 386DX, running DOS/Windows 3.1. I discovered qbasic.exe soon after playing around with some simple batch files and began creating all kinds of little GUI and 3D-Graphics based DOS applications.<br />
<br />
The experience of the direct feedback back then got me hooked. After some tinkering with TurboBasic - boy, was that fast - and another BASIC based Windows IDE (CA Realizer) around '95, a friend of mine gave me a CD with Borland C++ 5.0, which I then discovered step by step in a completely naive and trial/error based way (What is a "pointer"? Why does it crash now?). The next thing I remember are some bad memories involving Visual C++ 6 and tons of cross compiler compatibility macros, and discovering all of the details of the C++ standard that I wouldn't ever have wanted to know about.<br />
<br />
In these times, I created a big number of small programs, discovering the darkest corners of the Windows API, network protocols, hardware interfaces, OpenGL and other random things. I also tried out a lot of other programming languages, including most of the popular scripting languages and a short trip to OCaml, but I've mainly stuck to C and C++ for actual projects (still preferring C over C++ due to many factors). W32DASM was also one of my favorite tools at the time, without going into details of what kind of 1337 things that was used for, but it also helped me learn the details of x86 assembly.<br />
<br />
Then, during my time at the university, I worked for Nik Software, a former company which specialized in software for professional photographers, later bought out by Google. There I managed the creation of the company-wide cross-platform core library, providing higher level concepts needed for almost all products. This included an image-filtering framework capable of transparently using multi-core CPUs and GPUs to filter images of arbitrary sizes and a custom GUI framework, which allowed us to maintain a single code base for all platforms, while having the ability to implement advanced GUI concepts that were more or less impossible with other GUI frameworks at the time.<br />
<br />
For my masters thesis back in 2011, I created a compiler in D for an image filtering-specific DSL, which was able to translate to GPU shader code (GLSL or HSL), to C++ code and, thanks to LLVM, directly to machine code at runtime. It was then integrated into the company's core library to form the basis for new filters. This was the fist piece of software in the company which was written in D (controlled through an extern(C) interface). The language made this a very pleasant and an extremely efficient endeavor (apart from some friction caused by the C interfaces to the host application and to the LLVM libraries). I intentionally tried to keep the D code simple, without excessive use of advanced meta-programming and other "bleeding edge" features, so that the chance of running into compiler bugs was as low as possible (there have still been quite some of these, and getting 64-bit builds to work on Windows also still was a challenge at the time).<br />
<br />
What do you love and/or hate about D? This is more general than the specific vibe.d-related question above.<br />
<br />
- I basically love the initial (D1) design choices - the clean and easy to parse syntax (field access, templates, slices, foreach etc.), the module system and the low compile times. Also D's meta-programming abilities, including CTFE and the more recent support for user-defined attributes, are superb and, I'm sure other D programmers know this feeling as well, it's sometimes really hard for me now to force myself into doing things with certain other languages that could have been done much more efficiently in D, even when talking just about a few lines of code more or less.</div>Laeethhttps://wiki.dlang.org/?title=User_narratives_on_switching_to_D&diff=6305User narratives on switching to D2015-06-18T07:36:28Z<p>Laeeth: </p>
<hr />
<div>[We can clean up formatting later. I am not so good with wiki].<br />
<br />
Story 1: please state your agreement to use your name if you don't mind it being included. (It would make the account more vivid if so):<br />
<br />
Before I was mainly using C++ for my work(and dabbled in Rust, <br />
but never ended up switching to it)<br />
D's C-like syntax inspires familiarity to the point where I truly <br />
believe that D is easier to port C code to than C++ because you <br />
can write D in a "cleaned up" C for the most part, and slowly <br />
turn it into D whereas C++ is essentially a completely different <br />
style. Not too many languages can really claim this, and IMO it's <br />
a huge boon.<br />
<br />
D provides native performance directly on comparison with C/C++ <br />
while being much easier to jump in and bash out a few quick <br />
ideas(Phobos helps a lot with this.)<br />
<br />
Phobos offers far more than the C++ standard library as well. <br />
It's nice not to have to go hunting for libraries, C++11 helped <br />
with this a little I guess but it just feels like "it's there," <br />
whereas Andrei/Walter seem to actively be working towards "you <br />
should always be using Phobos or it should be fixed."<br />
<br />
Also, D's metaprogramming system is actually usable. I use CTFE <br />
to do a ton of precomputations at compiletime, I even recently <br />
learned that the compiler can unroll foreach loops in switches(! <br />
that's cool - D has a lot of neat tricks that nobody really seems <br />
to discuss,) I feel like I'm always learning new tricks in D, and <br />
not in the C++ way.<br />
<br />
The ability to use C libraries with barely any fuss(!), I ported <br />
a C's library's headers to D in about 10 minutes using htod and a <br />
bit of manual touchup. This is a `killer feature` in my opinion.<br />
<br />
Ranges/functional programming in general, C++ really has nothing <br />
on this. I think C++17 might be getting ranges but when I <br />
reviewed the paper they seemed far uglier and an <br />
afterthought(like most of C++), I've written large parts of my <br />
programs in purely functional style and LDC optimizes it to the <br />
equivalent imperative code.<br />
<br />
D's operator overloading is extremely well designed IMO,(it just <br />
goes with the rest of the 'make D work the way you want it to' <br />
feeling of the rest of the language)<br />
<br />
D(md) compiles pretty fast, I think it used to have a bigger <br />
advantage here over C++ before Clang became popular but it's <br />
still pretty darn fast and makes for python-esque edit-run-debug <br />
editing style. I went from compiling my projects on the <br />
university servers to my home desktop(and it compiles faster.)<br />
<br />
<br />
I think D's best quality is probably how approachable it is for <br />
C/C++ programmers compared to i.e, Rust which has a (weird) ML <br />
influence. I wouldn't be surprised if you could get a C or C++ <br />
programmer up to speed in D in an afternoon, at least enough to <br />
be efficient in it.<br />
<br />
D is of course not all roses, shared still feels half implemented <br />
and left to rot(D's memory model in general.) TDPL is aging, and <br />
there's not too much other literature on D - but Ali's book is <br />
very good. The compiler situation feels odd, LDC and GDC have <br />
very few contributors despite being better than dmd at optimizing <br />
and providing a lot of extra perks - i.e, LDC lets you use all of <br />
the LLVM sanitizers like the thread, memory, etc. ones, and LDC <br />
provides in-depth optimization analysis thanks to LLVM.<br />
<br />
But comparatively, this list is not so bad.<br />
<br />
I feel like I could write a book on why I use D, so I'm going to <br />
stop now : )<br />
<br />
====<br />
Story 2<br />
"In D, if you have a bug, you are 100% certain that you can resolve it yourself. You have all the C/C++ tools available to go all the way down to the memory and debug anything you want. You have statically typed language that allows huge projects to breathe very healthy and increment features at low cost.<br />
<br />
Nothing beats D in my opinion. It's 20 years ahead of everything out there. All you need to do, is know how to use it and understand it enough to resolve any bugs you come up with."<br />
<br />
Natively compiled: Moore's law predicts that the burden in advancements in computing speed will migrate into software. This may be enough to rule out increasingly the use of managed language for developments where cost is important and more than 1 server will be needed. Compiling vs interpreting can make all the difference between requiring 1000 servers vs 10 servers.<br />
<br />
Template metaprogramming: This is the first reason I've chosen to use D in the first place. The idea that I could write code that writes code, and make it statically typed and safe. C++ has this but the errors are insane, the static if is not there, CTFE is just starting to pick up, there's no traits or very limited compile-time reflection (ie. static if(__traits(compiles, { some_operation(); })). The compile time is also much slower, there's simply too many legacy features in the language that have made it suffer in the long run. Even a package manager like dub is something nobody can agree on, because the community is so divided.<br />
<br />
Overall, it would take decades for the most powerful language C++ to reach the current state of D in terms of compile-time capabilities. This is important because preprocessors are the only alternatives and they suck for larger projects.<br />
<br />
I started off as a C, C#, Javascript & PHP programmer with 6 years of experience, building mostly e-commerce and information systems on a contractual basis. One day, I decided I had enough and wanted to invest my time in a faster web engine because I was tired of seeing all those slow and bloated libraries that can barely serve 10 requests per second when they're put to any practical use.<br />
<br />
I decided to go for C++ and learn everything I could about writing an integrated solution. I found interesting libraries but everytime I wanted to add a feature, I'd have to import another library and it again became bloated but in terms of code base. Nothing seemed to work together (Qt & Boost?).<br />
<br />
The D programming language came up frequently in search results when looking for C++-related concepts, and I saw everything I needed in Phobos. The language features seemed similar at first but I quickly realized how much more convenient the language was as a whole and it felt much like a managed language overall.<br />
<br />
Even the vibe.d library was much more advanced than what I could find with an open source license that allowed static compilation at the time (1 yr 1/2 ago), so I went forward with that and worked my way through. The most interesting part is that everytime I had a problem, I never had to google the error from the compiler because it was quite straightforward. I did have to debug the memory a lot but all the tools from C/C++ work for that.<br />
<br />
So now I can build a full web application/server executable in less than 2mb packed, and it runs faster than anything out there. It's standalone, works cross-platform, etc. I really have to put the blame on the language for the speed at which this very large project was finished. I completed the STL-equivalent memory library, TLS/crypto security library, the low-level async TCP library, the HTTP/2 implementation and the integration of everything in a web application framework within about 10 months. I learned the language for about 6 months through that coming from a background more familiar with managed languages. I can't say D isn't meant for large projects, it's a really fucking solid language that was built for the future."<br />
===<br />
Story 3 (hedge fund guy)<br />
<br />
Coming back from lunch, the first speaker was Andy Smith, talking about using D in the world of financial software. Download his slides here.<br />
<br />
He got interested in D because of Walter and Andrei's names and took a look. He said he wrote a bit of code that didn't work and asked for help on the #d IRC channel on freenode and was surprised to find that somebody on IRC actually meant it when he said he'd help rewrite the example so it works and explain it - Andy said this left him with a good impression of the community.<br />
<br />
After this experience, he started using D at work. His company wanted to rewrite their infrastructure to take advantage of new computer hardware and he was going to use D for the prototype, but it ended up working well right into production.<br />
<br />
D scores highly on all requirements they had: it was correct, testable, reliable, modifable, productive, and performant.<br />
<br />
Among other wins in the language were: fast builds, easy testing, C syntax is easy learning, low level functions, the standard library, the module system helps with changes Editor's note: I'd also point out how much static typing helps in modifying code, and he found no nasty language surprises.<br />
<br />
In Phobos, he loved having the modules for: getopt, json, DateTime, atomics, bitops, csv (he specifically called out how nice the Struct[] population functions are) and loved how well they worked and that they were easy to use.</div>Laeethhttps://wiki.dlang.org/?title=User_narratives_on_switching_to_D&diff=6304User narratives on switching to D2015-06-18T07:33:33Z<p>Laeeth: </p>
<hr />
<div>[We can clean up formatting later. I am not so good with wiki].<br />
<br />
Story 1: please state your agreement to use your name if you don't mind it being included. (It would make the account more vivid if so):<br />
<br />
Before I was mainly using C++ for my work(and dabbled in Rust, <br />
but never ended up switching to it)<br />
D's C-like syntax inspires familiarity to the point where I truly <br />
believe that D is easier to port C code to than C++ because you <br />
can write D in a "cleaned up" C for the most part, and slowly <br />
turn it into D whereas C++ is essentially a completely different <br />
style. Not too many languages can really claim this, and IMO it's <br />
a huge boon.<br />
<br />
D provides native performance directly on comparison with C/C++ <br />
while being much easier to jump in and bash out a few quick <br />
ideas(Phobos helps a lot with this.)<br />
<br />
Phobos offers far more than the C++ standard library as well. <br />
It's nice not to have to go hunting for libraries, C++11 helped <br />
with this a little I guess but it just feels like "it's there," <br />
whereas Andrei/Walter seem to actively be working towards "you <br />
should always be using Phobos or it should be fixed."<br />
<br />
Also, D's metaprogramming system is actually usable. I use CTFE <br />
to do a ton of precomputations at compiletime, I even recently <br />
learned that the compiler can unroll foreach loops in switches(! <br />
that's cool - D has a lot of neat tricks that nobody really seems <br />
to discuss,) I feel like I'm always learning new tricks in D, and <br />
not in the C++ way.<br />
<br />
The ability to use C libraries with barely any fuss(!), I ported <br />
a C's library's headers to D in about 10 minutes using htod and a <br />
bit of manual touchup. This is a `killer feature` in my opinion.<br />
<br />
Ranges/functional programming in general, C++ really has nothing <br />
on this. I think C++17 might be getting ranges but when I <br />
reviewed the paper they seemed far uglier and an <br />
afterthought(like most of C++), I've written large parts of my <br />
programs in purely functional style and LDC optimizes it to the <br />
equivalent imperative code.<br />
<br />
D's operator overloading is extremely well designed IMO,(it just <br />
goes with the rest of the 'make D work the way you want it to' <br />
feeling of the rest of the language)<br />
<br />
D(md) compiles pretty fast, I think it used to have a bigger <br />
advantage here over C++ before Clang became popular but it's <br />
still pretty darn fast and makes for python-esque edit-run-debug <br />
editing style. I went from compiling my projects on the <br />
university servers to my home desktop(and it compiles faster.)<br />
<br />
<br />
I think D's best quality is probably how approachable it is for <br />
C/C++ programmers compared to i.e, Rust which has a (weird) ML <br />
influence. I wouldn't be surprised if you could get a C or C++ <br />
programmer up to speed in D in an afternoon, at least enough to <br />
be efficient in it.<br />
<br />
D is of course not all roses, shared still feels half implemented <br />
and left to rot(D's memory model in general.) TDPL is aging, and <br />
there's not too much other literature on D - but Ali's book is <br />
very good. The compiler situation feels odd, LDC and GDC have <br />
very few contributors despite being better than dmd at optimizing <br />
and providing a lot of extra perks - i.e, LDC lets you use all of <br />
the LLVM sanitizers like the thread, memory, etc. ones, and LDC <br />
provides in-depth optimization analysis thanks to LLVM.<br />
<br />
But comparatively, this list is not so bad.<br />
<br />
I feel like I could write a book on why I use D, so I'm going to <br />
stop now : )<br />
<br />
====<br />
Story 2<br />
"In D, if you have a bug, you are 100% certain that you can resolve it yourself. You have all the C/C++ tools available to go all the way down to the memory and debug anything you want. You have statically typed language that allows huge projects to breathe very healthy and increment features at low cost.<br />
<br />
Nothing beats D in my opinion. It's 20 years ahead of everything out there. All you need to do, is know how to use it and understand it enough to resolve any bugs you come up with."<br />
<br />
Natively compiled: Moore's law predicts that the burden in advancements in computing speed will migrate into software. This may be enough to rule out increasingly the use of managed language for developments where cost is important and more than 1 server will be needed. Compiling vs interpreting can make all the difference between requiring 1000 servers vs 10 servers.<br />
<br />
Template metaprogramming: This is the first reason I've chosen to use D in the first place. The idea that I could write code that writes code, and make it statically typed and safe. C++ has this but the errors are insane, the static if is not there, CTFE is just starting to pick up, there's no traits or very limited compile-time reflection (ie. static if(__traits(compiles, { some_operation(); })). The compile time is also much slower, there's simply too many legacy features in the language that have made it suffer in the long run. Even a package manager like dub is something nobody can agree on, because the community is so divided.<br />
<br />
Overall, it would take decades for the most powerful language C++ to reach the current state of D in terms of compile-time capabilities. This is important because preprocessors are the only alternatives and they suck for larger projects.<br />
<br />
I started off as a C, C#, Javascript & PHP programmer with 6 years of experience, building mostly e-commerce and information systems on a contractual basis. One day, I decided I had enough and wanted to invest my time in a faster web engine because I was tired of seeing all those slow and bloated libraries that can barely serve 10 requests per second when they're put to any practical use.<br />
<br />
I decided to go for C++ and learn everything I could about writing an integrated solution. I found interesting libraries but everytime I wanted to add a feature, I'd have to import another library and it again became bloated but in terms of code base. Nothing seemed to work together (Qt & Boost?).<br />
<br />
The D programming language came up frequently in search results when looking for C++-related concepts, and I saw everything I needed in Phobos. The language features seemed similar at first but I quickly realized how much more convenient the language was as a whole and it felt much like a managed language overall.<br />
<br />
Even the vibe.d library was much more advanced than what I could find with an open source license that allowed static compilation at the time (1 yr 1/2 ago), so I went forward with that and worked my way through. The most interesting part is that everytime I had a problem, I never had to google the error from the compiler because it was quite straightforward. I did have to debug the memory a lot but all the tools from C/C++ work for that.<br />
<br />
So now I can build a full web application/server executable in less than 2mb packed, and it runs faster than anything out there. It's standalone, works cross-platform, etc. I really have to put the blame on the language for the speed at which this very large project was finished. I completed the STL-equivalent memory library, TLS/crypto security library, the low-level async TCP library, the HTTP/2 implementation and the integration of everything in a web application framework within about 10 months. I learned the language for about 6 months through that coming from a background more familiar with managed languages. I can't say D isn't meant for large projects, it's a really fucking solid language that was built for the future."</div>Laeethhttps://wiki.dlang.org/?title=Programming_in_D_for_Python_Programmers&diff=6303Programming in D for Python Programmers2015-06-18T07:29:14Z<p>Laeeth: </p>
<hr />
<div>"Often, programming teams will resort to a hybrid approach, where they will mix Python and C++, trying to get the productivity of Python and the performance of C++. The frequency of this approach indicates that there is a large unmet need in the programming language department.<br />
<br />
D intends to fill that need. It combines the ability to do low-level manipulation of the machine with the latest technologies in building reliable, maintainable, portable, high-level code. D has moved well ahead of any other language in its abilities to support and integrate multiple paradigms like imperative, OOP, and generic programming"<br />
<br />
-- Walter Bright<br />
<br />
<br />
<br />
This section is under development - feel free to suggest improvements or additions.<br />
<br />
<br />
D is Like Native Python<br />
-----------------------<br />
*[http://bitbashing.io/2015/01/26/d-is-like-native-python.html D is like Native Python]<br />
<br />
*[http://tomerfiliba.com/blog/dlang/ D for the Win] A former Python programmer explores the benefits from moving to D<br />
<br />
*[http://blog.experimentalworks.net/2015/01/the-d-language-a-sweet-spot-between-python-and-c/ The D Language: a sweet-spot between Python and C]<br />
<br />
*[http://dconf.org/2015/talks/smith.html A hedge fund quant] finds that Python begins to choke on the data volumes requiring processing, but that D can cope and is productive.<br />
<br />
*[http://www.slideshare.net/LiranZvibel/d-talk - weka.io: Israeli stealth mode storage startup talk slides exploring similarities with Python]<br />
<br />
*[http://thebird.nl/blog/D_Dragon.html D is a Dragon: why D matters for bioinformatics] - summary: strong typing, speed, parallelisation with high-performance message passing, productivity, immutability, and high-level abstractions.<br />
<br />
*[http://bioinformatics.oxfordjournals.org/content/early/2015/02/18/bioinformatics.btv098.full.pdf+html Sambamba:] a [http://google-opensource.blogspot.nl/2015/03/gsoc-project-sambamba-published-in.html?utm_source=feedburner&utm_medium=feed&utm_campaign=Feed:+GoogleOpenSourceBlog+(Google+Open+Source+Blog Google Summer of Code Project involving the Open Bioinformatics Foundation] that is the fastest BAM parser. No Python-specific content, but this addresses a common-use domain for Python.<br />
<br />
<br />
AdRoll is [http://java.dzone.com/articles/big-data-and-python-utilizing known for their use of Python elsewhere], but their data scientists use D. According to Andrew Pascoe, senior data scientist at AdRoll, "One of the clearest advantages of using D compared to other typical data science workflows is that it compiles down into machine code. Without an interpreter or virtual machine layer, we can rip through data significantly faster than other tools like a Java hadoop framework, R, or python would allow. But D’s compiler is fast enough that in many cases it can be run as if it were a scripting language....The key thing here that separates D from other efficient languages like the oft-suggested C or C++ is that D frees you to program in the style you feel most comfortable with at the given time". He says that they have found that they "can rapidly prototype new infrastructure and analysis tasks, and when efficiency becomes a core concern, we have the ability to refactor that same code base to squeeze as much performance out as possible".<br />
<br />
*[http://tech.adroll.com/blog/data/2014/11/17/d-is-for-data-science.html AdRoll: D is for Data Science]<br />
<br />
*[https://d.readthedocs.org/en/latest/examples.html#plotting-with-matplotlib-python Plotting in D using python's matplotlib]<br />
<br />
<br />
IPython Notebook / Jupyter<br />
-----------------------------------<br />
An early-stage extension to Python exists to allow writing D extensions inline within an ipython/Jupyter notebook<br />
*[http://forum.dlang.org/post/dehleaecsihenaapyqhl@beta.forum.dlang.org Introduction on forum]<br />
*[https://github.com/DlangScience/PydMagic Source Code]<br />
<br />
<br />
Generators and List Comprehensions<br />
----------------------------------<br />
Python's generators and list comprehensions have been thought to be two of the most difficult concepts to replicate in other languages. For the D solution to the problem solved by Python generators, see D Ranges and lazy evaluation. For list comprehensions, see UFCS.<br />
<br />
*[http://www.drdobbs.com/cpp/uniform-function-call-syntax/232700394 Walter Bright on UFCS]<br />
*[https://www.youtube.com/watch?v=cQkBOCo8UrE Walter Bright youtube talk on component programming in D]<br />
<br />
*[http://www.informit.com/articles/printerfriendly/1407357 Theoretical article on ranges as a development of the iterator concept by the C++ guru, Dr Andrei Alexandrescu]<br />
*[http://ddili.org/ders/d.en/ranges.html Introduction to Ranges by Ali Çehreli - Part I]<br />
*[http://ddili.org/ders/d.en/ranges.html Introduction to Ranges by Ali Çehreli - Part II]<br />
*[http://dlang.org/d-array-article.html Introduction to D slices]<br />
<br />
*[http://dlang.org/phobos/std_range.html std.range structures and functions in the Phobos standard library]<br />
*[http://dlang.org/phobos/std_algorithm.html std.algorithm generic functions in Phobos]<br />
*[http://dlang.org/phobos/std_array.html std.array]<br />
<br />
*[https://www.semitwist.com/articles/article/view/combine-coroutines-and-input-ranges-for-dead-simple-d-iteration Combining co-routines and input ranges for dead-simple iteration]<br />
<br />
<br />
Parallel Programming<br />
--------------------<br />
Parallel programming has become increasingly in focus as we approach the beginning of the end of the [http://www.gotw.ca/publications/concurrency-ddj.htm free lunch from Moore's Law]. D makes multiprocessing and threading as simple as possible, but not simpler:<br />
<br />
*[http://www.informit.com/articles/article.aspx?p=1609144 Free chapter from Dr Andrei Alexandrescu's book on parallelism in D]<br />
*[http://ddili.org/ders/d.en/parallelism.html Ali Cehreli on parallelism]<br />
*[http://ddili.org/ders/d.en/concurrency.html Ali Cehreli on message-passing concurrency]<br />
*[http://ddili.org/ders/d.en/concurrency_shared.html Ali Cehreli on data-sharing concurrency]<br />
*[http://dlang.org/library/std/parallelism.html std.parallelism]<br />
<br />
<code> simple example from std.parallelism documentation<br />
<nowiki><br />
import std.algorithm, std.parallelism, std.range;<br />
<br />
void main() {<br />
// Parallel reduce can be combined with<br />
// std.algorithm.map to interesting effect.<br />
// The following example (thanks to Russel Winder)<br />
// calculates pi by quadrature using<br />
// std.algorithm.map and TaskPool.reduce.<br />
// getTerm is evaluated in parallel as needed by<br />
// TaskPool.reduce.<br />
//<br />
// Timings on an Athlon 64 X2 dual core machine:<br />
//<br />
// TaskPool.reduce: 12.170 s<br />
// std.algorithm.reduce: 24.065 s<br />
<br />
immutable n = 1_000_000_000;<br />
immutable delta = 1.0 / n;<br />
<br />
real getTerm(int i)<br />
{<br />
immutable x = ( i - 0.5 ) * delta;<br />
return delta / ( 1.0 + x * x ) ;<br />
}<br />
<br />
immutable pi = 4.0 * taskPool.reduce!"a + b"(<br />
std.algorithm.map!getTerm(iota(n))<br />
);<br />
}<br />
</nowiki><br />
</code><br />
<br />
Interfacing D with an existing codebase<br />
---------------------------------------<br />
*[http://dlang.org/interfaceToC.html C interfacing is simple and complete - D can call C, and C can call D]<br />
*[http://dlang.org/cpp_interface.html C++ interfacing is a key priority of the D core team but much can already be done - in fact more than is described here]<br />
*[https://github.com/ariovistus/pyd PyD] creates seamless interoperation between D and CPython, including for numpy arrays. [http://www.youtube.com/watch?v=y-k7GyOcs3o "It just works".] Make sure you visit the github code, and not the old version up at bitbucket.<br />
*Other options are to use cython wrappings to connect to D, or to write in D directly to the Python API. There are examples of this in the PyD examples directory within PyD<br />
*[https://github.com/JakobOvrum/LuaD LuaD] creates a simple interface between D and Lua<br />
<br />
<code> D calling embedded Python<br />
<nowiki><br />
void main() {<br />
auto context = new InterpContext();<br />
context.a = 2;<br />
context.py_stmts("print ('1 + %s' % a)");<br />
}<br />
</nowiki><br />
</code><br />
<br />
<code> Lua D example<br />
<nowiki><br />
import luad.all;<br />
<br />
void main()<br />
{<br />
auto lua = new LuaState;<br />
lua.openLibs();<br />
<br />
auto print = lua.get!LuaFunction("print");<br />
print("hello, world!");<br />
}<br />
</nowiki><br />
</code><br />
<br />
<br />
Web development, concurrency and JSON/BSON/XML<br />
----------------------------------------------<br />
Phobos includes bindings to the widely-used external curl library within Phobos (std.net.curl) and does include provision within std.csv, std.json and std.xml for processing structured data. The JSON and XML implementations in Phobos could be better, and many people choose to use an external library. The most popular solution for this is [http://vibed.org Vibe D], and this comes with a useful framework for web development, networking, fiber-based concurrency, JSON and BSON. One can write fiber-oriented code without having to deal with callbacks. (See [https://www.youtube.com/watch?v=Zs8O7MVmlfw CyberShadow's presentation] at Dconf 2013 for an excellent review of the differences).<br />
<br />
Atila Neaves has done one [https://atilanevesoncode.wordpress.com/2013/12/05/go-vs-d-vs-erlang-vs-c-in-real-life-mqtt-broker-implementation-shootout/ benchmark study on Vibed vs Go vc C vs Erlang] in a MQTT broker implementation<br />
<br />
Officially vibed is in beta, but the author seems to have high standards, and for many purposes you may find that this is good enough to be production-ready. (Of course, caveat emptor, it goes without saying).<br />
<br />
Other general solutions include those available in [https://github.com/adamdruppe/arsd Adam Ruppe's ARSD] micro-framework, and CyberShadow's [https://github.com/CyberShadow/ae AE] library. See the forums for some further possibilities on the JSON and XML front. D's slices facilitate fast and efficient parsing, and as of some time back, the XML parser in the Tango library was possibly the fastest in the world.<br />
<br />
<code> Simple HTTP server<br />
<nowiki><br />
import vibe.d;<br />
<br />
shared static this()<br />
{<br />
auto settings = new HTTPServerSettings;<br />
settings.port = 8080;<br />
<br />
listenHTTP(settings, &handleRequest);<br />
}<br />
<br />
void handleRequest(HTTPServerRequest req,<br />
HTTPServerResponse res)<br />
{<br />
if (req.path == "/")<br />
res.writeBody("Hello, World!", "text/plain");<br />
}<br />
</nowiki><br />
</code><br />
<code> Declaring a REST interface<br />
<nowiki><br />
interface IExampleAPI<br />
{<br />
// Matches "GET /"<br />
string getIndex();<br />
// Matches "GET /data"<br />
@property string data();<br />
// Matches "PUT /data"<br />
@property void data(string info);<br />
// Matches "POST /sum"<br />
// or "GET /sum?a=...&b=..."<br />
int postSum(int a, int b);<br />
// Matches "GET /item/<category>/<item>"<br />
@path("item/:category/:item")<br />
int getItem(string _category, int _item);<br />
}<br />
</nowiki><br />
</code><br />
<br />
<br />
<code> REST Client<br />
<nowiki><br />
class Example : IExampleAPI<br />
{<br />
override:<br />
string getIndex() { return "Index!"; }<br />
string _data;<br />
@property string data() { return _data; }<br />
@property void data(string v) { _data=v; }<br />
int postSum(int a, int b) {<br />
return a + b;<br />
}<br />
int getItem(string _category,string _item) {<br />
// ...<br />
}<br />
}<br />
<br />
void main(string[] args)<br />
{<br />
auto api = new RestInterfaceClient!IExampleAPI("http://localhost/");<br />
auto index = api.getIndex();<br />
api.data ="My data";<br />
assert(api.data =="My data");<br />
assert(api.postSum(2, 3) == 5);<br />
}<br />
</nowiki><br />
</code><br />
<code> REST Server<br />
<nowiki><br />
class Example : IExampleAPI<br />
{<br />
override:<br />
string getIndex() { return "Index!"; }<br />
string _data;<br />
@property string data() { return _data; }<br />
@property void data(string v) { _data=v; }<br />
int postSum(int a, int b) {<br />
return a + b;<br />
}<br />
int getItem(string _category,string _item) {<br />
// ...<br />
}<br />
}<br />
<br />
shared static this() // vibed replacement for main<br />
{<br />
auto routes = new URLRouter;<br />
registerRestInterface!IExampleAPI(routes, new Example(), "/");<br />
auto settings = new HTTPServerSettings;<br />
settings.port = 8080;<br />
listenHTTP(settings, routes);<br />
}<br />
</nowiki><br />
</code><br />
<br />
<br />
*[https://d.readthedocs.org/en/latest/examples.html#web-application Simple web application]<br />
<br />
<br />
Email<br />
-----<br />
There is support for sending emails by SMTP in the standard library under [http://dlang.org/phobos/std_net_curl#.SMTP std.net.curl.SMTP] in vibe.d, [https://github.com/adamdruppe/arsd arsd] and [https://github.com/CyberShadow/ae AE Utils]. <br />
<br />
<code> Vibe.d Send Email Example<br />
<nowiki><br />
import vibe.core.log;<br />
import vibe.mail.smtp;<br />
<br />
<br />
void main()<br />
{<br />
auto settings = new SMTPClientSettings("smtp.example.com", 25);<br />
settings.connectionType = SMTPConnectionType.startTLS;<br />
settings.authType = SMTPAuthType.plain;<br />
settings.username = "username";<br />
settings.password = "secret";<br />
<br />
auto mail = new Mail;<br />
mail.headers["From"] = "<user@isp.com>";<br />
mail.headers["To"] = "<recipient@domain.com>";<br />
mail.headers["Subject"] = "Testmail";<br />
mail.bodyText = "Hello, World!";<br />
<br />
logInfo("Sending mail...");<br />
sendMail(settings, mail);<br />
logInfo("done.");<br />
}<br />
</nowiki><br />
</code><br />
<br />
For MIME support see Arsd and AE Utils (under code.dlang.org there are bindings for gmime). No IMAP as yet, but bindings are under development.<br />
<br />
<br />
Numerical computing<br />
-------------------<br />
*[http://dlang.org/d-floating-point.html D Floating Point Features]<br />
*[http://dlang.org/phobos/std_bigint.html arbitrary precision - 'bignum' - arithmetic]<br />
*[http://digitalmars.com/sargon/halffloat.html Sargon half-precision fast floating point]<br />
*[http://code.dlang.org/?sort=updated&category=library.scientific Scientific Computing Projects at code.dlang.org]<br />
<br />
<br />
<br />
Libraries - what is the D equivalent of pypi and pip?<br />
------------------------------------------------------<br />
See [http://code.dlang.org code.dlang.org] and the DUB package manager.<br />
<br />
<br />
Scripting<br />
---------<br />
Since D provides type inference, high-level constructs, and fast compile-time it is a great language for writing [https://github.com/Laeeth/tools/blob/master/FetchDlang/fetchdlang.d scripts]. The first line of the file is ignored if it begins with #! - by combining this with [http://dlang.org/rdmd.html rdmd] which handles dependency resolution, D becomes a leader in machine-code scripting language.<br />
<br />
<code> reading comma separated / CSV text - example from std.csv<br />
<nowiki><br />
auto text = "Name,Occupation,Salary\r"<br />
"Joe,Carpenter,300000\nFred,Blacksmith,400000\r\n";<br />
<br />
foreach(record; csvReader!(string[string])<br />
(text, null))<br />
{<br />
writefln("%s works as a %s and earns $%s per year.",<br />
record["Name"], record["Occupation"],<br />
record["Salary"]);<br />
}<br />
</nowiki><br />
</code><br />
<br />
<code> generating optimized machine code at compile time for compiled regex pattern matching<br />
<nowiki><br />
string phone = "+31 650 903 7158";<br />
auto phoneReg = ctRegex!r"^\+([1-9][0-9]*) [0-9 ]*$";<br />
auto m = match(phone, phoneReg);<br />
assert(m);<br />
assert(m.captures[0] == "+31 650 903 7158");<br />
assert(m.captures[1] == "31");<br />
</nowiki><br />
</code><br />
<br />
<br />
<br />
<br />
Next Steps<br />
----------<br />
* [http://dlang.org/download.html Download] and install D for your platform<br />
* Play with the D REPL or [http://dpaste.dzfl.pl/ Pastebin]<br />
* Consider purchasing Dr Andrei Alexandrescu's [http://www.amazon.com/D-Programming-Language-Andrei-Alexandrescu/dp/0321635361 The D Programming Language], [http://www.amazon.com/dp/1783287217/?tag=packtpubli-20 Adam Ruppe's D Cookbook], and reading the free book [http://ddili.org/ders/d.en/index.html 'Programming in D' by Ali Çehreli]<br />
* Read the D solutions to [http://rosettacode.org/wiki/Category:D Rosetta Code] problems<br />
* Take a look at the [http://wiki.dlang.org/Videos D language videos]<br />
* Subscribe to [http://arsdnet.net/this-week-in-d/ This Week in D]<br />
* Attend a meeting of a [http://wiki.dlang.org/D_User_Groups D User Group] near you<br />
* Follow D on [http://www.linkedin.com/groups/D-Developer-Network-3923820 LinkedIn], [https://plus.google.com/communities/100033468228217743303 Google+], [https://www.facebook.com/dlang.org Facebook], [https://www.xing.com/net/dlang Xing], [http://www.reddit.com/r/d_language/ Reddit], [https://www.quora.com/D-programming-language Quora]<br />
* Follow some [http://planet.dsource.org/ D blogs]<br />
* Post in the [http://forum.dlang.org forums] - don't be shy; this is a very helpful community<br />
<br />
[[Category:Languages versus D]]</div>Laeethhttps://wiki.dlang.org/?title=Programming_in_D_for_Python_Programmers&diff=6302Programming in D for Python Programmers2015-06-18T07:28:56Z<p>Laeeth: </p>
<hr />
<div>"Often, programming teams will resort to a hybrid approach, where they will mix Python and C++, trying to get the productivity of Python and the performance of C++. The frequency of this approach indicates that there is a large unmet need in the programming language department.<br />
<br />
D intends to fill that need. It combines the ability to do low-level manipulation of the machine with the latest technologies in building reliable, maintainable, portable, high-level code. D has moved well ahead of any other language in its abilities to support and integrate multiple paradigms like imperative, OOP, and generic programming"<br />
<br />
-- Walter Bright<br />
<br />
<br />
<br />
This section is under development - feel free to suggest improvements or additions.<br />
<br />
<br />
D is Like Native Python<br />
-----------------------<br />
*[http://bitbashing.io/2015/01/26/d-is-like-native-python.html D is like Native Python]<br />
<br />
*[http://tomerfiliba.com/blog/dlang/ D for the Win] A former Python programmer explores the benefits from moving to D<br />
<br />
*[http://blog.experimentalworks.net/2015/01/the-d-language-a-sweet-spot-between-python-and-c/ The D Language: a sweet-spot between Python and C]<br />
<br />
*[http://dconf.org/2015/talks/smith.html A hedge fund quant] finds that Python begins to choke on the data volumes requiring processing, but that D can cope and is productive.<br />
<br />
*[http://www.slideshare.net/LiranZvibel/d-talk - weka.io: Israeli stealth mode storage startup talk slides exploring similarities with Python]<br />
<br />
*[http://thebird.nl/blog/D_Dragon.html D is a Dragon: why D matters for bioinformatics] - summary: strong typing, speed, parallelisation with high-performance message passing, productivity, immutability, and high-level abstractions.<br />
<br />
*[http://bioinformatics.oxfordjournals.org/content/early/2015/02/18/bioinformatics.btv098.full.pdf+html Sambamba:] a [http://google-opensource.blogspot.nl/2015/03/gsoc-project-sambamba-published-in.html?utm_source=feedburner&utm_medium=feed&utm_campaign=Feed:+GoogleOpenSourceBlog+(Google+Open+Source+Blog Google Summer of Code Project involving the Open Bioinformatics Foundation] that is the fastest BAM parser. No Python-specific content, but this addresses a common-use domain for Python.<br />
<br />
<br />
AdRoll is [http://java.dzone.com/articles/big-data-and-python-utilizing known for their use of Python elsewhere], but their data scientists use D. According to Andrew Pascoe, senior data scientist at AdRoll, "One of the clearest advantages of using D compared to other typical data science workflows is that it compiles down into machine code. Without an interpreter or virtual machine layer, we can rip through data significantly faster than other tools like a Java hadoop framework, R, or python would allow. But D’s compiler is fast enough that in many cases it can be run as if it were a scripting language....The key thing here that separates D from other efficient languages like the oft-suggested C or C++ is that D frees you to program in the style you feel most comfortable with at the given time". He says that they have found that they "can rapidly prototype new infrastructure and analysis tasks, and when efficiency becomes a core concern, we have the ability to refactor that same code base to squeeze as much performance out as possible".<br />
<br />
*[http://tech.adroll.com/blog/data/2014/11/17/d-is-for-data-science.html AdRoll: D is for Data Science]<br />
<br />
*[https://d.readthedocs.org/en/latest/examples.html#plotting-with-matplotlib-python Plotting in D using python's matplotlib]<br />
<br />
IPython Notebook / Jupyter<br />
-----------------------------------<br />
An early-stage extension to Python exists to allow writing D extensions inline within an ipython/Jupyter notebook<br />
*[http://forum.dlang.org/post/dehleaecsihenaapyqhl@beta.forum.dlang.org Introduction on forum]<br />
*[https://github.com/DlangScience/PydMagic Source Code]<br />
<br />
Generators and List Comprehensions<br />
----------------------------------<br />
Python's generators and list comprehensions have been thought to be two of the most difficult concepts to replicate in other languages. For the D solution to the problem solved by Python generators, see D Ranges and lazy evaluation. For list comprehensions, see UFCS.<br />
<br />
*[http://www.drdobbs.com/cpp/uniform-function-call-syntax/232700394 Walter Bright on UFCS]<br />
*[https://www.youtube.com/watch?v=cQkBOCo8UrE Walter Bright youtube talk on component programming in D]<br />
<br />
*[http://www.informit.com/articles/printerfriendly/1407357 Theoretical article on ranges as a development of the iterator concept by the C++ guru, Dr Andrei Alexandrescu]<br />
*[http://ddili.org/ders/d.en/ranges.html Introduction to Ranges by Ali Çehreli - Part I]<br />
*[http://ddili.org/ders/d.en/ranges.html Introduction to Ranges by Ali Çehreli - Part II]<br />
*[http://dlang.org/d-array-article.html Introduction to D slices]<br />
<br />
*[http://dlang.org/phobos/std_range.html std.range structures and functions in the Phobos standard library]<br />
*[http://dlang.org/phobos/std_algorithm.html std.algorithm generic functions in Phobos]<br />
*[http://dlang.org/phobos/std_array.html std.array]<br />
<br />
*[https://www.semitwist.com/articles/article/view/combine-coroutines-and-input-ranges-for-dead-simple-d-iteration Combining co-routines and input ranges for dead-simple iteration]<br />
<br />
<br />
Parallel Programming<br />
--------------------<br />
Parallel programming has become increasingly in focus as we approach the beginning of the end of the [http://www.gotw.ca/publications/concurrency-ddj.htm free lunch from Moore's Law]. D makes multiprocessing and threading as simple as possible, but not simpler:<br />
<br />
*[http://www.informit.com/articles/article.aspx?p=1609144 Free chapter from Dr Andrei Alexandrescu's book on parallelism in D]<br />
*[http://ddili.org/ders/d.en/parallelism.html Ali Cehreli on parallelism]<br />
*[http://ddili.org/ders/d.en/concurrency.html Ali Cehreli on message-passing concurrency]<br />
*[http://ddili.org/ders/d.en/concurrency_shared.html Ali Cehreli on data-sharing concurrency]<br />
*[http://dlang.org/library/std/parallelism.html std.parallelism]<br />
<br />
<code> simple example from std.parallelism documentation<br />
<nowiki><br />
import std.algorithm, std.parallelism, std.range;<br />
<br />
void main() {<br />
// Parallel reduce can be combined with<br />
// std.algorithm.map to interesting effect.<br />
// The following example (thanks to Russel Winder)<br />
// calculates pi by quadrature using<br />
// std.algorithm.map and TaskPool.reduce.<br />
// getTerm is evaluated in parallel as needed by<br />
// TaskPool.reduce.<br />
//<br />
// Timings on an Athlon 64 X2 dual core machine:<br />
//<br />
// TaskPool.reduce: 12.170 s<br />
// std.algorithm.reduce: 24.065 s<br />
<br />
immutable n = 1_000_000_000;<br />
immutable delta = 1.0 / n;<br />
<br />
real getTerm(int i)<br />
{<br />
immutable x = ( i - 0.5 ) * delta;<br />
return delta / ( 1.0 + x * x ) ;<br />
}<br />
<br />
immutable pi = 4.0 * taskPool.reduce!"a + b"(<br />
std.algorithm.map!getTerm(iota(n))<br />
);<br />
}<br />
</nowiki><br />
</code><br />
<br />
Interfacing D with an existing codebase<br />
---------------------------------------<br />
*[http://dlang.org/interfaceToC.html C interfacing is simple and complete - D can call C, and C can call D]<br />
*[http://dlang.org/cpp_interface.html C++ interfacing is a key priority of the D core team but much can already be done - in fact more than is described here]<br />
*[https://github.com/ariovistus/pyd PyD] creates seamless interoperation between D and CPython, including for numpy arrays. [http://www.youtube.com/watch?v=y-k7GyOcs3o "It just works".] Make sure you visit the github code, and not the old version up at bitbucket.<br />
*Other options are to use cython wrappings to connect to D, or to write in D directly to the Python API. There are examples of this in the PyD examples directory within PyD<br />
*[https://github.com/JakobOvrum/LuaD LuaD] creates a simple interface between D and Lua<br />
<br />
<code> D calling embedded Python<br />
<nowiki><br />
void main() {<br />
auto context = new InterpContext();<br />
context.a = 2;<br />
context.py_stmts("print ('1 + %s' % a)");<br />
}<br />
</nowiki><br />
</code><br />
<br />
<code> Lua D example<br />
<nowiki><br />
import luad.all;<br />
<br />
void main()<br />
{<br />
auto lua = new LuaState;<br />
lua.openLibs();<br />
<br />
auto print = lua.get!LuaFunction("print");<br />
print("hello, world!");<br />
}<br />
</nowiki><br />
</code><br />
<br />
<br />
Web development, concurrency and JSON/BSON/XML<br />
----------------------------------------------<br />
Phobos includes bindings to the widely-used external curl library within Phobos (std.net.curl) and does include provision within std.csv, std.json and std.xml for processing structured data. The JSON and XML implementations in Phobos could be better, and many people choose to use an external library. The most popular solution for this is [http://vibed.org Vibe D], and this comes with a useful framework for web development, networking, fiber-based concurrency, JSON and BSON. One can write fiber-oriented code without having to deal with callbacks. (See [https://www.youtube.com/watch?v=Zs8O7MVmlfw CyberShadow's presentation] at Dconf 2013 for an excellent review of the differences).<br />
<br />
Atila Neaves has done one [https://atilanevesoncode.wordpress.com/2013/12/05/go-vs-d-vs-erlang-vs-c-in-real-life-mqtt-broker-implementation-shootout/ benchmark study on Vibed vs Go vc C vs Erlang] in a MQTT broker implementation<br />
<br />
Officially vibed is in beta, but the author seems to have high standards, and for many purposes you may find that this is good enough to be production-ready. (Of course, caveat emptor, it goes without saying).<br />
<br />
Other general solutions include those available in [https://github.com/adamdruppe/arsd Adam Ruppe's ARSD] micro-framework, and CyberShadow's [https://github.com/CyberShadow/ae AE] library. See the forums for some further possibilities on the JSON and XML front. D's slices facilitate fast and efficient parsing, and as of some time back, the XML parser in the Tango library was possibly the fastest in the world.<br />
<br />
<code> Simple HTTP server<br />
<nowiki><br />
import vibe.d;<br />
<br />
shared static this()<br />
{<br />
auto settings = new HTTPServerSettings;<br />
settings.port = 8080;<br />
<br />
listenHTTP(settings, &handleRequest);<br />
}<br />
<br />
void handleRequest(HTTPServerRequest req,<br />
HTTPServerResponse res)<br />
{<br />
if (req.path == "/")<br />
res.writeBody("Hello, World!", "text/plain");<br />
}<br />
</nowiki><br />
</code><br />
<code> Declaring a REST interface<br />
<nowiki><br />
interface IExampleAPI<br />
{<br />
// Matches "GET /"<br />
string getIndex();<br />
// Matches "GET /data"<br />
@property string data();<br />
// Matches "PUT /data"<br />
@property void data(string info);<br />
// Matches "POST /sum"<br />
// or "GET /sum?a=...&b=..."<br />
int postSum(int a, int b);<br />
// Matches "GET /item/<category>/<item>"<br />
@path("item/:category/:item")<br />
int getItem(string _category, int _item);<br />
}<br />
</nowiki><br />
</code><br />
<br />
<br />
<code> REST Client<br />
<nowiki><br />
class Example : IExampleAPI<br />
{<br />
override:<br />
string getIndex() { return "Index!"; }<br />
string _data;<br />
@property string data() { return _data; }<br />
@property void data(string v) { _data=v; }<br />
int postSum(int a, int b) {<br />
return a + b;<br />
}<br />
int getItem(string _category,string _item) {<br />
// ...<br />
}<br />
}<br />
<br />
void main(string[] args)<br />
{<br />
auto api = new RestInterfaceClient!IExampleAPI("http://localhost/");<br />
auto index = api.getIndex();<br />
api.data ="My data";<br />
assert(api.data =="My data");<br />
assert(api.postSum(2, 3) == 5);<br />
}<br />
</nowiki><br />
</code><br />
<code> REST Server<br />
<nowiki><br />
class Example : IExampleAPI<br />
{<br />
override:<br />
string getIndex() { return "Index!"; }<br />
string _data;<br />
@property string data() { return _data; }<br />
@property void data(string v) { _data=v; }<br />
int postSum(int a, int b) {<br />
return a + b;<br />
}<br />
int getItem(string _category,string _item) {<br />
// ...<br />
}<br />
}<br />
<br />
shared static this() // vibed replacement for main<br />
{<br />
auto routes = new URLRouter;<br />
registerRestInterface!IExampleAPI(routes, new Example(), "/");<br />
auto settings = new HTTPServerSettings;<br />
settings.port = 8080;<br />
listenHTTP(settings, routes);<br />
}<br />
</nowiki><br />
</code><br />
<br />
<br />
*[https://d.readthedocs.org/en/latest/examples.html#web-application Simple web application]<br />
<br />
<br />
Email<br />
-----<br />
There is support for sending emails by SMTP in the standard library under [http://dlang.org/phobos/std_net_curl#.SMTP std.net.curl.SMTP] in vibe.d, [https://github.com/adamdruppe/arsd arsd] and [https://github.com/CyberShadow/ae AE Utils]. <br />
<br />
<code> Vibe.d Send Email Example<br />
<nowiki><br />
import vibe.core.log;<br />
import vibe.mail.smtp;<br />
<br />
<br />
void main()<br />
{<br />
auto settings = new SMTPClientSettings("smtp.example.com", 25);<br />
settings.connectionType = SMTPConnectionType.startTLS;<br />
settings.authType = SMTPAuthType.plain;<br />
settings.username = "username";<br />
settings.password = "secret";<br />
<br />
auto mail = new Mail;<br />
mail.headers["From"] = "<user@isp.com>";<br />
mail.headers["To"] = "<recipient@domain.com>";<br />
mail.headers["Subject"] = "Testmail";<br />
mail.bodyText = "Hello, World!";<br />
<br />
logInfo("Sending mail...");<br />
sendMail(settings, mail);<br />
logInfo("done.");<br />
}<br />
</nowiki><br />
</code><br />
<br />
For MIME support see Arsd and AE Utils (under code.dlang.org there are bindings for gmime). No IMAP as yet, but bindings are under development.<br />
<br />
<br />
Numerical computing<br />
-------------------<br />
*[http://dlang.org/d-floating-point.html D Floating Point Features]<br />
*[http://dlang.org/phobos/std_bigint.html arbitrary precision - 'bignum' - arithmetic]<br />
*[http://digitalmars.com/sargon/halffloat.html Sargon half-precision fast floating point]<br />
*[http://code.dlang.org/?sort=updated&category=library.scientific Scientific Computing Projects at code.dlang.org]<br />
<br />
<br />
<br />
Libraries - what is the D equivalent of pypi and pip?<br />
------------------------------------------------------<br />
See [http://code.dlang.org code.dlang.org] and the DUB package manager.<br />
<br />
<br />
Scripting<br />
---------<br />
Since D provides type inference, high-level constructs, and fast compile-time it is a great language for writing [https://github.com/Laeeth/tools/blob/master/FetchDlang/fetchdlang.d scripts]. The first line of the file is ignored if it begins with #! - by combining this with [http://dlang.org/rdmd.html rdmd] which handles dependency resolution, D becomes a leader in machine-code scripting language.<br />
<br />
<code> reading comma separated / CSV text - example from std.csv<br />
<nowiki><br />
auto text = "Name,Occupation,Salary\r"<br />
"Joe,Carpenter,300000\nFred,Blacksmith,400000\r\n";<br />
<br />
foreach(record; csvReader!(string[string])<br />
(text, null))<br />
{<br />
writefln("%s works as a %s and earns $%s per year.",<br />
record["Name"], record["Occupation"],<br />
record["Salary"]);<br />
}<br />
</nowiki><br />
</code><br />
<br />
<code> generating optimized machine code at compile time for compiled regex pattern matching<br />
<nowiki><br />
string phone = "+31 650 903 7158";<br />
auto phoneReg = ctRegex!r"^\+([1-9][0-9]*) [0-9 ]*$";<br />
auto m = match(phone, phoneReg);<br />
assert(m);<br />
assert(m.captures[0] == "+31 650 903 7158");<br />
assert(m.captures[1] == "31");<br />
</nowiki><br />
</code><br />
<br />
<br />
<br />
<br />
Next Steps<br />
----------<br />
* [http://dlang.org/download.html Download] and install D for your platform<br />
* Play with the D REPL or [http://dpaste.dzfl.pl/ Pastebin]<br />
* Consider purchasing Dr Andrei Alexandrescu's [http://www.amazon.com/D-Programming-Language-Andrei-Alexandrescu/dp/0321635361 The D Programming Language], [http://www.amazon.com/dp/1783287217/?tag=packtpubli-20 Adam Ruppe's D Cookbook], and reading the free book [http://ddili.org/ders/d.en/index.html 'Programming in D' by Ali Çehreli]<br />
* Read the D solutions to [http://rosettacode.org/wiki/Category:D Rosetta Code] problems<br />
* Take a look at the [http://wiki.dlang.org/Videos D language videos]<br />
* Subscribe to [http://arsdnet.net/this-week-in-d/ This Week in D]<br />
* Attend a meeting of a [http://wiki.dlang.org/D_User_Groups D User Group] near you<br />
* Follow D on [http://www.linkedin.com/groups/D-Developer-Network-3923820 LinkedIn], [https://plus.google.com/communities/100033468228217743303 Google+], [https://www.facebook.com/dlang.org Facebook], [https://www.xing.com/net/dlang Xing], [http://www.reddit.com/r/d_language/ Reddit], [https://www.quora.com/D-programming-language Quora]<br />
* Follow some [http://planet.dsource.org/ D blogs]<br />
* Post in the [http://forum.dlang.org forums] - don't be shy; this is a very helpful community<br />
<br />
[[Category:Languages versus D]]</div>Laeethhttps://wiki.dlang.org/?title=User:Laeeth&diff=6301User:Laeeth2015-06-18T07:13:47Z<p>Laeeth: </p>
<hr />
<div>*[[vibed faq addition]]<br />
*[[useful D snippets]]<br />
*[[User narratives on switching to D]]</div>Laeethhttps://wiki.dlang.org/?title=User_narratives_on_switching_to_D&diff=6203User narratives on switching to D2015-05-26T07:36:36Z<p>Laeeth: </p>
<hr />
<div>[We can clean up formatting later. I am not so good with wiki].<br />
<br />
Story 1: please state your agreement to use your name if you don't mind it being included. (It would make the account more vivid if so):<br />
<br />
Before I was mainly using C++ for my work(and dabbled in Rust, <br />
but never ended up switching to it)<br />
D's C-like syntax inspires familiarity to the point where I truly <br />
believe that D is easier to port C code to than C++ because you <br />
can write D in a "cleaned up" C for the most part, and slowly <br />
turn it into D whereas C++ is essentially a completely different <br />
style. Not too many languages can really claim this, and IMO it's <br />
a huge boon.<br />
<br />
D provides native performance directly on comparison with C/C++ <br />
while being much easier to jump in and bash out a few quick <br />
ideas(Phobos helps a lot with this.)<br />
<br />
Phobos offers far more than the C++ standard library as well. <br />
It's nice not to have to go hunting for libraries, C++11 helped <br />
with this a little I guess but it just feels like "it's there," <br />
whereas Andrei/Walter seem to actively be working towards "you <br />
should always be using Phobos or it should be fixed."<br />
<br />
Also, D's metaprogramming system is actually usable. I use CTFE <br />
to do a ton of precomputations at compiletime, I even recently <br />
learned that the compiler can unroll foreach loops in switches(! <br />
that's cool - D has a lot of neat tricks that nobody really seems <br />
to discuss,) I feel like I'm always learning new tricks in D, and <br />
not in the C++ way.<br />
<br />
The ability to use C libraries with barely any fuss(!), I ported <br />
a C's library's headers to D in about 10 minutes using htod and a <br />
bit of manual touchup. This is a `killer feature` in my opinion.<br />
<br />
Ranges/functional programming in general, C++ really has nothing <br />
on this. I think C++17 might be getting ranges but when I <br />
reviewed the paper they seemed far uglier and an <br />
afterthought(like most of C++), I've written large parts of my <br />
programs in purely functional style and LDC optimizes it to the <br />
equivalent imperative code.<br />
<br />
D's operator overloading is extremely well designed IMO,(it just <br />
goes with the rest of the 'make D work the way you want it to' <br />
feeling of the rest of the language)<br />
<br />
D(md) compiles pretty fast, I think it used to have a bigger <br />
advantage here over C++ before Clang became popular but it's <br />
still pretty darn fast and makes for python-esque edit-run-debug <br />
editing style. I went from compiling my projects on the <br />
university servers to my home desktop(and it compiles faster.)<br />
<br />
<br />
I think D's best quality is probably how approachable it is for <br />
C/C++ programmers compared to i.e, Rust which has a (weird) ML <br />
influence. I wouldn't be surprised if you could get a C or C++ <br />
programmer up to speed in D in an afternoon, at least enough to <br />
be efficient in it.<br />
<br />
D is of course not all roses, shared still feels half implemented <br />
and left to rot(D's memory model in general.) TDPL is aging, and <br />
there's not too much other literature on D - but Ali's book is <br />
very good. The compiler situation feels odd, LDC and GDC have <br />
very few contributors despite being better than dmd at optimizing <br />
and providing a lot of extra perks - i.e, LDC lets you use all of <br />
the LLVM sanitizers like the thread, memory, etc. ones, and LDC <br />
provides in-depth optimization analysis thanks to LLVM.<br />
<br />
But comparatively, this list is not so bad.<br />
<br />
I feel like I could write a book on why I use D, so I'm going to <br />
stop now : )</div>Laeethhttps://wiki.dlang.org/?title=User_narratives_on_switching_to_D&diff=6202User narratives on switching to D2015-05-26T07:35:56Z<p>Laeeth: </p>
<hr />
<div>[We can clean up formatting later. I am not so good with wiki].<br />
<br />
Story 1: please state your agreement to use your name if you don't mind it being included. (It would make the account more vivid if so):<br />
<br />
Before I was mainly using C++ for my work(and dabbled in Rust, <br />
but never ended up switching to it)<br />
D's C-like syntax inspires familiarity to the point where I truly <br />
believe that D is easier to port C code to than C++ because you <br />
can write D in a "cleaned up" C for the most part, and slowly <br />
turn it into D whereas C++ is essentially a completely different <br />
style. Not too many languages can really claim this, and IMO it's <br />
a huge boon.<br />
<br />
D provides native performance directly on comparison with C/C++ <br />
while being much easier to jump in and bash out a few quick <br />
ideas(Phobos helps a lot with this.)<br />
<br />
Phobos offers far more than the C++ standard library as well. <br />
It's nice not to have to go hunting for libraries, C++11 helped <br />
with this a little I guess but it just feels like "it's there," <br />
whereas Andrei/Walter seem to actively be working towards "you <br />
should always be using Phobos or it should be fixed."<br />
<br />
Also, D's metaprogramming system is actually usable. I use CTFE <br />
to do a ton of precomputations at compiletime, I even recently <br />
learned that the compiler can unroll foreach loops in switches(! <br />
that's cool - D has a lot of neat tricks that nobody really seems <br />
to discuss,) I feel like I'm always learning new tricks in D, and <br />
not in the C++ way.<br />
<br />
The ability to use C libraries with barely any fuss(!), I ported <br />
a C's library's headers to D in about 10 minutes using htod and a <br />
bit of manual touchup. This is a `killer feature` in my opinion.<br />
<br />
Ranges/functional programming in general, C++ really has nothing <br />
on this. I think C++17 might be getting ranges but when I <br />
reviewed the paper they seemed far uglier and an <br />
afterthought(like most of C++), I've written large parts of my <br />
programs in purely functional style and LDC optimizes it to the <br />
equivalent imperative code.<br />
<br />
D's operator overloading is extremely well designed IMO,(it just <br />
goes with the rest of the 'make D work the way you want it to' <br />
feeling of the rest of the language)<br />
<br />
I feel like I could write a book on why I use D, so I'm going to <br />
stop now : )</div>Laeethhttps://wiki.dlang.org/?title=User_narratives_on_switching_to_D&diff=6201User narratives on switching to D2015-05-26T07:35:36Z<p>Laeeth: Created page with "Story 1: please state your agreement to use your name if you don't mind it being included. (It would make the account more vivid if so): Before I was mainly using C++ for my..."</p>
<hr />
<div>Story 1: please state your agreement to use your name if you don't mind it being included. (It would make the account more vivid if so):<br />
<br />
Before I was mainly using C++ for my work(and dabbled in Rust, <br />
but never ended up switching to it)<br />
D's C-like syntax inspires familiarity to the point where I truly <br />
believe that D is easier to port C code to than C++ because you <br />
can write D in a "cleaned up" C for the most part, and slowly <br />
turn it into D whereas C++ is essentially a completely different <br />
style. Not too many languages can really claim this, and IMO it's <br />
a huge boon.<br />
<br />
D provides native performance directly on comparison with C/C++ <br />
while being much easier to jump in and bash out a few quick <br />
ideas(Phobos helps a lot with this.)<br />
<br />
Phobos offers far more than the C++ standard library as well. <br />
It's nice not to have to go hunting for libraries, C++11 helped <br />
with this a little I guess but it just feels like "it's there," <br />
whereas Andrei/Walter seem to actively be working towards "you <br />
should always be using Phobos or it should be fixed."<br />
<br />
Also, D's metaprogramming system is actually usable. I use CTFE <br />
to do a ton of precomputations at compiletime, I even recently <br />
learned that the compiler can unroll foreach loops in switches(! <br />
that's cool - D has a lot of neat tricks that nobody really seems <br />
to discuss,) I feel like I'm always learning new tricks in D, and <br />
not in the C++ way.<br />
<br />
The ability to use C libraries with barely any fuss(!), I ported <br />
a C's library's headers to D in about 10 minutes using htod and a <br />
bit of manual touchup. This is a `killer feature` in my opinion.<br />
<br />
Ranges/functional programming in general, C++ really has nothing <br />
on this. I think C++17 might be getting ranges but when I <br />
reviewed the paper they seemed far uglier and an <br />
afterthought(like most of C++), I've written large parts of my <br />
programs in purely functional style and LDC optimizes it to the <br />
equivalent imperative code.<br />
<br />
D's operator overloading is extremely well designed IMO,(it just <br />
goes with the rest of the 'make D work the way you want it to' <br />
feeling of the rest of the language)<br />
<br />
I feel like I could write a book on why I use D, so I'm going to <br />
stop now : )</div>Laeethhttps://wiki.dlang.org/?title=User:Laeeth&diff=6200User:Laeeth2015-05-26T07:29:52Z<p>Laeeth: </p>
<hr />
<div>[[vibed faq addition]]<br />
[[useful D snippets]]<br />
[[User narratives on switching to D]]</div>Laeethhttps://wiki.dlang.org/?title=Useful_D_snippets&diff=6118Useful D snippets2015-05-15T19:52:44Z<p>Laeeth: Created page with " http://dlang.org/intro-to-datetime.html import std.datetime; import core.stdc.time; void main() { time_t unixTime = core.stdc.time.time(null); auto stdTime =..."</p>
<hr />
<div><br />
http://dlang.org/intro-to-datetime.html<br />
<br />
import std.datetime;<br />
import core.stdc.time;<br />
void main() {<br />
time_t unixTime = core.stdc.time.time(null);<br />
auto stdTime = unixTimeToStdTime(unixTime);<br />
auto st = SysTime(stdTime);<br />
}</div>Laeethhttps://wiki.dlang.org/?title=User:Laeeth&diff=6117User:Laeeth2015-05-15T19:52:21Z<p>Laeeth: </p>
<hr />
<div>[[vibed faq addition]]<br />
[[useful D snippets]]</div>Laeethhttps://wiki.dlang.org/?title=Vibed_faq_addition&diff=6057Vibed faq addition2015-05-12T17:58:02Z<p>Laeeth: </p>
<hr />
<div>* how do I automatically terminate children when the parent has died?<br />
* how do I enable stack traces on segfault in Linux (info is there but not easy to find)<br />
* can I use utilities from vibed (like JSON handling) without using the vibed event loop?<br />
* how do I parse a JSON range into a struct<br />
* what is the relationship between vibed concurrency and dmd concurrency<br />
* when should I use fibers vs threads and new processes<br />
* what are the asynchronous library options and pros and cons of each - when to use which ?<br />
* how do I protect my vibed application using a proxy like nginx?<br />
* can I mix REST and manual routing for human-readable web pages in my application?<br />
* vibed terminates on error but I want my server application to keep running<br />
* does vibed work on ARM?<br />
* how do I get commercial support for vibed? <br />
* who uses vibed?<br />
* vibed is described as beta: how stable is it in practice?</div>Laeethhttps://wiki.dlang.org/?title=User:Csmith1991/Vibe.d_Documentation&diff=6056User:Csmith1991/Vibe.d Documentation2015-05-12T17:57:11Z<p>Laeeth: /* Vibe.d FAQ additions */</p>
<hr />
<div>==Vibe.d Documentation==<br />
{| class="wikitable"<br />
|-<br />
! Example<br />
! Status<br />
! Who's writing it?<br />
|-<br />
| app_skeleton<br />
| Not Started<br />
| N/A<br />
|-<br />
| auth_basic<br />
| Not Started<br />
| N/A<br />
|-<br />
| auth_digest<br />
| Not Started<br />
| N/A<br />
|-<br />
| bench-http-request<br />
| Not Started<br />
| N/A<br />
|-<br />
| bench-http-server<br />
| Not Started<br />
| N/A<br />
|-<br />
| bench-mongodb<br />
| Not Started<br />
| N/A<br />
|-<br />
| bench-urlrouter<br />
| Not Started<br />
| N/A<br />
|-<br />
| daytime<br />
| Not Started<br />
| N/A<br />
|-<br />
| diet<br />
| Not Started<br />
| N/A<br />
|-<br />
| download<br />
| Not Started<br />
| N/A<br />
|-<br />
| echoserver<br />
| Not Started<br />
| N/A<br />
|-<br />
| file_operations<br />
| Not Started<br />
| N/A<br />
|-<br />
| future<br />
| Not Started<br />
| N/A<br />
|-<br />
| http_info<br />
| Not Started<br />
| N/A<br />
|-<br />
| http_request<br />
| Not Started<br />
| N/A<br />
|-<br />
| http_reverse_proxy<br />
| Not Started<br />
| N/A<br />
|-<br />
| http_server<br />
| Not Started<br />
| N/A<br />
|-<br />
| http_static_server<br />
| Not Started<br />
| N/A<br />
|-<br />
| https_server<br />
| Not Started<br />
| N/A<br />
|-<br />
| https_server_sni<br />
| Not Started<br />
| N/A<br />
|-<br />
| json<br />
| Not Started<br />
| N/A<br />
|-<br />
| message<br />
| Not Started<br />
| N/A<br />
|-<br />
| mongodb<br />
| Not Started<br />
| N/A<br />
|-<br />
| redis-pubsub<br />
| Not Started<br />
| N/A<br />
|-<br />
| redis<br />
| Not Started<br />
| N/A<br />
|-<br />
| rest<br />
| Not Started<br />
| N/A<br />
|-<br />
| sendmail<br />
| Not Started<br />
| N/A<br />
|-<br />
| serialization<br />
| Not Started<br />
| N/A<br />
|-<br />
| task_control<br />
| Not Started<br />
| N/A<br />
|-<br />
| tcp_separate<br />
| Not Started<br />
| N/A<br />
|-<br />
| udp<br />
| Not Started<br />
| N/A<br />
|-<br />
| uploader<br />
| Not Started<br />
| N/A<br />
|-<br />
| web-i8n<br />
| Not Started<br />
| N/A<br />
|-<br />
| web<br />
| Not Started<br />
| N/A<br />
|-<br />
| [[User:Csmith1991/Vibe.d Documentation/websocket|websocket]]<br />
| In Progress<br />
| [[User:Csmith1991|csmith1991]]<br />
|-<br />
| [https://github.com/rejectedsoftware/vibe.d/issues/1096#issuecomment-101361547 See this comment]<br />
| Not Started<br />
| N/A<br />
|}<br />
<br />
==Vibe.d FAQ additions==<br />
[[Vibed_faq_addition ]]</div>Laeethhttps://wiki.dlang.org/?title=User:Csmith1991/Vibe.d_Documentation&diff=6055User:Csmith1991/Vibe.d Documentation2015-05-12T17:56:54Z<p>Laeeth: /* Vibe.d Documentation */</p>
<hr />
<div>==Vibe.d Documentation==<br />
{| class="wikitable"<br />
|-<br />
! Example<br />
! Status<br />
! Who's writing it?<br />
|-<br />
| app_skeleton<br />
| Not Started<br />
| N/A<br />
|-<br />
| auth_basic<br />
| Not Started<br />
| N/A<br />
|-<br />
| auth_digest<br />
| Not Started<br />
| N/A<br />
|-<br />
| bench-http-request<br />
| Not Started<br />
| N/A<br />
|-<br />
| bench-http-server<br />
| Not Started<br />
| N/A<br />
|-<br />
| bench-mongodb<br />
| Not Started<br />
| N/A<br />
|-<br />
| bench-urlrouter<br />
| Not Started<br />
| N/A<br />
|-<br />
| daytime<br />
| Not Started<br />
| N/A<br />
|-<br />
| diet<br />
| Not Started<br />
| N/A<br />
|-<br />
| download<br />
| Not Started<br />
| N/A<br />
|-<br />
| echoserver<br />
| Not Started<br />
| N/A<br />
|-<br />
| file_operations<br />
| Not Started<br />
| N/A<br />
|-<br />
| future<br />
| Not Started<br />
| N/A<br />
|-<br />
| http_info<br />
| Not Started<br />
| N/A<br />
|-<br />
| http_request<br />
| Not Started<br />
| N/A<br />
|-<br />
| http_reverse_proxy<br />
| Not Started<br />
| N/A<br />
|-<br />
| http_server<br />
| Not Started<br />
| N/A<br />
|-<br />
| http_static_server<br />
| Not Started<br />
| N/A<br />
|-<br />
| https_server<br />
| Not Started<br />
| N/A<br />
|-<br />
| https_server_sni<br />
| Not Started<br />
| N/A<br />
|-<br />
| json<br />
| Not Started<br />
| N/A<br />
|-<br />
| message<br />
| Not Started<br />
| N/A<br />
|-<br />
| mongodb<br />
| Not Started<br />
| N/A<br />
|-<br />
| redis-pubsub<br />
| Not Started<br />
| N/A<br />
|-<br />
| redis<br />
| Not Started<br />
| N/A<br />
|-<br />
| rest<br />
| Not Started<br />
| N/A<br />
|-<br />
| sendmail<br />
| Not Started<br />
| N/A<br />
|-<br />
| serialization<br />
| Not Started<br />
| N/A<br />
|-<br />
| task_control<br />
| Not Started<br />
| N/A<br />
|-<br />
| tcp_separate<br />
| Not Started<br />
| N/A<br />
|-<br />
| udp<br />
| Not Started<br />
| N/A<br />
|-<br />
| uploader<br />
| Not Started<br />
| N/A<br />
|-<br />
| web-i8n<br />
| Not Started<br />
| N/A<br />
|-<br />
| web<br />
| Not Started<br />
| N/A<br />
|-<br />
| [[User:Csmith1991/Vibe.d Documentation/websocket|websocket]]<br />
| In Progress<br />
| [[User:Csmith1991|csmith1991]]<br />
|-<br />
| [https://github.com/rejectedsoftware/vibe.d/issues/1096#issuecomment-101361547 See this comment]<br />
| Not Started<br />
| N/A<br />
|}<br />
<br />
==Vibe.d FAQ additions==<br />
[[http://wiki.dlang.org/Vibed_faq_addition]]</div>Laeethhttps://wiki.dlang.org/?title=Vibed_faq_addition&diff=6054Vibed faq addition2015-05-12T17:55:44Z<p>Laeeth: Created page with "* how do I automatically terminate children when the parent has died? * how do I enable stack traces on segfault in Linux (info is there but not easy to find) * can I use util..."</p>
<hr />
<div>* how do I automatically terminate children when the parent has died?<br />
* how do I enable stack traces on segfault in Linux (info is there but not easy to find)<br />
* can I use utilities from vibed (like JSON handling) without using the vibed event loop?<br />
* how do I parse a JSON range into a struct<br />
* what is the relationship between vibed concurrency and dmd concurrency<br />
* when should I use fibers vs threads and new processes<br />
* what are the asynchronous library options and pros and cons of each - when to use which ?<br />
* how do I protect my vibed application using a proxy like nginx?<br />
* can I mix REST and manual routing for human-readable web pages in my application?<br />
* vibed terminates on error but I want my server application to keep running<br />
* does vibed work on ARM?</div>Laeethhttps://wiki.dlang.org/?title=User:Laeeth&diff=6053User:Laeeth2015-05-12T17:50:54Z<p>Laeeth: Created page with "vibed faq addition"</p>
<hr />
<div>[[vibed faq addition]]</div>Laeethhttps://wiki.dlang.org/?title=GUI_Libraries&diff=6021GUI Libraries2015-05-11T19:48:37Z<p>Laeeth: </p>
<hr />
<div>=== Wrappers ===<br />
<br />
{{Projects<br />
| Projects =<br />
<br />
{{Project<br />
| name = '''GtkD'''<br />
| platform = Windows/POSIX/Mac OS X<br />
| license = LGPL<br />
| about = GTK+ is a highly usable, feature rich toolkit for creating graphical user interfaces which boasts cross platform compatibility and an easy to use API.<br />
| url = https://github.com/gtkd-developers/GtkD<br />
}}<br />
<br />
{{Project<br />
| name = '''DWT'''<br />
| platform = Windows/Linux-gtk<br />
| license = EPL<br />
| about = DWT is a library for creating cross-platform GUI applications. It's a port of the SWT Java library from Eclipse. DWT is compatible with D2 using the standard library (Phobos) and D1 using Tango. Now available on 32 and 64 bit, Linux and Windows. [http://www.dsource.org/projects/dwt Old dsource.org page].<br />
| url = https://github.com/d-widget-toolkit/dwt<br />
}}<br />
<br />
{{Project<br />
| name = '''qtD'''<br />
| platform = Windows/Linux/Mac OS X<br />
| license = GPL(code generator), Boost Software License 1.0<br />
| about = D bindings to the Qt cross-platform application and GUI library<br />
| url = https://bitbucket.org/qtd/repo<br />
}}<br />
<br />
{{Project<br />
| name = '''dqt''' (w0rp)<br />
| platform = Windows/Linux/Mac OS X<br />
| license = BSD 2-clause<br />
| about = Qt bindings for D<br />
| url = https://github.com/w0rp/dqt<br />
}}<br />
<br />
<br />
<br />
{{Project<br />
| name = '''wxD'''<br />
| platform = Windows/Linux/Mac OS X<br />
| license = wxWidgets(GNU LGPL based)<br />
| about = wxD is D programming language bindings for [http://www.wxwidgets.org wxWidgets], providing a portable GUI toolkit for D.<br />
| url = http://wxd.sourceforge.net/<br />
}}<br />
<br />
{{Project<br />
| name = '''FltkD'''<br />
| platform = <br />
| license = Academic Free License<br />
| about = Testing use of C++ FLTK GUI lib from D code<br />
| url = https://github.com/philippe-quesnel/FltkD<br />
}}<br />
{{Project<br />
| name = '''tkd'''<br />
| platform = Windows/Linux/Mac OS X<br />
| license = MIT License (MIT)<br />
| about = GUI toolkit for the D programming language based on Tcl/Tk<br />
| url = https://github.com/nomad-software/tkd<br />
}}<br />
{{Project<br />
| name = '''dtk'''<br />
| platform = Windows/Linux/Mac OS X<br />
| license = Boost<br />
| about = dtk is a D wrapper of the Tcl/Tk graphics library.<br />
| url = https://github.com/AndrejMitrovic/dtk<br />
}}<br />
{{Project<br />
| name = '''iup'''<br />
| platform = Windows/Linux/Mac OS X<br />
| license = Boost<br />
| about = Iup porting [http://forum.dlang.org/post/okejrntxjtspsdoagwah@forum.dlang.org forum] <br />
| url = https://bitbucket.org/alphaglosined/libglosined/src/85ab6b2135879848e7efd5f1dfa732f2cfb753f8/iup/?at=default<br />
}}<br />
}}<br />
<br />
=== Native ===<br />
{{Projects<br />
| Projects =<br />
{{Project<br />
| name = '''DFL'''<br />
| platform = Windows<br />
| license = In license.txt<br />
| about = D Forms Library is a graphical user interface library for Windows. The project as abandoned by its author but unofficial forks is alive.<br />
| url = http://www.dprogramming.com/dfl.php<br />
}}<br />
{{Project<br />
| name = '''DFL Rayerd fork'''<br />
| platform = Windows<br />
| license = In license.txt<br />
| about = DFL unofficial fork <br />
| url = https://github.com/Rayerd/dfl<br />
}}<br />
{{Project<br />
| name = '''DFL Rahim fork'''<br />
| platform = Windows<br />
| license = LGPL<br />
| about = DFL unofficial fork (with Entice Designer)<br />
| url = https://github.com/rahim14/DFL<br />
}}<br />
{{Project<br />
| name = '''DFL2'''<br />
| platform = Windows<br />
| license = LGPL 3.0<br />
| about = DFL FrankLike fork unofficial fork, now dfl can be build by [https://github.com/FrankLike/dco dco].<br />
| url = https://github.com/FrankLIKE/dfl2<br />
}}<br />
<br />
{{Project<br />
| name = '''DGui'''<br />
| platform = Windows<br />
| license = Boost 1.0<br />
| about = DGui is a graphic library for Windows that aims to make windows applications with small effort.<br />
| url = https://bitbucket.org/dgui/dgui<br />
}}<br />
{{Project<br />
| name = '''fxLib'''<br />
| platform = Windows<br />
| license = ??<br />
| about = A library for creating basic Win32 Apps with just a small amount of code.<br />
| url = https://github.com/aBothe/fxLib<br />
}}<br />
{{Project<br />
| name = '''DlangUI'''<br />
| platform = POSIX/Windows<br />
| license = Boost 1.0<br />
| about = Cross platform GUI library, a bit similar to Android UI API. Layouts, styles, themes, unicode, i18n, OpenGL based acceleration, widget set.<br />
| url = https://github.com/buggins/dlangui<br />
}}<br />
{{Project<br />
| name = '''DQuick'''<br />
| platform = Windows/Linux<br />
| license = Boost<br />
| about = A GUI library written in D<br />
| url = https://github.com/D-Quick/DQuick<br />
}}<br />
}}<br />
<br />
----<br />
[[Category:GUI]]<br />
[[Category:Library]]</div>Laeethhttps://wiki.dlang.org/?title=GUI_Libraries&diff=6020GUI Libraries2015-05-11T19:48:25Z<p>Laeeth: </p>
<hr />
<div>=== Wrappers ===<br />
<br />
{{Projects<br />
| Projects =<br />
<br />
{{Project<br />
| name = '''GtkD'''<br />
| platform = Windows/POSIX/Mac OS X<br />
| license = LGPL<br />
| about = GTK+ is a highly usable, feature rich toolkit for creating graphical user interfaces which boasts cross platform compatibility and an easy to use API.<br />
| url = https://github.com/gtkd-developers/GtkD<br />
}}<br />
<br />
{{Project<br />
| name = '''DWT'''<br />
| platform = Windows/Linux-gtk<br />
| license = EPL<br />
| about = DWT is a library for creating cross-platform GUI applications. It's a port of the SWT Java library from Eclipse. DWT is compatible with D2 using the standard library (Phobos) and D1 using Tango. Now available on 32 and 64 bit, Linux and Windows [http://www.dsource.org/projects/dwt Old dsource.org page].<br />
| url = https://github.com/d-widget-toolkit/dwt<br />
}}<br />
<br />
{{Project<br />
| name = '''qtD'''<br />
| platform = Windows/Linux/Mac OS X<br />
| license = GPL(code generator), Boost Software License 1.0<br />
| about = D bindings to the Qt cross-platform application and GUI library<br />
| url = https://bitbucket.org/qtd/repo<br />
}}<br />
<br />
{{Project<br />
| name = '''dqt''' (w0rp)<br />
| platform = Windows/Linux/Mac OS X<br />
| license = BSD 2-clause<br />
| about = Qt bindings for D<br />
| url = https://github.com/w0rp/dqt<br />
}}<br />
<br />
<br />
<br />
{{Project<br />
| name = '''wxD'''<br />
| platform = Windows/Linux/Mac OS X<br />
| license = wxWidgets(GNU LGPL based)<br />
| about = wxD is D programming language bindings for [http://www.wxwidgets.org wxWidgets], providing a portable GUI toolkit for D.<br />
| url = http://wxd.sourceforge.net/<br />
}}<br />
<br />
{{Project<br />
| name = '''FltkD'''<br />
| platform = <br />
| license = Academic Free License<br />
| about = Testing use of C++ FLTK GUI lib from D code<br />
| url = https://github.com/philippe-quesnel/FltkD<br />
}}<br />
{{Project<br />
| name = '''tkd'''<br />
| platform = Windows/Linux/Mac OS X<br />
| license = MIT License (MIT)<br />
| about = GUI toolkit for the D programming language based on Tcl/Tk<br />
| url = https://github.com/nomad-software/tkd<br />
}}<br />
{{Project<br />
| name = '''dtk'''<br />
| platform = Windows/Linux/Mac OS X<br />
| license = Boost<br />
| about = dtk is a D wrapper of the Tcl/Tk graphics library.<br />
| url = https://github.com/AndrejMitrovic/dtk<br />
}}<br />
{{Project<br />
| name = '''iup'''<br />
| platform = Windows/Linux/Mac OS X<br />
| license = Boost<br />
| about = Iup porting [http://forum.dlang.org/post/okejrntxjtspsdoagwah@forum.dlang.org forum] <br />
| url = https://bitbucket.org/alphaglosined/libglosined/src/85ab6b2135879848e7efd5f1dfa732f2cfb753f8/iup/?at=default<br />
}}<br />
}}<br />
<br />
=== Native ===<br />
{{Projects<br />
| Projects =<br />
{{Project<br />
| name = '''DFL'''<br />
| platform = Windows<br />
| license = In license.txt<br />
| about = D Forms Library is a graphical user interface library for Windows. The project as abandoned by its author but unofficial forks is alive.<br />
| url = http://www.dprogramming.com/dfl.php<br />
}}<br />
{{Project<br />
| name = '''DFL Rayerd fork'''<br />
| platform = Windows<br />
| license = In license.txt<br />
| about = DFL unofficial fork <br />
| url = https://github.com/Rayerd/dfl<br />
}}<br />
{{Project<br />
| name = '''DFL Rahim fork'''<br />
| platform = Windows<br />
| license = LGPL<br />
| about = DFL unofficial fork (with Entice Designer)<br />
| url = https://github.com/rahim14/DFL<br />
}}<br />
{{Project<br />
| name = '''DFL2'''<br />
| platform = Windows<br />
| license = LGPL 3.0<br />
| about = DFL FrankLike fork unofficial fork, now dfl can be build by [https://github.com/FrankLike/dco dco].<br />
| url = https://github.com/FrankLIKE/dfl2<br />
}}<br />
<br />
{{Project<br />
| name = '''DGui'''<br />
| platform = Windows<br />
| license = Boost 1.0<br />
| about = DGui is a graphic library for Windows that aims to make windows applications with small effort.<br />
| url = https://bitbucket.org/dgui/dgui<br />
}}<br />
{{Project<br />
| name = '''fxLib'''<br />
| platform = Windows<br />
| license = ??<br />
| about = A library for creating basic Win32 Apps with just a small amount of code.<br />
| url = https://github.com/aBothe/fxLib<br />
}}<br />
{{Project<br />
| name = '''DlangUI'''<br />
| platform = POSIX/Windows<br />
| license = Boost 1.0<br />
| about = Cross platform GUI library, a bit similar to Android UI API. Layouts, styles, themes, unicode, i18n, OpenGL based acceleration, widget set.<br />
| url = https://github.com/buggins/dlangui<br />
}}<br />
{{Project<br />
| name = '''DQuick'''<br />
| platform = Windows/Linux<br />
| license = Boost<br />
| about = A GUI library written in D<br />
| url = https://github.com/D-Quick/DQuick<br />
}}<br />
}}<br />
<br />
----<br />
[[Category:GUI]]<br />
[[Category:Library]]</div>Laeethhttps://wiki.dlang.org/?title=Coming_From&diff=5984Coming From2015-05-06T15:06:05Z<p>Laeeth: /* Porting */</p>
<hr />
<div>When coming from another language it is good to find out where D stands in relation to it. There is the [[DigitalMars:d/2.0/comparison.html | feature list]] which states if a feature exists or not and possibly an explanation. For a side-by-side comparison of many languages: [[Languages_Versus_D | Languages vs D]] or you can look at code snippets of from [http://rosettacode.org/wiki/Category:D Rosetta Code].<br />
<br />
A very superficial way to find out the popularity of D in relation to other languages can is at the [http://www.tiobe.com/tiobe_index/index.htm Tiobe Index] website.<br />
<br />
For information about syntactical differences or gotchas when coming from another language choose your language below.<br />
<br />
<br />
== General Comparison ==<br />
* [[Languages Versus D | Languages vs. D]]<br />
* [http://en.wikibooks.org/wiki/D_Transition_Guide D Transition Guide]<br />
* [http://dlang.org/comparison.html Feature List]<br />
* [http://rosettacode.org/wiki/Category:D Rosetta Code: D category]<br />
* [https://p0nce.github.io/d-idioms/ Idioms for D]<br />
<br />
== Specific Language ==<br />
<br />
* [http://dlang.org/ctod.html Programming in D for C Programmers]<br />
* [https://p0nce.github.io/d-idioms/#Porting-from-C-gotchas Porting from C gotchas]<br />
* [http://dlang.org/cpptod.html Programming in D for C++ Programmers]<br />
* [https://p0nce.github.io/d-idioms/#How-does-D-improve-on-C++17? How does D improve on C++ 17?]<br />
* [[Programming in D for CSharp Programmers | C#]]<br />
* [[Programming in D for Delphi Programmers | Delphi or Pascal]]<br />
* [[Programming in D for Eiffel Programmers | Eiffel]]<br />
* [[Programming in D for Java Programmers | Java]]<br />
* [[Programming in D for Python Programmers | Python]]<br />
* [[Programming in D for Ruby Programmers | Ruby]]<br />
* [[Programming in D for Basic Programmers | Basic]]<br />
<br />
== Porting ==<br />
If you are interested in converting your code to D start by looking at the [[PortingOverview | Porting Overview]].<br />
<br />
Walter Bright has observed that when you first start writing D you tend to write it like the existing languages you are familiar with. In time you may choose to make use of the higher-level features of D that make writing D code a pleasure rather than a chore. But programming is about using a tool to solve a problem, and there is no dogma in D that there is only one way to do it. Very often you don't need to make use of advanced D features like metaprogramming, templates, and compiler time function execution to achieve a useful result quickly.<br />
<br />
Converting C code with explicit memory allocation and resource management? Make use of the scope(exit) feature to automatically free pointers and close files when your function or code block finishes (whether successfully or on error).<br />
<br />
From Adam Ruppe "D this Week"<br />
<blockquote><br />
Don't be afraid to do things the C way.<br />
<br />
I've observed a lot of D programmers worrying about doing things the "D way", including asking how to convert working C standard library code to D or lamenting the lack of a D library to replace some C code.<br />
<br />
There's value in this: D can do a lot of things C can't. The "D way" can often be safer, less bug-prone, more beautiful, or more efficient than C code and libraries.<br />
<br />
However, D is also a language for practical programmers and sometimes code that works today is more important than ideal code that might be written at some point later. This is why D gives full access to C facilities, so you can use them!<br />
<br />
If you know how to do something with scanf, you can still use it in D, even while mixing with std.stdio's functions. Simply import core.stdc.stdio; and you can use all your familiar C functions.<br />
<br />
Want to do memory management the C way? Simply import core.stdc.stdlib; and use malloc and free. Combined with D features like scope(exit) to help with freeing and struct semantics to manage ownership you can rest assured that using D will offer advantages over C where needed, without tying your hands when you want to do things the old, familiar way.<br />
<br />
If you have a third-party C API, you don't have to reimplement that functionality in D to take advantage of it (though, there are times you do want to, to leverage D's unique offers). You can simple write an extern(C) function declaration and call the function directly from D, or you can also use dynamic library loading in D, the same way as in C, e.g. with dlopen or LoadLibrary.<br />
<br />
If you know how to solve a problem with pointers, structs, loops, and procedures as in C, you can use them in D too. Yes, the standard library offers a number of excellent range-based algorithms and help for coding in a functional programming style, and learning these is worth the investment. But, if you already know how to do it in C and need it done now, don't let Phobos' allure be an enemy to your productivity. You can still do your work with familiar language features.<br />
<br />
Moving to D opens up a whole new world of superior programming. But it doesn't shut you out of the old world. D aims to be a practical language for working programmers - remember that as you work with it. The new features will still be there to try tomorrow.<br />
<br />
</blockquote><br />
<br />
== Related ==<br />
* [[Language_Specification | Language Specification]]<br />
* [[D_Tutorial/Starting_With_D | Setting up an environment to compile programs]]<br />
* [[Neighbourhood | Seeking help using D]]<br />
* [[Development_with_D | Development with D]]<br />
* [[FAQ | Frequently Asked Questions]]<br />
<br />
[[Category:Languages versus D]]</div>Laeethhttps://wiki.dlang.org/?title=Coming_From&diff=5983Coming From2015-05-06T14:43:02Z<p>Laeeth: /* Porting */</p>
<hr />
<div>When coming from another language it is good to find out where D stands in relation to it. There is the [[DigitalMars:d/2.0/comparison.html | feature list]] which states if a feature exists or not and possibly an explanation. For a side-by-side comparison of many languages: [[Languages_Versus_D | Languages vs D]] or you can look at code snippets of from [http://rosettacode.org/wiki/Category:D Rosetta Code].<br />
<br />
A very superficial way to find out the popularity of D in relation to other languages can is at the [http://www.tiobe.com/tiobe_index/index.htm Tiobe Index] website.<br />
<br />
For information about syntactical differences or gotchas when coming from another language choose your language below.<br />
<br />
<br />
== General Comparison ==<br />
* [[Languages Versus D | Languages vs. D]]<br />
* [http://en.wikibooks.org/wiki/D_Transition_Guide D Transition Guide]<br />
* [http://dlang.org/comparison.html Feature List]<br />
* [http://rosettacode.org/wiki/Category:D Rosetta Code: D category]<br />
* [https://p0nce.github.io/d-idioms/ Idioms for D]<br />
<br />
== Specific Language ==<br />
<br />
* [http://dlang.org/ctod.html Programming in D for C Programmers]<br />
* [https://p0nce.github.io/d-idioms/#Porting-from-C-gotchas Porting from C gotchas]<br />
* [http://dlang.org/cpptod.html Programming in D for C++ Programmers]<br />
* [https://p0nce.github.io/d-idioms/#How-does-D-improve-on-C++17? How does D improve on C++ 17?]<br />
* [[Programming in D for CSharp Programmers | C#]]<br />
* [[Programming in D for Delphi Programmers | Delphi or Pascal]]<br />
* [[Programming in D for Eiffel Programmers | Eiffel]]<br />
* [[Programming in D for Java Programmers | Java]]<br />
* [[Programming in D for Python Programmers | Python]]<br />
* [[Programming in D for Ruby Programmers | Ruby]]<br />
* [[Programming in D for Basic Programmers | Basic]]<br />
<br />
== Porting ==<br />
If you are interested in converting your code to D start by looking at the [[PortingOverview | Porting Overview]].<br />
<br />
Walter Bright has observed that when you first start writing D you tend to write it like the existing languages you are familiar with. In time you may choose to make use of the higher-level features of D that make writing D code a pleasure rather than a chore. But programming is about using a tool to solve a problem, and there is no dogma in D that there is only one way to do it. Very often you don't need to make use of advanced D features like metaprogramming, templates, and compiler time function execution to achieve a useful result quickly.<br />
<br />
So it's often initially satisfying to start by porting the code as is, and then over time refine it or write a higher-level wrapper (you can start by wrapping only a few bits and build up over time).<br />
<br />
== Related ==<br />
* [[Language_Specification | Language Specification]]<br />
* [[D_Tutorial/Starting_With_D | Setting up an environment to compile programs]]<br />
* [[Neighbourhood | Seeking help using D]]<br />
* [[Development_with_D | Development with D]]<br />
* [[FAQ | Frequently Asked Questions]]<br />
<br />
[[Category:Languages versus D]]</div>Laeethhttps://wiki.dlang.org/?title=Programming_in_D_for_Python_Programmers&diff=5982Programming in D for Python Programmers2015-05-06T13:57:13Z<p>Laeeth: </p>
<hr />
<div>"Often, programming teams will resort to a hybrid approach, where they will mix Python and C++, trying to get the productivity of Python and the performance of C++. The frequency of this approach indicates that there is a large unmet need in the programming language department.<br />
<br />
D intends to fill that need. It combines the ability to do low-level manipulation of the machine with the latest technologies in building reliable, maintainable, portable, high-level code. D has moved well ahead of any other language in its abilities to support and integrate multiple paradigms like imperative, OOP, and generic programming"<br />
<br />
-- Walter Bright<br />
<br />
<br />
<br />
This section is under development - feel free to suggest improvements or additions.<br />
<br />
<br />
D is Like Native Python<br />
-----------------------<br />
*[http://bitbashing.io/2015/01/26/d-is-like-native-python.html D is like Native Python]<br />
<br />
*[http://tomerfiliba.com/blog/dlang/ D for the Win] A former Python programmer explores the benefits from moving to D<br />
<br />
*[http://blog.experimentalworks.net/2015/01/the-d-language-a-sweet-spot-between-python-and-c/ The D Language: a sweet-spot between Python and C]<br />
<br />
*[http://dconf.org/2015/talks/smith.html A hedge fund quant] finds that Python begins to choke on the data volumes requiring processing, but that D can cope and is productive.<br />
<br />
*[http://www.slideshare.net/LiranZvibel/d-talk - weka.io: Israeli stealth mode storage startup talk slides exploring similarities with Python]<br />
<br />
*[http://thebird.nl/blog/D_Dragon.html D is a Dragon: why D matters for bioinformatics] - summary: strong typing, speed, parallelisation with high-performance message passing, productivity, immutability, and high-level abstractions.<br />
<br />
*[http://bioinformatics.oxfordjournals.org/content/early/2015/02/18/bioinformatics.btv098.full.pdf+html Sambamba:] a [http://google-opensource.blogspot.nl/2015/03/gsoc-project-sambamba-published-in.html?utm_source=feedburner&utm_medium=feed&utm_campaign=Feed:+GoogleOpenSourceBlog+(Google+Open+Source+Blog Google Summer of Code Project involving the Open Bioinformatics Foundation] that is the fastest BAM parser. No Python-specific content, but this addresses a common-use domain for Python.<br />
<br />
<br />
AdRoll is [http://java.dzone.com/articles/big-data-and-python-utilizing known for their use of Python elsewhere], but their data scientists use D. According to Andrew Pascoe, senior data scientist at AdRoll, "One of the clearest advantages of using D compared to other typical data science workflows is that it compiles down into machine code. Without an interpreter or virtual machine layer, we can rip through data significantly faster than other tools like a Java hadoop framework, R, or python would allow. But D’s compiler is fast enough that in many cases it can be run as if it were a scripting language....The key thing here that separates D from other efficient languages like the oft-suggested C or C++ is that D frees you to program in the style you feel most comfortable with at the given time". He says that they have found that they "can rapidly prototype new infrastructure and analysis tasks, and when efficiency becomes a core concern, we have the ability to refactor that same code base to squeeze as much performance out as possible".<br />
<br />
*[http://tech.adroll.com/blog/data/2014/11/17/d-is-for-data-science.html AdRoll: D is for Data Science]<br />
<br />
*[https://d.readthedocs.org/en/latest/examples.html#plotting-with-matplotlib-python Plotting in D using python's matplotlib]<br />
<br />
<br />
Generators and List Comprehensions<br />
----------------------------------<br />
Python's generators and list comprehensions have been thought to be two of the most difficult concepts to replicate in other languages. For the D solution to the problem solved by Python generators, see D Ranges and lazy evaluation. For list comprehensions, see UFCS.<br />
<br />
*[http://www.drdobbs.com/cpp/uniform-function-call-syntax/232700394 Walter Bright on UFCS]<br />
*[https://www.youtube.com/watch?v=cQkBOCo8UrE Walter Bright youtube talk on component programming in D]<br />
<br />
*[http://www.informit.com/articles/printerfriendly/1407357 Theoretical article on ranges as a development of the iterator concept by the C++ guru, Dr Andrei Alexandrescu]<br />
*[http://ddili.org/ders/d.en/ranges.html Introduction to Ranges by Ali Çehreli - Part I]<br />
*[http://ddili.org/ders/d.en/ranges.html Introduction to Ranges by Ali Çehreli - Part II]<br />
*[http://dlang.org/d-array-article.html Introduction to D slices]<br />
<br />
*[http://dlang.org/phobos/std_range.html std.range structures and functions in the Phobos standard library]<br />
*[http://dlang.org/phobos/std_algorithm.html std.algorithm generic functions in Phobos]<br />
*[http://dlang.org/phobos/std_array.html std.array]<br />
<br />
*[https://www.semitwist.com/articles/article/view/combine-coroutines-and-input-ranges-for-dead-simple-d-iteration Combining co-routines and input ranges for dead-simple iteration]<br />
<br />
<br />
Parallel Programming<br />
--------------------<br />
Parallel programming has become increasingly in focus as we approach the beginning of the end of the [http://www.gotw.ca/publications/concurrency-ddj.htm free lunch from Moore's Law]. D makes multiprocessing and threading as simple as possible, but not simpler:<br />
<br />
*[http://www.informit.com/articles/article.aspx?p=1609144 Free chapter from Dr Andrei Alexandrescu's book on parallelism in D]<br />
*[http://ddili.org/ders/d.en/parallelism.html Ali Cehreli on parallelism]<br />
*[http://ddili.org/ders/d.en/concurrency.html Ali Cehreli on message-passing concurrency]<br />
*[http://ddili.org/ders/d.en/concurrency_shared.html Ali Cehreli on data-sharing concurrency]<br />
*[http://dlang.org/library/std/parallelism.html std.parallelism]<br />
<br />
<code> simple example from std.parallelism documentation<br />
<nowiki><br />
import std.algorithm, std.parallelism, std.range;<br />
<br />
void main() {<br />
// Parallel reduce can be combined with<br />
// std.algorithm.map to interesting effect.<br />
// The following example (thanks to Russel Winder)<br />
// calculates pi by quadrature using<br />
// std.algorithm.map and TaskPool.reduce.<br />
// getTerm is evaluated in parallel as needed by<br />
// TaskPool.reduce.<br />
//<br />
// Timings on an Athlon 64 X2 dual core machine:<br />
//<br />
// TaskPool.reduce: 12.170 s<br />
// std.algorithm.reduce: 24.065 s<br />
<br />
immutable n = 1_000_000_000;<br />
immutable delta = 1.0 / n;<br />
<br />
real getTerm(int i)<br />
{<br />
immutable x = ( i - 0.5 ) * delta;<br />
return delta / ( 1.0 + x * x ) ;<br />
}<br />
<br />
immutable pi = 4.0 * taskPool.reduce!"a + b"(<br />
std.algorithm.map!getTerm(iota(n))<br />
);<br />
}<br />
</nowiki><br />
</code><br />
<br />
Interfacing D with an existing codebase<br />
---------------------------------------<br />
*[http://dlang.org/interfaceToC.html C interfacing is simple and complete - D can call C, and C can call D]<br />
*[http://dlang.org/cpp_interface.html C++ interfacing is a key priority of the D core team but much can already be done - in fact more than is described here]<br />
*[https://github.com/ariovistus/pyd PyD] creates seamless interoperation between D and CPython, including for numpy arrays. [http://www.youtube.com/watch?v=y-k7GyOcs3o "It just works".] Make sure you visit the github code, and not the old version up at bitbucket.<br />
*Other options are to use cython wrappings to connect to D, or to write in D directly to the Python API. There are examples of this in the PyD examples directory within PyD<br />
*[https://github.com/JakobOvrum/LuaD LuaD] creates a simple interface between D and Lua<br />
<br />
<code> D calling embedded Python<br />
<nowiki><br />
void main() {<br />
auto context = new InterpContext();<br />
context.a = 2;<br />
context.py_stmts("print ('1 + %s' % a)");<br />
}<br />
</nowiki><br />
</code><br />
<br />
<code> Lua D example<br />
<nowiki><br />
import luad.all;<br />
<br />
void main()<br />
{<br />
auto lua = new LuaState;<br />
lua.openLibs();<br />
<br />
auto print = lua.get!LuaFunction("print");<br />
print("hello, world!");<br />
}<br />
</nowiki><br />
</code><br />
<br />
<br />
Web development, concurrency and JSON/BSON/XML<br />
----------------------------------------------<br />
Phobos includes bindings to the widely-used external curl library within Phobos (std.net.curl) and does include provision within std.csv, std.json and std.xml for processing structured data. The JSON and XML implementations in Phobos could be better, and many people choose to use an external library. The most popular solution for this is [http://vibed.org Vibe D], and this comes with a useful framework for web development, networking, fiber-based concurrency, JSON and BSON. One can write fiber-oriented code without having to deal with callbacks. (See [https://www.youtube.com/watch?v=Zs8O7MVmlfw CyberShadow's presentation] at Dconf 2013 for an excellent review of the differences).<br />
<br />
Atila Neaves has done one [https://atilanevesoncode.wordpress.com/2013/12/05/go-vs-d-vs-erlang-vs-c-in-real-life-mqtt-broker-implementation-shootout/ benchmark study on Vibed vs Go vc C vs Erlang] in a MQTT broker implementation<br />
<br />
Officially vibed is in beta, but the author seems to have high standards, and for many purposes you may find that this is good enough to be production-ready. (Of course, caveat emptor, it goes without saying).<br />
<br />
Other general solutions include those available in [https://github.com/adamdruppe/arsd Adam Ruppe's ARSD] micro-framework, and CyberShadow's [https://github.com/CyberShadow/ae AE] library. See the forums for some further possibilities on the JSON and XML front. D's slices facilitate fast and efficient parsing, and as of some time back, the XML parser in the Tango library was possibly the fastest in the world.<br />
<br />
<code> Simple HTTP server<br />
<nowiki><br />
import vibe.d;<br />
<br />
shared static this()<br />
{<br />
auto settings = new HTTPServerSettings;<br />
settings.port = 8080;<br />
<br />
listenHTTP(settings, &handleRequest);<br />
}<br />
<br />
void handleRequest(HTTPServerRequest req,<br />
HTTPServerResponse res)<br />
{<br />
if (req.path == "/")<br />
res.writeBody("Hello, World!", "text/plain");<br />
}<br />
</nowiki><br />
</code><br />
<code> Declaring a REST interface<br />
<nowiki><br />
interface IExampleAPI<br />
{<br />
// Matches "GET /"<br />
string getIndex();<br />
// Matches "GET /data"<br />
@property string data();<br />
// Matches "PUT /data"<br />
@property void data(string info);<br />
// Matches "POST /sum"<br />
// or "GET /sum?a=...&b=..."<br />
int postSum(int a, int b);<br />
// Matches "GET /item/<category>/<item>"<br />
@path("item/:category/:item")<br />
int getItem(string _category, int _item);<br />
}<br />
</nowiki><br />
</code><br />
<br />
<br />
<code> REST Client<br />
<nowiki><br />
class Example : IExampleAPI<br />
{<br />
override:<br />
string getIndex() { return "Index!"; }<br />
string _data;<br />
@property string data() { return _data; }<br />
@property void data(string v) { _data=v; }<br />
int postSum(int a, int b) {<br />
return a + b;<br />
}<br />
int getItem(string _category,string _item) {<br />
// ...<br />
}<br />
}<br />
<br />
void main(string[] args)<br />
{<br />
auto api = new RestInterfaceClient!IExampleAPI("http://localhost/");<br />
auto index = api.getIndex();<br />
api.data ="My data";<br />
assert(api.data =="My data");<br />
assert(api.postSum(2, 3) == 5);<br />
}<br />
</nowiki><br />
</code><br />
<code> REST Server<br />
<nowiki><br />
class Example : IExampleAPI<br />
{<br />
override:<br />
string getIndex() { return "Index!"; }<br />
string _data;<br />
@property string data() { return _data; }<br />
@property void data(string v) { _data=v; }<br />
int postSum(int a, int b) {<br />
return a + b;<br />
}<br />
int getItem(string _category,string _item) {<br />
// ...<br />
}<br />
}<br />
<br />
shared static this() // vibed replacement for main<br />
{<br />
auto routes = new URLRouter;<br />
registerRestInterface!IExampleAPI(routes, new Example(), "/");<br />
auto settings = new HTTPServerSettings;<br />
settings.port = 8080;<br />
listenHTTP(settings, routes);<br />
}<br />
</nowiki><br />
</code><br />
<br />
<br />
*[https://d.readthedocs.org/en/latest/examples.html#web-application Simple web application]<br />
<br />
<br />
Email<br />
-----<br />
There is support for sending emails by SMTP in the standard library under [http://dlang.org/phobos/std_net_curl#.SMTP std.net.curl.SMTP] in vibe.d, [https://github.com/adamdruppe/arsd arsd] and [https://github.com/CyberShadow/ae AE Utils]. <br />
<br />
<code> Vibe.d Send Email Example<br />
<nowiki><br />
import vibe.core.log;<br />
import vibe.mail.smtp;<br />
<br />
<br />
void main()<br />
{<br />
auto settings = new SMTPClientSettings("smtp.example.com", 25);<br />
settings.connectionType = SMTPConnectionType.startTLS;<br />
settings.authType = SMTPAuthType.plain;<br />
settings.username = "username";<br />
settings.password = "secret";<br />
<br />
auto mail = new Mail;<br />
mail.headers["From"] = "<user@isp.com>";<br />
mail.headers["To"] = "<recipient@domain.com>";<br />
mail.headers["Subject"] = "Testmail";<br />
mail.bodyText = "Hello, World!";<br />
<br />
logInfo("Sending mail...");<br />
sendMail(settings, mail);<br />
logInfo("done.");<br />
}<br />
</nowiki><br />
</code><br />
<br />
For MIME support see Arsd and AE Utils (under code.dlang.org there are bindings for gmime). No IMAP as yet, but bindings are under development.<br />
<br />
<br />
Numerical computing<br />
-------------------<br />
*[http://dlang.org/d-floating-point.html D Floating Point Features]<br />
*[http://dlang.org/phobos/std_bigint.html arbitrary precision - 'bignum' - arithmetic]<br />
*[http://digitalmars.com/sargon/halffloat.html Sargon half-precision fast floating point]<br />
*[http://code.dlang.org/?sort=updated&category=library.scientific Scientific Computing Projects at code.dlang.org]<br />
<br />
<br />
<br />
Libraries - what is the D equivalent of pypi and pip?<br />
------------------------------------------------------<br />
See [http://code.dlang.org code.dlang.org] and the DUB package manager.<br />
<br />
<br />
Scripting<br />
---------<br />
Since D provides type inference, high-level constructs, and fast compile-time it is a great language for writing [https://github.com/Laeeth/tools/blob/master/FetchDlang/fetchdlang.d scripts]. The first line of the file is ignored if it begins with #! - by combining this with [http://dlang.org/rdmd.html rdmd] which handles dependency resolution, D becomes a leader in machine-code scripting language.<br />
<br />
<code> reading comma separated / CSV text - example from std.csv<br />
<nowiki><br />
auto text = "Name,Occupation,Salary\r"<br />
"Joe,Carpenter,300000\nFred,Blacksmith,400000\r\n";<br />
<br />
foreach(record; csvReader!(string[string])<br />
(text, null))<br />
{<br />
writefln("%s works as a %s and earns $%s per year.",<br />
record["Name"], record["Occupation"],<br />
record["Salary"]);<br />
}<br />
</nowiki><br />
</code><br />
<br />
<code> generating optimized machine code at compile time for compiled regex pattern matching<br />
<nowiki><br />
string phone = "+31 650 903 7158";<br />
auto phoneReg = ctRegex!r"^\+([1-9][0-9]*) [0-9 ]*$";<br />
auto m = match(phone, phoneReg);<br />
assert(m);<br />
assert(m.captures[0] == "+31 650 903 7158");<br />
assert(m.captures[1] == "31");<br />
</nowiki><br />
</code><br />
<br />
<br />
<br />
<br />
Next Steps<br />
----------<br />
* [http://dlang.org/download.html Download] and install D for your platform<br />
* Play with the D REPL or [http://dpaste.dzfl.pl/ Pastebin]<br />
* Consider purchasing Dr Andrei Alexandrescu's [http://www.amazon.com/D-Programming-Language-Andrei-Alexandrescu/dp/0321635361 The D Programming Language], [http://www.amazon.com/dp/1783287217/?tag=packtpubli-20 Adam Ruppe's D Cookbook], and reading the free book [http://ddili.org/ders/d.en/index.html 'Programming in D' by Ali Çehreli]<br />
* Read the D solutions to [http://rosettacode.org/wiki/Category:D Rosetta Code] problems<br />
* Take a look at the [http://wiki.dlang.org/Videos D language videos]<br />
* Subscribe to [http://arsdnet.net/this-week-in-d/ This Week in D]<br />
* Attend a meeting of a [http://wiki.dlang.org/D_User_Groups D User Group] near you<br />
* Follow D on [http://www.linkedin.com/groups/D-Developer-Network-3923820 LinkedIn], [https://plus.google.com/communities/100033468228217743303 Google+], [https://www.facebook.com/dlang.org Facebook], [https://www.xing.com/net/dlang Xing], [http://www.reddit.com/r/d_language/ Reddit], [https://www.quora.com/D-programming-language Quora]<br />
* Follow some [http://planet.dsource.org/ D blogs]<br />
* Post in the [http://forum.dlang.org forums] - don't be shy; this is a very helpful community<br />
<br />
[[Category:Languages versus D]]</div>Laeeth