Python

Python is actually a few years older than Java, but in the last couple of years it has been tremendously successful and it is considered „modern“ today.

Python comes in two major versions Python 2 and Python 3. It took more than a decade for Python 3 to surpass Python 2, but it looks like that has finally happend a few years ago. The Python community was fortunately strong enough to support both versions at a high level for such a long time. But, please, use Python 3, if you can, preferrably a recent version.

Actually I recommend learning Python, because it is good to know it in this time. I would not call it a favorite language. To my impression Ruby has similar capabilities, but is a much more beautiful language. Perl is still a bit easier for „small tasks“, especially one liners using regular expressions. Raku tried to be a better replacement for Perl and has some great concepts, but didn’t really pick up momentum. Clojure is a phantastic language, but it forces two challenges on the ones who try to learn it. You need to embrace the Lisp-Syntax and the functional paradigm at once.

Then again there are statically typed languages, like Rust, Java, Kotlin, Scala, C#, F# or Swift, that tend to eliminate some errors at compile time and and that tend run faster, especially in conjunction with full native compilation like using llvm or Graal VM.

I do not like the syntax with „significant whitespace“, but since I use indention to emphasize structure anyway, I would not call that a show stopper.

So what is cool about Python?

I think that it is relatively easy to learn for someone who already knows several programming languages. It is a multi paradigm language which support object orientented programming, procedural programming and functional programming and it follows pretty much common sense of what can be find in other programming languages.

The most important advantage comes from the fact that Python is heavily used in certain areas and that there are a lot of libraries available, especially in these areas. It has actually bein among the most popular languages on Tiobe Index and it is actually Number 1 today (2025-04-10) and has been „number 1“ or at least „almost number 1“ since 2021.

I see the following areas:

  • Scripting language for system engineering and related tasks (competing and replacing Perl and Ruby and to a minor extend Bash)
  • Artificial Intelligence
  • Data Science
  • Scientific Computing
  • Usage as embedded language
  • Google is known to heavily rely on Python (among other languages)
  • Many other organizations list Python among the „recommended programming languages“, but do not recommend using Perl or Ruby
  • and of course a lot of programming as a general purpose language

In the end of the day the results that can be achieved count and a lot of cool software has been done in Python.
I will use Python in the future and explore where it can be useful.

Share Button

New Input Device

We have seen keyboards, mouses, touchscreens, touchpads, voice recognition and even foot pedals as inpunt devices.

But apparently this is all outdated technology. The newest generation of computers will come with some kind of rubber balloon which is squeezed in different ways. It has been proven that this can replace both keyboard and mouse and that after some practice it is much faster than a keyboard. The nice thing is that it also generates its own energy and does not need to be charged or connected with a cable.

The newest Gartner reports suggest that IT departments will save billions by applying this technology and bypassing the bottleneck keyboard+mouse.

Share Button

2025

Щасливого нового року! — Frohes neues Jahr! — Happy new year!

 

Share Button

Christmas 2024

З Рiздвом Христовим − Merry Christmas − Frohe Weihnachten

Share Button

Split GPX file

GPX-files are used to store planned and done routes, for example for cycling.
A lot of web sites and applications allow creating and editing such routes.

In practice it matters for a trip from A to B if there is one long route that covers the whole distance or many shorter routes. Long routes get hard to handle, because of the software gets slow or crashes when the data set is too big. And small routes are more difficult to use when wanting to have an overview and they require switching to another route during the day, which can be inconvenient.

In theory it is possible to just copy a long route and to delete parts of it to obtain shorter routes, but that does not work too well, if the route is already very long.

So one way to go is to make a long route with only rough planning, to have an overview and then split it into shorter routes that can then be modified to obtain a more accurate planning.
So the following program (written in Perl for Linux) will split a GPX file into n about equally long parts. It is quite simple, but I hope it will help to make this task a little bit easier.

License is GPL v3.

GITHUB

#!/usr/bin/perl -w

# (C) Karl Brodowsky 2024-06-09
# Licence GPS v3.0
# (see https://www.gnu.org/licenses/gpl-3.0.de.html )

