Author Topic: TIOBE Index of programming languages  (Read 10823 times)

0 Members and 4 Guests are viewing this topic.

Offline Siwastaja

  • Super Contributor
  • ***
  • Posts: 9475
  • Country: fi
Re: TIOBE Index of programming languages
« Reply #125 on: January 07, 2025, 03:38:32 pm »
I didn't choose Python because...

Wait a minute, you chose Python? What does this even mean? Chose for what, to do what?
 

Offline PicuinoTopic starter

  • Super Contributor
  • ***
  • Posts: 1084
  • Country: es
    • Picuino web
Re: TIOBE Index of programming languages
« Reply #126 on: January 07, 2025, 04:20:44 pm »
At that time I had to validate a program written with visual blocks to control hundreds of emergency stop buttons. Being visual programming, the program was done manually and validated manually, so it could have failures due to human error.
The fact is that the Siemens visual programming tool used a Pascal-like language (SCL) as an intermediate language to compile later to a PLC.

It occurred to me that the SCL code generated automatically by the tool could be used to validate that all signals ended up generating a safety stop. This involved interpreting the code written in high-level SCL language to apply several validation tests to rule out errors that might have been missed in the visual and field tests.

I wrote the code validation program in Python with a tendency to be very sensitive to any errors and report them. The result was a long list of errors that we had to subsequently validate manually. Most were due to non-standard cases, but they worked fine. We also found a couple of signal connection errors that had been overlooked, which thanks to the Python validation program we were able to correct.

So the first application I used Python for was SCL code validation for a safety PLC.

SCL: https://en.wikipedia.org/wiki/Structured_Control_Language
PLC: https://en.wikipedia.org/wiki/Programmable_logic_controller
« Last Edit: January 07, 2025, 04:23:07 pm by Picuino »
 

Offline PicuinoTopic starter

  • Super Contributor
  • ***
  • Posts: 1084
  • Country: es
    • Picuino web
Re: TIOBE Index of programming languages
« Reply #127 on: January 08, 2025, 07:59:14 am »
At first I tried to make the tool with AWK, which I already knew, but AWK was not powerful enough.
Then I considered switching to Perl, but after struggling several days with this language, a colleague recommended me to talk to the team in charge of summarizing and presenting the daily commissioning data, which was using Python. After talking to them they convinced me and I ended up choosing Python to develop the validation program.

Attached is the popularity index of that time.
https://web.archive.org/web/20040605110328/http://www.tiobe.com/
« Last Edit: January 08, 2025, 08:13:43 am by Picuino »
 

Offline PicuinoTopic starter

  • Super Contributor
  • ***
  • Posts: 1084
  • Country: es
    • Picuino web
Re: TIOBE Index of programming languages
« Reply #128 on: January 08, 2025, 06:15:12 pm »
Python macro to extract Tiobe Index image of 20 first languages from the web.

Code: [Select]
import os
import time
import datetime
from PIL import Image
from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from webdriver_manager.chrome import ChromeDriverManager
from selenium.webdriver.common.action_chains import ActionChains
from selenium.webdriver.common.by import By


browser_width = 600
browser_height = 1000
image_width = browser_width - 35
image_1_height = 650
image_2_height = 490
first_scroll = 780
tiobe_index_url = "https://www.tiobe.com/tiobe-index/"


def main():
    year_month = datetime.datetime.now().strftime("%Y_%m")
    print(f'Date: {year_month}')

    image_name_1 = f'tiobe_index_{year_month}_a.png'
    image_name_2 = f'tiobe_index_{year_month}_b.png'
    image_name_3 = f'tiobe_index_{year_month}.png'

    extract_images(image_name_1, image_name_2)
    join_images(image_name_1, image_name_2, image_name_3)


def join_images(image_name_1, image_name_2, image_name_3):
    if os.path.exists(image_name_3):
        return

    margin_top = 80
   
    im_1 = Image.open(image_name_1)
    im_2 = Image.open(image_name_2)
    im_3 = Image.new('RGB', (image_width, image_1_height + image_2_height), 'white')

    im_1_crop = im_1.crop((0, margin_top, image_width, margin_top + image_1_height))
    im_2_crop = im_2.crop((0, margin_top + 2, image_width, margin_top + 2 + image_2_height))

    im_3.paste(im_1_crop, (0, 0))
    im_3.paste(im_2_crop, (0, image_1_height))

    im_3.save(image_name_3)


