Scratchbook

Das Leben ist immer anders als die Realität.

Google Go – ein Rückblick

Claude, 28. Oktober 2016, 00:16 Uhr

Warning: Use of undefined constant ri_rand_compare - assumed 'ri_rand_compare' (this will throw an Error in a future version of PHP) in /home/httpd/vhosts/scratchbook.ch/httpdocs/wp-content/plugins/random-image-widget/random_image.php on line 129 Warning: Use of undefined constant ri_rand_compare - assumed 'ri_rand_compare' (this will throw an Error in a future version of PHP) in /home/httpd/vhosts/scratchbook.ch/httpdocs/wp-content/plugins/random-image-widget/random_image.php on line 130 Warning: preg_match(): Compilation failed: invalid range in character class at offset 4 in /home/httpd/vhosts/scratchbook.ch/httpdocs/wp-content/plugins/lightbox-plus/classes/shd.class.php on line 1384 Warning: preg_match(): Compilation failed: invalid range in character class at offset 4 in /home/httpd/vhosts/scratchbook.ch/httpdocs/wp-content/plugins/lightbox-plus/classes/shd.class.php on line 1384 Warning: preg_match(): Compilation failed: invalid range in character class at offset 4 in /home/httpd/vhosts/scratchbook.ch/httpdocs/wp-content/plugins/lightbox-plus/classes/shd.class.php on line 1384 Warning: preg_match(): Compilation failed: invalid range in character class at offset 4 in /home/httpd/vhosts/scratchbook.ch/httpdocs/wp-content/plugins/lightbox-plus/classes/shd.class.php on line 1384 Warning: preg_match(): Compilation failed: invalid range in character class at offset 4 in /home/httpd/vhosts/scratchbook.ch/httpdocs/wp-content/plugins/lightbox-plus/classes/shd.class.php on line 1384 Warning: preg_match(): Compilation failed: invalid range in character class at offset 4 in /home/httpd/vhosts/scratchbook.ch/httpdocs/wp-content/plugins/lightbox-plus/classes/shd.class.php on line 1384 Warning: preg_match(): Compilation failed: invalid range in character class at offset 4 in /home/httpd/vhosts/scratchbook.ch/httpdocs/wp-content/plugins/lightbox-plus/classes/shd.class.php on line 1384 Warning: preg_match(): Compilation failed: invalid range in character class at offset 4 in /home/httpd/vhosts/scratchbook.ch/httpdocs/wp-content/plugins/lightbox-plus/classes/shd.class.php on line 1384 Warning: preg_match(): Compilation failed: invalid range in character class at offset 4 in /home/httpd/vhosts/scratchbook.ch/httpdocs/wp-content/plugins/lightbox-plus/classes/shd.class.php on line 1384 Warning: preg_match(): Compilation failed: invalid range in character class at offset 4 in /home/httpd/vhosts/scratchbook.ch/httpdocs/wp-content/plugins/lightbox-plus/classes/shd.class.php on line 1384 Warning: preg_match(): Compilation failed: invalid range in character class at offset 4 in /home/httpd/vhosts/scratchbook.ch/httpdocs/wp-content/plugins/lightbox-plus/classes/shd.class.php on line 1384 Warning: preg_match(): Compilation failed: invalid range in character class at offset 4 in /home/httpd/vhosts/scratchbook.ch/httpdocs/wp-content/plugins/lightbox-plus/classes/shd.class.php on line 1384 Warning: preg_match(): Compilation failed: invalid range in character class at offset 4 in /home/httpd/vhosts/scratchbook.ch/httpdocs/wp-content/plugins/lightbox-plus/classes/shd.class.php on line 1384 Warning: preg_match(): Compilation failed: invalid range in character class at offset 4 in /home/httpd/vhosts/scratchbook.ch/httpdocs/wp-content/plugins/lightbox-plus/classes/shd.class.php on line 1384 Warning: preg_match(): Compilation failed: invalid range in character class at offset 4 in /home/httpd/vhosts/scratchbook.ch/httpdocs/wp-content/plugins/lightbox-plus/classes/shd.class.php on line 1384 Warning: preg_match(): Compilation failed: invalid range in character class at offset 4 in /home/httpd/vhosts/scratchbook.ch/httpdocs/wp-content/plugins/lightbox-plus/classes/shd.class.php on line 1384 Warning: preg_match(): Compilation failed: invalid range in character class at offset 4 in /home/httpd/vhosts/scratchbook.ch/httpdocs/wp-content/plugins/lightbox-plus/classes/shd.class.php on line 1384 Warning: preg_match(): Compilation failed: invalid range in character class at offset 4 in /home/httpd/vhosts/scratchbook.ch/httpdocs/wp-content/plugins/lightbox-plus/classes/shd.class.php on line 1384 Warning: preg_match(): Compilation failed: invalid range in character class at offset 4 in /home/httpd/vhosts/scratchbook.ch/httpdocs/wp-content/plugins/lightbox-plus/classes/shd.class.php on line 1384 Warning: preg_match(): Compilation failed: invalid range in character class at offset 4 in /home/httpd/vhosts/scratchbook.ch/httpdocs/wp-content/plugins/lightbox-plus/classes/shd.class.php on line 1384 Warning: preg_match(): Compilation failed: invalid range in character class at offset 4 in /home/httpd/vhosts/scratchbook.ch/httpdocs/wp-content/plugins/lightbox-plus/classes/shd.class.php on line 1384 Warning: preg_match(): Compilation failed: invalid range in character class at offset 4 in /home/httpd/vhosts/scratchbook.ch/httpdocs/wp-content/plugins/lightbox-plus/classes/shd.class.php on line 1384 Warning: preg_match(): Compilation failed: invalid range in character class at offset 4 in /home/httpd/vhosts/scratchbook.ch/httpdocs/wp-content/plugins/lightbox-plus/classes/shd.class.php on line 1384 Warning: preg_match(): Compilation failed: invalid range in character class at offset 4 in /home/httpd/vhosts/scratchbook.ch/httpdocs/wp-content/plugins/lightbox-plus/classes/shd.class.php on line 1384 Warning: preg_match(): Compilation failed: invalid range in character class at offset 4 in /home/httpd/vhosts/scratchbook.ch/httpdocs/wp-content/plugins/lightbox-plus/classes/shd.class.php on line 1384 Warning: preg_match(): Compilation failed: invalid range in character class at offset 4 in /home/httpd/vhosts/scratchbook.ch/httpdocs/wp-content/plugins/lightbox-plus/classes/shd.class.php on line 1384 Warning: preg_match(): Compilation failed: invalid range in character class at offset 4 in /home/httpd/vhosts/scratchbook.ch/httpdocs/wp-content/plugins/lightbox-plus/classes/shd.class.php on line 1384 Warning: preg_match(): Compilation failed: invalid range in character class at offset 4 in /home/httpd/vhosts/scratchbook.ch/httpdocs/wp-content/plugins/lightbox-plus/classes/shd.class.php on line 1384 Warning: preg_match(): Compilation failed: invalid range in character class at offset 4 in /home/httpd/vhosts/scratchbook.ch/httpdocs/wp-content/plugins/lightbox-plus/classes/shd.class.php on line 1384 Warning: preg_match(): Compilation failed: invalid range in character class at offset 4 in /home/httpd/vhosts/scratchbook.ch/httpdocs/wp-content/plugins/lightbox-plus/classes/shd.class.php on line 1384 Warning: preg_match(): Compilation failed: invalid range in character class at offset 4 in /home/httpd/vhosts/scratchbook.ch/httpdocs/wp-content/plugins/lightbox-plus/classes/shd.class.php on line 1384 Warning: preg_match(): Compilation failed: invalid range in character class at offset 4 in /home/httpd/vhosts/scratchbook.ch/httpdocs/wp-content/plugins/lightbox-plus/classes/shd.class.php on line 1384 Warning: preg_match(): Compilation failed: invalid range in character class at offset 4 in /home/httpd/vhosts/scratchbook.ch/httpdocs/wp-content/plugins/lightbox-plus/classes/shd.class.php on line 1384 Warning: preg_match(): Compilation failed: invalid range in character class at offset 4 in /home/httpd/vhosts/scratchbook.ch/httpdocs/wp-content/plugins/lightbox-plus/classes/shd.class.php on line 1384 Warning: preg_match(): Compilation failed: invalid range in character class at offset 4 in /home/httpd/vhosts/scratchbook.ch/httpdocs/wp-content/plugins/lightbox-plus/classes/shd.class.php on line 1384 Warning: preg_match(): Compilation failed: invalid range in character class at offset 4 in /home/httpd/vhosts/scratchbook.ch/httpdocs/wp-content/plugins/lightbox-plus/classes/shd.class.php on line 1384 Warning: preg_match(): Compilation failed: invalid range in character class at offset 4 in /home/httpd/vhosts/scratchbook.ch/httpdocs/wp-content/plugins/lightbox-plus/classes/shd.class.php on line 1384 Warning: preg_match(): Compilation failed: invalid range in character class at offset 4 in /home/httpd/vhosts/scratchbook.ch/httpdocs/wp-content/plugins/lightbox-plus/classes/shd.class.php on line 1384 Warning: preg_match(): Compilation failed: invalid range in character class at offset 4 in /home/httpd/vhosts/scratchbook.ch/httpdocs/wp-content/plugins/lightbox-plus/classes/shd.class.php on line 1384 Warning: preg_match(): Compilation failed: invalid range in character class at offset 4 in /home/httpd/vhosts/scratchbook.ch/httpdocs/wp-content/plugins/lightbox-plus/classes/shd.class.php on line 1384 Warning: preg_match(): Compilation failed: invalid range in character class at offset 4 in /home/httpd/vhosts/scratchbook.ch/httpdocs/wp-content/plugins/lightbox-plus/classes/shd.class.php on line 1384 Warning: preg_match(): Compilation failed: invalid range in character class at offset 4 in /home/httpd/vhosts/scratchbook.ch/httpdocs/wp-content/plugins/lightbox-plus/classes/shd.class.php on line 1384 Warning: preg_match(): Compilation failed: invalid range in character class at offset 4 in /home/httpd/vhosts/scratchbook.ch/httpdocs/wp-content/plugins/lightbox-plus/classes/shd.class.php on line 1384 Warning: preg_match(): Compilation failed: invalid range in character class at offset 4 in /home/httpd/vhosts/scratchbook.ch/httpdocs/wp-content/plugins/lightbox-plus/classes/shd.class.php on line 1384 Warning: preg_match(): Compilation failed: invalid range in character class at offset 4 in /home/httpd/vhosts/scratchbook.ch/httpdocs/wp-content/plugins/lightbox-plus/classes/shd.class.php on line 1384 Warning: preg_match(): Compilation failed: invalid range in character class at offset 4 in /home/httpd/vhosts/scratchbook.ch/httpdocs/wp-content/plugins/lightbox-plus/classes/shd.class.php on line 1384 Warning: preg_match(): Compilation failed: invalid range in character class at offset 4 in /home/httpd/vhosts/scratchbook.ch/httpdocs/wp-content/plugins/lightbox-plus/classes/shd.class.php on line 1384 Warning: preg_match(): Compilation failed: invalid range in character class at offset 4 in /home/httpd/vhosts/scratchbook.ch/httpdocs/wp-content/plugins/lightbox-plus/classes/shd.class.php on line 1384 Warning: preg_match(): Compilation failed: invalid range in character class at offset 4 in /home/httpd/vhosts/scratchbook.ch/httpdocs/wp-content/plugins/lightbox-plus/classes/shd.class.php on line 1384 Warning: preg_match(): Compilation failed: invalid range in character class at offset 4 in /home/httpd/vhosts/scratchbook.ch/httpdocs/wp-content/plugins/lightbox-plus/classes/shd.class.php on line 1384 Warning: preg_match(): Compilation failed: invalid range in character class at offset 4 in /home/httpd/vhosts/scratchbook.ch/httpdocs/wp-content/plugins/lightbox-plus/classes/shd.class.php on line 1384 Warning: preg_match(): Compilation failed: invalid range in character class at offset 4 in /home/httpd/vhosts/scratchbook.ch/httpdocs/wp-content/plugins/lightbox-plus/classes/shd.class.php on line 1384 Warning: preg_match(): Compilation failed: invalid range in character class at offset 4 in /home/httpd/vhosts/scratchbook.ch/httpdocs/wp-content/plugins/lightbox-plus/classes/shd.class.php on line 1384 Warning: preg_match(): Compilation failed: invalid range in character class at offset 4 in /home/httpd/vhosts/scratchbook.ch/httpdocs/wp-content/plugins/lightbox-plus/classes/shd.class.php on line 1384 Warning: preg_match(): Compilation failed: invalid range in character class at offset 4 in /home/httpd/vhosts/scratchbook.ch/httpdocs/wp-content/plugins/lightbox-plus/classes/shd.class.php on line 1384 Warning: preg_match(): Compilation failed: invalid range in character class at offset 4 in /home/httpd/vhosts/scratchbook.ch/httpdocs/wp-content/plugins/lightbox-plus/classes/shd.class.php on line 1384 Warning: preg_match(): Compilation failed: invalid range in character class at offset 4 in /home/httpd/vhosts/scratchbook.ch/httpdocs/wp-content/plugins/lightbox-plus/classes/shd.class.php on line 1384 Warning: preg_match(): Compilation failed: invalid range in character class at offset 4 in /home/httpd/vhosts/scratchbook.ch/httpdocs/wp-content/plugins/lightbox-plus/classes/shd.class.php on line 1384 Warning: preg_match(): Compilation failed: invalid range in character class at offset 4 in /home/httpd/vhosts/scratchbook.ch/httpdocs/wp-content/plugins/lightbox-plus/classes/shd.class.php on line 1384 Warning: preg_match(): Compilation failed: invalid range in character class at offset 4 in /home/httpd/vhosts/scratchbook.ch/httpdocs/wp-content/plugins/lightbox-plus/classes/shd.class.php on line 1384 Warning: preg_match(): Compilation failed: invalid range in character class at offset 4 in /home/httpd/vhosts/scratchbook.ch/httpdocs/wp-content/plugins/lightbox-plus/classes/shd.class.php on line 1384 Warning: preg_match(): Compilation failed: invalid range in character class at offset 4 in /home/httpd/vhosts/scratchbook.ch/httpdocs/wp-content/plugins/lightbox-plus/classes/shd.class.php on line 1384 Warning: preg_match(): Compilation failed: invalid range in character class at offset 4 in /home/httpd/vhosts/scratchbook.ch/httpdocs/wp-content/plugins/lightbox-plus/classes/shd.class.php on line 1384 Warning: preg_match(): Compilation failed: invalid range in character class at offset 4 in /home/httpd/vhosts/scratchbook.ch/httpdocs/wp-content/plugins/lightbox-plus/classes/shd.class.php on line 1384 Warning: preg_match(): Compilation failed: invalid range in character class at offset 4 in /home/httpd/vhosts/scratchbook.ch/httpdocs/wp-content/plugins/lightbox-plus/classes/shd.class.php on line 1384 Warning: preg_match(): Compilation failed: invalid range in character class at offset 4 in /home/httpd/vhosts/scratchbook.ch/httpdocs/wp-content/plugins/lightbox-plus/classes/shd.class.php on line 1384 Warning: preg_match(): Compilation failed: invalid range in character class at offset 4 in /home/httpd/vhosts/scratchbook.ch/httpdocs/wp-content/plugins/lightbox-plus/classes/shd.class.php on line 1384 Warning: preg_match(): Compilation failed: invalid range in character class at offset 4 in /home/httpd/vhosts/scratchbook.ch/httpdocs/wp-content/plugins/lightbox-plus/classes/shd.class.php on line 1384 Warning: preg_match(): Compilation failed: invalid range in character class at offset 4 in /home/httpd/vhosts/scratchbook.ch/httpdocs/wp-content/plugins/lightbox-plus/classes/shd.class.php on line 1384 Warning: preg_match(): Compilation failed: invalid range in character class at offset 4 in /home/httpd/vhosts/scratchbook.ch/httpdocs/wp-content/plugins/lightbox-plus/classes/shd.class.php on line 1384 Warning: preg_match(): Compilation failed: invalid range in character class at offset 4 in /home/httpd/vhosts/scratchbook.ch/httpdocs/wp-content/plugins/lightbox-plus/classes/shd.class.php on line 1384 Warning: preg_match(): Compilation failed: invalid range in character class at offset 4 in /home/httpd/vhosts/scratchbook.ch/httpdocs/wp-content/plugins/lightbox-plus/classes/shd.class.php on line 1384 Warning: preg_match(): Compilation failed: invalid range in character class at offset 4 in /home/httpd/vhosts/scratchbook.ch/httpdocs/wp-content/plugins/lightbox-plus/classes/shd.class.php on line 1384 Warning: preg_match_all(): Compilation failed: invalid range in character class at offset 4 in /home/httpd/vhosts/scratchbook.ch/httpdocs/wp-content/plugins/lightbox-plus/classes/shd.class.php on line 700 Warning: Invalid argument supplied for foreach() in /home/httpd/vhosts/scratchbook.ch/httpdocs/wp-content/plugins/lightbox-plus/classes/shd.class.php on line 707 Warning: preg_match_all(): Compilation failed: invalid range in character class at offset 4 in /home/httpd/vhosts/scratchbook.ch/httpdocs/wp-content/plugins/lightbox-plus/classes/shd.class.php on line 700 Warning: Invalid argument supplied for foreach() in /home/httpd/vhosts/scratchbook.ch/httpdocs/wp-content/plugins/lightbox-plus/classes/shd.class.php on line 707

