Skip to content

Instantly share code, notes, and snippets.

@satindar
satindar / animations.swift
Created October 25, 2016 16:57
Useful animation code
// Delay function
func delay(_ seconds: Double, completion: @escaping ()->Void) {
DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + .milliseconds(Int(seconds * 1000.0))) {
completion()
}
}
@satindar
satindar / Blerrgh post draft
Created May 8, 2015 04:26
Imperative vs. Functional Programming
With the rapid growth of languages and framworks such as Swift and React you may have heard the terms functional, declarative, and immutability more often. It's often contrasted with the term "imperative". Many authors of technical blogs will assume that you know are familiar with what these terms mean but since so many developers are self taught (particularly in web and mobile programming) it's a big assumption that the reader is comfortable with these terms.
When these terms are described to a developer they may offer the responses, "I have no idea what you are talking about" or "Oh, that makes sense. Isn't that just called...uh...programming?". Of course if you've only programmed in a certain domain you may only be familiar with one particular paradigm. Describing a paradigm as "data and behavior are encapsulated as objects and these objects can influence and change other objects by passing messages" may sound insane to a developer that has only worked with Haskell, but a Java developer would be right at