def extract_images(image_name_1, image_name_2):
    if os.path.exists(image_name_2):
        return

    driver = webdriver.Chrome(service=Service(ChromeDriverManager().install()))
    driver.get(tiobe_index_url)
    driver.set_window_size(browser_width, browser_height)
    time.sleep(5)

    element = driver.find_element(By.LINK_TEXT, 'here')
    actions = ActionChains(driver)
    actions.move_to_element(element).perform()

    driver.execute_script(f'window.scrollTo(0, window.scrollY + {first_scroll})')
    time.sleep(1)
    driver.save_screenshot(image_name_1)

    driver.execute_script(f'window.scrollTo(0, window.scrollY + {image_1_height})')
    time.sleep(1)
    driver.save_screenshot(image_name_2)

    driver.quit()


main()

You must click “Allow All” or “Deny” cookies when the banner appears. The program waits 5 seconds for it.
The rest of the operation is automatic.
« Last Edit: January 08, 2025, 06:31:17 pm by Picuino »
 

Offline Siwastaja

  • Super Contributor
  • ***
  • Posts: 9475
  • Country: fi
Re: TIOBE Index of programming languages
« Reply #129 on: January 08, 2025, 07:36:27 pm »
That's an interesting story. Sounds like an application for which many languages work, but not all very well and some are more horrible than others. Domain-specific languages like AWK are, as name suggests, specific to a domain, so work very well for a certain thing but not general purposes. Some languages like Perl or TCL apparently give PTSD to many; they are something very few chose to use, but had to use them because of external requirements (e.g., Perl as the only server-side web language in some configurations near the turn of millennium, or TCL as the only scripting language supported by some EDA tooling).

Python seems to enjoy quite wide acceptance by actual software developers choosing it because they like it, not because it's the only possibility. I don't really understand all the hype, but yeah sure, it is good enough and the shortcomings are not too disastrous. (I don't like the v2/v3 incompatibility mess and the usual library maintainability mess such that everything breaks all the time because library interfaces change for every version and you need to basically dockerize Python interpreter plus libraries with certain versions, but it seems every other popular language (like Rust) do the same and people just accept this as being the new normal. I guess it's the price you need to pay for non-ancient library interfaces. C standard library is stable and standardized, but very old and poorly thought out initially so you need to implement many small and trivial things for yourself from scratch.)
« Last Edit: January 08, 2025, 07:38:52 pm by Siwastaja »
 

Offline PicuinoTopic starter

  • Super Contributor
  • ***
  • Posts: 1084
  • Country: es
    • Picuino web
Re: TIOBE Index of programming languages
« Reply #130 on: January 09, 2025, 10:39:56 am »
Yes, there should be a middle ground between standardization and actuality.
Python's lack of standardization is a headache. For my website I have made a "virtual environment" with versions from years ago, which I don't update because it breaks compatibility with the version of theme that is customized. Recently I wanted to install a new library (rst2pdf) to print the whole web page to PDF, but the new version of the Jinja2 library is incompatible with the old version of Sphinx.
So, I've decided to upgrade all the libraries (Sphinx, Read the Docs, rst2pdf, etc) to a current version and customize the theme (Read the Docs) again. It is a tedious and laborious work that can leave errors in the web site until I correct them all, but it has been more than 10 years since I last upgraded the libraries and an update is needed.
« Last Edit: January 09, 2025, 10:47:37 am by Picuino »
 

Offline SiliconWizard

  • Super Contributor
  • ***
  • Posts: 15948
  • Country: fr
Re: TIOBE Index of programming languages
« Reply #131 on: January 11, 2025, 12:04:56 am »
Yeah, let's have some fun.
 

Offline PicuinoTopic starter

  • Super Contributor
  • ***
  • Posts: 1084
  • Country: es
    • Picuino web
Re: TIOBE Index of programming languages
« Reply #132 on: January 11, 2025, 02:15:36 pm »
There is a saying that explains it well: "People only throw stones at the tree with fruit".

Concerning Perl, nobody tell anything.
« Last Edit: January 11, 2025, 02:42:30 pm by Picuino »
 

Offline Siwastaja

  • Super Contributor
  • ***
  • Posts: 9475
  • Country: fi
Re: TIOBE Index of programming languages
« Reply #133 on: January 11, 2025, 03:15:21 pm »
Concerning Perl, nobody tell anything.

It's nearly forgotten now, that's why. I remember that still 10 years ago one could hear comments like "thank God I don't have to deal with Perl anymore".

I have never written more than a few lines of Perl myself, so I don't really understand why it is considered such horrible language; on surface, it does not look like one; in fact I see a lot of similarity with Python. But I guess the fact that most were happy to replace it with PHP tells a sad story.
 