„Die Lichtschalter funktionieren alle nicht mehr, der Bewegungsmelder bleibt stehen und überhaupt. Alles kaputt!“

Ich treffe am Einsatzort des Krisengebietes ein. Wir haben ein altes Bauernhaus im Appenzellerland mit unserer Gebäudeautomation ausgerüstet. In NodeJS. Jetzt spinnt dort alles rum und ich mache mich auf die Fehlersuche. Ah ja. Im Rahmen der Vereinheitlichung und des Aufräumens des Datenbankmodells hatten sich ein paar Zugriffe geändert.

Zum Beispiel einen Event speichern:

Alt:
event.edit(id)

Neu:
event.get(id)
event.edit()

Ich habe alle diese Aufrufe erwischt und angepasst, habe ich gemeint. Nun – ausser man verschiebt im Kalender ein Ereignis vor dem Editieren. Dann springt das Programm in eine dunkle Seitengasse, die so exotisch und versteckt ist, dass dort eh niemand reintrampen wird. Ausser der Kunde, der natürlich alles anklickt und die wildesten Sonderwege ausprobiert, an die man gar nie gedacht hat. Mit Strickleitern, Hintereingängen, Stichsägen und Falltüren. Genau dann kommt er in diese Seitengasse, in der mein Aufruf in zerfetzten Kleidern am Boden kauert. „Vergessen“, murmelt er. Das Programm ist aufgrund des alten, ungültigen Aufrufs abgestürzt und hat alle Sensoren im Stich gelassen. Nichts geht mehr, das Licht bleibt an, das Licht bleibt aus, alle Taster sind tot.

