ChatGPT says it can code for Sailfish

Me: Can you write in Qt5 or QML for the Sailfish mobile operating system?

ChatGPT: Yes, it is possible to write applications for the Sailfish mobile operating system using Qt5 and QML. Sailfish OS is based on the Qt framework, and the user interface of the operating system is built using QML. Developers can use the Qt Creator IDE and the Sailfish SDK to develop, test, and deploy applications for Sailfish OS.

Me: Can you write code for it?

ChatGPT: Yes, I can write code for Sailfish OS using Qt5 and QML.

Here is an example of a simple ā€œHello Worldā€ application written in QML:

import QtQuick 2.0

Rectangle {
width: 200
height: 200
Text {
text: ā€œHello World!ā€
anchors.centerIn: parent
}
}

This code creates a rectangle with the dimensions 200x200 pixels and a text element that says ā€œHello World!ā€ and centers it in the rectangle.

Here is an example of a simple ā€œHello Worldā€ application written in C++ and Qt5:

#include
#include

int main(int argc, char *argv[])
{
QGuiApplication app(argc, argv);

QQmlApplicationEngine engine;
engine.load(QUrl(QStringLiteral("qrc:/main.qml")));

return app.exec();

}

This code sets up a QGuiApplication and a QQmlApplicationEngine, which is used to load a QML file. The QML file ā€œmain.qmlā€ should contain the previous QML example.

Please note that this is just a simple example, and to create a functional Sailfish application more code and resources would be needed and also the examples above are not tested on Sailfish OS.


When you understand its limitations, ChatGPT is really impressive for some things. But its most impressive function is coding and documentation. We know for example that ChatGPT has written malwareā€¦

I barely understand C++ and have yet to try coding for Sailfish myself. It occurs to me that ChatGPT might be able to fix up old outdated apps.

1 Like

Can it write an updated compositor? :upside_down_face:

3 Likes

write the code of the compositor for wayland in c++ for the Sailfish mobile operating system?

#include <wayland-server.h>
#include <wayland-client.h>
#include <wayland-sailfish-server-protocol.h>
#include <sailfish-window-manager.h>

// Function to initialize the compositor
static void init_compositor(struct wl_display *display) {
    // Create a new wl_compositor
    struct wl_compositor *compositor = wl_display_create_compositor(display);
 
    // Create a window manager for sailfish
    struct sailfish_window_manager *window_manager = sailfish_window_manager_create(display, compositor);
 
    // Create a wayland shell
    struct wl_shell *shell = wl_shell_create(display, compositor);
 
    // Create a wayland output
    struct wl_output *output = wl_output_create(display, compositor);
 
    // Create a wayland input device
    struct wl_input_device *input_device = wl_input_device_create(display, compositor);
}
 
int main(int argc, char *argv[]) {
    // Create a display
    struct wl_display *display = wl_display_create();
 
    // Initialize the compositor
    init_compositor(display);
 
    // Run the display
    wl_display_run(display);
 
    // Clean up
    wl_display_destroy(display);
 
    return 0;
}

If only it was this simple !

1 Like

It not only can, it has!

3 Likes

By the time youā€™ve explained the problem to chatgpt, youā€™ve fixed it by hand. The problem is that many bugs are not even visible, as such, to the AI. Just because a human sees a bug, doesnā€™t mean the machine isnā€™t perfectly happy executing the instructions ā€˜as isā€™. And, ā€˜Iā€™m the operator with the pocket calculator. I type upon the keys and it makes a little melodyā€™.

2 Likes

Whenever I wanted ChatGPT to write something more complex than a single function I had to fix the result by hand which takes longer than writing it from scratch.

The only useful approach I found is if you donā€™t want to even think about the approach of how whatever you want should be written - let the AI give you a sample code and get inspired by it.

Though Iā€™m afraid that Iā€™ll slowly lose my problem solving skills if I rely on it too much.

2 Likes

I agree, thatā€™s exactly how Iā€™ve used it as well, with good results. Having some problem that needs solving, but you donā€™t have the time or energy to think about it too much yourself, so you ask the AI. Then you look at the answer and see that thereā€™s something in there that could actually work, and then you write the code, or fix the code that AI gave you.

But you really should only use it as one source for inspiration, and not as your only problem solving tool.

2 Likes

Jeez, I read other PEOPLEā€™s code for inspiration! There are many different kinds of coding style out there and reading @slava or @karry showā€™s some unique takes, aka, style !

But Iā€™m on an AI hate track at the moment. All that ugly Stable Diffusion crap which journalists are starting to push into article content. Itā€™s terrible.

