<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:atom="http://www.w3.org/2005/Atom" version="2.0">
    <channel>
      <title>Devcartes - Softwareentwicklung</title>
      <link>https://devcartes.de</link>
      <description></description>
      <generator>Zola</generator>
      <language>de</language>
      <atom:link href="https://devcartes.de/categories/softwareentwicklung/rss.xml" rel="self" type="application/rss+xml"/>
      <lastBuildDate>Thu, 01 Oct 2026 00:00:00 +0000</lastBuildDate>
      <item>
          <title>Godot jenseits von Spielen: Intro</title>
          <pubDate>Thu, 01 Oct 2026 00:00:00 +0000</pubDate>
          <author>Tristan</author>
          <link>https://devcartes.de/blog/desktop-application-with-godot-intro/</link>
          <guid>https://devcartes.de/blog/desktop-application-with-godot-intro/</guid>
          <description xml:base="https://devcartes.de/blog/desktop-application-with-godot-intro/">&lt;h2 id=&quot;einleitung&quot;&gt;Einleitung&lt;/h2&gt;
&lt;p&gt;Eine Game Engine nutzen, um eine Desktop Anwendung zu schreiben?&lt;/p&gt;
&lt;p&gt;Klingt auf den ersten Blick abwegig, aber gerade Godot eignet sich aus mehreren Gründen extrem gut dafür.&lt;/p&gt;
&lt;h2 id=&quot;warum-godot&quot;&gt;Warum Godot&lt;/h2&gt;
&lt;p&gt;Dass man ausgereifte und komplexere Desktopanwendungen mit Godot bauen kann, zeigt der &lt;strong&gt;Editor&lt;/strong&gt; für die Godot Engine, der nämlich ebenfalls in Godot geschrieben ist.
Außerdem hat Godot eine sehr gute &lt;strong&gt;Crossplattform-Unterstützung&lt;/strong&gt;, was man auch daran sieht, dass der Editor sowohl im Browser, als auch für mobile Endgeräte zur Verfügung steht.
Gerade auch die &lt;strong&gt;geringe Größe&lt;/strong&gt; der ausführbaren Dateien macht Godot zu einer interessanten Engine für mobile Geräte und das Web.
Auch GUIs lassen sich mit dem Editor oder dynamisch aus dem Code sehr einfach bauen und zwar ohne großen Aufwand &lt;strong&gt;responsive&lt;/strong&gt;.
Das ist bei anderen etablierten Desktop-GUI-Frameworks (z.B. Delphi oder .NET) nicht immer so einfach.
Wer Bedenken wegen der Ressourcennutzung hat, für den hat Godot einen &lt;strong&gt;Low Processor Mode&lt;/strong&gt;, der dafür sorgt, dass das Bild seltener und nur bei Bedarf erneuert wird.&lt;/p&gt;
&lt;h2 id=&quot;proof-of-concept&quot;&gt;Proof of Concept&lt;/h2&gt;
&lt;p&gt;Ich schreibe aktuell eine kleine Desktopanwendung mit Godot, die in erster Linie als Proof of Concept (PoC) gedacht war, sich mittlerweile aber als sehr nützlich für mein Studium erwiesen hat.&lt;/p&gt;
&lt;p&gt;KOReader, eine beliebte eBook-Lese-App, speichert Lesestatistiken, Notizen und Highlights in einem bestimmten Format, die ich exportieren, aufbereiten und später zum Nachschlagen nutzen möchte.&lt;/p&gt;
&lt;h3 id=&quot;beispiel-export&quot;&gt;Beispiel-Export&lt;/h3&gt;
&lt;p&gt;Am Ende soll eine Datei herauskommen, die in etwa so aussieht, wie der beispielhafte Ausschnitt aus dem Buch &lt;em&gt;What is it like to be a bat&lt;/em&gt; von &lt;em&gt;Thomas Nagel&lt;/em&gt;. Um den Text soll es an dieser Stelle aber überhaupt nicht gehen, es sind auch keine echten Highlights oder Notizen, sondern nur Beispiele.&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #CDD6F4; background-color: #1E1E2E;&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Title: What Is It Like to Be a Bat? / Wie ist es, eine Fledermaus zu sein?&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Author: Thomas Nagel&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;===========================================================================&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Page 7 (yellow)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Das Thema ›Bewusstsein‹ macht das Leib-Seele-Problem praktisch unlösbar.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;===========================================================================&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Page 8 (yellow)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Es ist höchst unwahrscheinlich, dass irgendeines dieser mit dem Leib-Seele-Problem nicht verwandten Beispiele erfolgreicher Reduktion die Beziehung zwischen Psyche und Gehirn erhellen wird.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;===========================================================================&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Page 47 (yellow)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;But no matter how the form may vary, the fact that an organism has conscious experience at all means, basically, that there is something it is like to be that organism.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;===========================================================================&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Page 53 (yellow)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Yet if I try to imagine this, I am restricted to the resources of my own mind, and those resources are inadequate to the task.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;===========================================================================&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Page 55 (purple)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Our own experience provides the basic material for our imagination, whose range is therefore limited. It will not help to try to imagine&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;---------------------------------------------------------------------------&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Note:&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Das ist eine Notiz von mir an mich&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;---------------------------------------------------------------------------&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;===========================================================================&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;h3 id=&quot;erklarung-zum-export&quot;&gt;Erklärung zum Export&lt;/h3&gt;
&lt;p&gt;Ich färbe meine Highlights und Notizen immer mit bestimmten Farben, die alle ihre eigene Bedeutung haben, um sie später einfacher zuordnen zu können.&lt;/p&gt;
&lt;p&gt;So kann ich ohne großen Aufwand und mit minimaler Unterbrechung Notizen beim Lesen machen und habe diese später in einer einfachen und sortierten Form vorliegen, die ich entweder ausdrucken oder digital weiterverwenden kann. Durch die Seitenzahlen finde ich die Textstellen schnell wieder.&lt;/p&gt;
&lt;h2 id=&quot;zum-ende&quot;&gt;Zum Ende&lt;/h2&gt;
&lt;p&gt;In diesem Artikel bin ich auf das &lt;strong&gt;Was&lt;/strong&gt; und &lt;strong&gt;Warum&lt;/strong&gt; eingegangen.
In den folgenden Artikeln werde ich auf das &lt;strong&gt;Wie&lt;/strong&gt; eingehen und &lt;strong&gt;Wo Godot nicht&lt;/strong&gt; die passende Wahl ist.&lt;/p&gt;
</description>
      </item>
      <item>
          <title>Guard Clauses</title>
          <pubDate>Sun, 23 Aug 2026 00:00:00 +0100</pubDate>
          <author>Tristan</author>
          <link>https://devcartes.de/blog/guard-clauses/</link>
          <guid>https://devcartes.de/blog/guard-clauses/</guid>
          <description xml:base="https://devcartes.de/blog/guard-clauses/">&lt;h2 id=&quot;einleitung&quot;&gt;Einleitung&lt;/h2&gt;
