<?xml version="1.0" encoding="UTF-8"?><rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/">
  <channel>
    <title>tools &amp;mdash; musicmatzes blog</title>
    <link>https://beyermatthias.de/tag:tools</link>
    <description></description>
    <pubDate>Thu, 03 Dec 2026 19:00:37 +0100</pubDate>
    <item>
      <title>How to improve your open source code (9) - Types</title>
      <link>https://beyermatthias.de/how-to-improve-your-open-source-code-9-types</link>
      <description>&lt;![CDATA[small&#xA;  This post was written during my trip through Iceland and published much&#xA;  later than it was written.&#xA;/small&#xA;&#xA;This is a really important topic in programming and I really hope to get&#xA;this article right. Not only for technical correctness, but also for&#xA;ease to understand, as explaining types is not that simple if one has&#xA;never heard of them.&#xA;&#xA;Let&#39;s give it a try...&#xA;&#xA;What are types&#xA;&#xA;Well, that&#39;s a question which is, in my opinion, not easy to answer. In&#xA;fact, I thought several days about this question before writing this&#xA;down, in hope it will become a sufficient answer. Hence, you might find&#xA;other answers which are easier to understand and maybe more correct as&#xA;mine, but I&#39;ll give it a try nonetheless.&#xA;&#xA;From what I think&#xA;&#xA;  Types are a combination of abilities and properties that are combined&#xA;  to express and limit a certain scope of a thing.&#xA;&#xA;For example, A type Car may have four wheels, two doors and a horn&#xA;(its properties) and can drive slow, drive fast and park (its&#xA;abilities). That is certainly not a real representation of a car (also&#xA;because only a car is a real representation of a car) but because of the&#xA;domain this is used in, it is sufficient in the scenario at hand.  The&#xA;type Car cannot be multiplied, but another type Number may have this&#xA;ability. Thus, the scope and abilities are also limited in a certain&#xA;way.&#xA;&#xA;I hope this description is a good one for you to understand.&#xA;&#xA;Now that we know what types are, we should also learn some other terms&#xA;around the subject of types. The first thing I want to talk about here&#xA;is &#34;strong typing&#34; and &#34;weak typing&#34;. The reason for this is: These&#xA;things do not exist. Yes, you&#39;ve read this correctly: There is no such&#xA;thing as &#34;strong typing&#34;. There is only stronger and weaker&#xA;typing. The Java programming language is not strongly typed, neither&#xA;is it weakly typed (but it is, of course badly typed... forgive me&#xA;that joke, pity java programmer).&#xA;&#xA;But what is a stronger typing? That is rather simple to explain,&#xA;actually. We discussed that types are limitations of things to be able&#xA;to only do some specific operations and such. These things are enforced&#xA;by the compiler or interpreter of the programming language, of course.&#xA;And stronger typing only says that the compiler has more information&#xA;(implicitly via the definition of the programming language) to enforce&#xA;these rules, the rules of &#34;the function A is defined for type T, so you&#xA;cannot call it on U&#34;. Of course there is more to that because of generic&#xA;typing and so on, but that&#39;s basically it.&#xA;&#xA;The next term is &#34;type inference&#34;. Type inference is nothing a&#xA;programmer experiences explicitely, because it happens implicitly. Type&#xA;inference is a feature of the compiler and interpreter of the language&#xA;to guess the type of a variable without the programmer stating the&#xA;actual type. It&#39;s nothing more to that actually.&#xA;&#xA;I mentioned the term &#34;generic types&#34; in one of the former paragraphs&#xA;already, so we should have a look there, too. Generic types, or shorter&#xA;Generics, are types which are partial, in a way. So for example, one&#xA;can define a Bag of things, whatever things is. This is often (at&#xA;least in typed languages - languages where types actually matter for the&#xA;compiler or interpreter) specified in the code via &#34;type parameters&#34;&#xA;(though this term differs from language to language).&#xA;&#xA;Why more types are better then few&#xA;&#xA;The more types you introduce in your programs (internally or even for&#xA;the public API), the more safety you get (speaking in the context of a&#xA;stronger typed programming language, but also if you do a lot of&#xA;runtime-type-checking in a weaker typed language).  That does not mean&#xA;that you should introduce a BlueCar, a BlackCar and a GreenCar as&#xA;types in your program, but rather a type Color and a type Car&#xA;whereas each Car has a Color - even if your domain is cars and not&#xA;colors.&#xA;&#xA;Maybe that example lacks a certain expressiveness, so consider this:&#xA;Your Car has wheels. You can set the number of wheels when&#xA;constructing the Car object. But instead of passing an integer here,&#xA;which would yield an API where one can pass 17 as valid number for the&#xA;number of wheels - or 1337 or possibly even -1. But if you introduce a&#xA;type which represents the number of wheels, you get some safety into the&#xA;construction of the Car object - safety checks in your code are not&#xA;necessary anymore and thus your code will be shorter, better focused on&#xA;what the actual problem is instead of fighting for valid values and of&#xA;course, the compiler or interpreter can do the work for you.&#xA;&#xA;Sounds nice, doesn&#39;t it? You can get this all with (almost) no cost&#xA;attached, you just have to write down some more types. If your&#xA;programming language contains feature like enumerations, you do not even&#xA;have to make validity checks anymore, as the compiler can execute them.&#xA;&#xA;Next&#xA;&#xA;In the next post we will focus on the coding environment.&#xA;&#xA;tags: #open-source #programming #software #tools #rust&#xA;]]&gt;</description>
      <content:encoded><![CDATA[<p><small>
  This post was written during my trip through Iceland and published much
  later than it was written.
</small></p>

<p>This is a really important topic in programming and I really hope to get
this article right. Not only for technical correctness, but also for
ease to understand, as explaining types is not that simple if one has
never heard of them.</p>

<p>Let&#39;s give it a try...</p>

<h1 id="what-are-types" id="what-are-types">What are types</h1>

<p>Well, that&#39;s a question which is, in my opinion, not easy to answer. In
fact, I thought several days about this question before writing this
down, in hope it will become a sufficient answer. Hence, you might find
other answers which are easier to understand and maybe more correct as
mine, but I&#39;ll give it a try nonetheless.</p>

<p>From what I think</p>

<blockquote><p>Types are a combination of abilities and properties that are combined
to express and limit a certain scope of a thing.</p></blockquote>

<p>For example, A type <code>Car</code> may have four wheels, two doors and a horn
(its properties) and can drive slow, drive fast and park (its
abilities). That is certainly not a real representation of a car (also
because only a car is a real representation of a car) but because of the
domain this is used in, it is sufficient in the scenario at hand.  The
type <code>Car</code> cannot be multiplied, but another type <code>Number</code> may have this
ability. Thus, the scope and abilities are also limited in a certain
way.</p>

<p>I hope this description is a good one for you to understand.</p>

<p>Now that we know what types are, we should also learn some other terms
around the subject of types. The first thing I want to talk about here
is “strong typing” and “weak typing”. The reason for this is: These
things do not exist. Yes, you&#39;ve read this correctly: There is no such
thing as “strong typing”. There is only strong<strong>er</strong> and weak<strong>er</strong>
typing. The Java programming language is not <em>strongly typed</em>, neither
is it <em>weakly typed</em> (but it is, of course <em>badly typed</em>... forgive me
that joke, pity java programmer).</p>

<p>But what is a stronger typing? That is rather simple to explain,
actually. We discussed that types are limitations of things to be able
to only do some specific operations and such. These things are enforced
by the compiler or interpreter of the programming language, of course.
And stronger typing only says that the compiler has more information
(implicitly via the definition of the programming language) to enforce
these rules, the rules of “the function A is defined for type T, so you
cannot call it on U”. Of course there is more to that because of generic
typing and so on, but that&#39;s basically it.</p>

<p>The next term is “type inference”. Type inference is nothing a
programmer experiences explicitely, because it happens implicitly. Type
inference is a feature of the compiler and interpreter of the language
to <em>guess</em> the type of a variable without the programmer stating the
actual type. It&#39;s nothing more to that actually.</p>

<p>I mentioned the term “generic types” in one of the former paragraphs
already, so we should have a look there, too. Generic types, or shorter
<em>Generics</em>, are types which are partial, in a way. So for example, one
can define a <code>Bag</code> of <em>things</em>, whatever <em>things</em> is. This is often (at
least in typed languages – languages where types actually matter for the
compiler or interpreter) specified in the code via “type parameters”
(though this term differs from language to language).</p>

<h1 id="why-more-types-are-better-then-few" id="why-more-types-are-better-then-few">Why more types are better then few</h1>

<p>The more types you introduce in your programs (internally or even for
the public API), the more safety you get (speaking in the context of a
stronger typed programming language, but also if you do a lot of
runtime-type-checking in a weaker typed language).  That does not mean
that you should introduce a <code>BlueCar</code>, a <code>BlackCar</code> and a <code>GreenCar</code> as
types in your program, but rather a type <code>Color</code> and a type <code>Car</code>
whereas each <code>Car</code> has a <code>Color</code> – even if your domain is cars and not
colors.</p>

<p>Maybe that example lacks a certain expressiveness, so consider this:
Your <code>Car</code> has wheels. You can set the number of wheels when
constructing the <code>Car</code> object. But instead of passing an integer here,
which would yield an API where one can pass 17 as valid number for the
number of wheels – or 1337 or possibly even -1. But if you introduce a
type which represents the number of wheels, you get some safety into the
construction of the <code>Car</code> object – safety checks in your code are not
necessary anymore and thus your code will be shorter, better focused on
what the actual problem is instead of fighting for valid values and of
course, the compiler or interpreter can do the work for you.</p>

<p>Sounds nice, doesn&#39;t it? You can get this all with (almost) no cost
attached, you just have to write down some more types. If your
programming language contains feature like enumerations, you do not even
have to make validity checks anymore, as the compiler can execute them.</p>

<h1 id="next" id="next">Next</h1>

<p>In the next post we will focus on the coding environment.</p>

<p>tags: <a href="https://beyermatthias.de/tag:open" class="hashtag"><span>#</span><span class="p-category">open</span></a>-source <a href="https://beyermatthias.de/tag:programming" class="hashtag"><span>#</span><span class="p-category">programming</span></a> <a href="https://beyermatthias.de/tag:software" class="hashtag"><span>#</span><span class="p-category">software</span></a> <a href="https://beyermatthias.de/tag:tools" class="hashtag"><span>#</span><span class="p-category">tools</span></a> <a href="https://beyermatthias.de/tag:rust" class="hashtag"><span>#</span><span class="p-category">rust</span></a></p>
]]></content:encoded>
      <guid>https://beyermatthias.de/how-to-improve-your-open-source-code-9-types</guid>
      <pubDate>Sun, 22 Apr 2018 16:39:30 +0200</pubDate>
    </item>
    <item>
      <title>How to improve your open source code (8) - Code verbosity</title>
      <link>https://beyermatthias.de/how-to-improve-your-open-source-code-8-code-verbosity</link>
      <description>&lt;![CDATA[small&#xA;  This post was written during my trip through Iceland and published much&#xA;  latern than it was written.&#xA;/small&#xA;&#xA;While we heavily focused on the code-surrounding things in the last&#xA;parts, we will return to focus on code-related things from here on.&#xA;&#xA;This article discusses code verbosity and how it can improve your open&#xA;source code and also your contributors experience a lot.&#xA;&#xA;What is code verbosity&#xA;&#xA;Code verbosity is mainly explicitness of code. For example, in Java you&#xA;have to be more explicit when declaring a variable than in (recent) C++&#xA;or even Ruby:&#xA;&#xA;String s = someFunctionCall(param); // Java&#xA;&#xA;auto s = someFunctionCall(param); // C++&#xA;&#xA;s = someFunctionCall param # Ruby&#xA;&#xA;So code verbosity is how explicit you have to state certain things&#xA;so that the compiler or interpreter understands your intention.&#xA;&#xA;Because we do not always tell the compiler or interpreter what we want&#xA;to do exactly and because we want to re-use functionality, we&#xA;introduced abstractions. So abstractions are a way to make code less&#xA;verbose, in some ways.&#xA;&#xA;How to make code less verbose&#xA;&#xA;Abstraction. It is as simple as this. You introduce abstraction to&#xA;minimize repetition which leads to less verbose code. Of course, you&#xA;cannot always make the code less verbose if the language does not allow&#xA;it: in the above example we used the auto keyword for specifying the&#xA;type in C++, which is nice, but not possible in Java. So in the borders&#xA;of your languages abilities, you can make code less verbose.&#xA;&#xA;If you do that right and the abstractions results in nice code, you&#xA;know that you&#39;ve done fine.&#xA;&#xA;How much is too much&#xA;&#xA;But there can also be too much abstraction which then yields unreadable&#xA;code. Not unreadable as in clustered with stuff but just too abstract to&#xA;grasp at first sight.&#xA;&#xA;Abstraction can get too much. So make sure you introduce sensible&#xA;abstractions, abstractions that can be combined nicely and of course one&#xA;can step around the abstractions and use the core functionality, the&#xA;not-abstracted things beneath.&#xA;&#xA;As a sidenote: sometimes it makes sense to hide certain things&#xA;completely or even introducing several layers of abstractions.&#xA;&#xA;Next&#xA;&#xA;This was a rather short one, I guess. The next article will be longer I&#xA;hope, as it will be about typing.&#xA;&#xA;tags: #open-source #programming #software #tools #rust&#xA;]]&gt;</description>
      <content:encoded><![CDATA[<p><small>
  This post was written during my trip through Iceland and published much
  latern than it was written.
</small></p>

<p>While we heavily focused on the code-surrounding things in the last
parts, we will return to focus on code-related things from here on.</p>

<p>This article discusses code verbosity and how it can improve your open
source code and also your contributors experience a lot.</p>

<h1 id="what-is-code-verbosity" id="what-is-code-verbosity">What is code verbosity</h1>

<p>Code verbosity is mainly explicitness of code. For example, in Java you
have to be more explicit when declaring a variable than in (recent) C++
or even Ruby:</p>

<pre><code>String s = someFunctionCall(param); // Java

auto s = someFunctionCall(param); // C++

s = someFunctionCall param # Ruby
</code></pre>

<p>So code verbosity is how <em>explicit</em> you have to <em>state</em> certain things
so that the compiler or interpreter understands your intention.</p>

<p>Because we do not always tell the compiler or interpreter what we want
to do <em>exactly</em> and because we want to re-use functionality, we
introduced <em>abstractions</em>. So abstractions are a way to make code less
verbose, in some ways.</p>

<h1 id="how-to-make-code-less-verbose" id="how-to-make-code-less-verbose">How to make code less verbose</h1>

<p>Abstraction. It is as simple as this. You introduce abstraction to
minimize repetition which leads to less verbose code. Of course, you
cannot always make the code less verbose if the language does not allow
it: in the above example we used the <code>auto</code> keyword for specifying the
type in C++, which is nice, but not possible in Java. So in the borders
of your languages abilities, you can make code less verbose.</p>

<p>If you do that right and the abstractions results in nice code, you
know that you&#39;ve done fine.</p>

<h1 id="how-much-is-too-much" id="how-much-is-too-much">How much is too much</h1>

<p>But there can also be too much abstraction which then yields unreadable
code. Not unreadable as in clustered with stuff but just too abstract to
grasp at first sight.</p>

<p>Abstraction can get too much. So make sure you introduce sensible
abstractions, abstractions that can be combined nicely and of course one
can step around the abstractions and use the core functionality, the
not-abstracted things beneath.</p>

<p>As a sidenote: sometimes it makes sense to hide certain things
completely or even introducing several layers of abstractions.</p>

<h1 id="next" id="next">Next</h1>

<p>This was a rather short one, I guess. The next article will be longer I
hope, as it will be about typing.</p>

<p>tags: <a href="https://beyermatthias.de/tag:open" class="hashtag"><span>#</span><span class="p-category">open</span></a>-source <a href="https://beyermatthias.de/tag:programming" class="hashtag"><span>#</span><span class="p-category">programming</span></a> <a href="https://beyermatthias.de/tag:software" class="hashtag"><span>#</span><span class="p-category">software</span></a> <a href="https://beyermatthias.de/tag:tools" class="hashtag"><span>#</span><span class="p-category">tools</span></a> <a href="https://beyermatthias.de/tag:rust" class="hashtag"><span>#</span><span class="p-category">rust</span></a></p>
]]></content:encoded>
      <guid>https://beyermatthias.de/how-to-improve-your-open-source-code-8-code-verbosity</guid>
      <pubDate>Wed, 04 Apr 2018 16:39:28 +0200</pubDate>
    </item>
    <item>
      <title>How to improve your open source code (7) - Contributor experience</title>
      <link>https://beyermatthias.de/how-to-improve-your-open-source-code-7-contributor-experience</link>
      <description>&lt;![CDATA[small&#xA;  This post was written during my trip through Iceland and published much&#xA;  latern than it was written.&#xA;/small&#xA;&#xA;This is the last post which does not deal with code directly, I promise.&#xA;&#xA;When it comes to open source hobby projects, contributions from others&#xA;are often happily taken. But making the contribution process smooth for&#xA;everyone does involve some precautions.&#xA;&#xA;In this article I want to summarize how to make a contribution to a&#xA;project as smooth as possible for all persons involved.&#xA;&#xA;Public code and contributions&#xA;&#xA;I wrote about this before and I want to shortly reiterate on it. &#34;Open&#34;&#xA;as in open source (or even better: open contributions) is not&#xA;black-white at all but there are several levels of grey in between, in my&#xA;opinion.&#xA;&#xA;The more open your code is, the better a contributor is able to&#xA;contribute. Whether it be discussion, requests, bug reports, bug fixes&#xA;or even feature implementation or general enhancement.  On the other&#xA;side, though, the more open your code is the less your contributors are&#xA;&#34;bound&#34; (in a mentally way) to your project. It can happen (and it&#xA;happened to me) that a contributor stops by for one pull request or&#xA;issue and then you&#39;ll never hear of them. The better the contribution&#xA;process is for them, the more likely they come back - and how relevant&#xA;the project is to them, of course.&#xA;&#xA;The contribution process in the rust community (for the Rust compiler&#xA;itself) is awesome, from what I&#39;ve heard. This, of course, enhances the&#xA;&#34;I will come back and give another issue a try&#34; a lot.&#xA;The&#xA;contribution process of the nixpkgs project is slightly worse (but still&#xA;rather good). Sometimes, nobody answers questions you might have for&#xA;your pull request for several days or even weeks.&#xA;This does not really make one eager to file another request.&#xA;&#xA;Platforms&#xA;&#xA;From what I think, github is the &#34;most open&#34; in the sense of&#xA;&#34;open contributions&#34;.&#xA;That&#39;s not only because of how github works, as other platforms&#xA;work equally well (gitlab, gitea, gogs, bitbucket) but also because&#xA;everyone is on github.&#xA;&#xA;If you want to close down contributions a bit, you could host your own&#xA;instances of gitea or gitlab - contributors can easily open an account&#xA;for their contribution, though that slight hurdle will make the &#34;casual&#xA;code dumper&#34; likely go away.&#xA;&#xA;Even &#34;more closed&#34; would be a email-patch-workflow, git supports (and&#xA;the kernel community uses successfully for years now). In this case, the&#xA;code is often made available via a web interface like cgit or&#xA;klaus.&#xA;&#xA;Readme&#xA;&#xA;A project should always contain a readme file in its root folder. The&#xA;readme file is often the first thing a contributor will look at, not&#xA;only but also because github renders and displays them.&#xA;&#xA;Therefore, keeping your readme file up to date and filled with current&#xA;information can be a good way to show your contributors (and users) what&#xA;is going on in the projects code base. It should contain a short&#xA;description what the project/code does and how it works (only from a&#xA;users view - implementation details or why you implemented this in&#xA;Haskell instead of JavaScript do not necessarily belong here). It should&#xA;contain a few examples how to use the code or, if it is a library, how&#xA;to call it. It also should contain build instructions (if necessary) or&#xA;a pointer to a &#34;BUILDING&#34; file if the build process is long or&#xA;complicated. At the end of the Readme file, a license statement (how the&#xA;project is licensed) should be pasted. Not the entire license, but only&#xA;a short note and a copyright note as well. It happens to be kind to do&#xA;so.&#xA;&#xA;Contributing File&#xA;&#xA;Often, projects contain a Contributing file where guidelines (or even&#xA;rules) are written down on how to contribute. It does not only contain&#xA;statements on how code is submitted but also how issues are filed or&#xA;requests should be made.&#xA;&#xA;I think it is extremely important to have such an file available,&#xA;especially if not hosting the code on a site like github, where it is&#xA;obvious that code is submitted through pull requests and issues are&#xA;submitted via the issue tracker.&#xA;&#xA;The length of such an file should respect the size of the project&#xA;itself. If the project contains 10KLOC, one should be able to read the&#xA;contribution file in less than two minutes, preferably in less than one&#xA;minute. It should state not only how code should be submitted, but also&#xA;whether it should conform to some style guide (which itself can be&#xA;outsourced to yet another file), how to behave in&#xA;the community, how to write bug reports and also how to file issues&#xA;(what information must be included).&#xA;&#xA;Issue handling&#xA;&#xA;Handling issues is clearly a way to improve the contributors experience.&#xA;As soon as a contributor files an issue, she or he should be greeted&#xA;and thanked for the issue. Take it this way: Someone just invested time&#xA;to look at your project and cared enough to have a question, try it out&#xA;or even found a bug. This is truly a cool thing and therefore they&#xA;should be thanked for this, as soon as you have the time to do so. The&#xA;Rust community even automated this, but I don&#39;t think this would be&#xA;necessary for a small or medium sized project/community.&#xA;&#xA;So be nice to every one. Nothing is worse than a maintainer that babbles&#xA;about bad things or insults the contributor because of his or her ideas&#xA;or ways an issue was proposed to be resolved. Don&#39;t ever do this. I&#39;ve&#xA;seen issues where the maintainer of the project started rambling about&#xA;how bad things were (not the project itself but rather its dependencies&#xA;or even things that had nothing to do with the project itself). I&#xA;cannot believe that such projects will last long, let alone survive at&#xA;all. These projects will die.&#xA;&#xA;Also, your ramblings have nothing to do with the issue at hand and even&#xA;if they do: be kind and humble will most likely be better in every way,&#xA;right?&#xA;&#xA;Next&#xA;&#xA;In the next part we will finally go back and actually talk code.&#xA;&#xA;What I want to discuss in the next article of this series is code&#xA;verbosity. I want to make sure how DRY a code actually needs to be and&#xA;how much abstraction is enough for the sake of understandability and&#xA;cleanness of code.&#xA;&#xA;tags: #open-source #programming #software #tools #rust&#xA;]]&gt;</description>
      <content:encoded><![CDATA[<p><small>
  This post was written during my trip through Iceland and published much
  latern than it was written.
</small></p>

<p>This is the last post which does not deal with code directly, I promise.</p>

<p>When it comes to open source hobby projects, contributions from others
are often happily taken. But making the contribution process smooth for
everyone does involve some precautions.</p>

<p>In this article I want to summarize how to make a contribution to a
project as smooth as possible for all persons involved.</p>

<h1 id="public-code-and-contributions" id="public-code-and-contributions">Public code and contributions</h1>

<p>I wrote about this before and I want to shortly reiterate on it. “Open”
as in open source (or even better: open contributions) is not
black-white at all but there are several levels of grey in between, in my
opinion.</p>

<p>The more open your code is, the better a contributor is able to
contribute. Whether it be discussion, requests, bug reports, bug fixes
or even feature implementation or general enhancement.  On the other
side, though, the more open your code is the less your contributors are
“bound” (in a mentally way) to your project. It can happen (and it
happened to me) that a contributor stops by for one pull request or
issue and then you&#39;ll never hear of them. The better the contribution
process is for them, the more likely they come back – and how relevant
the project is to them, of course.</p>

<p>The contribution process in the rust community (for the Rust compiler
itself) is awesome, from what I&#39;ve heard. This, of course, enhances the
“I will come back and give another issue a try” a lot.
The
contribution process of the nixpkgs project is slightly worse (but still
rather good). Sometimes, nobody answers questions you might have for
your pull request for several days or even weeks.
This does not really make one eager to file another request.</p>

<h1 id="platforms" id="platforms">Platforms</h1>

<p>From what I think, github is the “most open” in the sense of
“open contributions”.
That&#39;s not only because of how github works, as other platforms
work equally well (gitlab, gitea, gogs, bitbucket) but also because
<em>everyone is on github</em>.</p>

<p>If you want to close down contributions a bit, you could host your own
instances of gitea or gitlab – contributors can easily open an account
for their contribution, though that slight hurdle will make the “casual
code dumper” likely go away.</p>

<p>Even “more closed” would be a email-patch-workflow, git supports (and
the kernel community uses successfully for years now). In this case, the
code is often made available via a web interface like cgit or
<a href="https://github.com/jonashaag/klaus">klaus</a>.</p>

<h1 id="readme" id="readme">Readme</h1>

<p>A project should always contain a readme file in its root folder. The
readme file is often the first thing a contributor will look at, not
only but also because github renders and displays them.</p>

<p>Therefore, keeping your readme file up to date and filled with current
information can be a good way to show your contributors (and users) what
is going on in the projects code base. It should contain a short
description what the project/code does and how it works (only from a
users view – implementation details or why you implemented this in
Haskell instead of JavaScript do not necessarily belong here). It should
contain a few examples how to use the code or, if it is a library, how
to call it. It also should contain build instructions (if necessary) or
a pointer to a “BUILDING” file if the build process is long or
complicated. At the end of the Readme file, a license statement (how the
project is licensed) should be pasted. Not the entire license, but only
a short note and a copyright note as well. It happens to be kind to do
so.</p>

<h1 id="contributing-file" id="contributing-file">Contributing File</h1>

<p>Often, projects contain a <code>Contributing</code> file where guidelines (or even
rules) are written down on how to contribute. It does not only contain
statements on how code is submitted but also how issues are filed or
requests should be made.</p>

<p>I think it is extremely important to have such an file available,
<em>especially</em> if not hosting the code on a site like github, where it is
obvious that code is submitted through pull requests and issues are
submitted via the issue tracker.</p>

<p>The length of such an file should respect the size of the project
itself. If the project contains 10KLOC, one should be able to read the
contribution file in less than two minutes, preferably in less than one
minute. It should state not only how code should be submitted, but also
whether it should conform to some style guide (which itself can be
outsourced to yet another file), how to behave in
the community, how to write bug reports and also how to file issues
(what information must be included).</p>

<h1 id="issue-handling" id="issue-handling">Issue handling</h1>

<p>Handling issues is clearly a way to improve the contributors experience.
As soon as a contributor files an issue, she or he should be greeted
and thanked for the issue. Take it this way: Someone just invested time
to look at your project and cared enough to have a question, try it out
or even found a bug. This is truly a cool thing and therefore they
should be thanked for this, as soon as you have the time to do so. The
Rust community even automated this, but I don&#39;t think this would be
necessary for a small or medium sized project/community.</p>

<p>So be nice to every one. Nothing is worse than a maintainer that babbles
about bad things or insults the contributor because of his or her ideas
or ways an issue was proposed to be resolved. Don&#39;t ever do this. I&#39;ve
seen issues where the maintainer of the project started rambling about
how bad things were (not the project itself but rather its dependencies
or <em>even things that had nothing to do with the project itself</em>). I
cannot believe that such projects will last long, let alone survive at
all. These projects will die.</p>

<p>Also, your ramblings have nothing to do with the issue at hand and even
if they do: be kind and humble will most likely be better in every way,
right?</p>

<h1 id="next" id="next">Next</h1>

<p>In the next part we will finally go back and actually talk code.</p>

<p>What I want to discuss in the next article of this series is <em>code
verbosity</em>. I want to make sure how DRY a code actually needs to be and
how much abstraction is enough for the sake of understandability and
cleanness of code.</p>

<p>tags: <a href="https://beyermatthias.de/tag:open" class="hashtag"><span>#</span><span class="p-category">open</span></a>-source <a href="https://beyermatthias.de/tag:programming" class="hashtag"><span>#</span><span class="p-category">programming</span></a> <a href="https://beyermatthias.de/tag:software" class="hashtag"><span>#</span><span class="p-category">software</span></a> <a href="https://beyermatthias.de/tag:tools" class="hashtag"><span>#</span><span class="p-category">tools</span></a> <a href="https://beyermatthias.de/tag:rust" class="hashtag"><span>#</span><span class="p-category">rust</span></a></p>
]]></content:encoded>
      <guid>https://beyermatthias.de/how-to-improve-your-open-source-code-7-contributor-experience</guid>
      <pubDate>Tue, 20 Mar 2018 16:39:16 +0100</pubDate>
    </item>
    <item>
      <title>Why can&#39;t we map tuples on arguments in Rust?</title>
      <link>https://beyermatthias.de/why-cant-we-map-tuples-on-arguments-in-rust</link>
      <description>&lt;![CDATA[Why can&#39;t we do&#xA;&#xA;fn foo(i: i32, j: i32) -  i32 {&#xA;    i + j&#xA;}&#xA;&#xA;fn main() {&#xA;    println!(&#34;{}&#34;, foo((1, 2)));&#xA;}&#xA;&#xA;in Rust?&#xA;&#xA;The idea&#xA;&#xA;First of all: I don&#39;t know much about what is going on in rust-compiler-land,&#xA;hence I don&#39;t know whether this is technically possible or even in progress&#xA;already. I&#39;m simply writing down some thoughts here.&#xA;&#xA;The idea, or rather the question, is: Why can&#39;t we map tuples on arguments in&#xA;Rust? The code from above shows exactly what I mean by that: Why is the&#xA;compiler not able to unpack the tuple and pass it as list of arguments to the&#xA;function?&#xA;&#xA;It would be really cool if it could do that. The usecase is something like&#xA;this:&#xA;&#xA;somepossiblyfailingfn() // -  Result, &#xA;  .andthen(|res| (res, someotherfailingfn()?)) // Result(, ), &#xA;  .map(PartialEq::Eq) // Resultbool, &#xA;&#xA;for example.&#xA;If mapping of tuples on arguments would be possible, one could write code like&#xA;this, where failing functions are chained and operators and functions can then&#xA;be called on the results of the failing functions.&#xA;&#xA;Currently, one has to write it like this:&#xA;&#xA;somepossiblyfailingfn() // -  Result, &#xA;  .andthen(|res| (res, someotherfailingfn()?)) // Result(, ), &#xA;  .map(|(a, b)| a == b) // Resultbool, &#xA;&#xA;or, because it is solvable with one line less:&#xA;&#xA;somepossiblyfailingfn() // -  Result, &#xA;  .andthen(|res| Ok(res == someotherfailingfn()?)) // Resultbool, &#xA;&#xA;You might think that the overhead for that convenience is rather low and thus&#xA;it is not really beneficial to have such a functionality in the rust compiler.&#xA;&#xA;That is true. But there are great possibilities of API design if this is&#xA;mapping of tuples on arguments are possible.&#xA;For example, one could write an extension to the Result type which extends&#xA;tuples. Think of something like that:&#xA;&#xA;// assuming:&#xA;//&#xA;// somepossiblyfailingfn() -  ResultT, ;&#xA;// someotherfailingfn()) -  ResultU, ;&#xA;// evenotherfailingfn()) -  ResultW, ;&#xA;// yetanotherfailingf()) -  ResultV, ;&#xA;// checkresults(T, U, W, V) -  Resultbool, Error;&#xA;//&#xA;&#xA;somepossiblyfailingfn() // -  ResultT, &#xA;  .andthenchain(|| someotherfailingfn()) // Result(T, U), &#xA;  .andthenchain(|| evenotherfailingfn()) // Result(T, U, W), &#xA;  .andthenchain(|| yetanotherfailingf()) // Result(T, U, W, V), &#xA;  .andthen(checkresults)&#xA;&#xA;From an API-design standpoint, this is plain awesome.&#xA;&#xA;Lets compare that to what we have to write today to do this:&#xA;&#xA;somepossiblyfailingfn() // -  ResultT, &#xA;  .andthen(|a| Ok((a, someotherfailingfn()?)))&#xA;  .andthenchain(|(a, b)| Ok((a, b, evenotherfailingfn()?)))&#xA;  .andthenchain(|(a, b, c)| Ok((a, b, c, yetanotherfailingf()?)))&#xA;  .andthen(|(a, b, c, d)| checkresults(a, b, c, d))&#xA;&#xA;and that&#39;s really not that readable.&#xA;&#xA;From a technical point of view, the compiler is able to verify the length of&#xA;the tuples and thus is able to check whether the tuple actually matches the&#xA;number of parameters of a function.&#xA;&#xA;As said, I&#39;m not that much into the development of the language, thus I don&#39;t&#xA;know whether there are other things that prevent this, though.&#xA;&#xA;Update&#xA;&#xA;After posting this as a question&#xA;on users.rust-lang.org&#xA;and getting some nice replies with explanations why this cannot be, I&#xA;conclude:&#xA;&#xA;It is not possible to do it in a way that does not_ yield weird edge cases,&#xA;ugly implicit conversions and other weirdness we really do not want in the&#xA;language.&#xA;&#xA;But I learned something, and that was worth it!&#xA;&#xA;tags:  #tools #software #c++&#xA;]]&gt;</description>
      <content:encoded><![CDATA[<p>Why can&#39;t we do</p>

<pre><code>fn foo(i: i32, j: i32) -&gt; i32 {
    i + j
}

fn main() {
    println!(&#34;{}&#34;, foo((1, 2)));
}
</code></pre>

<p>in Rust?</p>

<h1 id="the-idea" id="the-idea">The idea</h1>

<p>First of all: I don&#39;t know much about what is going on in rust-compiler-land,
hence I don&#39;t know whether this is technically possible or even in progress
already. I&#39;m simply writing down some thoughts here.</p>

<p>The idea, or rather the question, is: Why can&#39;t we map tuples on arguments in
Rust? The code from above shows exactly what I mean by that: Why is the
compiler not able to unpack the tuple and pass it as list of arguments to the
function?</p>

<p>It would be really cool if it could do that. The usecase is something like
this:</p>

<pre><code>some_possibly_failing_fn() // -&gt; Result&lt;_, _&gt;
  .and_then(|res| (res, some_other_failing_fn()?)) // Result&lt;(_, _), _&gt;
  .map(PartialEq::Eq) // Result&lt;bool, _&gt;
</code></pre>

<p>for example.
If mapping of tuples on arguments would be possible, one could write code like
this, where failing functions are chained and operators and functions can then
be called on the results of the failing functions.</p>

<p>Currently, one has to write it like this:</p>

<pre><code>some_possibly_failing_fn() // -&gt; Result&lt;_, _&gt;
  .and_then(|res| (res, some_other_failing_fn()?)) // Result&lt;(_, _), _&gt;
  .map(|(a, b)| a == b) // Result&lt;bool, _&gt;
</code></pre>

<p>or, because it is solvable with one line less:</p>

<pre><code>some_possibly_failing_fn() // -&gt; Result&lt;_, _&gt;
  .and_then(|res| Ok(res == some_other_failing_fn()?)) // Result&lt;bool, _&gt;
</code></pre>

<p>You might think that the overhead for that convenience is rather low and thus
it is not really beneficial to have such a functionality in the rust compiler.</p>

<p>That is true. But there are great possibilities of API design if this is
mapping of tuples on arguments are possible.
For example, one could write an extension to the <code>Result</code> type which extends
tuples. Think of something like that:</p>

<pre><code>// assuming:
//
// some_possibly_failing_fn() -&gt; Result&lt;T, _&gt;;
// some_other_failing_fn()) -&gt; Result&lt;U, _&gt;;
// even_other_failing_fn()) -&gt; Result&lt;W, _&gt;;
// yet_another_failing_f()) -&gt; Result&lt;V, _&gt;;
// check_results(T, U, W, V) -&gt; Result&lt;bool, Error&gt;;
//

some_possibly_failing_fn() // -&gt; Result&lt;T, _&gt;
  .and_then_chain(|| some_other_failing_fn()) // Result&lt;(T, U), _&gt;
  .and_then_chain(|| even_other_failing_fn()) // Result&lt;(T, U, W), _&gt;
  .and_then_chain(|| yet_another_failing_f()) // Result&lt;(T, U, W, V), _&gt;
  .and_then(check_results)
</code></pre>

<p>From an API-design standpoint, this is plain awesome.</p>

<p>Lets compare that to what we have to write today to do this:</p>

<pre><code>some_possibly_failing_fn() // -&gt; Result&lt;T, _&gt;
  .and_then(|a| Ok((a, some_other_failing_fn()?)))
  .and_then_chain(|(a, b)| Ok((a, b, even_other_failing_fn()?)))
  .and_then_chain(|(a, b, c)| Ok((a, b, c, yet_another_failing_f()?)))
  .and_then(|(a, b, c, d)| check_results(a, b, c, d))
</code></pre>

<p>and that&#39;s really not that readable.</p>

<p>From a technical point of view, the compiler is able to verify the length of
the tuples and thus is able to check whether the tuple actually matches the
number of parameters of a function.</p>

<p>As said, I&#39;m not that much into the development of the language, thus I don&#39;t
know whether there are other things that prevent this, though.</p>

<h1 id="update" id="update">Update</h1>

<p>After posting this as a question
<a href="https://users.rust-lang.org/t/why-cant-we-map-tuples-on-arguments-in-rust/15628">on users.rust-lang.org</a>
and getting some nice replies with explanations why this cannot be, I
conclude:</p>

<p>It is not possible to do it in a way that does <em>not</em> yield weird edge cases,
ugly implicit conversions and other weirdness we really do not want in the
language.</p>

<p>But I learned something, and that was worth it!</p>

<p>tags:  <a href="https://beyermatthias.de/tag:tools" class="hashtag"><span>#</span><span class="p-category">tools</span></a> <a href="https://beyermatthias.de/tag:software" class="hashtag"><span>#</span><span class="p-category">software</span></a> <a href="https://beyermatthias.de/tag:c" class="hashtag"><span>#</span><span class="p-category">c</span></a>++</p>
]]></content:encoded>
      <guid>https://beyermatthias.de/why-cant-we-map-tuples-on-arguments-in-rust</guid>
      <pubDate>Tue, 13 Feb 2018 16:39:07 +0100</pubDate>
    </item>
    <item>
      <title>TIL: Don&#39;t use C++ for new projects</title>
      <link>https://beyermatthias.de/til-dont-use-c-for-new-projects</link>
      <description>&lt;![CDATA[Today I learned that the new C++ standard (C++17) has std::variant - but no&#xA;pattern matching.&#xA;&#xA;Variants and how they work&#xA;&#xA;Variants or &#34;tagged unions&#34; are a special form of data type.&#xA;They describe an abstract thing which could be one concrete thing or another&#xA;concrete thing.&#xA;Variants are available in a lot of languages, including and not limited to&#xA;ML, Haskell, Algol 68, Pascal, Ada, Rust and even C.&#xA;&#xA;With C++17, the C++ standard was extended to have the std::variant generic&#xA;type, which is basically a &#34;C union on steroids&#34;.&#xA;&#xA;(To the C++ greybeard programmers reading this: I know this is technically&#xA;not right, how it is implemented and how this works is very different from an&#xA;actual C union, but what it is used for is basically the same, so please don&#39;t&#xA;yell at me for this statement.)&#xA;&#xA;A std::variant can be used to express, for example, a return value of a&#xA;function which might have failed.&#xA;Maybe you think &#34;Hey, that&#39;s what exceptions are for&#34; - no, that&#39;s not what&#xA;exceptions are for, though a lot of programmer use them like this.&#xA;Exceptions are for unexpected behaviour of your program. If you&#39;re writing a&#xA;terminal calculator, an invalid input is an expected failure. An unexpected&#xA;failure would be that you cannot read from stdin!&#xA;&#xA;In cases where expected failures happen, a std::variant can be used to&#xA;return a &#34;I failed doing my job&#34;-value.&#xA;&#xA;Why you need pattern matching&#xA;&#xA;Pattern matching can be used to destructure variants efficiently (as in code,&#xA;readability, extendability and thus maintainability) to access their inner&#xA;values.&#xA;&#xA;For example, in Haskell, one can destructure a variant like this:&#xA;&#xA;data Result = Ok | Err&#xA;&#xA;explainresult :: Result -  [Char]&#xA;explainresult Ok  = &#34;All right&#34;&#xA;explainresult Err = &#34;Ouch&#34;&#xA;&#xA;Here, we define the variant Result and a function explainresult which&#xA;destructures the variant and returns a string based on the passed variant.&#xA;Of course, variants can hold data and this data can be accessed then.&#xA;&#xA;As a matter of fact, variants are incredible useful in everyday programming&#xA;and so is pattern matching for destructuring them.&#xA;&#xA;What C++17 offers instead of pattern matching&#xA;&#xA;C++17 does not offer pattern matching. Why? I don&#39;t know. But it really should&#xA;have, because the way this issue is solved in C++17 is painful: std::visit&#xA;is used for imitate pattern matching.&#xA;&#xA;On the first glance, the following code looks rather okayish (well, it is&#xA;still C++, right?):&#xA;&#xA;std::vectorstd::variant&lt;char, long, float, int, double, long long  vec = {5, &#39;2&#39;, 5.4, 100ll, 2011l, 3.5f, 2017};&#xA;&#xA;// display each value&#xA;for (auto&amp; v: vec){&#xA;  std::visit({std::cout &lt;&lt; e &lt;&lt; &#34; &#34;;}, v);&#xA;}&#xA;&#xA;But this is simple. What if we want to actually do something with the element&#xA;based on which type it has?&#xA;&#xA;Well, not so nice: We have to design our own visitor and equip it with the&#xA;functionality:&#xA;&#xA;struct Visitor {&#xA;    void operator()(const string&amp; s) const {&#xA;      // ...&#xA;    }&#xA;&#xA;    void operator()(const int n) const {&#xA;      // ...&#xA;    }&#xA;};&#xA;&#xA;While having a dedicated visitor which can be passed around is rather nice,&#xA;having it as the only option for pattern matching is hell.&#xA;&#xA;Also, the standard library does&#xA;not provide a helper for building a visitor object from a list of lambdas!&#xA;&#xA;All in all: Is the whole thing a step into the right direction? No. It is&#xA;rather a stumble into the rightish direction. Nothing more.&#xA;&#xA;A friendly advice from a non-Cpp programmer&#xA;&#xA;Take a grain of salt. I&#39;m not a (C++) professional, hence this might not&#xA;reflect the opinions of the broader community.&#xA;Also, the following might get some people really angry. But I don&#39;t care.&#xA;&#xA;Don&#39;t use C++ for new projects!&#xA;&#xA;I know C++ is a heavy target and the standard is backwards compatible and a&#xA;lot of people count on the standards committee to get this right and&#xA;yaddayaddayadda.&#xA;From my point of view, C++ tries to catch up. This is, of course, nice. But at&#xA;that speed, other languages will innovate much faster and better and C++ will&#xA;slowly die.&#xA;That&#39;s one reason I would never ever use C++ for a new project.&#xA;&#xA;tags:  #tools #software #c++&#xA;]]&gt;</description>
      <content:encoded><![CDATA[<p>Today I learned that the new C++ standard (C++17) has <code>std::variant</code> – but no
pattern matching.</p>

<h1 id="variants-and-how-they-work" id="variants-and-how-they-work">Variants and how they work</h1>

<p>Variants or “tagged unions” are a special form of data type.
They describe an abstract thing which could be one concrete thing or another
concrete thing.
Variants are available in a lot of languages, including and not limited to
ML, Haskell, Algol 68, Pascal, Ada, Rust and even C.</p>

<p>With C++17, the C++ standard was extended to have the <code>std::variant</code> generic
type, which is basically a “C union on steroids”.</p>

<p>(To the C++ greybeard programmers reading this: I know this is technically
not right, how it is implemented and how this works is very different from an
actual C union, but what it is used for is basically the same, so please don&#39;t
yell at me for this statement.)</p>

<p>A <code>std::variant</code> can be used to express, for example, a return value of a
function which might have failed.
Maybe you think “Hey, that&#39;s what exceptions are for” – no, that&#39;s not what
exceptions are for, though a lot of programmer use them like this.
Exceptions are for unexpected behaviour of your program. If you&#39;re writing a
terminal calculator, an invalid input is an <em>expected</em> failure. An unexpected
failure would be that you cannot read from <code>stdin</code>!</p>

<p>In cases where expected failures happen, a <code>std::variant</code> can be used to
return a “I failed doing my job”-value.</p>

<h1 id="why-you-need-pattern-matching" id="why-you-need-pattern-matching">Why you need pattern matching</h1>

<p>Pattern matching can be used to destructure variants efficiently (as in code,
readability, extendability and thus maintainability) to access their inner
values.</p>

<p>For example, in Haskell, one can destructure a variant like this:</p>

<pre><code>data Result = Ok | Err

explainresult :: Result -&gt; [Char]
explainresult Ok  = &#34;All right&#34;
explainresult Err = &#34;Ouch&#34;
</code></pre>

<p>Here, we define the variant <code>Result</code> and a function <code>explainresult</code> which
destructures the variant and returns a string based on the passed variant.
Of course, variants can hold data and this data can be accessed then.</p>

<p>As a matter of fact, variants are incredible useful in everyday programming
and so is pattern matching for destructuring them.</p>

<h1 id="what-c-17-offers-instead-of-pattern-matching" id="what-c-17-offers-instead-of-pattern-matching">What C++17 offers instead of pattern matching</h1>

<p>C++17 does not offer pattern matching. Why? I don&#39;t know. But it really should
have, because the way this issue is solved in C++17 is painful: <code>std::visit</code>
is used for imitate pattern matching.</p>

<p>On the first glance, the following code looks rather okayish (well, it is
still C++, right?):</p>

<pre><code>std::vector&lt;std::variant&lt;char, long, float, int, double, long long&gt;&gt;
           vec = {5, &#39;2&#39;, 5.4, 100ll, 2011l, 3.5f, 2017};

// display each value
for (auto&amp; v: vec){
  std::visit([](auto&amp;&amp; e){std::cout &lt;&lt; e &lt;&lt; &#34; &#34;;}, v);
}
</code></pre>

<p>But this is simple. What if we want to actually do something with the element
based on which type it has?</p>

<p>Well, not so nice: We have to design our own visitor and equip it with the
functionality:</p>

<pre><code>struct Visitor {
    void operator()(const string&amp; s) const {
      // ...
    }

    void operator()(const int n) const {
      // ...
    }
};
</code></pre>

<p>While having a dedicated visitor which can be passed around is rather nice,
having it as the <em>only</em> option for pattern matching is hell.</p>

<p>Also, the standard library does
<a href="https://bitbashing.io/std-visit.html">not provide a helper for building a visitor object from a list of lambdas</a>!</p>

<p>All in all: Is the whole thing a step into the right direction? No. It is
rather a stumble into the rightish direction. Nothing more.</p>

<h1 id="a-friendly-advice-from-a-non-cpp-programmer" id="a-friendly-advice-from-a-non-cpp-programmer">A friendly advice from a non-Cpp programmer</h1>

<p>Take a grain of salt. I&#39;m not a (C++) professional, hence this might not
reflect the opinions of the broader community.
Also, the following might get some people <strong>really</strong> angry. But I don&#39;t care.</p>

<p><strong>Don&#39;t use C++ for new projects!</strong></p>

<p>I know C++ is a heavy target and the standard is backwards compatible and a
lot of people count on the standards committee to get this right and
yaddayaddayadda.
From my point of view, C++ tries to catch up. This is, of course, nice. But at
that speed, other languages will innovate much faster and better and C++ will
slowly die.
That&#39;s one reason I would never ever use C++ for a new project.</p>

<p>tags:  <a href="https://beyermatthias.de/tag:tools" class="hashtag"><span>#</span><span class="p-category">tools</span></a> <a href="https://beyermatthias.de/tag:software" class="hashtag"><span>#</span><span class="p-category">software</span></a> <a href="https://beyermatthias.de/tag:c" class="hashtag"><span>#</span><span class="p-category">c</span></a>++</p>
]]></content:encoded>
      <guid>https://beyermatthias.de/til-dont-use-c-for-new-projects</guid>
      <pubDate>Fri, 09 Feb 2018 16:39:03 +0100</pubDate>
    </item>
    <item>
      <title>How to improve your open source code (6) - Version control</title>
      <link>https://beyermatthias.de/how-to-improve-your-open-source-code-6-version-control</link>
      <description>&lt;![CDATA[small&#xA;  This post was written during my trip through Iceland and published much&#xA;  later than it was written.&#xA;/small&#xA;&#xA;Version Control is one important aspect when developing software as a&#xA;whole, and especially when developing open source software.&#xA;&#xA;Here are some thoughts about it.&#xA;&#xA;Technology&#xA;&#xA;First of all, technology wise it doesn&#39;t matter which version control&#xA;system one uses. For the sake I&#39;m using git here as an example VCS,&#xA;though others might do as well.&#xA;&#xA;One important thing, at least in my opinion, is that the VCS has some&#xA;basic functionality. This is mainly that it can be used distributed and&#xA;has a branching functionality (which are two things I like to believe&#xA;go hand in hand).&#xA;&#xA;So I do not care whether one uses git, mecurial, or anything else. Most&#xA;important is that a (D)VCS is actually used.&#xA;&#xA;Branching model&#xA;&#xA;Branching is a method that came up before git was created, as bitkeeper&#xA;had such functionality (as far as I can tell) before Linus Torvalds&#xA;wrote git. It is only that git has revolutionised the way we do version&#xA;control and brought branching to wider knowledge and use.&#xA;&#xA;In my opinion it is really important how branching is done. There is not&#xA;simply &#34;the branching&#34; but there are many ways to do branching and one&#xA;might be better for certain use case than another. There are known&#xA;models such as feature branching, the gitflow branching model and a&#xA;rebase-merge workflow. I don&#39;t want to explain each of them because&#xA;others have done so way better than I ever could.&#xA;&#xA;What I want to tell is that branching is not only important, but as&#xA;flexible as you might not even guess. This is not necessarily a good&#xA;thing - I&#39;ll show you in a minute. In my opinion, branching and&#xA;developing a branching model for a project is like developing an API.&#xA;Once it is set up properly, it may serve as a communication rule for a&#xA;project, putting developers on the same page about how certain things&#xA;have to be handled. Having a protocol on how to work on things is a good&#xA;thing. If implemented properly, branching can improve the work of&#xA;everyone as it is one point less to think about.&#xA;&#xA;The bad thing about flexibility of branching functionality is that it&#xA;can be done wrong. It&#39;s as simply as that, but merging one branch into&#xA;another when one is not supposed to do that, creates overhead which&#xA;might not be reversible. This has happened to the best communities (for&#xA;example the kernel community) but also happens in small communities,&#xA;often due to too few knowledge of the tools at hand.&#xA;&#xA;To summarize: If an open source project gets to a certain size (both&#xA;code-wise and contributor/community-wise) a branching model should be&#xA;implemented. If there are rules that contributors agree upon, it can&#xA;improve working speed and therefore overall happiness in the community.&#xA;Because developers like to bikeshed, it could also worsen happiness, of&#xA;course. Though, it is better than no plan and chaos instead.&#xA;&#xA;Hosting&#xA;&#xA;I will not go into thoughts about hosting platforms in this article but&#xA;rather on the how and why.&#xA;&#xA;First of all, hosting the code somewhere with a way to show it in a web&#xA;browser is a good way to improve the &#34;open&#34; part of open source code. Of&#xA;course, tarball downloads and such suffice, but we are in the 21st&#xA;century, so having a nice web interface is something one can expect.&#xA;&#xA;Making the code browsable is often done via a VCS-specific web frontend,&#xA;for example cgit for code version controlled with git. Therefore this&#xA;web interfaces often also feature functionality to go back in time&#xA;and view the history of one file. Maybe this is not needed&#xA;often, but nevertheless helpful if needed.&#xA;&#xA;I personally do not care about comments on code in my web interfaces&#xA;or even ways to register users on the site, but of course some people like&#xA;that. There are web interfaces that feature such things, for example for&#xA;the git VCS there is gitea, gogs, gitlab, ... and many more. And of&#xA;course there are the closed providers github, bitbucket and others...&#xA;&#xA;Making code public and contributions easy&#xA;&#xA;Hosting helps a lot with enabling contributions from strangers. No&#xA;doubt, github makes contributions ridiculously easy.&#xA;&#xA;I don&#39;t want to reiterate what others have said better and most people&#xA;already know. What I want to point out here is that open source does not&#xA;mean &#34;open contributions&#34;. One is completely free to reject all&#xA;contributions one ones code base.&#xA;&#xA;I really want to stress this. Open source does indeed mean that everyone&#xA;is able to view the code, which also enables them to copy it (though&#xA;redistribution might be limited or forbidden, as only free software&#xA;allows you - by definition - to redistribute and alter code) but not&#xA;necessarily that one is allowed or welcome to send in changes, feature&#xA;requests or the like.&#xA;&#xA;So if you want people to contribute to your code and suggest changes,&#xA;features or report bugs, you should somehow give them the opportunity to&#xA;do so. Depending on how &#34;open&#34; you want to be with your development you&#xA;either should use a hosting platform (like github or bitbucket) or a&#xA;slightly more &#34;closed&#34; variant, for example hosting your code on&#xA;your own gitea instance. One step further you&#39;d host your code on a&#xA;site where people might be able to get it, maybe even with a &#34;git&#xA;clone&#34;, though not send in pull requests, feature requests or open&#xA;issues (for example a hosted git repository with cgit interface).&#xA;Issues and bug reports could still be done via a mailinglist, if&#xA;desired.&#xA;&#xA;In fact, that last bit is what I consider for my own project&#xA;imag.&#xA;&#xA;SemVer, Change Management, Release Management&#xA;&#xA;As soon as your code is out there, you have to think about change and&#xA;release management. In my opinion, these are topics closely related to&#xA;source code version control as VCS often offer functionality to do&#xA;releases in one form or another and are clearly involved in the process&#xA;of change management.&#xA;&#xA;First of all, I&#39;d like to suggest you read the SemVer specification. It&#xA;is not that long but will help you understanding the next few&#xA;paragraphs. So if you haven&#39;t read it already, go ahead and do so. Even&#xA;if you don&#39;t apply SemVer to your projects it might open your eyes in&#xA;one aspect or another.&#xA;&#xA;But before we get into releases, we should first talk about change&#xA;management, or better named for my points: Pull request management.&#xA;&#xA;What I personally do with my PRs is, merge them when they&#39;re ready. This&#xA;approach is easy and works, so far, pretty well. From time to time I&#xA;have changes in my working branches (as stated before, I use feature&#xA;branches) which might conflict with other peoples work. For the sake of&#xA;contributor experience, I pause my PRs and wait until they are done with&#xA;theirs. We will talk a lot about this in the next episode of this&#xA;series, so I won&#39;t go into much detail. For now: This is a simple&#xA;approach that works perfectly well so far for me and my (considerably&#xA;small) open source projects.&#xA;&#xA;But as soon as ones project grews bigger, that approach might not do the&#xA;job anymore. If there are too many changes in a short amount of time&#xA;which have to be agreed on and that have to be merged, it might be time&#xA;to think about an alternative approach.&#xA;&#xA;There are two ways I would tackle this problem. I never experienced it in&#xA;the &#34;real world&#34;/in my projects, so the following is just a write down&#xA;of my thoughts. Take a grain of salt from here on.&#xA;&#xA;The first approach I can think of is to assign certain subsystems to&#xA;certain people. If the amount of changes has become too big, one could&#xA;assume that the codebase has also become tremendous. If that is the&#xA;case, sub-maintainers can handle certain subsystems and the project&#xA;leader can then periodically merge all changes together. This requires,&#xA;of course, at least two people that are interested into the subject and&#xA;willing to contribute maintaining efforts to the project.&#xA;&#xA;If the latter is not the case or there are too few people around for&#xA;this, one could consider a merge-window style approach, like known from&#xA;Linus himself. Changes are pulled in every other week, for example, and&#xA;the rest of the time, only bug fixes are merged into the project.&#xA;&#xA;These two approaches might become handy some day if one is about to&#xA;maintain a large code base alone (as in &#34;as the only project owner&#34;).&#xA;&#xA;Now on to release management. In my opinion, releases should be done as&#xA;soon as something works and from there on periodically. I myself made&#xA;one mistake too often: Pull more things into one release than would have&#xA;been good. For example the imag 0.2.0 release was over one year ago.&#xA;0.3.0 is almost ready, but not yet. I should&#39;ve done more releases in&#xA;between.&#xA;&#xA;In my opinion, more releases with clear-cut edges are better than long&#xA;release-cycles. As soon as there is a new feature for users - release.&#xA;User-facing fixed - release. This might result in high numbers for&#xA;versioning, but who cares?&#xA;&#xA;This is where I want to throw SemVer in, to adjust my statement from the&#xA;last paragraph with a &#34;but&#34;.&#xA;&#xA;SemVer can be used to notify breaking user interfaces. This is a really&#xA;good thing and therefore I think SemVer should be applied everywhere.&#xA;SemVer also states that in the &#34; 0.y.z phase&#34; everything is allowed to&#xA;happen, also API breakage. This is where I want to adjust my statement&#xA;from above. A lot of releases should be done in the 0.y.z phase, but&#xA;also within that scope. As soon as a library or program hits the 1.0.0,&#xA;changes should be applied carefully. One really does not want to end up&#xA;with a program or library in version 127.0.0, right? That&#39;d also&#xA;decrease a users trust into the application as one can expect breakage&#xA;with every new release.&#xA;&#xA;So what I&#39;d do and actually plan doing with my projects is releasing a&#xA;number of zero-releases until I am confident that everything is all&#xA;right and then go from there. For imag specifically I am not thinking&#xA;about 1.0.0 because imag is far from ready, but for my other projects,&#xA;especially toml-query, I think of 1.0.0 already.&#xA;&#xA;Another point which popped into my head weeks after the initial draft of&#xA;this article was: Do not plan the features of the next release with a&#xA;release number! This might sound a bit odd, so let me explain. For&#xA;example, you&#39;re planning three major features for the next release,&#xA;which will be 0.15.0 then. And you&#39;re slowly getting to a point where&#xA;the release becomes ready, you might need three more weeks to get it&#xA;ready. Now, a contributor steps up and opens a pull request with&#xA;another feature, which is already completely implemented, tested and&#xA;also documented in the pull request. The contributor needs this feature&#xA;as soon as possible in your code and you also think that it might be a&#xA;great idea to release this as soon as possible. After you merged the&#xA;request, you release the source - as 0.15.0, despite your three features&#xA;are not yet completed.&#xA;&#xA;Two things come to mind in this scenario: First, if two of your three&#xA;features are already completed, they might show up in 0.15.0 but one&#xA;feature has to be moved to the next release. If these two features are&#xA;ready, but not tested, you might end up with a buggy&#xA;release and have to release 0.15.1 soonish - more effort for you. If you&#xA;do not merge your features into the master branch of your project, but&#xA;you have a 0.15.0-prepare branch or something like that, you end up with&#xA;a rather ugly merge-mess later on, as 0.15.0 is already released and you&#xA;cannot just rename a public branch.&#xA;&#xA;So how to handle this properly? I came to the conclusion that&#xA;release-branches is the way to go here. In the scenario described above,&#xA;you&#39;d branch off of the release before, most certainly 0.14.x and create&#xA;a new branch 0.15.0, where the pull request of the contributor would be&#xA;merged than. As soon as the release is out, 0.15.0 will be tagged and&#xA;merged back to the master branch.&#xA;&#xA;What my point is here: you&#39;d still need to rename your next milestone or&#xA;rewrite your issues for the next release. That&#39;s why I would not plan&#xA;&#34;0.15.0&#34;, but simply &#34;the next release&#34; - because you&#39;ll never know&#xA;whether your planned things will actually be the next release or the&#xA;the release after. So lessen the effort for yourself here!&#xA;&#xA;Next&#xA;&#xA;In the next article in this series I want to elaborate on how to make a&#xA;contribution as pleasing as possible for the contributor. I guess I can&#xA;talk a lot about that because I&#39;ve contributed to a lot of projects&#xA;already, including but not limited to linux,&#xA;nixpkgs and&#xA;nanoc.&#xA;&#xA;tags: #open-source #programming #software #tools #rust&#xA;]]&gt;</description>
      <content:encoded><![CDATA[<p><small>
  This post was written during my trip through Iceland and published much
  later than it was written.
</small></p>

<p>Version Control is one important aspect when developing software as a
whole, and especially when developing open source software.</p>

<p>Here are some thoughts about it.</p>

<h1 id="technology" id="technology">Technology</h1>

<p>First of all, technology wise it doesn&#39;t matter which version control
system one uses. For the sake I&#39;m using git here as an example VCS,
though others might do as well.</p>

<p>One important thing, at least in my opinion, is that the VCS has some
basic functionality. This is mainly that it can be used distributed and
has a branching functionality (which are two things I like to believe
go hand in hand).</p>

<p>So I do not care whether one uses git, mecurial, or anything else. Most
important is that a (D)VCS is actually used.</p>

<h1 id="branching-model" id="branching-model">Branching model</h1>

<p>Branching is a method that came up before git was created, as bitkeeper
had such functionality (as far as I can tell) before Linus Torvalds
wrote git. It is only that git has revolutionised the way we do version
control and brought branching to wider knowledge and use.</p>

<p>In my opinion it is really important how branching is done. There is not
simply “the branching” but there are many ways to do branching and one
might be better for certain use case than another. There are known
models such as feature branching, the gitflow branching model and a
rebase-merge workflow. I don&#39;t want to explain each of them because
others have done so way better than I ever could.</p>

<p>What I want to tell is that branching is not only important, but as
flexible as you might not even guess. This is not necessarily a good
thing – I&#39;ll show you in a minute. In my opinion, branching and
developing a branching model for a project is like developing an API.
Once it is set up properly, it may serve as a communication rule for a
project, putting developers on the same page about how certain things
have to be handled. Having a protocol on how to work on things is a good
thing. If implemented properly, branching can improve the work of
everyone as it is one point less to think about.</p>

<p>The bad thing about flexibility of branching functionality is that it
can be done wrong. It&#39;s as simply as that, but merging one branch into
another when one is not supposed to do that, creates overhead which
might not be reversible. This has happened to the best communities (for
example the kernel community) but also happens in small communities,
often due to too few knowledge of the tools at hand.</p>

<p>To summarize: If an open source project gets to a certain size (both
code-wise and contributor/community-wise) a branching model should be
implemented. If there are rules that contributors agree upon, it can
improve working speed and therefore overall happiness in the community.
Because developers like to bikeshed, it could also worsen happiness, of
course. Though, it is better than no plan and chaos instead.</p>

<h1 id="hosting" id="hosting">Hosting</h1>

<p>I will not go into thoughts about hosting platforms in this article but
rather on the how and why.</p>

<p>First of all, hosting the code somewhere with a way to show it in a web
browser is a good way to improve the “open” part of open source code. Of
course, tarball downloads and such suffice, but we are in the 21st
century, so having a nice web interface is something one can expect.</p>

<p>Making the code browsable is often done via a VCS-specific web frontend,
for example cgit for code version controlled with git. Therefore this
web interfaces often also feature functionality to go back in time
and view the history of one file. Maybe this is not needed
often, but nevertheless helpful if needed.</p>

<p>I personally do not care about comments on code in my web interfaces
or even ways to register users on the site, but of course some people like
that. There are web interfaces that feature such things, for example for
the git VCS there is gitea, gogs, gitlab, ... and many more. And of
course there are the closed providers github, bitbucket and others...</p>

<h1 id="making-code-public-and-contributions-easy" id="making-code-public-and-contributions-easy">Making code public and contributions easy</h1>

<p>Hosting helps a lot with enabling contributions from strangers. No
doubt, github makes contributions ridiculously easy.</p>

<p>I don&#39;t want to reiterate what others have said better and most people
already know. What I want to point out here is that open source does not
mean “open contributions”. One is completely free to reject all
contributions one ones code base.</p>

<p>I really want to stress this. Open source does indeed mean that everyone
is able to view the code, which also enables them to copy it (though
redistribution might be limited or forbidden, as only free software
allows you – by definition – to redistribute and alter code) but not
necessarily that one is allowed or welcome to send in changes, feature
requests or the like.</p>

<p>So if you want people to contribute to your code and suggest changes,
features or report bugs, you should somehow give them the opportunity to
do so. Depending on how “open” you want to be with your development you
either should use a hosting platform (like github or bitbucket) or a
slightly more “closed” variant, for example hosting your code on
your own gitea instance. One step further you&#39;d host your code on a
site where people might be able to get it, maybe even with a “git
clone”, though not send in pull requests, feature requests or open
issues (for example a hosted git repository with cgit interface).
Issues and bug reports could still be done via a mailinglist, if
desired.</p>

<p>In fact, that last bit is what I consider for my own project
<a href="https://imag-pim.org">imag</a>.</p>

<h1 id="semver-change-management-release-management" id="semver-change-management-release-management">SemVer, Change Management, Release Management</h1>

<p>As soon as your code is out there, you have to think about change and
release management. In my opinion, these are topics closely related to
source code version control as VCS often offer functionality to do
releases in one form or another and are clearly involved in the process
of change management.</p>

<p>First of all, I&#39;d like to suggest you read the SemVer specification. It
is not that long but will help you understanding the next few
paragraphs. So if you haven&#39;t read it already, go ahead and do so. Even
if you don&#39;t apply SemVer to your projects it might open your eyes in
one aspect or another.</p>

<p>But before we get into releases, we should first talk about change
management, or better named for my points: Pull request management.</p>

<p>What I personally do with my PRs is, merge them when they&#39;re ready. This
approach is easy and works, so far, pretty well. From time to time I
have changes in my working branches (as stated before, I use feature
branches) which might conflict with other peoples work. For the sake of
contributor experience, I pause my PRs and wait until they are done with
theirs. We will talk a lot about this in the next episode of this
series, so I won&#39;t go into much detail. For now: This is a simple
approach that works perfectly well so far for me and my (considerably
small) open source projects.</p>

<p>But as soon as ones project grews bigger, that approach might not do the
job anymore. If there are too many changes in a short amount of time
which have to be agreed on and that have to be merged, it might be time
to think about an alternative approach.</p>

<p>There are two ways I would tackle this problem. I never experienced it in
the “real world”/in my projects, so the following is just a write down
of my thoughts. Take a grain of salt from here on.</p>

<p>The first approach I can think of is to assign certain subsystems to
certain people. If the amount of changes has become too big, one could
assume that the codebase has also become tremendous. If that is the
case, sub-maintainers can handle certain subsystems and the project
leader can then periodically merge all changes together. This requires,
of course, at least two people that are interested into the subject and
willing to contribute maintaining efforts to the project.</p>

<p>If the latter is not the case or there are too few people around for
this, one could consider a merge-window style approach, like known from
Linus himself. Changes are pulled in every other week, for example, and
the rest of the time, only bug fixes are merged into the project.</p>

<p>These two approaches might become handy some day if one is about to
maintain a large code base alone (as in “as the only project owner”).</p>

<p>Now on to release management. In my opinion, releases should be done as
soon as something works and from there on periodically. I myself made
one mistake too often: Pull more things into one release than would have
been good. For example the imag 0.2.0 release was over one year ago.
0.3.0 is almost ready, but not yet. I should&#39;ve done more releases in
between.</p>

<p>In my opinion, more releases with clear-cut edges are better than long
release-cycles. As soon as there is a new feature for users – release.
User-facing fixed – release. This might result in high numbers for
versioning, but who cares?</p>

<p>This is where I want to throw SemVer in, to adjust my statement from the
last paragraph with a “but”.</p>

<p>SemVer can be used to notify breaking user interfaces. This is a really
good thing and therefore I think SemVer should be applied everywhere.
SemVer also states that in the “ 0.y.z phase” everything is allowed to
happen, also API breakage. This is where I want to adjust my statement
from above. A lot of releases should be done in the 0.y.z phase, but
also within that scope. As soon as a library or program hits the 1.0.0,
changes should be applied carefully. One really does not want to end up
with a program or library in version 127.0.0, right? That&#39;d also
decrease a users trust into the application as one can expect breakage
with every new release.</p>

<p>So what I&#39;d do and actually plan doing with my projects is releasing a
number of zero-releases until I am confident that everything is all
right and then go from there. For imag specifically I am not thinking
about 1.0.0 because imag is far from ready, but for my other projects,
especially toml-query, I think of 1.0.0 already.</p>

<p>Another point which popped into my head weeks after the initial draft of
this article was: Do not plan the features of the next release with a
release number! This might sound a bit odd, so let me explain. For
example, you&#39;re planning three major features for the next release,
which will be 0.15.0 then. And you&#39;re slowly getting to a point where
the release becomes ready, you might need three more weeks to get it
ready. Now, a contributor steps up and opens a pull request with
<em>another</em> feature, which is already completely implemented, tested and
also documented in the pull request. The contributor needs this feature
as soon as possible in your code and you also think that it might be a
great idea to release this as soon as possible. After you merged the
request, you release the source – as 0.15.0, despite your three features
are not yet completed.</p>

<p>Two things come to mind in this scenario: First, if two of your three
features are already completed, they might show up in 0.15.0 but one
feature has to be moved to the next release. If these two features are
ready, but not tested, you might end up with a buggy
release and have to release 0.15.1 soonish – more effort for you. If you
do not merge your features into the master branch of your project, but
you have a 0.15.0-prepare branch or something like that, you end up with
a rather ugly merge-mess later on, as 0.15.0 is already released and you
cannot just rename a public branch.</p>

<p>So how to handle this properly? I came to the conclusion that
release-branches is the way to go here. In the scenario described above,
you&#39;d branch off of the release before, most certainly 0.14.x and create
a new branch 0.15.0, where the pull request of the contributor would be
merged than. As soon as the release is out, 0.15.0 will be tagged and
merged back to the master branch.</p>

<p>What my point is here: you&#39;d still need to rename your next milestone or
rewrite your issues for the next release. That&#39;s why I would not plan
“0.15.0”, but simply “the next release” – because you&#39;ll never know
whether your planned things will actually be the <em>next</em> release or the
<em>the release after</em>. So lessen the effort for yourself here!</p>

<h1 id="next" id="next">Next</h1>

<p>In the next article in this series I want to elaborate on how to make a
contribution as pleasing as possible for the contributor. I guess I can
talk a lot about that because I&#39;ve contributed to a lot of projects
already, including but not limited to <a href="https://kernel.org">linux</a>,
<a href="https://github.com/nixos/nixpkgs">nixpkgs</a> and
<a href="https://nanoc.ws">nanoc</a>.</p>

<p>tags: <a href="https://beyermatthias.de/tag:open" class="hashtag"><span>#</span><span class="p-category">open</span></a>-source <a href="https://beyermatthias.de/tag:programming" class="hashtag"><span>#</span><span class="p-category">programming</span></a> <a href="https://beyermatthias.de/tag:software" class="hashtag"><span>#</span><span class="p-category">software</span></a> <a href="https://beyermatthias.de/tag:tools" class="hashtag"><span>#</span><span class="p-category">tools</span></a> <a href="https://beyermatthias.de/tag:rust" class="hashtag"><span>#</span><span class="p-category">rust</span></a></p>
]]></content:encoded>
      <guid>https://beyermatthias.de/how-to-improve-your-open-source-code-6-version-control</guid>
      <pubDate>Sat, 03 Feb 2018 16:38:57 +0100</pubDate>
    </item>
    <item>
      <title>Extending an Iterator in Rust</title>
      <link>https://beyermatthias.de/extending-an-iterator-in-rust</link>
      <description>&lt;![CDATA[A common thing one has to do in Rust to leverage zero-cost abstractions and&#xA;convenience is to extend types.&#xA;By &#34;extending&#34; them I mean adding functionality (functions) to the type which&#xA;make it more convenient to use and &#34;improve&#34; it for the domain at hand.&#xA;&#xA;From time to time, one needs to extend generic types, which is a difficult&#xA;thing to do. Especially when it comes to iterators, where extending is often&#xA;tricky.&#xA;&#xA;That&#39;s why I want to write some notes on it down.&#xA;&#xA;How do filters work?&#xA;&#xA;I have this crate called &#34;filters&#34; which offers nice functionality for&#xA;building predicates with the builder pattern.&#xA;A predicate is nothing more than a function which takes something by reference&#xA;and returns a boolean for it:&#xA;&#xA;fn(&amp;self, some: &amp;Thing) -  bool;&#xA;&#xA;The function is now allowed to decide whether the Thing shall be used. This&#xA;is useful when working with iterators:&#xA;&#xA;let filter = LowerThan::new(5);&#xA;vec![1,2,3,4,5,6,7,8,9].iter().filter(|e| filter.filter(&amp;e)).collect()&#xA;&#xA;Filters can, as I mentioned, be build with the builder-pattern:&#xA;&#xA;let filter = HigherThan::new(5)&#xA;    .and(LowerThan::new(20))&#xA;    .and(UnequalTo::new(15));&#xA;&#xA;vec![1,2,3,4,5,6,7,8,9].iter().filter(|e| filter.filter(&amp;e)).collect()&#xA;&#xA;One can also define own filters (in fact, the HigherThan, LowerThan and&#xA;UnequalTo types do not ship with the crate) by implementing the Filter&#xA;trait:&#xA;&#xA;struct LowerThan(u64);&#xA;impl Filteru64 for LowerThan {&#xA;  fn filter(&amp;self, elem: &amp;u64) -  bool {&#xA;    elem &lt; self.0&#xA;  }&#xA;}&#xA;&#xA;What are we going to do?&#xA;&#xA;What we&#39;re going to do is rather easy. We want a functionality implemented on&#xA;all iterator types which gives us the possibility to pass an object for&#xA;filtering rather than writing down this nasty closure (as shown above):&#xA;&#xA;iterator.filter(|e| filter.filter(&amp;e))&#xA;&#xA;We want to write:&#xA;&#xA;iterator.filterwith(somefilter)&#xA;&#xA;And we want to get back a nice iterator type.&#xA;&#xA;Step 1: A type&#xA;&#xA;First, we need a type representing a iterator which is filtered. This type, of&#xA;course, has to be abstract over the actual iterator we want to filter (that&#39;s&#xA;also how the rust standard library does this under the hood).&#xA;The type also has to be generic over the filter in use.&#xA;So basically we write down an entirely generic type:&#xA;&#xA;pub struct FilteredIteratorT, F, I(F, I)&#xA;    where F: FilterT,&#xA;          I: IteratorItem = T;&#xA;&#xA;Here F is a filter over T and I is the iterator over T. The&#xA;FilteredIterator holds both F and I.&#xA;&#xA;Step 2: Implement Iterator on this type&#xA;&#xA;The next step is implementing iterator on this new type.&#xA;Because we want to use this iterator in a chain like this, for example:&#xA;&#xA;forest&#xA;    .filteredwith(TreeWithColor::new(Color::Green))&#xA;    .map(|tree| tree.getname())&#xA;    .enumerate()&#xA;    .map(|(i, treename)| {&#xA;      storetreenumber(treename, i)&#xA;    })&#xA;    .fold(Ok(()), |acc, e| {&#xA;      // ...&#xA;    })&#xA;&#xA;we have to implement Iterator on it.&#xA;&#xA;Because the type is generic, so is our iterator implementation.&#xA;&#xA;implT, F, I Iterator for FilteredIteratorT, F, I&#xA;    where F: FilterT,&#xA;          I: IteratorItem = T&#xA;{&#xA;    type Item = T;&#xA;&#xA;    fn next(&amp;mut self) -  OptionSelf::Item {&#xA;        // ...&#xA;    }&#xA;}&#xA;&#xA;The implementation is left out as task for the reader. Hint: The only function&#xA;one needs is Filter::filter() and a while let Some(e).&#xA;&#xA;Step 3: Transforming one iterator into a filtered iterator&#xA;&#xA;Next, we want to be able to transform an existing iterator type into a&#xA;filtered iterator.&#xA;As I wrote above, we do this by providing a new trait for this.&#xA;Because of the generic parameters our FilteredIterator type has, we need&#xA;generic types in our trait as well:&#xA;&#xA;pub trait FilterWithT, F: Filter&lt;T  : IteratorItem = T + Sized {&#xA;    fn filterwith(self, f: F) -  FilteredIteratorT, F, Self;&#xA;}&#xA;&#xA;The trait provides only one function: filterwith(). This function takes&#xA;self owning and a Filter which is used in the FilteredIterator later.&#xA;&#xA;Step 4: Extending all iterators&#xA;&#xA;Last but not least, we implement this trait on all Iterators.&#xA;Even more generics here, of course:&#xA;&#xA;implI, T, F: Filter&lt;T  FilterWithT, F for I&#xA;    where I: IteratorItem = T&#xA;{&#xA;    fn filterwith(self, f: F) -  FilteredIteratorT, F, Self {&#xA;        FilteredIterator(f, self)&#xA;    }&#xA;}&#xA;&#xA;The actual implementation is trivial, sure. But the type signature is not, so&#xA;I&#39;ll explain.&#xA;&#xA;I is the type we implement the FilterWith trait for. Because we want to&#xA;   implement it for all iterators, we have to use a generic type.&#xA;I is, of course, generic itself. We want to be able to filter all&#xA;   iterators over all types. So, T is the Item of the Iterator.&#xA;F is needed because FilterWith is generic over the provided filter: We&#xA;   can filter with any Filter we want. So we have to be generic over that as&#xA;   well.&#xA;&#xA;The output of the filterwith function is a FilteredIterator which is&#xA;generic over T and F - but wait! FilteredIterator is generic over three&#xA;types!&#xA;&#xA;That&#39;s true. But the third generic type is the iterator it encapsulated - the&#xA;iterator it actually filters. Because of that, we return `FilteredIterator&lt;T,&#xA;F, Self  ` here - we don&#39;t need a generic type as third type here because we&#xA;know that the iterator which will be encapsulated has exactly the type which&#xA;the trait gets currently implemented for.&#xA;&#xA;(I hope that explanation is easy to understand.)&#xA;&#xA;Conclusion&#xA;&#xA;Extending types in Rust is incredible easy - if one can grok generics. I know&#xA;that generics are not that easy to grok for a beginner - I had a hard time&#xA;learning how to use them myself. But it is really worth it, as our test shows:&#xA;&#xA;[test]&#xA;fn testfilterwith() {&#xA;    struct Foo;&#xA;    impl Filteru64 for Foo {&#xA;        fn filter(&amp;self, u: &amp;u64) -  bool {&#xA;            u   5&#xA;        }&#xA;    }&#xA;    let foo = Foo;&#xA;&#xA;    let v : Vecu64 = vec![1, 2, 3, 4, 5, 6, 7, 8, 9, 0]&#xA;        .intoiter()&#xA;        .filterwith(foo)&#xA;        .collect();&#xA;&#xA;    assert_eq!(v, vec![6, 7, 8, 9]);&#xA;}&#xA;&#xA;tags:  #tools #software #rust #open-source&#xA;]]&gt;</description>
      <content:encoded><![CDATA[<p>A common thing one has to do in Rust to leverage zero-cost abstractions and
convenience is to <em>extend</em> types.
By “extending” them I mean adding functionality (functions) to the type which
make it more convenient to use and “improve” it for the domain at hand.</p>

<p>From time to time, one needs to extend generic types, which is a difficult
thing to do. Especially when it comes to iterators, where extending is often
tricky.</p>

<p>That&#39;s why I want to write some notes on it down.</p>

<h1 id="how-do-filters-work" id="how-do-filters-work">How do filters work?</h1>

<p>I have this crate called “filters” which offers nice functionality for
building predicates with the builder pattern.
A predicate is nothing more than a function which takes something by reference
and returns a boolean for it:</p>

<pre><code>fn(&amp;self, some: &amp;Thing) -&gt; bool;
</code></pre>

<p>The function is now allowed to decide whether the <code>Thing</code> shall be used. This
is useful when working with iterators:</p>

<pre><code>let filter = LowerThan::new(5);
vec![1,2,3,4,5,6,7,8,9].iter().filter(|e| filter.filter(&amp;e)).collect()
</code></pre>

<p>Filters can, as I mentioned, be build with the builder-pattern:</p>

<pre><code>let filter = HigherThan::new(5)
    .and(LowerThan::new(20))
    .and(UnequalTo::new(15));

vec![1,2,3,4,5,6,7,8,9].iter().filter(|e| filter.filter(&amp;e)).collect()
</code></pre>

<p>One can also define own filters (in fact, the <code>HigherThan</code>, <code>LowerThan</code> and
<code>UnequalTo</code> types do not ship with the crate) by implementing the <code>Filter</code>
trait:</p>

<pre><code>struct LowerThan(u64);
impl Filter&lt;u64&gt; for LowerThan {
  fn filter(&amp;self, elem: &amp;u64) -&gt; bool {
    *elem &lt; self.0
  }
}
</code></pre>

<h1 id="what-are-we-going-to-do" id="what-are-we-going-to-do">What are we going to do?</h1>

<p>What we&#39;re going to do is rather easy. We want a functionality implemented on
<em>all</em> iterator types which gives us the possibility to pass an object for
filtering rather than writing down this nasty closure (as shown above):</p>

<pre><code>iterator.filter(|e| filter.filter(&amp;e))
</code></pre>

<p>We want to write:</p>

<pre><code>iterator.filter_with(some_filter)
</code></pre>

<p>And we want to get back a nice iterator type.</p>

<h1 id="step-1-a-type" id="step-1-a-type">Step 1: A type</h1>

<p>First, we need a type representing a iterator which is filtered. This type, of
course, has to be abstract over the actual iterator we want to filter (that&#39;s
also how the rust standard library does this under the hood).
The type also has to be generic over the filter in use.
So basically we write down an entirely generic type:</p>

<pre><code>pub struct FilteredIterator&lt;T, F, I&gt;(F, I)
    where F: Filter&lt;T&gt;,
          I: Iterator&lt;Item = T&gt;;
</code></pre>

<p>Here <code>F</code> is a filter over <code>T</code> and <code>I</code> is the iterator over <code>T</code>. The
<code>FilteredIterator</code> holds both <code>F</code> and <code>I</code>.</p>

<h1 id="step-2-implement-iterator-on-this-type" id="step-2-implement-iterator-on-this-type">Step 2: Implement Iterator on this type</h1>

<p>The next step is implementing iterator on this new type.
Because we want to use this iterator in a chain like this, for example:</p>

<pre><code>forest
    .filtered_with(TreeWithColor::new(Color::Green))
    .map(|tree| tree.get_name())
    .enumerate()
    .map(|(i, tree_name)| {
      store_tree_number(tree_name, i)
    })
    .fold(Ok(()), |acc, e| {
      // ...
    })
</code></pre>

<p>we have to implement <code>Iterator</code> on it.</p>

<p>Because the type is generic, so is our iterator implementation.</p>

<pre><code>impl&lt;T, F, I&gt; Iterator for FilteredIterator&lt;T, F, I&gt;
    where F: Filter&lt;T&gt;,
          I: Iterator&lt;Item = T&gt;
{
    type Item = T;

    fn next(&amp;mut self) -&gt; Option&lt;Self::Item&gt; {
        // ...
    }
}
</code></pre>

<p>The implementation is left out as task for the reader. Hint: The only function
one needs is <code>Filter::filter()</code> and a <code>while let Some(e)</code>.</p>

<h1 id="step-3-transforming-one-iterator-into-a-filtered-iterator" id="step-3-transforming-one-iterator-into-a-filtered-iterator">Step 3: Transforming one iterator into a filtered iterator</h1>

<p>Next, we want to be able to transform an existing iterator type into a
filtered iterator.
As I wrote above, we do this by providing a new trait for this.
Because of the generic parameters our <code>FilteredIterator</code> type has, we need
generic types in our trait as well:</p>

<pre><code>pub trait FilterWith&lt;T, F: Filter&lt;T&gt;&gt; : Iterator&lt;Item = T&gt; + Sized {
    fn filter_with(self, f: F) -&gt; FilteredIterator&lt;T, F, Self&gt;;
}
</code></pre>

<p>The trait provides only one function: <code>filter_with()</code>. This function takes
<code>self</code> owning and a <code>Filter</code> which is used in the <code>FilteredIterator</code> later.</p>

<h1 id="step-4-extending-all-iterators" id="step-4-extending-all-iterators">Step 4: Extending all iterators</h1>

<p>Last but not least, we implement this trait on all <code>Iterator</code>s.
Even more generics here, of course:</p>

<pre><code>impl&lt;I, T, F: Filter&lt;T&gt;&gt; FilterWith&lt;T, F&gt; for I
    where I: Iterator&lt;Item = T&gt;
{
    fn filter_with(self, f: F) -&gt; FilteredIterator&lt;T, F, Self&gt; {
        FilteredIterator(f, self)
    }
}
</code></pre>

<p>The actual implementation is trivial, sure. But the type signature is not, so
I&#39;ll explain.</p>
<ol><li><code>I</code> is the type we implement the <code>FilterWith</code> trait for. Because we want to
implement it for <em>all</em> iterators, we have to use a generic type.</li>
<li><code>I</code> is, of course, generic itself. We want to be able to filter all
iterators over <em>all</em> types. So, <code>T</code> is the <code>Item</code> of the Iterator.</li>
<li><code>F</code> is needed because <code>FilterWith</code> is generic over the provided filter: We
can filter with any Filter we want. So we have to be generic over that as
well.</li></ol>

<p>The output of the <code>filter_with</code> function is a <code>FilteredIterator</code> which is
generic over <code>T</code> and <code>F</code> – but wait! <code>FilteredIterator</code> is generic over three
types!</p>

<p>That&#39;s true. But the third generic type is the iterator it encapsulated – the
iterator it actually filters. Because of that, we return <code>FilteredIterator&lt;T,
F, Self&gt;</code> here – we don&#39;t need a generic type as third type here because we
know that the iterator which will be encapsulated has exactly the type which
the trait gets currently implemented for.</p>

<p>(I hope that explanation is easy to understand.)</p>

<h1 id="conclusion" id="conclusion">Conclusion</h1>

<p>Extending types in Rust is incredible easy – if one can grok generics. I know
that generics are not that easy to grok for a beginner – I had a hard time
learning how to use them myself. But it is really worth it, as our test shows:</p>

<pre><code>#[test]
fn test_filter_with() {
    struct Foo;
    impl Filter&lt;u64&gt; for Foo {
        fn filter(&amp;self, u: &amp;u64) -&gt; bool {
            *u &gt; 5
        }
    }
    let foo = Foo;

    let v : Vec&lt;u64&gt; = vec![1, 2, 3, 4, 5, 6, 7, 8, 9, 0]
        .into_iter()
        .filter_with(foo)
        .collect();

    assert_eq!(v, vec![6, 7, 8, 9]);
}
</code></pre>

<p>tags:  <a href="https://beyermatthias.de/tag:tools" class="hashtag"><span>#</span><span class="p-category">tools</span></a> <a href="https://beyermatthias.de/tag:software" class="hashtag"><span>#</span><span class="p-category">software</span></a> <a href="https://beyermatthias.de/tag:rust" class="hashtag"><span>#</span><span class="p-category">rust</span></a> <a href="https://beyermatthias.de/tag:open" class="hashtag"><span>#</span><span class="p-category">open</span></a>-source</p>
]]></content:encoded>
      <guid>https://beyermatthias.de/extending-an-iterator-in-rust</guid>
      <pubDate>Fri, 02 Feb 2018 16:38:56 +0100</pubDate>
    </item>
    <item>
      <title>Maybe it&#39;s time for a crates team</title>
      <link>https://beyermatthias.de/maybe-its-time-for-a-crates-team</link>
      <description>&lt;![CDATA[After reading another post in the users.rust-lang.org forum where a crate&#xA;author is looking for a maintainer for his crate, I started thinking.&#xA;Do we need a &#34;crates-team&#34; in the rust community?&#xA;&#xA;Incentive&#xA;&#xA;The Rust community has a lot of great teams.&#xA;Each of these teams has a different goal: The Core team, for example&#xA;&#xA;  is responsible for steering the design and development process, overseeing the&#xA;  introduction of new features, and ultimately making decisions for which there&#xA;  is no consensus [...]&#xA;&#xA;(source)&#xA;&#xA;Because people change, interests of people change and also because the&#xA;life-situations people are in change, a crate author might not be able to&#xA;continue maintaining their crates.&#xA;I, for one, have such a problem: I am about to go on a really long vacation&#xA;from may 2018 until early 2019. Most of that time I will be off the grid, in a&#xA;mobile home in northern America. This is a one-time opportunity for me and I&#xA;am really looking forward to that experience.&#xA;But because of that I will have issues maintaining my crates in that time.&#xA;I have 7 projects where I cannot continue development for about one year:&#xA;&#xA;toml-query&#xA;filters&#xA;kairos&#xA;task-hookrs&#xA;git-dit (and libgitdit)&#xA;is-match&#xA;&#xA;and of course imag, which contains over 40 crates at the time of writing.&#xA;All of the above are ready to be used (imag is not) and are, in fact, used by&#xA;others from what I know.&#xA;&#xA;In my case, this is only temporarily: I will be able (and am willing to)&#xA;continue development on them in 2019. But people change, interests change,&#xA;people get kids, a dog or some new hobby.&#xA;The end result is always: They have less time (or no time anymore) to continue&#xA;developing their crates.&#xA;&#xA;So why not have a team available which takes over maintainership?&#xA;&#xA;What a crates-team would do&#xA;&#xA;The crates-team won&#39;t always be able to continue development of the crate,&#xA;but it might be able to continue maintainership.&#xA;That is: Merge pull requests which add new functionality (or even just discuss&#xA;whether this new functionality would be a nice addition to the crate), update&#xA;the dependencies from time to time, fix and close bugs in the codebase,&#xA;update the documentation and document known bugs.&#xA;&#xA;The team would consist of people from the community (so basically hobbyists)&#xA;which are willing to maintain a few crates in their free time.&#xA;The crates-team would, of course, not take over maintainership for all&#xA;abandoned crates. It would rather discuss whether a crate shall be maintained&#xA;by them and then do so (or not).&#xA;&#xA;Some ideas on basic rules for the team:&#xA;&#xA;Only the following things are in the scope of &#34;maintaining&#34; a crate in the&#xA;  crates-team:&#xA;    Update the dependencies to the newest version if and only if updating&#xA;      to the newest version is as simple as updating the version number in the&#xA;      Cargo.toml file. If it is more complicated, the crates-team is allowed&#xA;      to reject any requests or reply to such requests with a variant of the&#xA;      phrase &#34;You&#39;re welcome to file an PR for this!&#34;&#xA;    Updating the documentation of a crate&#xA;    Publish new versions of the crate, the first newly published version&#xA;      should change the cargo metainformation maintenance = ... to&#xA;      passively-maintained.&#xA;    Discuss and (if consensus is reached) merge pull requests which add new&#xA;      functionality to the crate&#xA;    Merge pull requests which&#xA;        Fix bugs&#xA;        Update dependencies&#xA;        Update documentation&#xA;A crate only gets maintained if at least 2 members of the crates-team are&#xA;  willing to maintain the crate (these two get rights to publish new versions)&#xA;&#xA;More rules are possible, of course.&#xA;&#xA;Discussion&#xA;&#xA;I&#39;d love to discuss the subject on either&#xA;users.rust-lang.org&#xA;or&#xA;reddit!&#xA;&#xA;Also, feel free to reach out via mail (the thing which looks like an &#39;a&#39;)&#xA;(thisdomain) (dot) de.&#xA;&#xA;tags:  #tools #software #rust #open-source&#xA;]]&gt;</description>
      <content:encoded><![CDATA[<p>After reading another post in the users.rust-lang.org forum where a crate
author is looking for a maintainer for his crate, I started thinking.
Do we need a “crates-team” in the rust community?</p>

<h1 id="incentive" id="incentive">Incentive</h1>

<p>The Rust community has a lot of great teams.
Each of these teams has a different goal: The Core team, for example</p>

<blockquote><p>is responsible for steering the design and development process, overseeing the
introduction of new features, and ultimately making decisions for which there
is no consensus [...]</p></blockquote>

<p>(<a href="https://www.rust-lang.org/en-US/community.html">source</a>)</p>

<p>Because people change, interests of people change and also because the
life-situations people are in change, a crate author might not be able to
continue maintaining their crates.
I, for one, have such a problem: I am about to go on a <em>really</em> long vacation
from may 2018 until early 2019. Most of that time I will be off the grid, in a
mobile home in northern America. This is a one-time opportunity for me and I
am really looking forward to that experience.
But because of that I will have issues maintaining my crates in that time.
I have 7 projects where I cannot continue development for about one year:</p>
<ul><li>toml-query</li>
<li>filters</li>
<li>kairos</li>
<li>task-hookrs</li>
<li>git-dit (and libgitdit)</li>
<li>is-match</li></ul>

<p>and of course imag, which contains over 40 crates at the time of writing.
All of the above are ready to be used (imag is not) and are, in fact, used by
others from what I know.</p>

<p>In my case, this is only temporarily: I will be able (and am willing to)
continue development on them in 2019. But people change, interests change,
people get kids, a dog or some new hobby.
The end result is always: They have less time (or no time anymore) to continue
developing their crates.</p>

<p>So why not have a team available which takes over maintainership?</p>

<h1 id="what-a-crates-team-would-do" id="what-a-crates-team-would-do">What a crates-team would do</h1>

<p>The crates-team won&#39;t always be able to continue <em>development</em> of the crate,
but it might be able to continue <em>maintainership</em>.
That is: Merge pull requests which add new functionality (or even just discuss
whether this new functionality would be a nice addition to the crate), update
the dependencies from time to time, fix and close bugs in the codebase,
update the documentation and document known bugs.</p>

<p>The team would consist of people from the community (so basically hobbyists)
which are willing to maintain a few crates in their free time.
The crates-team would, of course, not take over maintainership for all
abandoned crates. It would rather discuss whether a crate shall be maintained
by them and then do so (or not).</p>

<p>Some ideas on basic rules for the team:</p>
<ul><li>Only the following things are in the scope of “maintaining” a crate in the
crates-team:
<ul><li>Update the dependencies to the newest version <strong>if and only if</strong> updating
to the newest version is as simple as updating the version number in the
<code>Cargo.toml</code> file. If it is more complicated, the crates-team is allowed
to reject any requests or reply to such requests with a variant of the
phrase “You&#39;re welcome to file an PR for this!”</li>
<li>Updating the documentation of a crate</li>
<li>Publish new versions of the crate, the first newly published version
should change the cargo metainformation <code>maintenance = ...</code> to
<code>passively-maintained</code>.</li>
<li>Discuss and (if consensus is reached) merge pull requests which add new
functionality to the crate</li>
<li>Merge pull requests which
<ul><li>Fix bugs</li>
<li>Update dependencies</li>
<li>Update documentation</li></ul></li></ul></li>
<li>A crate only gets maintained if at least 2 members of the crates-team are
willing to maintain the crate (these two get rights to publish new versions)</li></ul>

<p>More rules are possible, of course.</p>

<h1 id="discussion" id="discussion">Discussion</h1>

<p>I&#39;d love to discuss the subject on either
<a href="https://users.rust-lang.org/t/maybe-its-time-for-a-crates-team/15291">users.rust-lang.org</a>
or
<a href="https://www.reddit.com/r/rust/comments/7tcux6/maybe_its_time_for_a_crates_team_blogpost/">reddit</a>!</p>

<p>Also, feel free to reach out via mail (the thing which looks like an &#39;a&#39;)
(thisdomain) (dot) de.</p>

<p>tags:  <a href="https://beyermatthias.de/tag:tools" class="hashtag"><span>#</span><span class="p-category">tools</span></a> <a href="https://beyermatthias.de/tag:software" class="hashtag"><span>#</span><span class="p-category">software</span></a> <a href="https://beyermatthias.de/tag:rust" class="hashtag"><span>#</span><span class="p-category">rust</span></a> <a href="https://beyermatthias.de/tag:open" class="hashtag"><span>#</span><span class="p-category">open</span></a>-source</p>
]]></content:encoded>
      <guid>https://beyermatthias.de/maybe-its-time-for-a-crates-team</guid>
      <pubDate>Sat, 27 Jan 2018 16:38:52 +0100</pubDate>
    </item>
    <item>
      <title>git-dit github import</title>
      <link>https://beyermatthias.de/git-dit-github-import</link>
      <description>&lt;![CDATA[So I started developing an importer for importing github issues into git-dit&#xA;the distributed issue tracker build on git.&#xA;&#xA;Turns out it works well, though some things are not yet implemented:&#xA;&#xA;Wrapping of text. This is difficult because quotations are wrapped, but the&#xA;  quotation character is not prepended to the new line - which results in&#xA;  broken format&#xA;Importing only issues. Right now, PRs are imported ... which is not exactly&#xA;  what we want. I really hope I can figure this out to actually attach PR&#xA;  comments to the actual commits of the PR. This would be really nice. Issues&#xA;  shall be imported without parent (orphaned) like git-dit wants it.&#xA;Mapping of github handles to real names and email addresses.&#xA;Mapping github labels to git-dit &#34;trailers&#34;.&#xA;&#xA;Have a look&#xA;at my importer tool here&#xA;(Just be told: This is WIP and shouldn&#39;t be used right now)!&#xA;&#xA;Or at git-dit itself here&#xA;(I am co-author).&#xA;&#xA;tags:  #tools #software #rust #open-source #git #github&#xA;]]&gt;</description>
      <content:encoded><![CDATA[<p>So I started developing an importer for importing github issues into git-dit
– the distributed issue tracker build on git.</p>

<p>Turns out it works well, though some things are not yet implemented:</p>
<ul><li>Wrapping of text. This is difficult because quotations are wrapped, but the
quotation character is not prepended to the new line – which results in
broken format</li>
<li>Importing only issues. Right now, PRs are imported ... which is not exactly
what we want. I really hope I can figure this out to actually attach PR
comments to the actual commits of the PR. This would be really nice. Issues
shall be imported without parent (orphaned) like git-dit wants it.</li>
<li>Mapping of github handles to real names and email addresses.</li>
<li>Mapping github labels to git-dit “trailers”.</li></ul>

<p>Have a look
<a href="https://github.com/matthiasbeyer/git-dit-github-import">at my importer tool here</a>
(Just be told: This is WIP and shouldn&#39;t be used right now)!</p>

<p>Or at <a href="https://github.com/neithernut/git-dit">git-dit itself here</a>
(I am co-author).</p>

<p>tags:  <a href="https://beyermatthias.de/tag:tools" class="hashtag"><span>#</span><span class="p-category">tools</span></a> <a href="https://beyermatthias.de/tag:software" class="hashtag"><span>#</span><span class="p-category">software</span></a> <a href="https://beyermatthias.de/tag:rust" class="hashtag"><span>#</span><span class="p-category">rust</span></a> <a href="https://beyermatthias.de/tag:open" class="hashtag"><span>#</span><span class="p-category">open</span></a>-source <a href="https://beyermatthias.de/tag:git" class="hashtag"><span>#</span><span class="p-category">git</span></a> <a href="https://beyermatthias.de/tag:github" class="hashtag"><span>#</span><span class="p-category">github</span></a></p>
]]></content:encoded>
      <guid>https://beyermatthias.de/git-dit-github-import</guid>
      <pubDate>Wed, 17 Jan 2018 16:38:48 +0100</pubDate>
    </item>
    <item>
      <title>How to improve your open source code (5) - Planning of an Application or Library</title>
      <link>https://beyermatthias.de/how-to-improve-your-open-source-code-5-planning-of-an-application-or-library</link>
      <description>&lt;![CDATA[small&#xA;  This post was written during my trip through Iceland and published much&#xA;  latern than it was written.&#xA;/small&#xA;&#xA;In this and also maybe in the next few articles we will focus on rather&#xA;code-related things than on direct code properties. I hope that&#39;s okay.&#xA;&#xA;Planning of an application or library is not easy, not at all. But how&#xA;much planning do we actually do before writing code? And should we do&#xA;more?&#xA;&#xA;My thoughts on the subject.&#xA;&#xA;What we&#39;ve learned&#xA;&#xA;One that has studied computer science should know at least some UML&#xA;types like class diagrams, flow charts, module plans and use case&#xA;diagrams. They are used in (let&#39;s call it) &#34;normal&#34; software development&#xA;and in the professional world out there.&#xA;&#xA;But when we are developing open source software for our own needs and&#xA;maybe for our friends, we do that often in our chambers at home. Class&#xA;diagrams are often not being developed and I can say that I never saw a&#xA;hobby programmer draw a use case diagram before writing the code of the&#xA;application.&#xA;&#xA;Why we don&#39;t use it&#xA;&#xA;Why is that? Well, because open source software is often done as a hobby&#xA;type of thing, there is often no need for planning ahead. A hobbyist is&#xA;able to hold use case, simple class diagrams and flow charts &#34;in his&#xA;mind&#34; because he has great knowledge of the domain.&#xA;&#xA;In fact. as he defines the domain entirety, he is both stakeholder,&#xA;project leader, software architect, programmer, tester and marketing guy&#xA;at the same time. He knows what problems are about to be solved and&#xA;therefore can adjust every aspect of the application to the needs&#xA;required.&#xA;&#xA;This holds true for small and medium sized applications or code bases,&#xA;where the problems is of certain complexity but not too big. Basically&#xA;one could say that every aspect of the domain has to fit into one head&#xA;without much effort, in the open-source-programming-at-home-world. With&#xA;a bit of training, I believe, one can even get to a point where only a&#xA;few aspects of the domain have to be in a persons mind to be able to&#xA;work on a solution&#xA;&#xA;But there is certainly a point where the effort needed to solve a&#xA;specific problem explodes. One can still write software to solve the&#xA;problem at hand, but not in reasonable time.&#xA;&#xA;So why don&#39;t we hobby programmers do not use planning tools like we&#39;ve&#xA;learned in university? Why don&#39;t we use diagrams to make things clearer,&#xA;better documented, even before the real programming starts? The answer&#xA;is quite simple: because it annoys the hell out of us. We don&#39;t like to&#xA;plan ahead. We don&#39;t like to adjust plans as soon as we find out that&#xA;changing a small aspect of our library could be changed to gain more&#xA;flexibility and overall goodness. We don&#39;t like to check our plans&#xA;before writing down the next module until it works.&#xA;&#xA;Coding is fun, planning is not.&#xA;&#xA;But should we use these things&#xA;&#xA;In my opinion, this is foolish. We really should use the things we&#xA;learned in university to plan out software and of course also to&#xA;document it. It would be such a huge improvement of everything to simply&#xA;think a bit more about it before actually implementing it!&#xA;&#xA;How we do it&#xA;&#xA;What we do and why we do not use tools to plan ahead is explained with&#xA;one sentence: We program from the user interface to the implementation,&#xA;because the other way round is to complicated. Or, with other words: We&#xA;program top-down because bottom-up needs planning and therefore not that&#xA;easy.&#xA;&#xA;Of course, I&#39;m speaking about the average case. I&#39;ve programmed&#xA;bottom-up before but, for me, it seems much more error prone than&#xA;top-down does, especially without a plan.&#xA;&#xA;Also, I do not say that top-down is not error prone. Not at all. When&#xA;writing an API without an actual implementation in mind, one easily&#xA;results in sacrificing cleanness and speed at some points to keep the&#xA;API nice, which is not always a good idea. So top-down is only good as&#xA;long as we get it right.&#xA;&#xA;Tooling&#xA;&#xA;Tooling is one big problem in this context. We do not have a toolchain&#xA;for planning just yet. At least I do not have one that I would like to&#xA;use. Because we are really good at controlling (versioning, moving&#xA;around, managing) our source code (for example with git, and to some&#xA;extend github), we also want to be able to do this with charts&#xA;diagrams. But we also want the niceness of SVG-rendered graphics. We&#xA;don&#39;t want to play around with layout all day long, but use tools to&#xA;simply get the job done.&#xA;&#xA;And there are no such tools available.&#xA;&#xA;Sure, one can use graphviz to design such things, but then again we do&#xA;not have a nice overview on what&#39;s going on while editing our work. One&#xA;could use ascii-art to draw all those things, but hey... ascii-art. We&#xA;are better than that, aren&#39;t we? We could render the ascii-art into&#xA;SVG... though the tooling there is not yet as good as it should be. And&#xA;even if it would be, version controlling these things with git is (I&#xA;fail to believe otherwise) painful.&#xA;&#xA;Conclusion&#xA;&#xA;Well, I can only conclude the obvious here. We need better tooling for&#xA;the open source programming community to do their planning, if they need&#xA;to. Clearly, one does not always have to (or want to) plan things before&#xA;trying out. But when one does, the tooling should be there and be useful&#xA;and help with the process.&#xA;&#xA;Next&#xA;&#xA;In the next episode we will talk about version control of open source&#xA;software projects. I&#39;m not going into details about git or other systems&#xA;used, but rather on the style how they should be used so everyone is&#xA;pleased with it. This might be strongly biased, but hey, isn&#39;t this&#xA;whole article series biased?&#xA;&#xA;tags: #open-source #programming #software #tools #rust&#xA;]]&gt;</description>
      <content:encoded><![CDATA[<p><small>
  This post was written during my trip through Iceland and published much
  latern than it was written.
</small></p>

<p>In this and also maybe in the next few articles we will focus on rather
code-related things than on direct code properties. I hope that&#39;s okay.</p>

<p>Planning of an application or library is not easy, not at all. But how
much planning do we actually do before writing code? And should we do
more?</p>

<p>My thoughts on the subject.</p>

<h1 id="what-we-ve-learned" id="what-we-ve-learned">What we&#39;ve learned</h1>

<p>One that has studied computer science should know at least some UML
types like class diagrams, flow charts, module plans and use case
diagrams. They are used in (let&#39;s call it) “normal” software development
and in the professional world out there.</p>

<p>But when we are developing open source software for our own needs and
maybe for our friends, we do that often in our chambers at home. Class
diagrams are often not being developed and I can say that I never saw a
hobby programmer draw a use case diagram before writing the code of the
application.</p>

<h1 id="why-we-don-t-use-it" id="why-we-don-t-use-it">Why we don&#39;t use it</h1>

<p>Why is that? Well, because open source software is often done as a hobby
type of thing, there is often no need for planning ahead. A hobbyist is
able to hold use case, simple class diagrams and flow charts “in his
mind” because he has great knowledge of the domain.</p>

<p>In fact. as he defines the domain entirety, he is both stakeholder,
project leader, software architect, programmer, tester and marketing guy
at the same time. He knows what problems are about to be solved and
therefore can adjust every aspect of the application to the needs
required.</p>

<p>This holds true for small and medium sized applications or code bases,
where the problems is of certain complexity but not too big. Basically
one could say that every aspect of the domain has to fit into one head
without much effort, in the open-source-programming-at-home-world. With
a bit of training, I believe, one can even get to a point where only a
few aspects of the domain have to be in a persons mind to be able to
work on a solution</p>

<p>But there is certainly a point where the effort needed to solve a
specific problem explodes. One can still write software to solve the
problem at hand, but not in reasonable time.</p>

<p>So why don&#39;t we hobby programmers do not use planning tools like we&#39;ve
learned in university? Why don&#39;t we use diagrams to make things clearer,
better documented, even before the real programming starts? The answer
is quite simple: because it annoys the hell out of us. We don&#39;t like to
plan ahead. We don&#39;t like to adjust plans as soon as we find out that
changing a small aspect of our library could be changed to gain more
flexibility and overall goodness. We don&#39;t like to check our plans
before writing down the next module until it works.</p>

<p>Coding is fun, planning is not.</p>

<h1 id="but-should-we-use-these-things" id="but-should-we-use-these-things">But should we use these things</h1>

<p>In my opinion, this is foolish. We really should use the things we
learned in university to plan out software and of course also to
document it. It would be such a huge improvement of everything to simply
think a bit more about it before actually implementing it!</p>

<h1 id="how-we-do-it" id="how-we-do-it">How we do it</h1>

<p>What we do and why we do not use tools to plan ahead is explained with
one sentence: We program from the user interface to the implementation,
because the other way round is to complicated. Or, with other words: We
program top-down because bottom-up needs planning and therefore not that
easy.</p>

<p>Of course, I&#39;m speaking about the average case. I&#39;ve programmed
bottom-up before but, for me, it seems much more error prone than
top-down does, especially without a plan.</p>

<p>Also, I do <em>not</em> say that top-down is not error prone. Not at all. When
writing an API without an actual implementation in mind, one easily
results in sacrificing cleanness and speed at some points to keep the
API nice, which is not always a good idea. So top-down is only good as
long as we get it right.</p>

<h1 id="tooling" id="tooling">Tooling</h1>

<p>Tooling is one big problem in this context. We do not have a toolchain
for planning just yet. At least I do not have one that I would like to
use. Because we are really good at controlling (versioning, moving
around, managing) our source code (for example with git, and to some
extend github), we also want to be able to do this with charts
diagrams. But we also want the niceness of SVG-rendered graphics. We
don&#39;t want to play around with layout all day long, but use tools to
simply get the job done.</p>

<p>And there are no such tools available.</p>

<p>Sure, one can use graphviz to design such things, but then again we do
not have a nice overview on what&#39;s going on while editing our work. One
could use ascii-art to draw all those things, but hey... ascii-art. We
are better than that, aren&#39;t we? We could render the ascii-art into
SVG... though the tooling there is not yet as good as it should be. And
even if it would be, version controlling these things with git is (I
fail to believe otherwise) painful.</p>

<h1 id="conclusion" id="conclusion">Conclusion</h1>

<p>Well, I can only conclude the obvious here. We need better tooling for
the open source programming community to do their planning, if they need
to. Clearly, one does not always have to (or want to) plan things before
trying out. But when one does, the tooling should be there and be useful
and help with the process.</p>

<h1 id="next" id="next">Next</h1>

<p>In the next episode we will talk about version control of open source
software projects. I&#39;m not going into details about git or other systems
used, but rather on the style how they should be used so everyone is
pleased with it. This might be strongly biased, but hey, isn&#39;t this
whole article series biased?</p>

<p>tags: <a href="https://beyermatthias.de/tag:open" class="hashtag"><span>#</span><span class="p-category">open</span></a>-source <a href="https://beyermatthias.de/tag:programming" class="hashtag"><span>#</span><span class="p-category">programming</span></a> <a href="https://beyermatthias.de/tag:software" class="hashtag"><span>#</span><span class="p-category">software</span></a> <a href="https://beyermatthias.de/tag:tools" class="hashtag"><span>#</span><span class="p-category">tools</span></a> <a href="https://beyermatthias.de/tag:rust" class="hashtag"><span>#</span><span class="p-category">rust</span></a></p>
]]></content:encoded>
      <guid>https://beyermatthias.de/how-to-improve-your-open-source-code-5-planning-of-an-application-or-library</guid>
      <pubDate>Fri, 08 Dec 2017 16:38:38 +0100</pubDate>
    </item>
  </channel>
</rss>