Tja – mit Go wäre das nicht passiert.

Was ist das eigentlich, ein Typensystem, statische Typisierung und warum brauche ich das?

So richtig erklären konnte mir das bisher niemand. Wieder einmal mehr greift mir die Praxis und die eigene Erfahrung unter die Arme.

Go prüft, ob alle Typen identisch sind. Es prüft, ob alle Parameter bei den Funktionsaufrufen vorhanden sind und ob die vom richtigen Typ sind. Das passiert beim Kompilieren. Und da der ganze Code kompiliert werden muss, wird alles überprüft, auch die hintersten Winkel und Seitengassen. Nichts bleibt zurück, keiner geht vergessen.

Oh, du willst den Zeitstempel von int auf int64 beim Typ File ändern?

Gut, aber dann musst du das hier:

und hier:

und hier auch ändern, sonst kracht es wieder würde es wieder krachen. Stattdessen kompilier‘ ich gar nicht erst.

Go ist streng in der Hinsicht. Erst wenn das Programm korrekt ist; erst, wenn alle Wellenlinien bereinigt sind, gibt der Compiler das Programm frei und übersetzt es in Maschinencode. Dafür läuft es dann stabil, Fehler werden im vornhinein verhindert. Wie ein aufmerksamer Wächter, der mir beim Programmieren über die Schulter schaut. „Da hast du was vergessen, und hier; und das funktioniert so nicht, das muss anders sein – und hier, und hier, und hier. Motzt er mit erhobenem Zeigefinger rum. Was ist dir lieber: Ein strenger Compiler, der dir alles mit roten Wellenlinien anmalt, oder ein rotes Gesicht; vor Scham, dass die Anlage abgestürzt ist? Mit Go hätte mich der Compiler angepfurrt: „Hey, event.edit() akzeptiert gar keine Parameter, und trotzdem übergibst du eine id. WAS SOLL DER SCHEISS?“ und bricht ab. Einmal einen Komplettabsturz der Steuerungsanlage verhindert, und die Lichtschalter hätten weiterhin funktioniert.