&lt;p&gt;Softwareentwickler aller Erfahrungsstufen, weltweit kennen das Problem:&lt;br /&gt;
Man schaut sich Code von Kollegen oder eigenen, älteren Code an und hat keine Ahnung, was dieser eigentlich macht.
Er ist so tief verschachtelt und nimmt so viele Abzweigungen, dass man überhaupt nicht mehr weiß, welches Kriterium nun zum Abbruch der Funktion geführt hat oder welchen Wert eine Variable zu Zeitpunkt des Ausstiegs hat.&lt;/p&gt;
&lt;p&gt;Viel schöner wäre es doch, wenn man seine Funktion lesen könnte wie ein Buch, von oben nach unten, und dabei auf einen Blick erkennen kann, an welcher Stelle die Funktion vorzeitig verlassen wird und warum.&lt;/p&gt;
&lt;p&gt;Eines der Werkzeuge, auch Patterns genannt, in der Softwareentwicklung, das genau diesem Zweck dient, nennt man Guard Clauses.&lt;/p&gt;
&lt;p&gt;Sie machen deinen Code sowohl lesbarer und wartbarer als auch robuster.&lt;/p&gt;
&lt;h2 id=&quot;was-sind-guard-clauses&quot;&gt;Was sind Guard Clauses&lt;/h2&gt;
&lt;p&gt;Guard Clauses (ins Deutsche frei übersetzt Schutzklausel), sind ein Pattern, bei dem man frühzeitig aus einer Funktion aussteigt, wenn eine bestimmte Bedingung eintritt, die die weitere Abarbeitung des Codes unnötig macht.&lt;/p&gt;
&lt;p&gt;Das Prinzip ist, dass man Ausnahmen zuerst behandelt und dann den eigentlichen Programmfluss.&lt;/p&gt;
&lt;p&gt;Entscheide selbst, welchen der beiden folgenden Codeabschnitte du lesbarer findest:&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #CDD6F4; background-color: #1E1E2E;&quot; &gt;&lt;code data-lang=&quot;rust&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #CBA6F7;&quot;&gt;if&lt;/span&gt;&lt;span&gt; user&lt;/span&gt;&lt;span style=&quot;color: #94E2D5;&quot;&gt;.&lt;/span&gt;&lt;span&gt;is_logged_in &lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;{&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #CBA6F7;&quot;&gt;    if&lt;/span&gt;&lt;span&gt; user&lt;/span&gt;&lt;span style=&quot;color: #94E2D5;&quot;&gt;.&lt;/span&gt;&lt;span&gt;has_permission &lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;{&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #CBA6F7;&quot;&gt;        if&lt;/span&gt;&lt;span&gt; user&lt;/span&gt;&lt;span style=&quot;color: #94E2D5;&quot;&gt;.&lt;/span&gt;&lt;span&gt;name &lt;/span&gt;&lt;span style=&quot;color: #94E2D5;&quot;&gt;==&lt;/span&gt;&lt;span style=&quot;color: #A6E3A1;&quot;&gt; &amp;quot;Max&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #9399B2;font-style: italic;&quot;&gt;            // logik kommt hier&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;        }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;    }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;pre class=&quot;giallo&quot; style=&quot;color: #CDD6F4; background-color: #1E1E2E;&quot; &gt;&lt;code data-lang=&quot;rust&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #CBA6F7;&quot;&gt;if&lt;/span&gt;&lt;span style=&quot;color: #94E2D5;&quot;&gt; !&lt;/span&gt;&lt;span&gt;user&lt;/span&gt;&lt;span style=&quot;color: #94E2D5;&quot;&gt;.&lt;/span&gt;&lt;span&gt;is_logged_in &lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;{&lt;/span&gt;&lt;span style=&quot;color: #CBA6F7;&quot;&gt; return&lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;; }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #CBA6F7;&quot;&gt;if&lt;/span&gt;&lt;span style=&quot;color: #94E2D5;&quot;&gt; !&lt;/span&gt;&lt;span&gt;user&lt;/span&gt;&lt;span style=&quot;color: #94E2D5;&quot;&gt;.&lt;/span&gt;&lt;span&gt;has_permission &lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;{&lt;/span&gt;&lt;span style=&quot;color: #CBA6F7;&quot;&gt; return&lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;; }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #CBA6F7;&quot;&gt;if&lt;/span&gt;&lt;span&gt; user&lt;/span&gt;&lt;span style=&quot;color: #94E2D5;&quot;&gt;.&lt;/span&gt;&lt;span&gt;name &lt;/span&gt;&lt;span style=&quot;color: #94E2D5;&quot;&gt;!=&lt;/span&gt;&lt;span style=&quot;color: #A6E3A1;&quot;&gt; &amp;quot;Max&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt; {&lt;/span&gt;&lt;span style=&quot;color: #CBA6F7;&quot;&gt; return&lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;; }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #9399B2;font-style: italic;&quot;&gt;//logik kommt hier&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;Wichtig!&lt;/strong&gt; Die Bedingungen der Guard Clauses sind &lt;strong&gt;logisch negiert&lt;/strong&gt;, da wir prüfen, wann wir &lt;strong&gt;nicht weitermachen&lt;/strong&gt; dürfen.&lt;/p&gt;
&lt;h2 id=&quot;wann-solltest-du-guard-clauses-nutzen&quot;&gt;Wann solltest du Guard Clauses nutzen&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;Wenn dein Code zu tief verschachtelt ist&lt;/li&gt;
&lt;li&gt;Bei Vorbedingungen (Preconditions), die den Rest der Funktion hinfällig machen (z.B. Null-Checks)&lt;/li&gt;
&lt;li&gt;Wenn die Ausnahmen klar vom Normalfall abgegrenzt werden können&lt;/li&gt;
&lt;li&gt;Wenn du Code von oben nach unten lesen willst, wie ein Buch&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;wann-solltest-du-guard-clauses-nicht-nutzen&quot;&gt;Wann solltest du Guard Clauses nicht nutzen&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;Wenn es nicht &lt;strong&gt;den einen Normalfall&lt;/strong&gt; gibt, sondern mehrere gleichwertige Zweige
&lt;ul&gt;
&lt;li&gt;z.B. wenn je nach User-Rolle unterschiedliche Logik ausgeführt werden soll (Zweige sind gleichwertig)&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Wenn es viele Vorbedingungen (mehr als 5 - 6) gibt, dann lohnt es sich in eine eigene Validierungsfunktion auszulagern&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;best-practices&quot;&gt;Best Practices&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;Guard Clauses am Anfang der Funktion bündeln&lt;/li&gt;
&lt;li&gt;Eine Bedingung pro Guard Clause&lt;/li&gt;
&lt;li&gt;Aussagekräftige Fehler zurückgeben oder sauberes Logging statt stiller &lt;em&gt;returns&lt;/em&gt;&lt;/li&gt;
&lt;li&gt;Guards nicht schachteln&lt;/li&gt;
&lt;li&gt;Reihenfolge nach Wahrscheinlichkeit, statistisch häufige Fehler zuerst prüfen&lt;/li&gt;
&lt;li&gt;Trotzdem das &lt;strong&gt;Single Responsibility Principle&lt;/strong&gt; einhalten&lt;/li&gt;
&lt;li&gt;In Teams das Pattern klar als Standard definieren, das spart Zeit und Diskussionen im Code Review&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;schluss&quot;&gt;Schluss&lt;/h2&gt;
&lt;p&gt;Du siehst also, Guard Clauses sind ein sehr einfaches und nützliches Pattern, um deinen Code zu verbessern.
Sie reduzieren Verschachtelung und erhöhen somit die Lesbarkeit.&lt;/p&gt;
&lt;p&gt;Doch trotz der Einfachheit nutzen nicht alle erfahrenen Entwickler sie.&lt;/p&gt;
&lt;p&gt;Was denkst du, woran liegt das?&lt;br /&gt;
Liegt es vielleicht daran, dass viele Entwickler mit if-else-Verschachtelungen groß geworden sind und Guard Clauses sich fremd anfühlen?&lt;/p&gt;
</description>
      </item>
      <item>
          <title>Empfehlungen: Exercism</title>
          <pubDate>Thu, 04 Jun 2026 00:00:00 +0100</pubDate>
          <author>Tristan</author>
          <link>https://devcartes.de/blog/recommendations-exercism/</link>
          <guid>https://devcartes.de/blog/recommendations-exercism/</guid>
          <description xml:base="https://devcartes.de/blog/recommendations-exercism/">&lt;p&gt;&lt;strong&gt;Quick Facts:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Anbieter:&lt;/strong&gt; Exercism.org (gemeinnützig, Open Source)&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Gründung:&lt;/strong&gt; 2013&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Sprachen:&lt;/strong&gt; Über 70 Programmiersprachen – z.B. Python, Go, Rust, C# uvm.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Formate:&lt;/strong&gt; Browser-basierte Aufgaben + Kommandozeilen-Tool&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Besonderheit:&lt;/strong&gt; 1:1 Mentoring durch erfahrene Entwickler:innen&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Preis:&lt;/strong&gt; komplett kostenlos&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Link:&lt;/strong&gt; &lt;a rel=&quot;external&quot; href=&quot;https://exercism.org&quot;&gt;exercism.org&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;hr /&gt;