Offline brucehoult

  • Super Contributor
  • ***
  • Posts: 4840
  • Country: nz
Re: TIOBE Index of programming languages
« Reply #134 on: January 11, 2025, 11:29:02 pm »
Concerning Perl, nobody tell anything.

It's nearly forgotten now, that's why. I remember that still 10 years ago one could hear comments like "thank God I don't have to deal with Perl anymore".

I have never written more than a few lines of Perl myself, so I don't really understand why it is considered such horrible language; on surface, it does not look like one; in fact I see a lot of similarity with Python. But I guess the fact that most were happy to replace it with PHP tells a sad story.

I don't get it. I like Perl. There is a certain class of problem -- generally quite small programs -- for which it is excellent.

Here's a Perl program I wrote: https://hoult.org/logbook

It processes a file like this ....

Code: [Select]
serial date rego hours minutes launch crew comment
1 07/09/85 KN 15 A P2
2 07/09/85 KN 20 A P2
3 07/09/85 KN 15 A P2
4 28/09/85 HW 59 A P2
5 29/09/85 HW 1 4 A P2
6 20/10/85 KN 16 A P2
7 20/10/85 KN 16 A P2
8 20/10/85 KN 15 A P2
9 17/11/85 KN 18 A P2

... and a file like this ...

Code: [Select]
rego type
274KS ASK21
EX Ka6CR
EY Ka6CR
DG DG1000
FQ T53
FY ASK13
GA Phoebus C
GZ Std Libelle
HT Blanik

... both easily edited in any spreadsheet or text editor, into this ...

Code: [Select]
Logbook stats from flight 1 to 9999


Glider  Flights  Total     PIC
======  ======= ======  ====== 
LM      81       70:51   64:09
IP      36       56:55   56:55
PJ      76       45:13   44:21
GR      87       44:43   44:13
EX      19       25:24   25:24
KN      56       24:13   12:49
WN      18       19:39   19:39
HT      32       12:18    8:46
GZ      9         9:32    9:32
WZ      12        9:06    7:58
HW      16        7:33    3:54
TA      20        7:24    5:46
WG      7         6:39    6:39
274KS   6         2:42    2:42
DG      1         2:30    0:00
MS      4         2:09    2:09
NE      2         2:00    2:00
LV      16        1:52    0:14
IJ      3         1:32    1:15
NW      5         1:31    0:00
N4793N  1         1:13    1:13
N57CG   1         1:07    0:00
PC      1         1:02    0:00
EY      2         1:02    1:02
SH      2         0:46    0:43
N999KS  1         0:45    0:45
FY      6         0:38    0:28
FQ      1         0:37    0:00
NP      1         0:35    0:00
IN      1         0:34    0:00
GA      1         0:33    0:33
MY      1         0:30    0:00
JT      1         0:19    0:19
KW      1         0:09    0:00


Glider Type     Flights  Total     PIC  Avg
=============== ======= ======  ======  ===     
DG1000          164      92:26   88:34  34
Janus           83       71:37   64:52  52
Club Libelle    36       56:55   56:55  95
Blanik          110      46:56   27:38  26
Ka6CR           21       26:26   26:26  76
PW-5            25       26:18   26:18  63
Grob 103        37       20:48   16:57  34
Std Libelle     9         9:32    9:32  64
ASK21           7         3:27    3:27  30
ASK13           9         2:10    1:43  14
Ka7             16        1:52    0:14  7
Grob 109        5         1:31    0:00  18
Duo Discus      1         1:07    0:00  67
Puchacz         1         1:02    0:00  62
T53             1         0:37    0:00  37
Phoebus C       1         0:33    0:33  33
Pirat           1         0:19    0:19  19


Crew    Flights   Time  Avg
====    ======= ======  ===     
P       93      120:03  77
P1      321     203:25  38
P2      113      40:08  21


Launch  flights
======  =======
A       496
S       5
W       26

Total flights: 527
Total Time   : 363:36
Total PIC    : 323:28
 

Offline SiliconWizard

  • Super Contributor
  • ***
  • Posts: 15948
  • Country: fr
Re: TIOBE Index of programming languages
« Reply #135 on: January 11, 2025, 11:54:24 pm »
There is a saying that explains it well: "People only throw stones at the tree with fruit".

Concerning Perl, nobody tell anything.

I don't know about "nobody", but this guy also has a comedy sketch for Perl programmers:

 

