Going from Swift to Go: Basic Flow Control

Going from Swift to Go: Basic Flow Control

Time for some basic flow control. In this post, we will look at if statements, switch blocks, and for loops in Swift and Go. If Statements In both Swift and Go, if statements have the same format: if something { execute } else { do something else }, where the else statement is optional. Example: if 3 > 2 { //do something } else { //this should not execute } Switch Blocks In both Swift and go, the switch statement…

Read More Read More

Going from Swift to Go: Testing

Going from Swift to Go: Testing

Unit testing is crucial for any project; but the two types of testing found in Swift and Go are fundamentally different. In Swift, the testing is assertion-based, while the testing in Go is output-based. However, these two things are very easy to switch between. Testing in Swift In a separate target (usually a target with ‘test’ in the name), we create a class that is a subclass of ‘XCTestCase’, and import XCTest at the top. To write the actual test,…

Read More Read More

Going from Swift to Go: Parsable Structs

Going from Swift to Go: Parsable Structs

Structs are a basic element of object-oriented languages, and usually simple to implement. But when dealing with Swift and Go, one thing we frequently run into is parsing with json–that means creating a struct that can parse json data. How can we do this? Basic Structs In both Swift and Go, we start a struct with ‘struct’ followed by the struct name (reverse order in Go). In the following lines, between the brackets, we have a list of variables, declared…

Read More Read More

Going from Swift to Go: Dictionaries/Maps

Going from Swift to Go: Dictionaries/Maps

Part 4 of the From Swift to Go series. In Swift, Dictionaries let you assign a variable to a key value; in Go, maps are used in the same manner. While the names are different, functionally the two are the same. Here we will discuss the syntax differences between the two. Create Empty Dictionary/Map In Swift, a dictionary is created similar to an array, such as var myArray : [Int] = [], except we declare two types (separated by a…

Read More Read More

Going from Swift to Go: Arrays & Slices

Going from Swift to Go: Arrays & Slices

Part 3 of the Swift to Go series. When it comes to Arrays and Dictionaries, there is one main difference between Swift and Go: Dealing with memory. While in Swift you can count on the compiler to handle memory for you, in Go you must specify and manage memory yourself. Empty Arrays In Swift, we start with ‘let/var’, depending on if the array will change, followed by a name. To specify type, we use : [type], like a standard variable….

Read More Read More

Going from Swift to Go: Method Signatures

Going from Swift to Go: Method Signatures

Part 2 of the Swift to Go series. There are a few syntax differences between Swift and Go with regards to method names/signatures, but beyond this they are very similar. Function without parameters or return values In both swift and Go, the basic function is the same; first declare ‘func’, then choose a function name followed by (), and finish with the content in brackets. Example: func functionName() { //content here } In Go, it is also possible to set…

Read More Read More

Going from Swift to Go: Creating Variables

Going from Swift to Go: Creating Variables

Jumping from the Swift programming language to the Go programming language is easy, as I discovered. But how does creating variables compare? Variable Declaration (without assignment) In Swift, first we declare whether the variable will change or not, so we choose let or var. Second, we choose a variable name, followed by some semicolons and the type of the variable. Example: var myNumber : Int? . Note that we have to add a ‘?’ to make this an optional, because…

Read More Read More

What it’s like to work at Sphere

What it’s like to work at Sphere

Sphere is a vision-driven company. As a result, we work harder than the average company, not just smarter. We know that as our success builds upon itself, so does the impact we have on people’s lives. So I thought I’d lay out what it’s like on the inside. Our company culture gives an idea but here’s a day-to-day account. First, our team is fully remote. This means Mattermost chats and Skype calls. That said, we function just like a traditional…

Read More Read More

Sphere’s mission and vision

Sphere’s mission and vision

At Sphere, we understand the primary drivers behind social media’s ubiquity and seek to undo its pernicious influence. Humanity wasn’t meant to interact behind screens. It wasn’t meant to convey emotion through images less than one square inch. Life is so much richer than that and too many of us have forgotten how to make the most of it. The biggest danger behind social media, I believe, is the devaluation of human interactions. Unfortunately, there aren’t many ways to undo…

Read More Read More