&lt;h2 id=&quot;worum-geht-es&quot;&gt;Worum geht es?&lt;/h2&gt;
&lt;p&gt;Auf Exercism lernst du Programmieren durch praktische Übungen und wertvolles Feedback von erfahrenen Mentoren.
Hier gibt es keine Videokurse oder Tutorials im eigentlichen Sinn, was aus meiner Sicht ein absoluter Vorteil ist und für die Plattform spricht.&lt;/p&gt;
&lt;h2 id=&quot;fur-wen-ist-die-plattform&quot;&gt;Für wen ist die Plattform?&lt;/h2&gt;
&lt;p&gt;&lt;strong&gt;Ideal für:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Einsteiger, die nach den Grundlagen einer Sprache &lt;strong&gt;üben&lt;/strong&gt; wollen&lt;/li&gt;
&lt;li&gt;Fortgeschrittene, die eine neue Sprache &lt;strong&gt;schnell&lt;/strong&gt; und &lt;strong&gt;idiomatisch&lt;/strong&gt; lernen möchten&lt;/li&gt;
&lt;li&gt;Autodidakten, die &lt;strong&gt;konstruktives Feedback&lt;/strong&gt; vermissen&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;Du solltest mitbringen:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Grundlegendes Verständnis von Variablen, Schleifen, Funktionen (je nach Track unterschiedlich)&lt;/li&gt;
&lt;li&gt;Motivation, Probleme selbstständig zu lösen&lt;/li&gt;
&lt;li&gt;Englischkenntnisse (alle Aufgaben und Diskussionen sind auf Englisch)&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;Eher nicht geeignet, wenn:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Du einen klassischen Videokurs mit Dozent suchst&lt;/li&gt;
&lt;li&gt;Du ein großes Projekt bauen willst (Exercism fokussiert kleine, isolierte Übungen)&lt;/li&gt;
&lt;li&gt;Du keinen englischen Text lesen magst&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;wie-funktioniert-es&quot;&gt;Wie funktioniert es?&lt;/h2&gt;
&lt;p&gt;Exercism ist in sogenannte &lt;strong&gt;Tracks&lt;/strong&gt; aufgeteilt, einen Track pro Programmiersprache. Jeder Track enthält Dutzende bis hunderte Übungen, sortiert nach Schwierigkeit.&lt;/p&gt;
&lt;p&gt;Der typische Workflow:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Track auswählen:&lt;/strong&gt; z. B. Go, Python oder Rust.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Erste Übung:&lt;/strong&gt; meistens &quot;Hello World&quot;, um die Umgebung zu testen.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Aufgabe herunterladen:&lt;/strong&gt; entweder im Browser-Editor oder per CLI.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Code schreiben:&lt;/strong&gt; bis alle Tests bestehen.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Lösung einreichen:&lt;/strong&gt; optional mit einer Frage an den Mentor.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Feedback erhalten:&lt;/strong&gt; meist innerhalb weniger Stunden bis zwei Tage.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Überarbeitung:&lt;/strong&gt; basierend auf dem Feedback die Lösung verbessern.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Nächste Übung:&lt;/strong&gt; der Track schaltet nach und nach neue Aufgaben frei.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Zusätzlich gibt es &lt;strong&gt;&quot;Practice&quot;-Übungen&lt;/strong&gt; und &lt;strong&gt;&quot;Concept&quot;-Übungen&lt;/strong&gt; (die ein bestimmtes Sprachfeature erklären, z. B. Slices in Go oder Pattern Matching in Rust).&lt;/p&gt;
&lt;h2 id=&quot;was-lernst-du&quot;&gt;Was lernst du?&lt;/h2&gt;
&lt;p&gt;Neben der Syntax einer Sprache, lernst du hier auch wie man idiomatischen Code schreibt.
Hierbei helfen vor allem die sehr geduldigen und erfahrenen Mentoren.&lt;/p&gt;
&lt;h2 id=&quot;warum-lohnt-sich-exercism&quot;&gt;Warum lohnt sich Exercism?&lt;/h2&gt;
&lt;p&gt;Sowohl Anfänger, als auch Profis können hier viel lernen und sich mit anderen austauschen.
Jeder in seiner jeweiligen Geschwindigkeit und bis zu der Tiefe, die für ihn angenehm ist.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Bonus:&lt;/strong&gt; Alles Open Source. Du kannst sogar eigene Übungen beitragen oder Fehler in den Aufgaben korrigieren.&lt;/p&gt;
&lt;h2 id=&quot;wie-startest-du-am-besten&quot;&gt;Wie startest du am besten?&lt;/h2&gt;
&lt;p&gt;Meine Empfehlung für einen schnellen Einstieg:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Wähle eine Sprache, die du schon ein bisschen kennst&lt;/strong&gt; – nicht die erste, die du lernen willst, sonst kämpfst du mit Syntax &lt;em&gt;und&lt;/em&gt; dem Workflow.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Installiere das CLI-Tool&lt;/strong&gt; (&lt;code&gt;exercism&lt;/code&gt; auf der Kommandozeile). Das Browser-Interface ist okay, aber mit lokalem Editor (VS Code etc.) und echten Tests macht es mehr Spaß.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Setze dir ein wöchentliches Ziel&lt;/strong&gt;: Zwei bis drei Übungen pro Woche sind realistisch, wenn du nebenbei arbeitest oder studierst.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Nutze das Mentoring aktiv&lt;/strong&gt; – stelle deine Fragen so konkret es geht, denn je genauer deine Frage, umso besser das Feedback.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Schau dir nach dem eigenen Lösen die Community-Lösungen an&lt;/strong&gt; – nachdem du deine Lösung eingereicht hast, werden dir oft andere Ansätze gezeigt. Fremden Code zu lesen und zu verstehen ist auch eine wichtige Fähigkeit für einen Entwickler.&lt;/li&gt;
&lt;/ol&gt;
&lt;h2 id=&quot;personliches-highlight&quot;&gt;Persönliches Highlight&lt;/h2&gt;
&lt;p&gt;Mein persönliches Highlight war der &lt;strong&gt;Rust-Track&lt;/strong&gt;, hier sind vor allem die Mentoren, die ich bisher erlebt habe sehr ausführlich, geduldig und erfahren.
Außerdem ist der Track sehr ausgereift.&lt;/p&gt;
&lt;h2 id=&quot;zum-schluss&quot;&gt;Zum Schluss&lt;/h2&gt;
&lt;p&gt;Exercism ist eine echte Perle unter den Lernplattformen und meiner Meinung nach viel zu unbekannt.&lt;/p&gt;
&lt;p&gt;Wenn dir die Seite also gefällt, dann lass den Entwicklern doch eine kleine Spende da oder hilf mit, indem du Dokumentation schreibst, Aufgaben verbesserst oder sogar neue einreichst. Oder empfehle sie einfach nur weiter.&lt;/p&gt;
&lt;p&gt;Bist ein echter Profi in einer Sprache, dann könntest du auch als Mentor mithelfen.&lt;/p&gt;
&lt;p&gt;Besucht auch gerne mein &lt;a rel=&quot;external&quot; href=&quot;https://exercism.org/profiles/tristanappdev&quot;&gt;Exercism Profil&lt;/a&gt; und schaut euch meine Lösungen, Testimonials oder Contributions an.&lt;/p&gt;
</description>
      </item>
      <item>
          <title>Rusty Bytes: Traits und mehr</title>
          <pubDate>Wed, 11 Mar 2026 00:00:00 +0100</pubDate>
          <author>Tristan</author>
          <link>https://devcartes.de/blog/rusty-bytes-traits/</link>
          <guid>https://devcartes.de/blog/rusty-bytes-traits/</guid>
          <description xml:base="https://devcartes.de/blog/rusty-bytes-traits/">&lt;h2 id=&quot;was-sind-traits&quot;&gt;Was sind Traits?&lt;/h2&gt;