Offline PicuinoTopic starter

  • Super Contributor
  • ***
  • Posts: 1084
  • Country: es
    • Picuino web
Re: TIOBE Index of programming languages
« Reply #136 on: January 12, 2025, 09:15:02 am »
I prefer Python code.
I know it is slower, but it is much easier to read.

Code: [Select]
import sys
from collections import defaultdict

start_flight = int(sys.argv[1]) if len(sys.argv) > 1 else 1
end_flight = int(sys.argv[2]) if len(sys.argv) > 2 else 9999

print(f"Logbook stats from flight {start_flight} to {end_flight}")

def get_file(filename):
    data = defaultdict(dict)
    with open(filename, 'r') as f:
        headers = f.readline().strip().split("\t")
        for line in f:
            fields = line.strip().split("\t")
            for i, field in enumerate(fields):
                data[fields[0]][headers[i]] = field
    return data

def print_header(*args):
    print("\n\n" + "\t".join(args))
    print("\t".join("=" * len(arg) for arg in args))

def hhmm(minutes):
    hh = minutes // 60
    mm = minutes % 60
    return f"{hh:3}:{mm:02}"

flights = get_file("flights")
gliders = get_file("gliders")

total_flights = 0
total_time = 0
total_time_pic = 0

by_glider = defaultdict(lambda: defaultdict(int))
by_type = defaultdict(lambda: defaultdict(int))
by_crew = defaultdict(lambda: defaultdict(int))
by_launch = defaultdict(int)

for f in flights.values():
    serial = int(f['serial'])
    time = int(f['hours']) * 60 + int(f['minutes'])
   
    if serial < start_flight or serial > end_flight:
        continue

    crew = f['crew']
    pic_time = time if crew != "P2" else 0
    rego = f['rego']
    glider = gliders[rego]
    glider_type = glider['type']
    launch = f['launch']

    total_flights += 1
    total_time += time
    total_time_pic += pic_time

    by_glider[rego]['flights'] += 1
    by_glider[rego]['time'] += time
    by_glider[rego]['timePIC'] += pic_time

    by_type[glider_type]['flights'] += 1
    by_type[glider_type]['time'] += time
    by_type[glider_type]['timePIC'] += pic_time

    by_crew[crew]['flights'] += 1
    by_crew[crew]['time'] += time

    by_launch[launch] += 1

print_header("Glider", "Flights", " Total", "   PIC")
for rego in sorted(by_glider, key=lambda k: by_glider[k]['time'], reverse=True):
    print(f"{rego}\t{by_glider[rego]['flights']}\t"
          f"{hhmm(by_glider[rego]['time'])}\t"
          f"{hhmm(by_glider[rego]['timePIC'])}")

print_header("Glider Type    ", "Flights", " Total", "   PIC", "Avg")
for glider_type in sorted(by_type, key=lambda k: by_type[k]['time'], reverse=True):
    avg = int(by_type[glider_type]['time'] / by_type[glider_type]['flights'] + 0.5)
    print(f"{glider_type:<15}\t{by_type[glider_type]['flights']}\t"
          f"{hhmm(by_type[glider_type]['time'])}\t"
          f"{hhmm(by_type[glider_type]['timePIC'])}\t{avg}")

print_header("Crew", "Flights", "  Time", "Avg")
for crew in sorted(by_crew):
    avg = int(by_crew[crew]['time'] / by_crew[crew]['flights'] + 0.5)
    print(f"{crew}\t{by_crew[crew]['flights']}\t"
          f"{hhmm(by_crew[crew]['time'])}\t{avg}")

print_header("Launch", "Flights")
for launch in sorted(by_launch):
    print(f"{launch}\t{by_launch[launch]}")

print(f"\nTotal flights: {total_flights}")
print(f"Total Time   : {hhmm(total_time)}")
print(f"Total PIC    : {hhmm(total_time_pic)}")
« Last Edit: January 12, 2025, 09:57:13 am by Picuino »
 

Offline brucehoult

  • Super Contributor
  • ***
  • Posts: 4840
  • Country: nz
Re: TIOBE Index of programming languages
« Reply #137 on: January 12, 2025, 10:42:49 am »
I prefer Python code.
I know it is slower, but it is much easier to read.

Possibly, but it doesn't like interpreting an empty string as an integer

Code: [Select]
  File "/Users/bruce/people/bruce/gliding/logbook/calc.py", line 42, in <module>
    time = int(f['hours']) * 60 + int(f['minutes'])
           ~~~^^^^^^^^^^^^
ValueError: invalid literal for int() with base 10: ''

