Alejandro Martinez

08 June, 2019Art of Programming and ParadigmsFunctional ProgrammingSwiftWWDCiOS DevelopmentmacOS DevelopmentSwiftUIπŸ• 4min read

WWDC'19 marks the start of a new era

WWDC '19 is over, and what a week! Let me start by saying that this is probably the best WWDC ever. We have seen the announcement of game changing technologies for the Apple developer community, but even ignoring those big announcements, the rest of smaller details make on itself a great WWDC.

There are many new things that would be interesting to talk about, and I plan to release a video discussing this WWDC announcements in general and talking about my wishes. But there is no doubt that for me the announcement of the year is SwiftUI.

It's something I've been desiring for years and that I thought we would never have. At the moment of the announcement I was so excited that I had to jump and scream, and I even recorded my most successful video on the same afternoon.

I wish I had more time to dedicate to this because it would have been a great chance to give more to the community and grow my audience, but one has other responsibilities and limited time.

But back to SwiftUI.

SwiftUI

SwiftUI is a GAME CHANGER. As simple as that. As I said on the video, this is our future. I'm super excited to have a development environment that finally can compete, in terms of productivity, with others like React, Flutter, Elm. Trust me, functional programming and the theory behind are really nice, and something that I love to talk about (maybe too much), but at the end of the day what matters is the effect that it has on our day to day. And a declarative UI framework like the mentioned ones has been shown to be the best way of building UIs. A productivity boost compared to more imperative approaches.

But what is more incredible to me is that Apple hasn't just give us a UI declarative framework, they have give us a whole new system, they've gone the extra mile (and kilometer!). The SwiftUI syntax is just the tip of the iceberg, it's the whole package that makes this something amazing and revolutionary.

Let me give you a big picture of the whole package πŸ“¦:

Starting with the obvius. The SwiftUI DSL is beautiful and makes it super easy to write and read UI code. It leverages new Swift features like function builders to reduce the clutter and make a nice DSL.

SwiftUI example

But because Apple is able to improve not only the framework, but also the language and the tools, we finally have Swift hot reloading. Change something in your Swift file, save, and those changes are compiled and injected in the running binary. (this works for other Swift code, not only SwiftUI, but it shines with it). This was possible in the past with some dodgy hacks, but the hope is that with official Apple support this is now just part of our day to day development. The amount of time that this will save it's uncountable.

This great integration between framework, language and tooling is what allows them to bring us next level UI development. Something that I've seen sometimes on other communities, but I've never seen it done in such a beautiful and integrated way. Xcode previews.

Xcode previews are the other part of the puzzle that is gonna change our lives. An empowered playground driven development with the best of interface builder, but much better because the previews are literally your code running. It doesn't show a fake rendered UI, no. It compiles and runs your code to show you the real UI. All of it without running the app, without having to navigate to the specific screens, with live and immediate changes. The feedback cycle is as fast as it can be.

SwiftUI interface builder

But Xcode previews don't stop there, and this was only part of my deepest dreams. The preview of your code is not only a preview, but also an interface design tool. You can drag and drop UI elements, click on them to change their properties, etc. And the craziest thing is that it changes the code for you to reflect the changes, the code is the source of truth. This gives us the best of both worlds, you can write code or use the design tool, interchangeably. And if that was not enough, you can click on the code elements to show the inspector panels to change properties of the views, in the code.

But the story doesn't end with the UI. Apple has also released Combine, an FRP framework. This means that Apple finally sees FRP as the way of dealing with asynchronous programming. It makes it easy to benefit from the declarative aspect of SwiftUI if we can hook the rest of our logic in a similar way.

It's still early days of all this tech. SwiftUI is still buggy and sometimes frustrating to learn. But the doors have been opened, things will just get better from here.

A new era has begun.

If you want to know more about what's behind SwiftUI subscribe to my channel as new Swift videos are in the works.

πŸ‘‰πŸ» If you have any feedback you can reach me at alexito4

RSS

Alejandro Martinez
alexito4@gmail.com

Buka pintu