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.