Which version of Python is required to run that code? Does it need 3, or will 2 do?
 

Online Nominal Animal

  • Super Contributor
  • ***
  • Posts: 7312
  • Country: fi
    • My home page and email address
Re: TIOBE Index of programming languages
« Reply #138 on: January 12, 2025, 01:15:11 pm »
Code: [Select]
  File "/Users/bruce/people/bruce/gliding/logbook/calc.py", line 42, in <module>
    time = int(f['hours']) * 60 + int(f['minutes'])
           ~~~^^^^^^^^^^^^
ValueError: invalid literal for int() with base 10: ''
Try
    time = int('0' + f['hours'], 10) * 60 + int('0' + f['minutes'], 10)
or
    time = int('0' + f.get('hours', ''), 10) * 60 + int('0' + f.get('minutes', ''), 10)
instead.

I personally prefer awk for these.  It was designed for this kind of thing, after all.  (You will want to read all but the largest data file in BEGIN handler, though.)

My personal avoidance of Perl stems from having had to maintain/extend/support a horrible Perl web service code base for a few years, written by people I really do like.  I'm a simple man, and don't deal well with such complicated emotions! :D

The reason for many switching from Perl to PHP for server-side scripting was more due to PHP providing a cgi interpreter and web hotels providing PHP backends, and PR work by the Zend and PHP folks, than anything else.  Of course, many more learners were drawn toward PHP (instead of Perl) because of the perceived ease of use of PHP compared to Perl; Perl syntax is much more dense/varied/detailed than PHP's, which is quite close to BASIC or C in its (lack of) complexity.  (I mean, compare the complexity of the lexers/parsers for these languages.)
« Last Edit: January 12, 2025, 01:21:18 pm by Nominal Animal »
 

Offline PicuinoTopic starter

  • Super Contributor
  • ***
  • Posts: 1084
  • Country: es
    • Picuino web
Re: TIOBE Index of programming languages
« Reply #139 on: January 12, 2025, 02:50:36 pm »
I used to program a lot of tasks in AWK before I learned Python. Then, to help learn Python, I dropped AWK. I often miss it for its simplicity and power in this type of task. The problem is that I haven't used it in years and I'm very rusty on AWK.
 

Offline SiliconWizard

  • Super Contributor
  • ***
  • Posts: 15948
  • Country: fr
Re: TIOBE Index of programming languages
« Reply #140 on: January 12, 2025, 10:00:04 pm »
It looks like the examples you gave can be written using Lua with relative ease, without the hundreds of MB, all the headaches due to dependencies and the whitespace nonsense. And much easier to read than Perl.
But Lua is not in TIOBE's top 20, so I guess it's off-limits.
 

Offline PicuinoTopic starter

  • Super Contributor
  • ***
  • Posts: 1084
  • Country: es
    • Picuino web
Re: TIOBE Index of programming languages
« Reply #141 on: January 12, 2025, 10:18:30 pm »
Lua is great!
Position 27 of Tiobe index in january, 2025.
It has few libraries, which is its weak point.


Code: [Select]
January 2025 Tiobe Index. Other programming languages.
21 Prolog               0.92%
22 Classic Visual Basic 0.89%
23 SAS                  0.79%
24 Lisp                 0.75%
25 Kotlin               0.74%
26 Ada                  0.65%
27 Lua                  0.59%
28 (Visual) FoxPro      0.55%
29 Transact-SQL         0.54%
30 Scala                0.49%
31 Julia                0.49%
32 Perl                 0.49%
33 Dart                 0.48%
34 Haskell              0.46%
35 Objective-C          0.36%
36 VBScript             0.33%
37 Bash                 0.29%
38 ABAP                 0.27%
39 Solidity             0.26%
40 GAMS                 0.24%
41 PowerShell           0.22%
42 TypeScript           0.22%
43 PL/SQL               0.22%
44 Elixir               0.18%
45 D                    0.16%
46 Logo                 0.16%
47 RPG                  0.15%
48 Awk                  0.15%
49 ML                   0.15%
50 X++                  0.15%


The following list of languages denotes #51 to #100.
Since the differences are relatively small,
the programming languages are only listed
(in alphabetical order).

ABC, ActionScript, Algol, Apex, APL, CFML,
CHILL, Clipper, CLIPS, Clojure, Curl, Elm,
Erlang, F#, Forth, Groovy, Hack, Icon, Inform,
Io, J#, JScript, LabVIEW, Ladder Logic,
Modula-2, Mojo, MQL5, NATURAL, Nim,
OCaml, Occam, OpenCL, OpenEdge ABL,
PL/I, PostScript, Q, Ring, S, Scheme,
Simulink, Smalltalk, SPARK, SPSS, Stata,
SystemVerilog, Tcl, Vala/Genie, VHDL,
Wolfram, Zig
« Last Edit: January 14, 2025, 06:06:19 am by Picuino »
 

