Unlocking Mixins with Swift 5.9 Macros June 12, 2023
It's been a while since the last time I thought about traits and mixins in Swift, but the WWDC23 presentations about macros brought a lot of memories from those times...
A world of coding đź’», by Alejandro Martinez
It's been a while since the last time I thought about traits and mixins in Swift, but the WWDC23 presentations about macros brought a lot of memories from those times...
WWDC23 is over and as previous year I'm sharing my unedited notes from all the sessions I've watched.This year has been quite entertaining as the main focus has been on...
One of the many things I love about working with The Composable Architecture is how it encourages the developer to focus on domain modeling. I think that properly designing the...
Buckle up. This is an adventurer journal while exploring what's the best way of exposing the new style of formatting APIs in Foundation. We will walk through the paths of...
The folks at Point-Free have given us yet again a new tool to improve our Swift development: swift-dependencies, see their announcement. Let me show the journey I've been for the...
I've been very excited about memory ownership improvements to come to Swift, and now that they seem to materialize, I needed to share it with you. Specially because I feel...
One of the nice things about Swift Concurrency is its cooperative thread pool. When writting concurrent code you should not think about threads but is still good to know how...
In the early days of Swift, one thing I really enjoyed was the focus on properties (bye-bye ivars!) and the unification of stored and computed property syntax. It became very...
Swift's Optional type is one of the biggest hits of the language. Mainly because it's opt-in. Everything is non-optional by default, which solves the old problem of having to deal...
Sometimes some topic gets in my head and doesn't leave until I've gone far enough to satisfy my curiosity. Usually this ends up with me spending days writing some code...
Following Structured Concurrency was one of the best decisions Swift could have made when introducing concurrency into the language. The impact of that decision on all the code written with...
One of the beautiful things about Pointfree's Composable Architecture is how you can start using it on a smaller part of your app. It makes it very easy to improve...
Today I want to show you a rather obscure feature of Swift. You will learn a bit about Swift's type system, type inference and other nice powers that the language...
Today I want to share a weekend experiment where I built the classic Matrix effect in SwiftUI. It all started after seeing this tweet of the effect implemented in Compose....
One of the most important aspects to understand about Swift Concurrency is how cancellation of async tasks works. You may expect that when a task is cancelled, it immediately stops,...
WWDC21 has brought many cool things and there is one that will facilitate a lot the creation of new projects with dependencies. Until now it was a bit of a...
We're just in the week of WWDC and it's clear that Swift's Concurrency it's the biggest topic that will change how we develop. I've been following its evolution for months...
As last year I decided to share my unedited notes from the sessions I'm watching. The difference is that this time I've focued more on the topics and not on...
Swift is about to get its Concurrency features. Their development is going very well, with many proposals actively reviewed and a lot of the work already available in recent snapshots....
SwiftUI's layout system is very nice to get started with. Combining stacks and modifiers you can get very far very quickly, but at some point you will need to pass...
Swift is well known for its lean syntax that helps newcomers understand the code relatively quickly. But it's also a language with advanced and powerful features. Sometimes this makes part...
In this post I want to show you a little behind the curtain. As you may have noticed if you follow me on Twitter, recently the tweets with links to...
One of the major benefits of SwiftUI is its amazing DSL. A feature that not only makes it nice to read but also makes it possible to use the type...
SwiftUI is an amazing tool to create all sorts of views in our applications. But many times we want that ease of use to generate graphics that can be used...
Having a good process to update your tools is very important, specially for those that affect directly your code. I've talked about how I update swiftformat and this post will...
Talking about how one updates a tool may seem a bit nonsensical, after all, what dificutlies can you have when updating a tool? Well, you would be surprised! But no,...
Optional equitability is one of those aspects of Swift that seems simple at a first glance but that makes you stop and think twice when you encounter it in actual...
Sometimes when writing Swift code you want to reference an instance before its creation. It's not a very common, which is why I'm writing this post so I can easily...
This post is a personal opinionated piece around unit testing and the dogmas of our industry. Be sure to come here with an open mind and respectul toughts. I will...
The introduction of SwiftUI and previews changed completely my process of developing applications. Having such an easy way of quickly prototyping UI ideas affected the rest of my process. But...
Swift type system is quite powerful and the where clause is a very important part of how developers interface with it. This keyword allows developers to constraint code to a...
Swift 5.3 comes with a nice addition for enums: it will synthesize the required implementation to conform to the Comparable protocol. This reduces a lot the boilerplate needed to make...
A couple of weekends ago I was reading my Twitter timeline and I, don't know how, ended up in this old tweet."This isn't a Louie Mantia color."(That means it isn't...
PointFree has released a library with their Composable Architecture and I've been showing it a little bit on livestreams and videos. This page wants to serve as an index and...
Protocol extensions are one of the most powerful features in Swift, but they also come with a bit of danger. In this post I will explore how this feature interacts...
I shared a very special video on my Following Swift Evolution video series the other day, Road to Swift 6! I think it's an important moment to look at what...
With the release Xcode 11 is now easier than ever before to work with the Swift Package manager. If I enjoyed making CLI tools with Swift before, now it's a...
One of the common things we want to display with SwiftUI are lists of our models. The basics of it are pretty easy, you just need to use a ForEach...
SwiftUI has some presentation modifiers to display alerts, sheets and full screen views. On one hand, presenting an alert is nice and easy, it feels really well designed. But on...
In my previous post about SwiftUI buttons I described a technique to reuse button configuration with a ViewModifier. Now that beta 2 is out, we finally have the proper tools...
Yesterday I shared with you a post where I was trying to understand SwiftUI's layout system in order to implement equally spaced distribution for views inside stacks.I was able to...
One of the things that I still don't fully understand about SwiftUI is how to customise the layout of views.HStack and VStack are fine for the majority of cases, but...
The abstractions on SwiftUI are so composable that customising the UI it's basically an intrinsic property of the framework. Let's take a quick look at some things you can do...
WWDC'19 has been great and I'm obviously hyper excited about SwiftUI but if there is one thing that I like more than watching a great announcement is watching great video...
After all the game changing announcements on the WWDC one of the words that is used a lot is "finally!". We're excited and happy that Apple as finally given us...
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...
I've already mentioned how I moved tasks from Todoist to Bear but one of the missing pieces of the migration was some lists that I had on Reminders.These lists were...
The Property Delegates proposal has been in review for some days by now and is a good example of the strength of the Swift community.This is a feature that many...
Last year I wrote about Improving struct composition in Swift by levering the using keyword and feature taken from Jai. Recently I've been inspired by pointfree to implement this feature...
There is this commonly followed programming rule that says that parameter lists must be short.Nobody wants to see a constructor with more than 2 arguments right?Right?Well, let me tell you...
Today I've used Protocols to make a generic function only accept a certain number of types. The interesting part is that the only thing the protocol has is an associatedtype,...
After finalising the InterpolableLanguage protocol in the third part of this series we will finally put it to good use and show an example of this can be used on...
In the first article of this series we made a safe string type that was safe to use but with a cumbersome API, and on the second article we made...
In the previous article we made a safe string type that was safe to use but with a cumbersome API. In this part we will use new Swift 5 interpolation...
The String problem is something that I've explored before, in my 2015 post Solving the Strings Problem in Swift. The solution back then was far from ideal as Swift was...
This is a small trick that I use when I'm writing a script in Swift that performs some operation in a large number of objects, usually files. More often than...
After having clear the requirements for a notes system and comparing different options I decided to give an honest try to Bear. Now, one of the first things I need...
In the past few days the Swift community has been awoken again with the promise of a better way of using Swift for scripting, all thanks to swift-sh.I made a...
Everyone knows that NSSpain is one of my favourite conferences but sadly this year I haven't been able to assist. Luckily for me the recordings are already up so I...
One of the best things of modern Swift is the introduction of KeyPath. It allows us to reference getters and setters as first class values in our code. With them...
On 2014 I wrote a post about how to drive a UISegmentedControl with the new powerful Swift enums. Back then the major complain was that to get all the cases...
I was reading the Rust forums when I saw this post talking about an oficial Rust error crate. It reminded me about the discussions in the Swift forums about making...
As every year after WWDC is time to sit down and watch the videos of the sessions! I wrote last year about How I watch the WWDC videos and this...
Today I woke up to receive great news for the Swift community. The Swift Forums now have a new section to talk about some community projects!On the post that I...
RxTesting makes testing a custom Rx operator an enjoyable experience. Being able to fake time simplifies a lot the develpemnt of reactive code and helps on building confidence in the...
How flatMapLatest cancels an API request? This is a common question that people has when they start learning about Rx. Specially since RxSwift has an example of this in the...
p5.js and the rest of Processing projects are an amazing way of making coding more accessible to everyone, allowing creative people to make interactive applications with ease and teachers to...
One year ago I decided to start working on a Lox interpreter in Swift following Bob Nystrom's book Crafting Interpreters. Today I'm happy to say that the work has been...
Today I was reading Composing types in Swift which showcases the different ways of composing the different types in Swift: structs, classes and enums. Is a good read, specially if...
While programming with a static type system there are times when you write the definition of a function but you still don’t have any idea on how to implement it.func...
Swift forums are live! This is a great change that many of us have been waiting for a long time and that marks a new era for the Swift community....
I recently discovered the podcast LambdaCast, a really interesting podcast about functional programming with hosts that are at different points on the path to functional programming. This gives an interesting...
Watch how I create and publish a library with Swift Package Manager for the first time!With the help of the command line tool is pretty easy. After creating a folder...
In this post I'm gonna explore the talk Idiomatic Kotlin by Dimitry Jemerov. I'm gonna do it by showing how each of the topics the author talks about could be...
I've been always a big fan of productivity, time is gold. But funny enough, as many other people, we fall into the traps of being productive by just spending more...
Some days ago I finally merged one of the biggest Pull Request our team has seen, the migration of our codebase to Swift 3. I decided to write some words...
The chapter 5 of Crafting Interpreters has been published and after a first read I started writing some Swift code to continue my implementation of the interpreter. Here there are...
A couple of days ago I was reading Crafting Interpreters written by Bob Nystrom and it awoke my passion for programming languages so I decided to implement an interpreter for...
One of the things I think is really important in any team is to keep track of the performance. Not to use it as ammo to blame individuals but to...
Yesterday I gave a talk about Functional Reactive Programming to my coworkers at LifeWorks. At first, I wanted to give some insight about it to the Android team, as they...
I've always been a big fan of Linked Lists. Maybe is because it was one of the first data structures that I learn how to implement and they were my...
The post Mock yourself, not your tests immediately captured my attention just by saying "I feel like we abuse of them". As I've been having more and more the same...
One of the things that Apple released on WWDC was the official support for Xcode plugins. Although in a very limited way, is really nice to see Apple opening Xcode...
Being able to conform to a protocol and automatically have the implementation that you need is really a game changer. Having trait like functionality is one of the most interesting...
This is an update to an previous post about using blocks to simplify in Objective-C.Swift makes working with functions much enjoyable simplifying its syntax and, specially, closing the gap between...
The other day, while I was writing a Swift script, I added an option to make it run continuosly so it could be on a server doing its job without...
In the script that I was recently writing, from where the post “The state of Swift scripting” emerged, I found that when the scrip is interrupted (Ctrl + C in...
This is the second part of my posts about the sate of scripting with Swift. In the previous post I wrote about what I expect from a language toolset when...
In the past few days I’ve spend some time writing a little script in Swift and I thought it was a good time to revisit the state of the Swift...
Getting C-level performance in Swift for numerical algorithms is quirky but not particularly difficult. If you limit yourself to value types (no classes or existentials), use unsafe pointers and tuples...
I really recommend reading how Maxim made his FlatBuffer library 10 thousand times faster Swift.The interesting part is when he realized how much faster the C implementation was compared with...
For those occasions when you need to check something some state at regular intervals.Just drop this snippet at the top of your file:static dispatchsourcet timer; void DebugTimer(dispatchblockt block) { dispatchqueuet...
The other day I had to work with some date formatting on iOS and Android and I end up using the great website. I immediately missed the option to change...
Good analysis of the rejected Swift proposals by Chris.I can see why, yet still feel the opposite. This is one of those cases where we can hardly say anything objective...
A while ago I wondered how easy would be to make a screenshot of a window in OS X from another application using some system API. With that idea in...
From Rust Traits page:There’s one more restriction on implementing traits: either the trait, or the type you’re writing the impl for, must be defined by you. So, we could implement...
I was reading about Error Handling in Rust to have a better understanding of the implications of typed throws in Swift (thanks to David for the proposal). At the end...
We are used to treat closures as first class citizens in our code. Same goes to functions as they are interchangeable. But we often don’t think of them as actual...
Since Swift was open sourced I've ben scanning trough the mailing lists and there has been some interesting proposals for the future of the language. There are other places were...
In this post I try to port the type based solution to the strings problem ideas by Tom Moertel to Swift.I started this some days ago as an exercise to...
Sometimes is a small Swift library that makes it easy to run code... sometimes. Well, actually, just once.Sometimes.execute(key) { // This will run just once }It was highly inspired by...
I’ve been following the linked blog because I’m really interested in the usage of Swift in environments different from the typical Apps. And because using it for robotics seems pretty...
Today I had to do a little research on the state of JSON mappers in Swift for a new project. I’ve been using a simple JSON library to help me...
The other day I had some spare time and I started exploring the idea of a Stack in Swift using protocols. For what? For fun.A Stack is a data structure...
The author of the linked post gives some reasons on why Swift is a good language for an introduction to computer science class. I’m really interested in Swift being a...
This post is one of those ones that I’ve been wanting to write for a while. It was some days ago when, by coincidence, I was reading a post about...
In the last version of BWallpapers I added the ability to save the wallpaper to a specific Wallpaper album in the Photos app.You can use the Photos.framework to do that....
Protocols in Swift are really powerful thanks to be able to be generic and to protocol extensions. But there is some things that drive us nuts. Mainly the usage of...
The other day while I was adding the ability to generate the protocol file to my Sketch plugin I took the opportunity to make a couple of changes to the...
2018/08/23: A new version of this post is available. Using KeyPath to simplify the call site and reduce possible mistakes.A while ago when Swift came out I had the idea...
From Wikipedia, Singleton in Software Engineering:In software engineering, the singleton pattern is a design pattern that restricts the instantiation of a class to one object. This is useful when exactly...
I would like to talk about a video of a great talk that I really recommend. I’m really interested on the topic of sharing code between iOS and Mac because...
Yesterday night I found myself reading this code in GitHub for dictionary in array { - if let interaction = Interaction(dictionary: dictionary) { - interactions.append(interaction) -...
As I said on my Fist impressions on WWDC 2015 I was really excited for finally having traits in Swift, in form of Protocol extensions. After playing with them this...
I mentioned the new Swift error handling in my WWDC first impressions post. And although it’s true that I still have not had the opportunity to use it in a...
Every year, after the WWDC I usually record a podcast episode talking about my feelings of the keynote. This year I've been keeping a list of the things that I...
Today I’ve been updating BingWallpapers to use the last version of Swift and also include the latest changes of WallpapersKit, the framework that is shared across the Mac and iOS...
When I wrote my srly script I thought on doing it in Swift, but at the end I decided to go with a well known scripting language, Ruby.After Ayaka’s talk...
If you like this post I recommend you to read a more recent article about the same topic: Solving the String problem with Swift 5.Some days ago I read this...
Yes, the title is not wrong. Apple just released Xcode 6.3 beta that includes multiple huge improvements to Swift 1.2 solving a lot of concerns that we all had. But...
By default a Swift playground stops it's execution when the top level function finishes. If you want to run async code you will never see the results. The system doesn't...
One of the most exciting things in Swift is the possibility to write and run scripts. It turns out that writing scripts is one of the best ways to learn...
People say that languages with headers are things from the past, but I still think that they are really useful. As I said before, we don't have to make a...
Matt talks on NSHipster about default protocol implementations. I already said that it's a feature that I miss in Siwft (and in Objective-C). I'd never saw any big talk about...
One of the coolest parts about Swift is how powerful all the types are. Structs are not like basic C structs, they have a lot of similarities with classes, and...
Crhis give us some cool ideas for open source projects in Siwft. A web framework (like Rails or like Sinatra). Some people have already been experimenting in this direction. Since I...
This is another thing about extensions that I was not expecting. The other day while implementing Jlaner I had some problems with extensions.The problem is that you can't overwrite methods...
For now, the Siwft and Objective-C protocols are two diferent things. The biggest differences is that Swift protocols can have structs and enums and can be adopted by value types.This...
Nate Cook writed afull featured Set Type in Swift. This are the things that I really like about some languages. The ability to extend the language itself with its own tools....
The oficial Swift blog is giving us clarifications about Access Control and protected It seems like it's their conscious decision to make an horizontal access control system instead of a vertical...
Really interesting talk about Object-Oriented Programming in a time when I wasn't even born! It´s really amazing how the tools that I use every day were created so many years...
This is a case of direct translation from Objective-C methods that don’t really look right in swift. The reason this works is swift’s external parameter names, which I think...
Yesterday I made a question about the acces controls that we have in Swift: Why internal and no protected? There was not a really good answer in the social networks and...
This is a question that I have in my mind since Apple introduced the access modifiers. Why we want internal and not protected? The thing is that when I'm creating or...
In these weeks, since Apple has announced his new programming language, I've been trying to learn something about it. As I said before, my approach hasn't been a full change...
So at the end Swift is more functional than we firstly thought :)...
2018/08/18: Swift 4.2 introduces automatic synthesis of enum values. Check out the new version of this post. 2016/09/29: Updated for Swift 3.One of the most cool features in Swift are...
Yesterday Apple released the new beta4 with new changes in the Swift language. The big thing is the new acces control with three acces levels (private, internal and public). This...
I really like when a language gives the power to extend it easily. In Swift the clousures are really powerful. You can use clousures to do lazyness and implement the while...