Swift/Win32 Programming!

Hello Win32 developers and Swift users,

The Windows port has been coming along pretty well. Although it is not yet complete, it is now at the point where you can start doing interesting things with it. As such, I put together a little Hello World^WSwift program for Windows using just Swift! As the saying goes, a picture is worth a thousand words ...

The source code for this is up on GitHub. It is still pretty raw, so expect sharp edges if you are going to start playing with that code, but, this certainly seems to be the start of bringing Windows development to Swift!

CC: @Chris_Lattner3 @pvieito @Torust


That’s quite the milestone! Congrats!!!


Very cool! :tada:

1 Like

Absolutely amazing! Thanks.:genie:

This is amazing! Thanks for pushing this forward.

Who needs JPG compression when you've got Windows font rendering?

In all seriousness, this is great! Amazing job!


I'm going to grumble at you for manually allocating an UMBP to store a UTF-16 string instead of using Array.



Haha, I never said this was good code! :smile: Cleaning up the demo eventually is a good idea, for now, more bug fixing in the compiler to get Foundation running seem to be more pressing :-)


This is really really awesome @compnerd, congratulations!!


Huge congrats, this is great stuff!

Fantastic, well done!

This is amazing! Thanks for your hard work.

This is awesome! Great job @compnerd :tada:

Keep the good work! @compnerd :+1:

1 Like

Does it support exceptions yet? That's so 2016! LOL

Seriously now, this is awesome. Congrats @compnerd!


Really cool, great work

This is amazing! Great work!

Though it now makes meI wonder if Swift's introspection/reflection facilities could be used to declare the event handlers implicitly when an object implements a certain method instead of having to subclass a WindowClass.

Also, could this be done for UWP APIs?

The WindowClass itself is just a representation of WNDCLASS. The methods that you are thinking of are in the WindowDelegate. You simply implement the event handler that you care about. You will absolutely have to subclass the WndProc in order to handle an event, and when you sublcas, you have to handle all the events (which is done implicitly by the protocol extension). The WindowDelegate that the user defines only needs to handle the events that they care about.

This is possible to make work for the UWP cass of applications as well, the primary issue is the lack of certain APIs/Libraries (e.g. DbgHelp) that are needed for other things like Foundation. But, I've taken care to minimise the use of APIs unavailable in UWP, so it should be feesible to do that.



Congratulations this is fabulous!!