Offline brucehoult

  • Super Contributor
  • ***
  • Posts: 4840
  • Country: nz
Re: TIOBE Index of programming languages
« Reply #142 on: January 12, 2025, 11:18:16 pm »
    time = int('0' + f['hours'], 10) * 60 + int('0' + f['minutes'], 10)

That's simpler than the ternary operator I was thinking of, which is rather verbose in Python.

Though it looks to me as if this Perlish idiom works too:

    time = int(f['hours'] or 0) * 60 + int(f['minutes'] or 0)

Quote
I personally prefer awk for these.  It was designed for this kind of thing, after all.  (You will want to read all but the largest data file in BEGIN handler, though.)

Perl is strictly more powerful than awk. All awk scripts can be trivially converted to Perl, and indeed Perl has always come with converters for awk and sed.

I'm not sure, but I may have written this Perl script before Python existed, or at least became popular. Certainly before Python 2. It could well have been in 1992 when I started flying a lot more, and in different types of aircraft (Ka6, Libelle).
« Last Edit: January 12, 2025, 11:23:35 pm by brucehoult »
 

Online DiTBho

  • Super Contributor
  • ***
  • Posts: 4461
  • Country: gb
Re: TIOBE Index of programming languages
« Reply #143 on: January 13, 2025, 12:07:18 am »
On Gentoo, talking about Catalyst:
Perl is more problematic than awk.
Python is more problematic than Perl.

Awk is faster than Perl.
Perl is faster than Python.

Conclusion: I prefer awk scripts  :D
The opposite of courage is not cowardice, it is conformity. Even a dead fish can go with the flow
 

Offline PicuinoTopic starter

  • Super Contributor
  • ***
  • Posts: 1084
  • Country: es
    • Picuino web
Re: TIOBE Index of programming languages
« Reply #144 on: January 13, 2025, 06:19:41 pm »
This is ChatGPT's translation of the Perl program into AWK language. I think you can easily see the difference with Python and why I didn't go back to using AWK.

Code: [Select]
BEGIN {
    # Initialize variables
    startFlight = ARGV[1] ? ARGV[1] : 1
    endFlight = ARGV[2] ? ARGV[2] : 9999
    totalFlights = 0
    totalTime = 0
    totalTimePIC = 0

    print "Logbook stats from flight " startFlight " to " endFlight

    # Function to format time in hh:mm
    function hhmm(minutes) {
        hh = int(minutes / 60)
        mm = minutes % 60
        if (hh < 10) hh = "0" hh
        if (mm < 10) mm = "0" mm
        return hh ":" mm
    }

    # Read the flights file
    while ((getline < "flights") > 0) {
        split($0, fields, "\t")
        flightData[fields[1]] = fields
    }

    # Read the gliders file
    while ((getline < "gliders") > 0) {
        split($0, fields, "\t")
        gliderData[fields[1]] = fields
    }
}

# Process each flight
{
    flight = $0
    flightDetails = flightData[$1]  # Get flight details
    if (flightDetails == "") next  # If no data, skip this line

    serial = flightDetails[1]
    time = flightDetails[2] * 60 + flightDetails[3]
    if (serial < startFlight || serial > endFlight) next

    crew = flightDetails[4]
    PICtime = (crew != "P2") ? time : 0
    rego = flightDetails[5]
    glider = gliderData[rego]
    type = glider[1]
    launch = flightDetails[6]

    totalFlights++
    totalTime += time
    totalTimePIC += PICtime

    # Track data by glider
    byGlider[rego, "flights"]++
    byGlider[rego, "time"] += time
    byGlider[rego, "timePIC"] += PICtime

    # Track data by glider type
    byType[type, "flights"]++
    byType[type, "time"] += time
    byType[type, "timePIC"] += PICtime

    # Track data by crew
    byCrew[crew, "flights"]++
    byCrew[crew, "time"] += time

    # Track data by launch type
    byLaunch[launch]++
}