use strict;
use utf8;
use Encode qw(decode encode);

binmode STDOUT, ":utf8";
binmode STDIN, ":utf8";

my $header =<<'EOH';
<?xml version='1.0' encoding='UTF-8'?>
<gpx version="1.1" creator="https://www.komoot.de" xmlns="http://www.topografix.com/GPX/1/1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd">
  <metadata>
    <name><<TITLE>></name>
    <author>
      <link href="https://www.komoot.de">
        <text>komoot</text>
        <type>text/html</type>
      </link>
    </author>
  </metadata>
  <trk>
    <name><<TITLE>></name>
    <trkseg>
EOH
my $footer =<<'EOF';
    </trkseg>
  </trk>
</gpx>
EOF

sub usage($) {
    my $msg = $_[0];
    if ($msg) {
        chomp $msg;
        print $msg, "\n\n";
    }
    print <<"EOU";
USAGE

$0 <<FILE>> <<NAME>> <<NUMBER_OF_PARTS>>
EOU

    if ($msg) {
        exit 1;
    } else {
        exit 0;
    }
}

if (scalar(@ARGV) == 0 || $ARGV[0] =~ m/^-{0,2}help/) {
    usage("");
}
if (scalar(@ARGV) != 3) {
    usage("wrong number of arguments");
}
my $file = $ARGV[0];
my $file_u = decode("utf-8", $file);
unless (-f $file && -r $file) {
    usage("$file_u is not a readable file");
}
unless ($file =~ m/.+\.gpx$/) {
    usage("$file_u is not a gpx-file");
}
my $name = decode("utf-8", $ARGV[1]);
$name =~ s/^\s+//;
$name =~ s/\s+$//;
$name =~ s/\r//g;