Eyyy, statische Typisierung ist ja echt toll!

Und ich merke, wie ich disziplinierter werde. Das färbt auf andere Programmiersprachen ab. So benutze ich mehrstufiges Logging statt immer nur überall von Hand „print“ ein- und auszukommentieren. Korrekte Fehlerbehandlung und sprechende Fehlermeldungen, statt ein try{} catch{} ohne Meldung oder ein stillschweigendes Except-pass. Das Überladen von Rückgabewerten mit Fehlermeldungen ist dank mehrteiligen Rückgabewerten in Go Vergangenheit.

Über die Lesbarkeit von Programmcode

Open Source ist toll – jeder kann den Programmcode ansehen. Theoretisch. Ob man ihn dann versteht, das steht auf einem ganz anderen Blatt geschrieben. Wieviel Rotz gibt es, bei dem selbst die ursprünglichen Autoren nicht mehr durchblicken? Wie oft stand ich schon vor Code, der so grauenhaft durchabstrahiert, siebenfach aufgeschichtet, an dunklen Ecken und Enden mit Affenpflästerchen verziert ist und überall mit Abhängigkeitsspritzen geimpft wurde? Ich begreife gar nichts mehr, fühle mich dumm und unfähig und werde von Bachelor- und Masteraugen mitleidig von der Seite angeschaut.

