Category: Other stuff

Is Tiobe Index misinformation?

Is Tiobe Index misinformation?

news, false, conceptEvery month a new Tiobe Index is published purporting to show the most popular programming languages. Except, if you look at other programming language popularity surveys, lists etc, the Tiobe Index increasingly seems to be at odds with everybody else.

Take the programming language C. As you can imagine I have a particular interest in it. I was at first delighted when I saw it at #3 in the Tiobe Index. In fact, in their most recent index it is listed as the 2nd most popular programming language. Well that is just crazy. No matter how much I might want it, there is no way on Earth that it is the 2nd most popular programming language.

It’s not just me saying it. Let’s look at who else says it.

SiteC's RankingComments
Tiobe Index2Updated monthly
GitHub Octoverse Programming languages9Annually- this is October 2022
Reddit Programming languages10Subreddits for programming languages
Red Monk Programming Language Rankings10June 2022. Updated every 6 months
StackOverflow developer survey11Annually
Statista most used programming languages 202211
Hackerrank Developer skills report 202312

There are other programming language lists or surveys but those show what I mean.  No one else has C anywhere that high. Here it’s in positions 9-12 with an average roughly around 10.5 if you exclude Tiobe or 9.3 if you don’t.  I think their methodology is flawed and biased by age. Older languages appear to carry more weight.

Never mind C, what about JavaScript? Everyone else has it in first place (except HackerRank who has it in 4th). Tiobe index has it in 7th. Misinformation is defined as “false information that is spread, regardless of intent to mislead.”. Maybe that’s a bit harsh but that’s how I regard the Tiobe Index.

A New PC

A New PC

Computer monitors
Image by Gerd Altmann from Pixabay

Moving to a new PC can be a time consuming process. This is my 10th PC since 1989 and I’ve been accumulating files, old programs, websites, manuals etc. as I moved from PC to PC. My first PC had a 20 MB disk, the 2nd PC had a hard disk with 240 MB capacity. On my new PC it’s 10 TB and 1 TB SSD.

It’s another i7 but 11th Gen Intel(R) Core(TM) i7-11700K. Only 32 GB RAM for now as they didn’t have 64 GB in stock but the motherboard can go up to 128 GB.

I estimated that I had accumulated just over 2 TB of my stuff and once I got my new PC setup started the process of moving files across. 2 TB seems a lot but VMs under Hyper-V can easily eat up a few hundred GBs.

Both PCs had a gigabit network card and were plugged into a gigabit switch so what speed did it give me? 11 MB/S. That’s not gigabit speed which would be about 1000 MB/s but closer to 100 Mbs. Trouble was the switch was plugged into a router and I think that pulled things down. I borrowed a crossover cable. Setup both Pcs with static IP and connected them directly. That was much better and it was soon maxing out at 112 MBs.

Windows of course put its spoke in. If you are copying large files- anything over about 1 MB then it uses the full bandwidth but smaller files pull it down and I’d see as slow as KB/s speeds. So I’d have three or four files copying at the same time.

As well as just copying files to the new PC, I was cleaning up my old PC to sell it so I was either deleting stuff or moving it. Overall my total elapsed time was something like 28 hours over four days and evenings. Plus of course installing software (Visual Studio, VS Code, Android Studio, MS Office). It all takes time. Luckily I’ve been quite disciplined and kept all licences and serial numbers in an encrypted text file.

Then I discovered that my new PC’s video cards had different connectors. My old one had DVIs but this one I could only find an HDMI and 2 DisplayPorts. There was a DVI connector on the video card but the firm that did it put the card in the top slot and the DVI (2nd row) was covered up by a blanking plate! It’s a RTX 2060 card. I removed it and all was well.

RTX 2060

Is variable++ faster than ++variable?

Is variable++ faster than ++variable?

TimingsOne of the things I as told when I learnt C++ and then later C was that a post-inc (i.e. variable++) was faster than a pre-inc i.e. ++variable. Frankly I’m not sure if it is really true but its not a difficult thing to test.

Here’s a short program

#include <stdio.h>
#include "hr_time.h"

#define NUMLOOPS 100000000