unless (length($name) > 0) {
    usage("$name must be at least 1 character");
}
if ($name =~ m/[<>"']/) {
    usage("$name contains illegal characters");
}
print "name=$name\n";

my $number_of_parts = $ARGV[2];
if ($number_of_parts < 2) {
    usage("at least 2 parts are required");
}

open INPUT, "<:utf8", $file || usage("cannot open $file_u");
my @points = ();
my $point = "";
while (<INPUT>) {
    if (m/^\s*<trkpt/) {
        $point = $_;
    } elsif (m/^\s*<(ele|time)>/) {
        $point .= $_;
    } elsif (m/^\s*<\/trkpt>/) {
        $point .= $_;
        push @points, $point;
        $point = "";
    } else {
        print;
    }
}
close INPUT;
print "\n";

my $length = scalar(@points);

sub part_length($$) {
    my ($remaining_length, $remaining_number_of_parts) = @_;
    ($remaining_length - 1) / $remaining_number_of_parts + 1;
}

my $part_length = part_length($length, $number_of_parts);
print "length = $length part_length = $part_length number_of_parts = $number_of_parts\n";

if ($part_length < 2) {
    usage("too many parts part_length=$part_length");
}
my $remaining_length;
my $remaining_number_of_parts = $number_of_parts;
my $i = 0;
while ($remaining_number_of_parts > 0) {
    $remaining_length=scalar(@points);
    $part_length = int(part_length($remaining_length, $remaining_number_of_parts) + 0.5);
    my $header_i = $header;
    my $title_i = sprintf("%s (%d)", $name, $i);
    $header_i =~ s/<<TITLE>>/$title_i/g;
    my $file_i = $file;
    my $file_u_i = decode("utf-8", $file);
    $file_i =~ s/\.gpx$/_$i.gpx/;
    print "i=$i remaining_number_of_parts=$remaining_number_of_parts remaining_length=$remaining_length\n";
    print "i=$i file_i=$file_u_i title_i=$title_i\n";
    open OUTPUT, ">:utf8", $file_i;
    print OUTPUT $header_i;
    for (my $j = 0; $j < $part_length; $j++) {
        my $point = $points[0];
        if ($j < $part_length -1) {
            shift @points;
        }
        print OUTPUT $point;
    }
    print OUTPUT $footer;
    close OUTPUT;
    $i++;
    $remaining_number_of_parts--;
}

P.S. I plan to return to regular posts in this blog during this year.

Share Button

New Numeric Type

Russian Informatics scientists have invented a new numeric type for computers. Russian made computer chips have it already implemented in hardware.

The numbers are expressed in the form

    \[a_0 + 17 \cdot a_1 + 17 \cdot 19 \cdot a_2 + 17 \cdot 19 \cdot 21  \cdot  a_3 + 17 \cdot 19 \cdot 21 \cdot 23 \cdot a_4 + 17 \cdot 19 \cdot 21 \cdot 23 \cdot 25  \cdot  a_5 + 17 \cdot 19 \cdot 21 \cdot 23 \cdot 25  \cdot  27 \cdot  a_6 + 17 \cdot 19 \cdot 21 \cdot 23 \cdot 25  \cdot  27 \cdot  29 \cdot   a_7 + 17 \cdot 19 \cdot 21 \cdot 23 \cdot 25  \cdot  27 \cdot  29 \cdot 31 \cdot  a_8\]

a_0, a_1, \ldots are each expressed by 6 bits. The exact encoding, which combination of bits have which meaning is a state secret, so it will be necessary to get the hardware and the software only from Russian quality suppliers, that are absolutely not assosicated with FSB or the fascist regime.

This will revolutionize computing world wide through higher efficiency and greener IT.

Share Button

New Year 2024

Sala we ya nû pîroz be! — Srechno novo leto! — السنة الجديدة المبتهجة — Un an nou fericit! — Bun di bun an! — Happy New Year! — Gott nytt år! — Среќна нова година! — Sugeng warsa enggal! — ¡Próspero año nuevo! — Весёлого нового года! — Bonne année! — Щасливого нового року! — Καλή Χρονια! — Een gelukkig nieuwjaar! — Feliĉan novan jaron! — Sretna nova godina! — Cung chúc tân xuân! — Gelukkig nieuwjaar! — Boldog új évet! — Naya barsa ko hardik shuvakamana! — 새해 복 많이 받으세요 — Ath bhliain faoi mhaise! — Laimīgu Jauno gadu! — Nav varsh ki subhkamna! — うれしい新しい年 — Onnellista uutta vuotta! — Lokkich nijjier! — FELIX SIT ANNUS NOVUS! — Akemashite omedetô! — Frohes neues Jahr! — Felice Anno Nuovo! — Feliz año nuevo! — Shnorhavor nor tari! — Hääd uut aastat! — Срећна нова година! — Laimīgu jauno gadu! — عام سعيد — สวัสดีปีใหม่ — Godt Nyttår! — Gott nýggjár! — سال نو مبارک — Feliz ano novo! — Yeni yılınız kutlu olsun! — Šťastný nový rok! — Subho nababarsho! — Próspero ano novo! — Selamat tahun baru! — 新年好 — Честита нова година! — Szczęśliwego nowego roku! — Gleðilegt nýtt ár! — Godt nytår! — Laimingų naujųjų metų!

Share Button

Christmas 2023

Bon nadal — Bella Festas daz Nadal — Fröhliche Weihnachten — Prettige Kerstdagen — کريسمس مبارک — Mutlu Noeller — 즐거운 성탄, 성탄 축하 — Sretan božić — Kellemes Karácsonyi Ünnepeket — God Jul! — Nollaig Shona Dhuit! — Vesele Vianoce — Buon Natale — Häid jõule — Priecîgus Ziemassvçtkus — Vesele bozicne praznike — Su Šventom Kalėdom — Veselé Vánoce — God Jul — Natale hilare — καλά Χριστούγεννα — Merry Christmas — Hyvää Joulua — クリスマスおめでとう ; メリークリスマス — Crăciun fericit — Joyeux Noël — Срећан Божић — Gëzuar Krishtlindjet — Feliĉan Kristnaskon — ميلاد مجيد — Zalig Kerstfeest — Selamat Hari Natal — 圣诞快乐 — Gleðileg jól — क्रिसमस मंगलमय हो — Feliz Navidad — Wesołych Świąt Bożego Narodzenia — Gledhilig jól — Glædelig Jul — Честита Коледа — Feliz Natal — З Рiздвом Христовим

Generated by the following Kotin program:

Element.kt
package net.itsky.xmas

data class Element(val key: Long, val text: String) {
    override fun hashCode(): Int {
        return key.hashCode();
    }

    override fun equals(other: Any?): Boolean {
        if (other is Element) {
            return this.key == other.key;
        } else {
            return false;
        }
    }

    override fun toString(): String {
        return text
    }
}

Main.kt
package net.itsky.xmas

import java.security.SecureRandom

fun main() {
    val texts: List = listOf(
        "Bella Festas daz Nadal", "Bon nadal", "Buon Natale", "Crăciun fericit",
        "Feliz Natal", "Feliz Navidad", "Feliĉan Kristnaskon", "Fröhliche Weihnachten", "Gledhilig jól",
        "Gleðileg jól", "Glædelig Jul", "God Jul!", "God Jul", "Gëzuar Krishtlindjet", "Hyvää Joulua", "Häid jõule",
        "Joyeux Noël", "Kellemes Karácsonyi Ünnepeket", "Merry Christmas", "Mutlu Noeller", "Natale hilare",
        "Nollaig Shona Dhuit!", "Prettige Kerstdagen", "Priecîgus Ziemassvçtkus", "Selamat Hari Natal", "Sretan božić",
        "Su Šventom Kalėdom", "Vesele Vianoce", "Vesele bozicne praznike", "Veselé Vánoce",
        "Wesołych Świąt Bożego Narodzenia", "Zalig Kerstfeest", "καλά Χριστούγεννα", "З Рiздвом Христовим",
        "Срећан Божић", "Честита Коледа", "ميلاد مجيد", "کريسمس مبارک", "क्रिसमस मंगलमय हो",
        "クリスマスおめでとう ; メリークリスマス", "圣诞快乐", "즐거운 성탄, 성탄 축하"
    );
    val random: SecureRandom = SecureRandom();
    val elementsList: List = texts.map { Element(random.nextLong(), it) }
    val elements: Set = HashSet(elementsList);

    var first = true
    for (e in elements) {
        if (first) {
            first = false
        } else {
            print(" — ")
        }
        print(e)

    }
    println();
}

Share Button

Russia introduces new character encoding to replace Unicode

Russian computer scientists have created a new character encoding that will replace Unicode.

The encoding looks like this:

.0.1.2.3.4.5.6.7.8.9.A.B.C.D.E.F
0.NULSOHSTXETXEOTENQACKBELBSHTLFVTFFCRSOSI
1.DLEDC1DC2DC3DC4NAKSYNETBCANEMSUBESCFSGSRSDEL
2.SPC! «»%ZV()*+-,./
3.0123456789:;=?@
4.АБВГДЕЁЈЖЗИӢКЛМН
5.ОПРСТУФХЦЧШЩЪЫЬЭ
6.ЮЯӒЂӤЉЊӦӰӞҦЋѢӘѪЏ
7.абвгдеёјжзиӣклмн
8.опрстуфхцчшщъыьэ
9.юяӓђӥљњӧӱӟҧћѣәѫџ
A.&{|}~-З́з́ѲѳѺѻ
B.ҀҁѹѸѠѡѾѿѢѣ
C.ѤѥѦѧѨѩѪѫѬѭѮѯѰѱ
D.ѴѴѶѷΑαΒβΓγΔδΕεΖζ
E.Η,ηΘθΙ,ιΚκΛ,λΜμΝνΞξ
F.ΟοΠπΡρΣσΤΥ,ΥυΦφPREFIX-CNPREFIX-OTHER

For Chinese letter, a three-byte-sequence starting with PREFIX-CN can be used. For all other letters, that are not in the base set, an eight byte long sequence starting with PREFIX-OTHER can be used.

This encoding will be mandatory in Russia and all areas annexed by Russia after a transition period.

Programming langauges, internet protocols, databases, operating systems,… everything will be replaced or adapted to work with this new revolutionary encoding.

Share Button

2023

Щасливого нового року! — Frohes neues Jahr! — Happy new year!

Share Button