Und jeder macht es wieder anders. Jeder benutzt einen anderen Trick der Programmiersprache. Diese Tricks erscheinen dann anderen wiederum als mysteriöses Voodoo und bleiben ungelöst, verborgen, rätselhaft. Sie funktionieren einfach, und keiner weiss, warum.

Muss das so sein?

Nein.

Go hat es geschafft, die Sprachbausteine auf so wenige Teile herunterzubrechen, dass man ein Problem, einen Gedankengang, einen Algorithmus gerade so kompakt wie nötig, aber nicht kompakter; und gerade so ausschweifend wie nötig, aber nicht weiter, herunterbrechen muss. Die einen müssen unter Umständen etwas mehr schreiben, als sie es in ihrer Programmiersprache gewohnt sind. Die anderen merken, dass sie für die gleiche Problemlösung weniger schreiben, als sie es sich in ihrem Enterprise-OOP-Pattern-Denken gewohnt sind. Am Ende ist es für alle nachvollziehbar. Und somit lesbar. Und somit wartbar.

Jon Calhoun sagt:

„In den meisten Sprachen ist es nicht einfach, sich durch komplizierte Programmbibliotheken oder Anwendungen zu wühlen, die du nicht selber geschrieben hast. Aber in Go ist es wirklich einfach und verständlich! (Quelle)