int main() {
  stopWatch s;
  startTimer(&s);
  int j=0;
  for (int i=0;i<NUMLOOPS;i++){
    ++j;
  }
  stopTimer(&s);
  printf("PreInc = %10.5f\n",diff(&s));

  startTimer(&s);   
  j=0;
  for (int i=0;i<NUMLOOPS;i++){
    j--;
  }
  stopTimer(&s);
  printf("PostInc = %10.5f\n",diff(&s));  
}

You can get the siurce code including hr_time.h and .c from the timings.zip file on GitHub. I used VS Code with clang to build this on Ubuntu. Here is the tasks.json file to build it. It assumes that the file is in your workspace folder and creates a file called ex1. The timings.zip file contains the json files as well.

{
    "version": "2.0.0",
    "tasks": [
        {
            "type": "shell",
            "label": "clang build active file",
            "command": "/usr/bin/clang",
            "args": [
                "-g",
                "${file}","${workspaceFolder}/hr_time.c",              
                "-o",
                "${fileDirname}/ex1",                
                "-lm"
            ],
            "options": {
                "cwd": "/usr/bin"
            },
            "group": {
                "kind": "build",
                "isDefault": true
            }
        }
    ]
}

Ignore the first three runs which were for 10 million not 100 million. All do indeed show that post-inc is indeed faster. Not by a great margin but each of the last 100 million loops takes between 94% and 96% of the preinc time.

Cling – an interactive C++ interpreter

Cling – an interactive C++ interpreter

Computer screen
Image by Markus Spiske from Pixabay

When I first learned to program back in 1976, I had a teletype and a BASIC interpreter. Apart from a couple of years writing BASIC programs in my first job, all my work after that was with compilers.

So I’m a bit rusty with interpreters. The idea is that the interpreter reads a line of code and then executes it; parsing it and calling various routines to execute statements and parse then evaluate expressions. It’s kind if unusual to do this with C++. Cling is built on the top of LLVM and Clang libraries.

This is different to sites like repl.it, codepad.org or ideone.com; they compile the whole program and run it. With an interpreter, it runs line by line and you can print out variables at any time.  Interpreters are probably more like debuggers.

As well as C++, cling can execute C, Objective-C and that even less used language Objective-C++.  Developed at Cern it has a very extensive set of tutorials.

Nearly finished translating asteroids to C++

Nearly finished translating asteroids to C++

Asteroids screenshotI always wanted to do this and have most of it done. It just needs a bit of polishing plus making it cross-platform. It wasn’t the hardest  thing I’ve done although I did start by trying to make the common part for asteroids, player ship, bullets and aliens, the bit that managed position and velocity into a base class.

I then spent a day wrestling with the compiler trying to access this in those methods that used this and in the end found it easier to make it into its own class and had an instance of it in each of the classes. I.e. using composition rather than inheritance.

Rewriting in C++ made things like saving high scores to disk and reloading a bit simpler using C++ strings.  Now I just have to get my main PC up and running and then polish the code and publish it on GitHub.

 

 

 

An interesting project- Converting BASIC Computer Games

An interesting project- Converting BASIC Computer Games

Basic Computer games bookYes it’s that book again, one I have mentioned a few times.  Now there’s a project to convert all of the games from the book into C#, Java, JavaScript, Python, Ruby and VB.NET. As with all Git sites, you can download all code from the site in a zip file or individual files. So far though its very early in the project and there’s only a .BAS file in each of the subfolders for each of the games in the book. If you fancy getting involved, pick a game, a language and start coding. Sadly there’s no desire for C or C++ but that still leaves C# .

I still have this book and its sequel (More BASIC Computer games!) but to be honest I wouldn’t have bothered with most of the games in either book. They are all very much of the era (1978) which was just on the cusp of the home computer revolution and so were mostly obsolete within seven or eight years, due mainly to the terminal I/O. They’re ok for learning programming and of course you could run them in a Linux terminal.

Learning a programming language is not so easy

Learning a programming language is not so easy

Never stop learning
Image by Gerd Altmann from Pixabay

