🌱 Seedling Planted: Updated:

Coming from Python is not a problem for Swift. He said


Finally starting to write some Swift

TL;DR: One rabbit hole after another et voilà: Swift.

My choice: why Swift? (and its details)

I come from the world of hard engineering. More than a decade of process engineering. I learned Python to help me automate some work tasks and then, the popular rabbit hole. Being my first programming language, learning it was quite complicated at first because you have to change your way of understanding the computer and how it thinks.

Fortunately, Python is very versatile, and I was able to learn it that way. First understanding the syntax and simple variable types. Then, understanding the most used libraries for data analysis and data science. Some web applications with Django. And finally Machine Learning to enter an even deeper second rabbit hole.

The moment you realize that your curiosity is growing bigger, you think of going deeper into something closer (we all have a phone in our hands), mainly to see if what you’ve learned can be applied. We use apps every day, but I wanted to know how they’re made. How much can Python help me with this?

I’ve had an iPhone for many years (since the 5c), but some time ago I started wondering if it was easy to make an app. Although iOS apps can be made in several ways, I think it’s better to do it natively using Swift.

The end point of this moment culminates with building apps for iOS and MacOS that have artificial intelligence and machine learning features. I think it’s a good approach to go new brick on old brick.

Drawing parallels

Two lines are parallel if they are in a plane and don’t intersect at any point. What? I wanted to see if I could establish a metaphor to see how similar Python and Swift were and I came up with a bad joke. Still, I think it works for this case.

Going to the core of the comparison, both are easily readable languages, not like those lower-level languages. A high-level language (like Python and Swift) differs from a low-level one (like machine language) in that the former is easier to read. Thus, there are many functions that are practically the same, like when we want to print to the screen:

# Python
print("This prints to the screen in Python")
// Swift
print("This prints to the screen in Swift")

Continuing with the comparisons, both can follow object-oriented programming (we’ll obviously continue in another seedling), functional programming, and are languages that can be used for machine learning and artificial intelligence.

Drawing anti-parallels

While both are high-level, perhaps there are more differences that highlight their characteristics. Python was designed to be simple and readable, very flexible and above all make the difficult easy although not efficient. Swift was designed to be safe, modern and fast (compiles much faster than Python). Additionally, it’s more strict and structured, which doesn’t happen with Python as it can have ambiguous behaviors:

# Python

x = 10
x = "hello"  # Python allows it
// Swift

var x = 10
x = "hello"  // Error at compilation

Obviously, we’ll continue seeing these differences as the garden grows.