Der Code ist wirklich offen, und zwar so, dass ich ihn verstehe. Gleichzeitig kriege ich einen guten Programmierstil und „so macht man das in Go“ vermittelt.

CamelCase war noch nie mein Ding, ich mag diese Schreibweise nicht. Tabs statt Spaces zur Einrückung? Bäh. Aber das spielt keine Rolle. Keiner mag den Codestil von Go, aber alle lieben den Codeformatter. So sieht Code überall immer gleich lesbar aus. Leere Zeichen am Zeilenende? Endlose Diskussionen darüber, ob Klammern auf eine neue oder auf die gleichen Zeile gehören? Spaces und Tabs gemischt, seltsame Einrückungen? Alles Vergangenheit.

Vertraute Konstrukte aus z.B. JavaScript wie anonyme, selbstausführende Funktionen oder Closures sind übernommen funktionieren auch da. Alles wie gewohnt, aber fein aufgebohrt und durchdacht. Alles einmal neu gemacht, ohne Altlasten.

Am Anfang war ich „nur“ begeistert von der Möglichkeit, wie einfach man damit nebenläufige Programme schreiben kann. Dann habe ich Interfaces entdeckt und es dämmert mir, welche Macht sich dahinter verbirgt. So richtig eingesetzt habe ich sie noch nicht, aber das kommt noch. Und dieses Typensystem! Eigentlich etwas völlig Unspektakuläres. Aber wenn man damit arbeitet, erkennt man dessen Vorzüge.

