Swift as an Artistic / Creative Coding Platform

Hi, I think it's the first time writing a post.

I am a digital artist, specialising in audio-visual music. And I personally think Swift is a great language for creative coding, and I wanted to hear about others' opinions. - For those who don't recognise the phrase 'creative coding', it is essentially coding for digital art. (ex. Processing, openFrameworks, C4iOS, Max/MSP/Jitter, TouchDesigner...)

Here's some pros:

  • Swift is an expressive language. Artist often have very specific task they need to achieve, and Swift has a lot of tools that can help them - like result builder, protocol, concurrency.
  • Some digital artists are not really familiar with programming, thus they tend to make unsafe programming mistakes - memory leakage, null pointer exception, data race, and so on. Swift code is inherently less vulnerable to those kind of mistakes.
  • Swift is fast. Some artworks like simulation work will take up a lot of CPU time and memory space. Swift is better than a lot of creative coding languages and tools out there.

But there are some obstacles too:

  • Cross-platform graphics / audio libraries that support Swift are rare, and often not maintained.
  • Apple-specific APIs like SceneKit and AudioKit are usually great, but we cannot always use Macs for displaying artwork.
  • Nobody uses Swift for artistic purposes. And that means there are no tutorials on how to do things.

I recently made an artwork called uncanny symmetry. It was done with Swift and SwiftUI, and it was a breeze thanks to Swift. Personally I would like to keep on using Swift for my artworks, and I am actually thinking of making cross-platform audio frameworks for Swift that behaves like SuperCollider or FAUST - if I can.

Are there anyone out there who are interested in creative coding in Swift?

14 Likes

Are any of these useful for you?

2 Likes

I also think this is a missing space in the ecosystem. I while ago I took a stab and "porting" some concepts from Processing to Swift Processing and p5 in Swift | Alexito's World and actually got approached by multiple people that really liked the idea. There is definitely some niche for this we just need somebody to build the proper tools.

The language itself is great for this IMO, we just need some layer like p5 that makes common things more approachable. And of course multiplatform support.

I don't have much to add to this, just that I hope sooner or later this whole is filled :)

2 Likes

Thanks for the recommendations! SDL one looks quite promising. Unfortunately, like SkiaKit you recommended, many of the creative-coding related projects are not actively maintained. Even Apple's own SpriteKit is not really getting much attention nowadays.

That's so cool! Thanks for sharing. I have seen your video before, and I must say I was inspired.

I agree that Swift is great for creative coding, and I would very much like to continue to invest time in this field. So since I wrote the original post, I actually started to write an audio framework, and I managed to get it to output some sine wave and FM audio.

This article was my main inspiration, but I am using libsoundio / SoundIO Swift Binding to make it cross-platform. I think it is going well. Maybe I will share my progress later.

Is this one better?

I have no experience with it, I just remember it being used for https://forums.swift.org/t/new-framework-for-gui-apps-on-linux-and-macos/

2 Likes

Can confirm that this works on MacOS, Linux and Windows (because as you said, I'm using it for the GUI framework).

@Jae ask me anything if the usage is unclear (there are no examples in my SkiaKit repo, but there are some in the Widgets in the VertexUI/VertexGUI repo). Just open an Issue if you want to know something.

1 Like

Woah thanks! That looks perfect.

Terms of Service

Privacy Policy

Cookie Policy