END {
    # Print data by glider
    print "\n\nGlider", "Flights", " Total", "   PIC"
    for (glider in byGlider) {
        if (byGlider[glider, "time"] > 0) {
            printf "%s\t%d\t%s\t%s\n",
                glider,
                byGlider[glider, "flights"],
                hhmm(byGlider[glider, "time"]),
                hhmm(byGlider[glider, "timePIC"])
        }
    }

    # Print data by glider type
    print "\n\nGlider Type", "Flights", " Total", "   PIC", "Avg"
    for (type in byType) {
        if (byType[type, "time"] > 0) {
            avg = int(byType[type, "time"] / byType[type, "flights"] + 0.5)
            printf "%-15s\t%d\t%s\t%s\t%d\n",
                type,
                byType[type, "flights"],
                hhmm(byType[type, "time"]),
                hhmm(byType[type, "timePIC"]),
                avg
        }
    }

    # Print data by crew
    print "\n\nCrew", "Flights", "  Time", "Avg"
    for (crew in byCrew) {
        avg = int(byCrew[crew, "time"] / byCrew[crew, "flights"] + 0.5)
        printf "%s\t%d\t%s\t%d\n",
            crew,
            byCrew[crew, "flights"],
            hhmm(byCrew[crew, "time"]),
            avg
    }

    # Print data by launch type
    print "\n\nLaunch", "flights"
    for (launch in byLaunch) {
        printf "%s\t%d\n", launch, byLaunch[launch]
    }

    # Print totals
    print "\nTotal flights: " totalFlights
    print "Total Time   : " hhmm(totalTime)
    print "Total PIC    : " hhmm(totalTimePIC)
}
 

Online DiTBho

  • Super Contributor
  • ***
  • Posts: 4461
  • Country: gb
Re: TIOBE Index of programming languages
« Reply #145 on: January 13, 2025, 08:56:21 pm »
What about Ruby?
The opposite of courage is not cowardice, it is conformity. Even a dead fish can go with the flow
 

Offline PicuinoTopic starter

  • Super Contributor
  • ***
  • Posts: 1084
  • Country: es
    • Picuino web
Re: TIOBE Index of programming languages
« Reply #146 on: January 13, 2025, 09:04:21 pm »
I think Ruby is very similar to Python and, if Python didn't exist, I would use Ruby as an alternative.
For me the problem with Ruby is that I knew it existed when I had already learned Python, so I didn't have much incentive to learn this language.

When I have some time I will translate the program to Ruby.

Code: [Select]
start_flight = ARGV[0]&.to_i || 1
end_flight = ARGV[1]&.to_i || 9999

puts "Logbook stats from flight #{start_flight} to #{end_flight}"

def get_file(filename)
  data = {}
  File.open(filename, "r") do |file|
    headers = file.readline.chomp.split("\t")
    file.each_line do |line|
      fields = line.chomp.split("\t")
      key = fields[0]
      fields.each_with_index do |field, i|
        data[key] ||= {}
        data[key][headers[i]] = field
      end
    end
  end
  data
end

def print_header(*headers)
  puts "\n\n" + headers.join("\t")
  puts headers.map { |h| "=" * h.length }.join("\t")
end

def hhmm(minutes)
  hh = minutes / 60
  mm = minutes % 60
  format("%3d:%02d", hh, mm)
end

flights = get_file("flights")
gliders = get_file("gliders")

total_flights = 0
total_time = 0
total_time_pic = 0
by_glider = Hash.new { |h, k| h[k] = { flights: 0, time: 0, time_pic: 0 } }
by_type = Hash.new { |h, k| h[k] = { flights: 0, time: 0, time_pic: 0 } }
by_crew = Hash.new { |h, k| h[k] = { flights: 0, time: 0 } }
by_launch = Hash.new(0)

flights.values.each do |f|
  serial = f["serial"].to_i
  time = f["hours"].to_i * 60 + f["minutes"].to_i
  next if serial < start_flight || serial > end_flight

  crew = f["crew"]
  pic_time = crew != "P2" ? time : 0
  rego = f["rego"]
  glider = gliders[rego]
  type = glider["type"]
  launch = f["launch"]

  total_flights += 1
  total_time += time
  total_time_pic += pic_time

  by_glider[rego][:flights] += 1
  by_glider[rego][:time] += time
  by_glider[rego][:time_pic] += pic_time

  by_type[type][:flights] += 1
  by_type[type][:time] += time
  by_type[type][:time_pic] += pic_time

  by_crew[crew][:flights] += 1
  by_crew[crew][:time] += time

  by_launch[launch] += 1
end

print_header("Glider", "Flights", " Total", "   PIC")
by_glider.sort_by { |_k, v| -v[:time] }.each do |rego, data|
  puts "#{rego}\t#{data[:flights]}\t#{hhmm(data[:time])}\t#{hhmm(data[:time_pic])}"