„Naja Typensystem, was soll das überhaupt, was will ich damit? Die Maschine soll sich darum kümmern, ist schliesslich ihre Aufgabe, mir Arbeit abzunehmen. Ist doch egal, ob da int oder int64 steht, warum gibts überhaupt diese Unterteilung? Wenn ich ein int will, mache ich eben ein parseInt() in JavaScript oder ein int() in Python, und schon habe ich, was ich brauche.“

So habe ich früher gedacht. Bis dann auf einmal die Lichtschalter im Appenzellerhaus nicht mehr funktionieren, weil ich im Rahmen eines Refactorings einen Datentyp und einen Aufruf geändert und diesen neuen Aufruf überall ersetzt habe – ausser dort, in dieser dunklen Seitengasse. Der ging vergessen. Und da JavaScript eine interpretierte Sprache ist, tritt der Fehler erst zur Laufzeit auf; erst dann, wenn das Programm in diese Gasse reintritt. BOOM. Hat man einen Compiler und ein Typensystem, haut der einem vorher auf die Finger und solche Fehler treten gar nicht erst auf. Ich weiss, dass das Programm robust funktioniert, sobald es kompiliert. Das gibt mir Sicherheit und ein gutes Gefühl.

Alles so kleine Details und Glitzerfunken, die einem beim ersten Mal drüberschauen nicht auffallen. Erst wenn man damit arbeitet, merkt man, wie durchdacht und ausgereift das Ganze ist. Wieviel Denkarbeit in kleine Details investiert ist. Es ist grossartig!

Mittlerweile habe ich den Checksummer – mein Code-Dojo – nach Go portiert. Und auch wenn es auf den ersten Blick mehr Code ist, auf mehrere Dateien verteilt – ich empfinde es wartbarer. Vorallem lässt es sich auf einen Raspi kopieren, ohne eine Python-Umgebung und irgendwelche anderen Abhängigkeiten.

Die Hackerspaces denken laut darüber nach, die SpaceAPI zu implementieren. Darauf meldet sich jemand mit einer Implementation in Rust in über tausend Zeilen Code und man braucht dafür einen Redis-Server. Hashtag #overengineering.

jackie
Wieso?

Meine Variante in Go füllt gerade mal 80 Zeilen und ist genau so statisch typisiert.

Programmieren soll wieder einfacher werden, so dass es jeder kann und versteht. Was kann man alles weglassen? So simpel wie möglich, das ist die Philosophie von Go. Und ich bin dankbar dafür.

Warning: count(): Parameter must be an array or an object that implements Countable in /home/httpd/vhosts/scratchbook.ch/httpdocs/wp-content/themes/scratchbook/navigation_bar_bottom.php on line 1