it seems ridiculous that we have to embed an entire browser, meant for internet web browsing, just to create a cross-platform UI with moderate ease.

Why are native or semi-native UI frameworks lagging so far behind? am I wrong in thinking this? are there easier, declarative frameworks for creating semi-native UIs on desktop that don’t look like windows 1998?

Irdial
link
fedilink
English
110M

This is because each desktop operating system using a different graphics rendering engine—Quartz on macOS and X/Wayland on Linux, for example. In order to write an application that works on all major operating systems, you either need to use a graphics library that has already done the heavy lifting of calling the native frameworks under the hood or you have to do it yourself. Or you can use a web-based graphics library that has also already done that heavy lifting, with the added advantage that you can use languages like HTML, CSS, and Javascript to easily create visual elements. This is attractive when the alternatives like Qt are notoriously difficult to deploy and force you to use C/C++.

Quartz (usually referred to as Core Graphics) isn’t recommended anymore on Macs.

Developers should be using SwiftUI now, which is a completely different approach:

class HelloWorldView: NSView {
    override func draw(_ dirtyRect: NSRect) {
        super.draw(dirtyRect)

        // Drawing code here.
        guard let context = NSGraphicsContext.current?.cgContext else { return }

        // Set text attributes
        let attributes: [NSAttributedString.Key: Any] = [
            .font: NSFont.systemFont(ofSize: 24),
            .foregroundColor: NSColor.black
        ]

        // Create the string
        let string = NSAttributedString(string: "Hello World", attributes: attributes)

        // Draw the string
        string.draw(at: CGPoint(x: 20, y: 20))
    }
}

Here’s the same thing with SwiftUI:

struct HelloWorldView: View {
    var body: some View {
        Text("Hello World")
            .font(.system(size: 24))
            .foregroundColor(.black)
            .padding()
    }
}
Create a post

Welcome to the main community in programming.dev! Feel free to post anything relating to programming here!

Cross posting is strongly encouraged in the instance. If you feel your post or another person’s post makes sense in another community cross post into it.

Hope you enjoy the instance!

Rules

Rules

  • Follow the programming.dev instance rules
  • Keep content related to programming in some way
  • If you’re posting long videos try to add in some form of tldr for those who don’t want to watch videos

Wormhole

Follow the wormhole through a path of communities !webdev@programming.dev



  • 1 user online
  • 1 user / day
  • 1 user / week
  • 1 user / month
  • 1 user / 6 months
  • 1 subscriber
  • 1.21K Posts
  • 17.8K Comments
  • Modlog