end

print_header("Glider Type", "Flights", " Total", "   PIC", "Avg")
by_type.sort_by { |_k, v| -v[:time] }.each do |type, data|
  avg = (data[:time] / data[:flights].to_f).round
  puts "#{type.ljust(15)}\t#{data[:flights]}\t#{hhmm(data[:time])}\t#{hhmm(data[:time_pic])}\t#{avg}"
end

print_header("Crew", "Flights", "  Time", "Avg")
by_crew.each do |crew, data|
  avg = (data[:time] / data[:flights].to_f).round
  puts "#{crew}\t#{data[:flights]}\t#{hhmm(data[:time])}\t#{avg}"
end

print_header("Launch", "Flights")
by_launch.each do |launch, count|
  puts "#{launch}\t#{count}"
end

puts "\nTotal flights: #{total_flights}"
puts "Total Time   : #{hhmm(total_time)}"
puts "Total PIC    : #{hhmm(total_time_pic)}"
« Last Edit: January 13, 2025, 09:08:09 pm by Picuino »
 

Online tggzzz

  • Super Contributor
  • ***
  • Posts: 21465
  • Country: gb
  • Numbers, not adjectives
    • Having fun doing more, with less
Re: TIOBE Index of programming languages
« Reply #147 on: January 13, 2025, 09:43:18 pm »
Having used Smalltalk in the 80s, I looked at Ruby, decided it was a me-too language with insufficient benefits over established languages, and hence only worth learning when necessary. As with other such languages  Delphi, C#, I never regretted that decision.

Ruby has the disadvantages of untyped languages with none of the advantages, and is single threaded. Plain old Java (not J2EE nor Spring) is much better in all respects.
« Last Edit: January 13, 2025, 09:45:21 pm by tggzzz »
There are lies, damned lies, statistics - and ADC/DAC specs.
Glider pilot's aphorism: "there is no substitute for span". Retort: "There is a substitute: skill+imagination. But you can buy span".
Having fun doing more, with less
 

Offline cfbsoftware

  • Regular Contributor
  • *
  • Posts: 137
  • Country: au
    • Astrobe: Oberon IDE for Cortex-M and FPGA Development
Re: TIOBE Index of programming languages
« Reply #148 on: January 13, 2025, 10:40:59 pm »
Code: [Select]
January 2025 Tiobe Index. Other programming languages.
21 Prolog               0.92%
22 Classic Visual Basic 0.89%
23 SAS                  0.79%
24 Lisp                 0.75%
25 Kotlin               0.74%
26 Ada                  0.65%
27 Lua                  0.59%
28 (Visual) FoxPro      0.55%
29 Transact-SQL         0.54%
30 Scala                0.49%
31 Julia                0.49%
32 Perl                 0.49%
33 Dart                 0.48%
34 Haskell              0.46%
35 Objective-C          0.36%
36 VBScript             0.33%
37 Bash                 0.29%
38 ABAP                 0.27%
39 Solidity             0.26%
40 GAMS                 0.24%
41 PowerShell           0.22%
42 TypeScript           0.22%
43 PL/SQL               0.22%
44 Elixir               0.18%
45 D                    0.16%
46 Logo                 0.16%
47 RPG                  0.15%
48 Awk                  0.15%
49 ML                   0.15%
50 X++                  0.15%
69 Inform
70 Io
71 J#
72 JScript
73 LabVIEW
74 Ladder Logic
75 Modula-2
76 Mojo
77 MQL5
78 NATURAL
79 Nim
80 OCaml
81 Occam
82 OpenCL
83 OpenEdge ABL
84 PL/I
85 PostScript
86 Q
87 Ring
88 S
89 Scheme
90 Simulink
91 Smalltalk
92 SPARK
93 SPSS
94 Stata
95 SystemVerilog
96 Tcl
97 Vala/Genie
98 VHDL
99 Wolfram
100 Zig
What happened to 51-68? Which did you use to massage this data? PERL, AWK, Python, ...? ;)
« Last Edit: January 13, 2025, 10:43:49 pm by cfbsoftware »
Chris Burrows
CFB Software
https://www.astrobe.com
 

Offline PicuinoTopic starter

  • Super Contributor
  • ***
  • Posts: 1084
  • Country: es
    • Picuino web
Re: TIOBE Index of programming languages
« Reply #149 on: January 14, 2025, 06:02:29 am »
I formatted them by hand with Excel and made a mistake. It is now corrected.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf