San Francisco, Is Tech All There Is?

Everybody talks about all the changes the city of San Francisco is undergoing. All the good things that are disappearing and all the not so good things that are taking their place: Google busses, evictions, sky high housing market, neighborhood gentrification. The list goes on an on.

The surprising thing, though, is hearing people talk about San Francisco as this technology focused mecca. That’s not my city.

San Francisco

In a recent New York Time’s article two writers discuss why they are abandoning San Francisco (spoiler: it’s because of all the tech):

Living in San Francisco is a predictable affair. Each day you awake to layers of fog, the temperature is always the same, and as you travel the city, you bump into one tech-related thing after another. Twenty-somethings working on MacBook laptops jockeying for power outlets in a crowded cafe. Entrepreneurs on street corners pitching venture capitalists about their new photo-filter apps. And people talking about tech everywhere: at breakfast, lunch and dinner, and even in bathrooms.

[...] I always felt that San Francisco was a bit too techie, even for me.

There is so much more to this city than technology.

I just recently went to a night at the Academy of Sciences where I saw no one talking about apps or taking photos with their Google Glass. With Pride around the corner it’s hard to forget that this is a city that loves to celebrate in the streets (Bay to Breakers, How Weird, Fillmore Jazz Festival…). Golden Gate park is taken over almost every weekend with some party or another (Hardly Strictly Bluegrass, Outside Lands, …). We have open studios, a lively Castro theatre, many international and independent film festivals, theater and music performances plus a multitude of underground talent too long to list here.

San Francisco is changing and I would argue that’s a good thing. You’ll get out of this city what you look for in it, but don’t assume that’s all there is.

San Francisco

Top 10 Features of Swift Language Syntax for JavaScript Developers

Swift is Apple’s new language for Cocoa and Cocoa Touch, created as an evolution of Objective-C and intended for native OS X and iOS development.

Reading Swift’s new documentation I found a few of its features very interesting. Some of these new features are typical of other high performing languages such as C, Java, etc. Long time ago I used to code in C and C++ and now, years later, I still miss some of the more advanced language syntax in Javascript. Although some go as far as saying that “Swift is basically JavaScript on steroids”, the two have different goals (web vs. native).

Apple Swift Logo

#1. Constants

Such a simple thing and such a great help. I’ve always missed constants in JavaScript. A variable is declared with the keyword var a const with let.

let maximumNumberOfLoginAttempts = 10
var currentLoginAttempt = 0

Note: All the code samples have been extracted from the docs.

Read the official documentation about Constants

#2. Strong Type

Some people attribute some of the success of JavaScript to loose typing. Although it gives the language an incredible flexibility it also makes it harder to debug and more prone to runtime errors.

In Swift you can indicate the expected value type that a variable is to store as follows

var welcomeMessage: String

Swift is type safe, which means that it will always enforce the right type to be used in expressions. If the wrong type is passed in an assignment or feature call, compilation will fail.

Type declaration is not mandatory and so Swift uses type inference to determine the type of variables if not specified during creation. This is done by examining the values provided in code.

Read the official documentation about Type Safety and Type Inference

#3. Tuples

A tuple is a type that groups multiple values into a single compound value. It is a short way to express complex structures without defining an object.

let http404Error = (404, "Not Found")
// http404Error is of type (Int, String), and equals (404, "Not Found")

