{"id":211,"date":"2016-09-09T14:04:20","date_gmt":"2016-09-09T14:04:20","guid":{"rendered":"http:\/\/dlang.org\/blog\/?p=211"},"modified":"2021-10-08T11:10:18","modified_gmt":"2021-10-08T11:10:18","slug":"gsoc-report-dstep","status":"publish","type":"post","link":"https:\/\/dlang.org\/blog\/2016\/09\/09\/gsoc-report-dstep\/","title":{"rendered":"GSoC Report: DStep"},"content":{"rendered":"<p><em>Wojciech Sz\u0119szo\u0142 is a Computer Science major at the University of Wroc\u0142aw. As part of Google Summer of Code 2016, he chose to make improvements to Jacob Carlborg&#8217;s <a href=\"https:\/\/github.com\/jacob-carlborg\/dstep\">DStep<\/a>, a tool to generate D bindings from C and Objective-C header files.<\/em><\/p>\n<hr \/>\n<p><img loading=\"lazy\" class=\"size-full wp-image-213 alignleft\" src=\"http:\/\/dlang.org\/blog\/wp-content\/uploads\/2016\/09\/GSoC-icon-192.png\" alt=\"GSoC-icon-192\" width=\"192\" height=\"192\" \/>It was December of last year and I was writing an image processing project for a course at <a href=\"https:\/\/international.uni.wroc.pl\/en\/s3.php\">my university<\/a>. I would normally use <a href=\"https:\/\/www.python.org\/\">Python<\/a>, but the project required some custom processing, so I wasn&#8217;t able to use <a href=\"http:\/\/www.numpy.org\/\">numpy<\/a>. And writing the inner loops of image processing algorithms in plain Python isn&#8217;t the best idea. So I decided to use D.<\/p>\n<p>I&#8217;ve been conscious about the existence of the D language for as long as I can remember, but I&#8217;d never convinced myself before to try it out. The first thing I needed to do was to load an image. At the time, I didn&#8217;t know that there is <a href=\"https:\/\/code.dlang.org\/\">a DUB repository<\/a> containing bindings to image loading libraries, so I started writing bindings to <a href=\"http:\/\/libjpeg.sourceforge.net\/\">libjpeg<\/a> by myself. It didn&#8217;t end very well, so I thought there should be a tool that will do the job for me. That&#8217;s when I found <a href=\"https:\/\/github.com\/jacob-carlborg\/dstep\">DStep<\/a> and <a href=\"https:\/\/dlang.org\/htod.html\">htod<\/a>.<\/p>\n<p>Unluckily, the capabilities of DStep weren&#8217;t satisfying (mostly the lack of any kind of support for the preprocessor) and htod didn&#8217;t run on Linux. I ended up coding my project in C++, but as GSoC (<a href=\"https:\/\/summerofcode.withgoogle.com\/\">Google Summer of Code<\/a>) was lurking on the horizon, I decided that I should give it a try with DStep. I began by\u00a0contacting Craig Dillabaugh (<em>Ed. Note: Craig volunteers to organize GSoC projects using D<\/em>) to learn if there was any need for developing such a project. It sparked some discussion on <a href=\"http:\/\/forum.dlang.org\/\">the forum<\/a>, the idea was accepted, and, more importantly, Russel Winder agreed to be the mentor of the project. After some time I needed to prepare and submit an official proposal. There was an interview and fortunately I was accepted.<\/p>\n<p>The first commit I made for DStep is dated to February, 1. It was a proof of concept that C preprocessor definitions can be translated to D using <a href=\"http:\/\/clang.llvm.org\/doxygen\/group__CINDEX.html\">libclang<\/a>. Then I improved the testing framework by replacing the old <a href=\"https:\/\/cucumber.io\/\">Cucumber-based<\/a> tests with some written in D. I made a few more improvements before the actual GSoC coding period began.<\/p>\n<p>During GSoC, I added support for translation of preprocessor macros (constants and functions). It required implementing a parser for a small part of the C language as the information from libclang was insufficient. I implemented translation of comments, improved formatting of the output code (e.g. made DStep keep the spacing from C sources), fixed most of the issues from <a href=\"https:\/\/github.com\/jacob-carlborg\/dstep\/issues\">the GitHub issue list<\/a> and ported DStep to Windows. While I was coding I was getting support from Jacob Carlborg. He did a great job by reviewing all of the commits I made. When I didn&#8217;t know how to accomplish something with D, I could always count on help on <a href=\"http:\/\/forum.dlang.org\/\">forum.dlang.org<\/a>.<\/p>\n<p>DStep was the first project of such a size that I coded in D. I enjoyed its modern features, notably <a href=\"http:\/\/dlang.org\/spec\/module.html\">the module system<\/a>, <a href=\"http:\/\/dlang.org\/spec\/garbage.html\">garbage collector<\/a>, <a href=\"http:\/\/dlang.org\/spec\/arrays.html\">built-in arrays<\/a>, and <a href=\"http:\/\/dlang.org\/spec\/template.html\">powerful templates<\/a>. I used <a href=\"http:\/\/dlang.org\/spec\/unittest.html\">unittest blocks<\/a> a lot. It would be nice to have named unit tests, so that they can be run selectively. From the perspective of a newcomer, the lack of consistency and symmetry in some features is troubling, at least before getting used to it. For example there is <a href=\"http:\/\/dlang.org\/spec\/hash-map.html\">a built-in hash map<\/a> and no hash set, some identifiers that should be keywords starts with <code>@<\/code>\u00a0(<em>Ed. Note: see the <a href=\"http:\/\/dlang.org\/spec\/attribute.html\">Attributes documentation<\/a><\/em>), etc. I was very sad when I read that the <code>in<\/code> keyword is not yet fully implemented. Despite those little issues, the language served me very well overall. I suppose I will use D for my personal toy projects in the future. And for DStep of course. I have some unfinished business with it :).<\/p>\n<p>I would like to encourage all students to take part in future editions of GSoC. And I must say the <a href=\"https:\/\/dlang.org\/foundation.html\">D Language Foundation<\/a> is a very good place to do this. I learned a lot during this past summer and it was a very exciting experience.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Wojciech Sz\u0119szo\u0142 is a Computer Science major at the University of Wroc\u0142aw. As part of Google Summer of Code 2016, he chose to make improvements to Jacob Carlborg&#8217;s DStep, a tool to generate D bindings from C and Objective-C header files. It was December of last year and I was writing an image processing project [&hellip;]<\/p>\n","protected":false},"author":8,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[12,19,9],"tags":[],"_links":{"self":[{"href":"https:\/\/dlang.org\/blog\/wp-json\/wp\/v2\/posts\/211"}],"collection":[{"href":"https:\/\/dlang.org\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/dlang.org\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/dlang.org\/blog\/wp-json\/wp\/v2\/users\/8"}],"replies":[{"embeddable":true,"href":"https:\/\/dlang.org\/blog\/wp-json\/wp\/v2\/comments?post=211"}],"version-history":[{"count":4,"href":"https:\/\/dlang.org\/blog\/wp-json\/wp\/v2\/posts\/211\/revisions"}],"predecessor-version":[{"id":305,"href":"https:\/\/dlang.org\/blog\/wp-json\/wp\/v2\/posts\/211\/revisions\/305"}],"wp:attachment":[{"href":"https:\/\/dlang.org\/blog\/wp-json\/wp\/v2\/media?parent=211"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dlang.org\/blog\/wp-json\/wp\/v2\/categories?post=211"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dlang.org\/blog\/wp-json\/wp\/v2\/tags?post=211"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}