&lt;p&gt;Traits sind Rusts Version von Interfaces.
Ein Trait definiert eine Schnittstelle, eine Menge von Methoden, die ein Typ implementieren muss, außer es gibt eine Standardimplementierung.
Wer schon mit Interfaces aus C#, Java oder Kotlin gearbeitet hat, kennt das Konzept.&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #CDD6F4; background-color: #1E1E2E;&quot; &gt;&lt;code data-lang=&quot;rust&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #CBA6F7;&quot;&gt;trait&lt;/span&gt;&lt;span style=&quot;color: #F9E2AF;font-style: italic;&quot;&gt; Greet&lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #CBA6F7;&quot;&gt;    fn&lt;/span&gt;&lt;span style=&quot;color: #89B4FA;font-style: italic;&quot;&gt; hello&lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #94E2D5;&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span style=&quot;color: #F38BA8;&quot;&gt;self&lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: #94E2D5;&quot;&gt; -&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: #F9E2AF;font-style: italic;&quot;&gt; String&lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #CBA6F7;&quot;&gt;struct&lt;/span&gt;&lt;span style=&quot;color: #F9E2AF;font-style: italic;&quot;&gt; German&lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #CBA6F7;&quot;&gt;struct&lt;/span&gt;&lt;span style=&quot;color: #F9E2AF;font-style: italic;&quot;&gt; English&lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #CBA6F7;&quot;&gt;impl&lt;/span&gt;&lt;span style=&quot;color: #F9E2AF;font-style: italic;&quot;&gt; Greet&lt;/span&gt;&lt;span style=&quot;color: #CBA6F7;&quot;&gt; for&lt;/span&gt;&lt;span style=&quot;color: #F9E2AF;font-style: italic;&quot;&gt; German&lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #CBA6F7;&quot;&gt;    fn&lt;/span&gt;&lt;span style=&quot;color: #89B4FA;font-style: italic;&quot;&gt; hello&lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #94E2D5;&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span style=&quot;color: #F38BA8;&quot;&gt;self&lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: #94E2D5;&quot;&gt; -&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: #F9E2AF;font-style: italic;&quot;&gt; String&lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #F9E2AF;font-style: italic;&quot;&gt;        String&lt;/span&gt;&lt;span style=&quot;color: #94E2D5;&quot;&gt;::&lt;/span&gt;&lt;span style=&quot;color: #89B4FA;font-style: italic;&quot;&gt;from&lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #A6E3A1;&quot;&gt;&amp;quot;Hallo!&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;    }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #CBA6F7;&quot;&gt;impl&lt;/span&gt;&lt;span style=&quot;color: #F9E2AF;font-style: italic;&quot;&gt; Greet&lt;/span&gt;&lt;span style=&quot;color: #CBA6F7;&quot;&gt; for&lt;/span&gt;&lt;span style=&quot;color: #F9E2AF;font-style: italic;&quot;&gt; English&lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #CBA6F7;&quot;&gt;    fn&lt;/span&gt;&lt;span style=&quot;color: #89B4FA;font-style: italic;&quot;&gt; hello&lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #94E2D5;&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span style=&quot;color: #F38BA8;&quot;&gt;self&lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: #94E2D5;&quot;&gt; -&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: #F9E2AF;font-style: italic;&quot;&gt; String&lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #F9E2AF;font-style: italic;&quot;&gt;        String&lt;/span&gt;&lt;span style=&quot;color: #94E2D5;&quot;&gt;::&lt;/span&gt;&lt;span style=&quot;color: #89B4FA;font-style: italic;&quot;&gt;from&lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #A6E3A1;&quot;&gt;&amp;quot;Hello!&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;    }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Traits können auch eine &lt;strong&gt;Standardimplementierung&lt;/strong&gt; mitbringen, die ein Typ überschreiben kann aber nicht muss:&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #CDD6F4; background-color: #1E1E2E;&quot; &gt;&lt;code data-lang=&quot;rust&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #CBA6F7;&quot;&gt;trait&lt;/span&gt;&lt;span style=&quot;color: #F9E2AF;font-style: italic;&quot;&gt; Greet&lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #CBA6F7;&quot;&gt;    fn&lt;/span&gt;&lt;span style=&quot;color: #89B4FA;font-style: italic;&quot;&gt; hello&lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #94E2D5;&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span style=&quot;color: #F38BA8;&quot;&gt;self&lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: #94E2D5;&quot;&gt; -&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: #F9E2AF;font-style: italic;&quot;&gt; String&lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #F9E2AF;font-style: italic;&quot;&gt;        String&lt;/span&gt;&lt;span style=&quot;color: #94E2D5;&quot;&gt;::&lt;/span&gt;&lt;span style=&quot;color: #89B4FA;font-style: italic;&quot;&gt;from&lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #A6E3A1;&quot;&gt;&amp;quot;Hi!&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;    }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;So weit, so bekannt.&lt;/p&gt;
&lt;p&gt;Interessant wird es, wenn man Traits als Parameter verwendet, denn da beginnt die eigentliche Frage:
Was passiert dann zur Compile-Zeit und welche Auswirkungen hat es auf die Laufzeit?&lt;/p&gt;
&lt;hr /&gt;
&lt;h2 id=&quot;monomorphisierung-polymorphismus-zur-compile-zeit&quot;&gt;Monomorphisierung – Polymorphismus zur Compile-Zeit&lt;/h2&gt;
&lt;p&gt;Wenn eine Funktion einen generischen Typ mit Trait-Bound erwartet, erzeugt der Rust-Compiler für jeden konkreten Typ, mit dem die Funktion aufgerufen wird, eine eigene spezialisierte Version.
Das nennt sich &lt;strong&gt;Monomorphisierung&lt;/strong&gt;.&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #CDD6F4; background-color: #1E1E2E;&quot; &gt;&lt;code data-lang=&quot;rust&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #CBA6F7;&quot;&gt;fn&lt;/span&gt;&lt;span style=&quot;color: #89B4FA;font-style: italic;&quot;&gt; greet&lt;/span&gt;&lt;span style=&quot;color: #89DCEB;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #F9E2AF;font-style: italic;&quot;&gt;T&lt;/span&gt;&lt;span style=&quot;color: #94E2D5;&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color: #F9E2AF;font-style: italic;&quot;&gt; Greet&lt;/span&gt;&lt;span style=&quot;color: #89DCEB;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #EBA0AC;&quot;&gt;g&lt;/span&gt;&lt;span style=&quot;color: #94E2D5;&quot;&gt;: &amp;amp;&lt;/span&gt;&lt;span style=&quot;color: #F9E2AF;font-style: italic;&quot;&gt;T&lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;) {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #89B4FA;font-style: italic;&quot;&gt;    println!&lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #A6E3A1;&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;{}&lt;/span&gt;&lt;span style=&quot;color: #A6E3A1;&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;,&lt;/span&gt;&lt;span&gt; g&lt;/span&gt;&lt;span style=&quot;color: #94E2D5;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #89B4FA;font-style: italic;&quot;&gt;hello&lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;());&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Der Compiler sieht, dass &lt;code&gt;greet&lt;/code&gt; mit &lt;code&gt;German&lt;/code&gt; und &lt;code&gt;English&lt;/code&gt; aufgerufen wird, und erzeugt intern je eine Funktion für Englisch und eine für Deutsch:&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #CDD6F4; background-color: #1E1E2E;&quot; &gt;&lt;code data-lang=&quot;rust&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #CBA6F7;&quot;&gt;fn&lt;/span&gt;&lt;span style=&quot;color: #89B4FA;font-style: italic;&quot;&gt; greet_german&lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #EBA0AC;&quot;&gt;g&lt;/span&gt;&lt;span style=&quot;color: #94E2D5;&quot;&gt;: &amp;amp;&lt;/span&gt;&lt;span style=&quot;color: #F9E2AF;font-style: italic;&quot;&gt;German&lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;) {&lt;/span&gt;&lt;span style=&quot;color: #89B4FA;font-style: italic;&quot;&gt; println!&lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #A6E3A1;&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;{}&lt;/span&gt;&lt;span style=&quot;color: #A6E3A1;&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;,&lt;/span&gt;&lt;span&gt; g&lt;/span&gt;&lt;span style=&quot;color: #94E2D5;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #89B4FA;font-style: italic;&quot;&gt;hello&lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;()); }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #CBA6F7;&quot;&gt;fn&lt;/span&gt;&lt;span style=&quot;color: #89B4FA;font-style: italic;&quot;&gt; greet_english&lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #EBA0AC;&quot;&gt;g&lt;/span&gt;&lt;span style=&quot;color: #94E2D5;&quot;&gt;: &amp;amp;&lt;/span&gt;&lt;span style=&quot;color: #F9E2AF;font-style: italic;&quot;&gt;English&lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;) {&lt;/span&gt;&lt;span style=&quot;color: #89B4FA;font-style: italic;&quot;&gt; println!&lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #A6E3A1;&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;{}&lt;/span&gt;&lt;span style=&quot;color: #A6E3A1;&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;,&lt;/span&gt;&lt;span&gt; g&lt;/span&gt;&lt;span style=&quot;color: #94E2D5;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #89B4FA;font-style: italic;&quot;&gt;hello&lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;()); }&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Das ist gleichbedeutend mit dem &lt;code&gt;impl Trait&lt;/code&gt;-Syntax, der etwas lesbarer ist:&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #CDD6F4; background-color: #1E1E2E;&quot; &gt;&lt;code data-lang=&quot;rust&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #CBA6F7;&quot;&gt;fn&lt;/span&gt;&lt;span style=&quot;color: #89B4FA;font-style: italic;&quot;&gt; greet&lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #EBA0AC;&quot;&gt;g&lt;/span&gt;&lt;span style=&quot;color: #94E2D5;&quot;&gt;: &amp;amp;&lt;/span&gt;&lt;span style=&quot;color: #CBA6F7;&quot;&gt;impl&lt;/span&gt;&lt;span style=&quot;color: #F9E2AF;font-style: italic;&quot;&gt; Greet&lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;) {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #89B4FA;font-style: italic;&quot;&gt;    println!&lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #A6E3A1;&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;{}&lt;/span&gt;&lt;span style=&quot;color: #A6E3A1;&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;,&lt;/span&gt;&lt;span&gt; g&lt;/span&gt;&lt;span style=&quot;color: #94E2D5;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #89B4FA;font-style: italic;&quot;&gt;hello&lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;());&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;Vorteil:&lt;/strong&gt;&lt;br /&gt;
Zur Laufzeit gibt es keinen Overhead. Der Compiler kennt den konkreten Typ, kann ihn inline optimieren und direkt den richtigen Funktionsaufruf einsetzen.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Nachteil:&lt;/strong&gt;&lt;br /&gt;
Die Binärgröße wächst, denn für jeden Typ, mit dem die Funktion genutzt wird, landet eine eigene Kopie im kompilierten Code.&lt;/p&gt;
&lt;hr /&gt;
&lt;h2 id=&quot;dynamic-dispatch-polymorphismus-zur-laufzeit&quot;&gt;Dynamic Dispatch – Polymorphismus zur Laufzeit&lt;/h2&gt;
&lt;p&gt;Manchmal ist der konkrete Typ erst zur Laufzeit bekannt, so zum Beispiel wenn verschiedene Typen in einer Liste gesammelt werden sollen.&lt;/p&gt;
&lt;p&gt;Hier kommt &lt;code&gt;dyn Trait&lt;/code&gt; ins Spiel.&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #CDD6F4; background-color: #1E1E2E;&quot; &gt;&lt;code data-lang=&quot;rust&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #CBA6F7;&quot;&gt;fn&lt;/span&gt;&lt;span style=&quot;color: #89B4FA;font-style: italic;&quot;&gt; greet&lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #EBA0AC;&quot;&gt;g&lt;/span&gt;&lt;span style=&quot;color: #94E2D5;&quot;&gt;: &amp;amp;&lt;/span&gt;&lt;span style=&quot;color: #CBA6F7;&quot;&gt;dyn&lt;/span&gt;&lt;span style=&quot;color: #F9E2AF;font-style: italic;&quot;&gt; Greet&lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;) {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #89B4FA;font-style: italic;&quot;&gt;    println!&lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #A6E3A1;&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;{}&lt;/span&gt;&lt;span style=&quot;color: #A6E3A1;&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;,&lt;/span&gt;&lt;span&gt; g&lt;/span&gt;&lt;span style=&quot;color: #94E2D5;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #89B4FA;font-style: italic;&quot;&gt;hello&lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;());&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Statt einer spezialisierten Funktion pro Typ erzeugt der Compiler ein &lt;strong&gt;Trait Object&lt;/strong&gt;.
Das ist ein sogenannter &lt;strong&gt;Fat Pointer&lt;/strong&gt;, der aus zwei Teilen besteht, einem Zeiger auf die Daten und einem Zeiger auf eine &lt;strong&gt;vtable&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;Die vtable wiederum ist eine Tabelle mit Funktionszeigern für alle Methoden des Traits, wo zur Laufzeit die richtige Implementierung nachgeschlagen und aufgerufen wird.&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #CDD6F4; background-color: #1E1E2E;&quot; &gt;&lt;code data-lang=&quot;rust&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #CBA6F7;&quot;&gt;let&lt;/span&gt;&lt;span&gt; greeters&lt;/span&gt;&lt;span style=&quot;color: #94E2D5;&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color: #F9E2AF;font-style: italic;&quot;&gt; Vec&lt;/span&gt;&lt;span style=&quot;color: #89DCEB;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #F9E2AF;font-style: italic;&quot;&gt;Box&lt;/span&gt;&lt;span style=&quot;color: #89DCEB;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #CBA6F7;&quot;&gt;dyn&lt;/span&gt;&lt;span style=&quot;color: #F9E2AF;font-style: italic;&quot;&gt; Greet&lt;/span&gt;&lt;span style=&quot;color: #89DCEB;&quot;&gt;&amp;gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: #94E2D5;&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color: #89B4FA;font-style: italic;&quot;&gt; vec!&lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;[&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #F9E2AF;font-style: italic;&quot;&gt;    Box&lt;/span&gt;&lt;span style=&quot;color: #94E2D5;&quot;&gt;::&lt;/span&gt;&lt;span style=&quot;color: #89B4FA;font-style: italic;&quot;&gt;new&lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #F9E2AF;font-style: italic;&quot;&gt;German&lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #F9E2AF;font-style: italic;&quot;&gt;    Box&lt;/span&gt;&lt;span style=&quot;color: #94E2D5;&quot;&gt;::&lt;/span&gt;&lt;span style=&quot;color: #89B4FA;font-style: italic;&quot;&gt;new&lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #F9E2AF;font-style: italic;&quot;&gt;English&lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;];&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #CBA6F7;&quot;&gt;for&lt;/span&gt;&lt;span&gt; g&lt;/span&gt;&lt;span style=&quot;color: #CBA6F7;&quot;&gt; in&lt;/span&gt;&lt;span style=&quot;color: #94E2D5;&quot;&gt; &amp;amp;&lt;/span&gt;&lt;span&gt;greeters&lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #89B4FA;font-style: italic;&quot;&gt;    println!&lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #A6E3A1;&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;{}&lt;/span&gt;&lt;span style=&quot;color: #A6E3A1;&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;,&lt;/span&gt;&lt;span&gt; g&lt;/span&gt;&lt;span style=&quot;color: #94E2D5;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #89B4FA;font-style: italic;&quot;&gt;hello&lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;());&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Das wäre mit Monomorphisierung nicht möglich, da der Compiler den Typ jedes Eintrags zur Compile-Zeit kennen müsste.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Vorteil:&lt;/strong&gt;&lt;br /&gt;
Flexibel, kleinere Binärgröße, heterogene Collections möglich.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Nachteil:&lt;/strong&gt;&lt;br /&gt;
Laufzeit-Overhead durch den vtable-Lookup, keine Inlining-Optimierungen möglich.&lt;/p&gt;
&lt;hr /&gt;
&lt;h2 id=&quot;wann-was&quot;&gt;Wann was?&lt;/h2&gt;
&lt;table&gt;&lt;thead&gt;&lt;tr&gt;&lt;th&gt;&lt;/th&gt;&lt;th&gt;&lt;code&gt;impl Trait&lt;/code&gt; / Generics&lt;/th&gt;&lt;th&gt;&lt;code&gt;dyn Trait&lt;/code&gt;&lt;/th&gt;&lt;/tr&gt;&lt;/thead&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td&gt;&lt;strong&gt;Auflösung&lt;/strong&gt;&lt;/td&gt;&lt;td&gt;Compile-Zeit&lt;/td&gt;&lt;td&gt;Laufzeit&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;&lt;strong&gt;Performance&lt;/strong&gt;&lt;/td&gt;&lt;td&gt;Höher&lt;/td&gt;&lt;td&gt;Etwas geringer&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;&lt;strong&gt;Binärgröße&lt;/strong&gt;&lt;/td&gt;&lt;td&gt;Wächst pro Typ&lt;/td&gt;&lt;td&gt;Konstant&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;&lt;strong&gt;Heterogene Collections&lt;/strong&gt;&lt;/td&gt;&lt;td&gt;✗&lt;/td&gt;&lt;td&gt;✓&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;&lt;strong&gt;Typinformation&lt;/strong&gt;&lt;/td&gt;&lt;td&gt;Vollständig bekannt&lt;/td&gt;&lt;td&gt;Zur Compile-Zeit nicht bekannt&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;p&gt;Als Faustregel gilt:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;impl Trait&lt;/code&gt; ist der Standard&lt;/li&gt;
&lt;li&gt;&lt;code&gt;dyn Trait&lt;/code&gt; kommt zum Einsatz wenn der Typ erst zur Laufzeit bekannt ist oder eine heterogene Collection benötigt wird.&lt;/li&gt;
&lt;/ul&gt;
&lt;hr /&gt;
&lt;h2 id=&quot;fazit&quot;&gt;Fazit&lt;/h2&gt;
&lt;p&gt;Traits sind mehr als nur Interfaces.
Die Entscheidung zwischen Monomorphisierung und Dynamic Dispatch ist eine Entscheidung zwischen Compile-Zeit-Garantien und Laufzeit-Flexibilität.&lt;/p&gt;
&lt;p&gt;Im Vergleich zu Java oder C#, wo jeder Methodenaufruf über eine virtuelle Tabelle aufgelöst wird, gibt Rust einem die Wahl und man muss sich explizit entscheiden, was man möchte.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Explizit&lt;/strong&gt; und &lt;strong&gt;ohne Overhead&lt;/strong&gt;, sind zwei Grundprinzipien bei Rust, die man sich mit einer etwas steileren Lernkurve und mehr Boilerplate-Code erkauft.&lt;/p&gt;
</description>
      </item>
    </channel>
</rss>
