It is high time Xojo innovated like its competitors

I had to read a Database and change some value in every Dataset. Was an experience. after trying that with Xojo I learned how slow the Database connectors are physically. There is no chance to make that faster. It is let’s say a bit faster with Java or C++

Is Xojo really that much slower handling database stuff?

Below is a sample code from the 8th code samples. It downloads a zipped IP-to-country CSV file and creates a database from it.

\ Application notes: download and create IP-to-country database:
needs[ net/http utils/elapsed ]

var q1 var q2 \ the insertion queries
"geoip.db" constant db-name

\ Grab the database file.  The downloaded CSV file will be left on TOS
\ On failure, quit
: download-ip-zip \ -- b
  "Downloading IP2LOCATION ZIP file.\n" .
  "https://download.ip2location.com/lite/IP2LOCATION-LITE-DB1.CSV.ZIP" net:get if
    \ a buffer with the zipfile data is on TOS.  Lets open and save just the one bit we want:
    nip f:zipopen "IP2LOCATION-LITE-DB1.CSV" f:zip@ nip
    \ If it's null, we were not successful:
    null? if
      "Sorry! The IP2LOCATION database doesn't seem to have the expected file.\n" .  bye
    then
  else
    \ couldn't even connect:
    "Sorry! Unable to download the IP2LOCATION database.\n" .  bye
  then ;

\ Create a database schema to hold the downloaded data:
: create-schema \ db --
  quote * 
  DROP TABLE IF EXISTS ips;
  DROP TABLE IF EXISTS cty;

  CREATE TABLE ips (ip1 integer, ip2 integer, cc text);
  CREATE INDEX ips1 on ips (ip1);
  CREATE INDEX ips2 on ips (ip2);

  CREATE TABLE cty (cc text PRIMARY KEY, name text);
  CREATE INDEX cty2 on cty (name);

  BEGIN;
  * db:exec ;
  
\ Creates the prepared queries for processing the data:
: create-query \ db -- db 
  "insert into ips values (?,?,?)" db:prepare q1 !
  "insert or ignore into cty values (?,?)" db:prepare q2 ! ;

\ Creates the database in the current directory:
: create-db \ -- db 
  "Creating the SQLite database to hold IP-to-country information: " . 
  db-name dup . cr db:open 
  create-schema 
  create-query ;

\ This takes the CSV data and parses it and puts it into the database:
: process-data \ db data -- db
  "Processing the data\n" .
  (
    "\"" "" s:replace!     \ remove " characters
    s:trim "," s:/         \ split line into fields [ip1, ip2, code, countryname]
    \ data are : [startip, endip, code, name].  
    \ If the 'name' field had commas, there will be more fields, which we'll ignore
    dup>r
    \ first insert into the ips table:
    q1 @ swap db:bind db:exec
    \ next insert into the country table:
    q2 @ r> 2 20 a:slice db:bind db:exec
  ) s:eachline ;

\ Clean up:
: close-db \ db --
  db:commit drop 
  db:close ;

: app:main
  \ clear the database file, first:
  db-name f:rm drop

  0 d:start-timer
  create-db 
  download-ip-zip 
  0 true d:elapsed-timer-hmds "Downloaded in " . . cr
  0 d:start-timer
  process-data
  0 true d:elapsed-timer-hmds "Processed in " . . cr
  close-db 
  "Finished!\n" . ;

Test run:

Creating the SQLite database to hold IP-to-country information: geoip.db
Downloading IP2LOCATION ZIP file.
Downloaded in 3.845s
Processing the data
Processed in 3.384s
Finished!

How would Java or Xojo handle this task?

1 Like

I tried assisting Thorsten with his issue in Xojo
It was an order of magnitude or more slower than the equivalent in Java

< joking >
in a way most of the rest of us could read :stuck_out_tongue:
< /joking >
TBH I expect the overall architecture would be similar to what you have in 8th
More code or less code ? :man_shrugging:
But thats neither here nor there

1 Like

And, what it has to do with this fact? Nothing. There are many systems as fast as or even faster than 8th. So what?

I could ask the same; Java is faster than Xojo, so what? I have not claimed 8th to be particularly fast, the only optimization it uses is a tail call elimination. It’s still fast enough for me. You on other hand always say, how slow and shitty Xojo is and how every Xojo user should use Java instead.

I just wondered, why Xojo is that much slower interfacing databases than Java? After all the most of the work is done by the database itself, not user application.

Starts with bad interfacing, slowe programming language, slow String handling and so on. Results in real slow … I had to face this discussion where people wanted to show me that Xojo is faster than Java. Wow. But by the way, RUST and C++ are even quite a bit faster. When and if optimized.

Well look in the mysql community plugin and you might get some idea why
Its open sourced C code
(In fact if you have a full install of Xojo its already on your machine in Extras > Database Plugin Resources > MySQL) and there are VS, Xcode and makefiles for it
There is a fair amount of conversions from string to native integer types etc going on
(like MySQLCursor.cpp lines 730711, 731, and several other places you’ll see strtoi, sscanf, etc)

The reality is that it was so much slower than Java for the task given that it was frustratingly slow
The work wasnt done IN the DB
Heck just loading LOTs of rows into a DB using Xojo vs Java was hugely different
Still using roughly the same code (commit sizes the same, connected to the same db etc)
All I can say is - it can be vastly slower

This may, or may not, be relevant to YOUR application

But if you have to deal with large row sets it might be

Thanks for the information!

A post was split to a new topic: TOF IP to country code

https://spectrum.ieee.org/top-programming-languages-2024

Apparently a lot more popular too :slight_smile:

Why the hell is HTML listed as a programming language?

1 Like

Because it’s considered a declarative programming language, describing how a computer should put together and present a page of information?

2 Likes

No, it’s a markup language, so akin to a word processor or desktop publisher. If that is their definition, then #1 should be Microsoft Word and #2 Microsoft Excel then all the other word processors and spreadsheets out there. Those are “programmed” by way more people than any of the languages listed all of the listed languages combined.

2 Likes

Agreed
HTML isnt a programming language in any way shape or form any more than Markdown, RTF, JSON or XML is a programming language
None of them is even close to being Turning complete

Someone will accuse me of gatekeeping I’m sure :stuck_out_tongue:

if we consider markup as programming langauges then Postscript is much more older and widley used than anything else…

1 Like

On the other Site, SVG is turing complete!

Forgive me, i thought your original question was asked in good faith, so I answered it.

In the case of the chart, I guess you’re arguing that the IEEE is wrong for considering HTML a language or demanding that they include Word and Excel, which are both XML.

I do not represent the IEEE, and I’m sure they are capable of defending their own decisions. I couldn’t tell you why xlsx and docx are not included and could only provide speculation. Perhaps it’s a lack of interactivity in the final product, or that docx is not directly written? :person_shrugging:

I don’t see any value in arguing against it being a programming language, the same way people argue against shell scripting being programming. It seems to serve no real purpose outside of being pedantic.

I wasn’t aware PostScript wasn’t seen as a programming language until this post.

WEB (not the interwebs but WEB from TeX) probably predates postscript

Indeed its not YOUR doing that they are listed
They shouldnt be

Oh it definitely is
Try writing it by hand sometime and OMG !