Very convenient as the return value of functions. (self link ####)

Read the official documentation about Tuples

#4. Range operator

The range operator is a shorthand way to define a range of values. It comes in two flavors closed and half-closed.

The closed range operator includes all the values in the expression. In the example below values 1, 2, 3, 4 and 5.

for index in 1...5 {
    println("\(index) times 5 is \(index * 5)")
}

The half-closed range omits the last value (very useful when iterating over arrays or lists).

let names = ["Anna", "Alex", "Brian", "Jack"]
let count = names.count
for i in 0..count {
    println("Person \(i + 1) is called \(names[i])")
}

Read the official documentation about the Range Operator

#5 The (supercharged) Switch Operator

Compared with JS, Swift’s switch operator is really powerful control flow operator. I’ve never been a fan of the switch command, but I could grow to like it in Switch.

Since Swift has tuples and ranges, the case expression of a switch command can be more elaborate and more useful. Swift also includes new concepts to control the flow such as the fallthrough keyword, value bindings and the where clause.

Range matching case: A case clause can match a range of values, not just a single value.

let count = 3_000_000_000_000
let countedThings = "stars in the Milky Way"
var naturalCount: String
switch count {
case 0:
    naturalCount = "no"
case 1...3:
    naturalCount = "a few"
case 4...9:
    naturalCount = "several"
case 10...99:
    naturalCount = "tens of"
case 100...999:
    naturalCount = "hundreds of"
case 1000...999_999:
    naturalCount = "thousands of"
default:
    naturalCount = "millions and millions of"
}
println("There are \(naturalCount) \(countedThings).")
// prints "There are millions and millions of stars in the Milky Way.”

Tuples matching case: values can be tested against tuples

let somePoint = (1, 1)
switch somePoint {
case (0, 0):
    println("(0, 0) is at the origin")
case (_, 0):
    println("(\(somePoint.0), 0) is on the x-axis")
case (0, _):
    println("(0, \(somePoint.1)) is on the y-axis")
case (-2...2, -2...2):
    println("(\(somePoint.0), \(somePoint.1)) is inside the box")
default:
    println("(\(somePoint.0), \(somePoint.1)) is outside of the box")
}
// prints "(1, 1) is inside the box”

Read the official documentation about the Switch Operator

#6. (Advanced) Function syntax

The regular syntax of a function is Swift is slightly different from JavaScript in order to accommodate for the parameter and return type definition.

func sayHello(personName: String) -> String {
    let greeting = "Hello, " + personName + "!"
    return greeting
}

CoffeeScript guys might like the use of the ->, and might find it more familiar than regular JS folks, specially when dealing with Swift’s closure syntax.

Besides the new syntax, the most powerful new features of functions in Swift are multiple return values, external parameter names & Variadic Parameters.

#6.1. Multiple Return Values

A function in swift can return a complex value as a tuple type.

func count(string: String) -> (vowels: Int, consonants: Int, others: Int) {
    var vowels = 0, consonants = 0, others = 0
    for character in string {
        switch String(character).lowercaseString {
        case "a", "e", "i", "o", "u":
            ++vowels
        case "b", "c", "d", "f", "g", "h", "j", "k", "l", "m",
        "n", "p", "q", "r", "s", "t", "v", "w", "x", "y", "z":
            ++consonants
        default:
            ++others
        }
    }
    return (vowels, consonants, others)
}

#6.2 External Parameter Names

Functions in Swift can expose the name of each parameter to use when calling the function. This helps readability by indicating the purpose of each argument and reduces errors.

func someFunction(externalParameterName localParameterName: Int) {
    // function body goes here, and can use localParameterName
    // to refer to the argument value for that parameter
}

#6.3 Variadic Parameters

A feature of crazy name (at least to my Spanish ears), used to indicate that a parameter can accept zero or more values of certain type.

func arithmeticMean(numbers: Double...) -> Double {
    var total: Double = 0
    for number in numbers {
        total += number
    }
    return total / Double(numbers.count)
}
arithmeticMean(1, 2, 3, 4, 5)

Read the official documentation about Functions

#7 Enumeration type

It’s such as a small thing but, just like constants, it can make your code so much more clean, readable and less error prone.

enum Planet {
    case Mercury, Venus, Earth, Mars, Jupiter, Saturn, Uranus, Neptune
}

Read the official documentation about Enumerations

#8 Classes and structures (aka Object Oriented Programming)

Native support for classes.

class SomeClass {
    // class definition goes here
    var width = 0
}

OOP is simple but powerful and with classes come all sort of good things:

  • Inheritance
  • Getters and setters
  • Property Observers
  • Native self property
  • Type (aka static) methods
  • etc, etc

Read the official documentation about Classes and Structures

#9 Automatic Reference Counting (aka Smart memory management)

One of the great features of Swift that many developers of Objective-C are anticipating. Here’s the description directly from Apple’s documentation:

Swift uses Automatic Reference Counting (ARC) to track and manage your app’s memory usage. In most cases, this means that memory management “just works” in Swift, and you do not need to think about memory management yourself. ARC automatically frees up the memory used by class instances when those instances are no longer needed.

Read the official documentation about Automatic Reference Counting

#10 Generics

Not present in JavaScript but popular in C++. Generics are functions and complex types that don’t require an explicit specific type (Int, String, etc) but instead work with any type indicated at creation.

func swapTwoValues<T>(inout a: T, inout b: T) {
    let temporaryA = a
    a = b
    b = temporaryA
}

Mostly used for collection classes (Array and Dictionary types are actually generic collections in Swift).

Read the official documentation about Generics

In closing

Swift lies somewhere between Objective-C and JavaScript. Should be much easier to pick up for those JavaScript developers itching to learn development in the Apple ecosystem.

Maybe it’s time to try some native coding?

For more goodness on Swift & JS you can check out Swift for JavaScript developers.

Underscores in Apple’s Swift Numbers

I’m catching up with Apple’s new language Swift, and this declaration of numbers caught my attention: in order to help readability numerals can be written with underscores (eg: 12_345).

Apple Swift Logo

Numeric literals can contain extra formatting to make them easier to read. Both integers and floats can be padded with extra zeroes and can contain underscores to help with readability. Neither type of formatting affects the underlying value of the literal:

let paddedDouble = 000123.456
let oneMillion = 1_000_000
let justOverOneMillion = 1_000_000.000_000_1

Excerpt From: “The Swift Programming Language.”.

I also just learned that this feature is already present in some languages such as Perl, Ruby and Java but not in Javascript :(

I like the idea of not only creating new languages, but rethinking how we write code and how we can improve the coder experience (after UX, we now need a new field of CX).

On Ideas Vs Products

John Maeda on Steve Jobs on Ideas

On The Changing Advertising Ecosystem

This article does a fair job at covering some of the changes the industry is going through in recent years.

Burned by the recession, clients are loath to greenlight risky work and bottom-line pressures are driving them to wring costs from their shops. To grow, independents are selling to public holding companies and succumbing to the balance-sheet demands that can dull a free-spirited culture. Often, the result is chasing business they might once have scorned while private.

[...] Fees have gotten smaller and once-huge accounts have become projects doled out to multiple agencies. “Now accounts are half the size they used to be. [Agencies have to] pitch more, because there’s more project work, fewer AOR opportunities and even those are half as much as they used to be.”

~A Tale of Two Crispins: Why There Won’t Be Another Agency of the Decade

We Need Less “Content Marketing” And More “Meaningful Marketing”

TL;DR: “Content marketing” should focus less on content creation and more on meaningful connections made possible by valuable content

We —those in the business of marketing on the web— have a constant obsession with newness, with defining today’s zeitgeist, with being current and relevant, etc. One of the new terms that’s being abused these days is “Content Marketing”. A concept that seems old if looked closely. Brands need to do much more than just blast their messages left and right, they need to create content to engage their customers. But since when is this new? Brands always had that duty, and good ones delivered on it by creating their own content (commercials, radio plugs, print ads, etc) or by supporting 3rd party content.

Branded entertainment is a significant departure from previous brand marketing strategy [...] The rise of branded entertainment is enabling brands to shift from being mere sponsors to creators. We’re all used to seeing brands sponsoring entertainment as a means to get their logo and messaging in front of consumer eyeballs [...], now brands are becoming destination sites and platforms for entertainment, in and of themselves.

Let me entertain you: The rise of branded entertainment

Yes, brands need to entertain but that’s nothing new. The term “Content Marketing” places all the focus on content. Brands have always created content. What some have neglected is creating a lasting connection with the consumer. When these were created they were in an offline mode, meaning the messages where sent out and the customer could never participate. Because connections had that offline, non-realtime quality they were emotional connections, the ones with the highest chances to stick. We should bring that back.

The web has made one-to-one connections possible. Because of this the true focus of “content marketing” should be the creation of content that the consumers can (and want to) engage with, thus creating those connections. The Brand’s challenge is creating content that can rise above competition and that can be valuable enough to create a lasting relationship with its audience.

If I could I would rename “Content Marketing” to “Meaningful Marketing”.

On Constrains and Creativity

When you don’t have any money, it is easy to feel limited in what you can achieve. However, we have often found the most creative ideas come when you don’t have the luxury of big budgets.

Richard Branson: Why you should always aim high

Creativity needs constrains to flourish.

On Coding & Managing

No software engineering manager at a tech company should spend less than 30% of his or her time coding. Whether managing a team, a division, or all of engineering, when managers spend less than 30% of their time coding, they encounter a significant degradation in their ability to execute their responsibilities.

Engineering Managers Should Code 30% of Their Time

I can’t say if coding should take 10%, 30% or 50% of a manager’s time, but in order to stay relevant team leads should keep their skills sharp. It is a really tough thing, though, since there are so many things a manger is involved with. It is very easy to deprioritize coding, even more so when your team is talented.

On Getting Free Publicity on Black Friday

Amazon announced their crazy Drone delivery service on Sunday. Rumor has it that they’ve planned that announcement to coincide with the busy weekend of shopping and benefit from the generated chatter right in time for Cyber Monday.

Why did Amazon do that? The answer is free advertising. Even better: free advertising the night before the biggest e-commerce shopping day of the year, Cyber Monday.

How much was that free advertising worth? “60 Minutes” gave more than 15 minutes to its Amazon story. A 30-second spot during the 7 p.m. show usually costs just over $100,000. If you figure Amazon got 30 30-second commercials’ worth of time, you can estimate that it got about $3 million worth of “earned” media.

The Real Reason Amazon Announced Delivery Drones Last Night: $3 Million In Free Advertising On Cyber Monday

Is Jeff Bezos the most skilled content marketing expert?

On Gays Out-marketing The Church

“I think maybe we’ve been out-marketed, sometimes. We’ve been caricatured as being anti-gay. When you have forces like Hollywood, when you have forces like politicians, when you have forces like some opinion-molders that are behind it, it’s a tough battle.” ~Cardinal Timothy Dolan of New York

It’s a new world for PR.

  • My name is Omar Rodriguez-Rodriguez. I'm a creative, a technologist, a coder, a traveler, and an art fanatic.

  • Categories