When I started, back in the dark ages there weren’t many programming languages about. It was a choice of BASIC, Fortran, C, Pascal and Cobol or some obscure languages apl, lisp, snobol etc. At Uni I learnt BASIC in first year then Pascal. We touched on Cobol in one course, enough to put me off it for life. We also did one semester on assembly language for a 6800 CPU. That was fun and probably helped me to learn 6502 and Z80 a few years later.,

Back then once I started learning other languages, it was long before the web existed. Programming languages came with manuals – user guides, reference guides. So you could learn enough to get started and then dip into the reference guide as and when you needed.

But since the Web appeared, the manuals no longer exist as printed books. But what I’ve noticed is, it gets harder to acquire a new technology if you are not working in it fulltime. I learnt PHP and HTML twenty years ago and reinforced that learning by creating websites. But now technologies like Blazor and ASP.NET MVC are quite a bit more complicated.  I’m doing  Udemy course on Blazor with over 200 lessons (most about 5 minutes long) and have only got up to lesson 55. Finding the time is probably one of the hardest things.

C is probably one of the easiest programming languages to learn but any other language or complicated technology is going to take a lot longer. I think It should be easier. There is an immense amount of free material on the web including sites to pose questions (StackOverflow), low cost courses (Udemy), free videos (Youtube) and yet it doesn’t seem easier.  Back pre-web you had to pay for programming languages. But unless you are a student or have a lot of spare time to study, it can be slow learning new stuff.

 

Interesting number sequence

Interesting number sequence

Chess Set
Image by Clker-Free-Vector-Images from Pixabay

Here’s an interesting puzzle (well for some people). If I have the integers 4,5,6,7 and 8 and a special C function f so that f(4)=2, f(5) = 5, f(6)=10, f(7)=40 and f(8) = 92. What is the function f? And no it’s not a simple array containing the numbers 2,5,10,40,92 at positions 4-8!

I also checked the OEIS (Online Encyclopaedia of Integer sequences) and it’s not in there either. Years ago I was fooled by a integer sequence that was the maximum number of electrons in orbital shells but its definitely not that.

Here’s a minor clue. It is game related. Answer in a day or two.

PagedOut a technical programming magazine

PagedOut a technical programming magazine

PagedOut Issue 1 frontcoverIt’s not often that I recommend somebody else but when I see something that I think deserves it, I’m happy to. PagedOut is a free experimental (one article == one page) technical magazine about programming (especially programming tricks!), hacking, security hacking, retro computers, modern computers, electronics, demoscene, and other similar topics. That’s their description! It’s published by Gynvael Coldwind, an IT Security engineer at Google.

It isn’t game related and not totally C oriented. In fact there are currently only two issues out, downloadable as PDFs and the second one has half a dozen C articles but the first issue has none.  There’s a bit of C++, Python, Go and some other stuff including assembly and the content varies enormously and is mostly Linux oriented but there is a bit Windows as well.

The big thing is that each article is just one page long. That’s by design. They accept submissions from anyone, subject to their standards and review but it must fit in one page.

I’ve always had a bit of a hacker mentality going back to when I crashed a mainframe (twice) at University. I didn’t mean to honest….  Being naturally inquisitive I think has helped me as a professional programmer.

 

An uncensored alternative to GitHub

An uncensored alternative to GitHub

Digital cash
Image by WorldSpectrum from Pixabay

I use GitHub a lot, I’ll be the first to admit it but there have been recent cases where GitHub has censored projects because of the US DMCA law ((I’m in the UK so different laws apply here but GitHub is in the US and being owned by Microsoft is not going to ignore the law) so radicle offers a er radical alternative.

It uses Peer to Peer thus avoiding needing servers which can be seized.  People share a bit of their bandwidth and storage and act as anonymous servers; I suspect you don’t see or have any access to stuff stored on your computer. It uses digital cash so those with lot of bandwidth and storage can do more hosting and receive payment from those who are using it.  I’ve seen Ethereum mentioned for 2021 but I think it uses Electron having looked at the community pages.

Slightly ironically, the project is currently hosted on GitHub!  

Am I going to switch to it? Not yet but in the future, who knows?