1 Like

Hey, thanks for your reply, Iā€™m hoping ChatGPT to explain the problem to me, or at least guess at it. At the very least, itā€™s supposed to be able to document code.

Secondly. youā€™re thinking from the perspective of a coder. The enormous barriers to us non-coders would prevent me even trying.
I wouldnā€™t know where the problem is, how itā€™s encoded, how it should be coded nor how to recompile it ChatGPT may know or be able to guess all of that.
Ideally, ChatGPT can ease a bunch of new coders into developing for Sailfish.

There are other low-hanging fruit - software developed for Aurora which can be converted. Thereā€™s at least one N900 software package Iā€™d like to convert (the sleep analysis one). Maybe ChatGPT can even port stuff to QML?

1 Like

Unlikely to work well for a complete application. I think @jojo did his one qml page at a time with very elaborate prompts, basically specifying the construction which requires understanding how it works.

I think it would just lead to frustration. Better you just post a link to the software in question in ā€˜Applicationsā€™ and ask if a developer has time and interest. Of course, kicking the can to see what comes out might be worth it. Iā€™d ask @jojo

Iā€™m not against it in theory, Iā€™m just not impressed with the output thus far. And I really hate that a lot of people with poor discernment and bad taste are publishing AI images and calling it art. I know some capable artists using AIs and Iā€™ve even made a bunch of algorithmic art including pieces that have been exhibited. So Iā€™m not just anti. I just hate the ugliness and carelessness of it all. And no, chatgpt cannot write poetry. It emulates the writing of poetry.

1 Like

Iā€™m not a fan either, hence late to the game. But itā€™s really useful when you know how and coding is supposed to be its best functionā€¦

My experience of ChatGPT (and stable diffusion) is that you need to discover what itā€™s good at and what it isnā€™t. Particularly with ChatGPT, if itā€™s not good at something, you canā€™t get it to be good at it. You need to wait for OpenAI to cater for it.
For example, if itā€™s trained on 100,000x more Android source code than Sailfish source code, then of course itā€™s going to be hit & miss. By the sounds of it, it may never have seen Sailfishā€™s source code, but has read the QML and QT5 manuals.
Maybe itā€™s not ready yet, at least for this function ā€“ I donā€™t know.
Hmm maybe we can put in requests.

Microsoft is throwing $billions at the project and itā€™s practically guaranteed to be able to enable lay people to (laboriously) write full iDroid apps within 18 months. Theyā€™ll combine it with a UI design function and create the first real codeless compiler. There are 4 other LLMs coming this year.
And a hundred more iDroid apps isnā€™t going to make any difference to them, but it will make a huge difference to Sailfish.

Was the project a conversion or a new UI?

I missed this sleep analyser too from N900 ! I remember that with Jolla phone, when the screen was off, sensors were deactivated as well . I donā€™t know if this policy continues with SONY x* devices. A ton of good software was written for N900 and I still miss itā€¦

2 Likes

You can find the project here: jojo_/harbour-openai - harbour-openai - Codeberg.org

It was about creating an app from scratch, that would be a client for OpenAIā€™s API. You can also read my opinion and how it went in the README.md file.

1 Like

My 2cts on this topic is:

  • it does write code
  • the code looks correct
  • that does not mean it works
  • itā€™s useful for having a code structure (@sanginteret example)
  • just like debugging someoneā€™s else code, it takes more time than debugging your own
3 Likes

I have scheme macros in emacs that write code. Iā€™ve had those for decades. They generally write appropriate code.

But I also worked in automation of typesetting systems a long time ago. There are, simply, heuristics and patterns. That latter leading to more of the former. Thatā€™s all that gpt is, at itā€™s best.

To many scientists, thatā€™s all we are.

Surprisingly, ChatGPT doesnā€™t know what itā€™s been trained on.

Summary

"As a language model, I have been trained on a large dataset of text from the internet, including source code from various open-source projects. However, I do not have information on how much of the Sailfish OS source code and how much application source code have been included in the training dataset. It is possible that there is some Sailfish OS source code in the dataset, but it is not something that I am aware of.

It is also important to note that as a language model, my understanding of the Sailfish OS source code is limited to the information that is present in the training dataset and my understanding of the code can be limited in cases where the information is not clear, complete or up-to-date."

1 Like

This is going to annoy you. Your first and second instructions in README are listed as the same.

I presume you tried to get it to document and debug its own code.

The whole Linux/SF directory structure intimidates me. Does ChatGPT tell you what to put where?

I may have a go at this and itā€™s much more ambitious than what I was originally talking about.