Swala – Swift & Scala

After experiencing both Swift and Scala for a substantial enough period of time to get a feel for them, in that order, I’d like to share my thoughts about them. Not because my thoughts are ridiculously original – however – they may give you some insight into the languages and what it’s like to work with them on their own. Or together in a cross-functional manner (if you’re into that thing). I’ll start by sharing a mini-light-bulb moment I had a few days ago.

I had been working on a Scala project just previous and was getting used to working with it when I had to jump back to Swift and write a couple of lines. After analysing it for a little while I started to add things and write a simple for loop to update data in a UITableView. A younger me at University would write something like this:

for (int x = 0; x < 5; x++) { //process things }

Extremely standard and laborious if you ask me. With the updates that Swift brings it made the process a lot more enjoyable and readable, and Scala even more so. So much that I tried to write something like this:

indexPath.section(1).foreach(//process each cell)

So much more… eloquent. Once that error highlighting popped up I just thought “well, shit. I forgot how to write a for loop in Swift!”. Such a derp moment. It ended up something more like this:

for index in 0...(indexPath.section(1).count - 1) { //process things }

I know, I know… perhaps not the exact method but if you’re half decent you can figure it out! 🙂

It was at this point in time I could see a little better on what these languages do well and how they’ve progressed from what I was taught in Java. When I was diving into Swift I saw a few functional style techniques which was great, I wanted to get more familiar, yet after reading other blog posts and experiencing something more functional first hand I can see that it’s true. Swift is pretty much an amalgamation of different techniques from different languages and pulls it off really well (don’t get me wrong!) yet, it’s not something that can replace every single language as much as some people may want it to.

The first of many moments I’ll have like this I’m sure, and that’s the beauty of mixing languages. You get to see first hand the different styles to see what works well where, just how I like to be in the gym mixing it up from time to time or even just making friends from a plethora of backgrounds.

Each one is interesting, unique and has it’s own story to tell.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s