Categories
Programming Video

Worth watching: Videos on programming paradigms and object-oriented vs. functional programming

Watching programmers debate can sometimes be like watching a monkey knife fight.

Even in this day and age, when programming languages freely mix object-oriented and functional features, there are still arguments over which approach is “better”, or at least which one should be used in a given situation. Here are some videos that cover these paradigms; they might event give you some insight on how you can use them in your day-to-day coding.

4 Programming Paradigms In 40 Minutes – Aja Hammerly

Here’s a nice overview of four programming paradigms: object-oriented, functional, procedural, and logical, including the strengths of each. Start with this one.

Why Isn’t Functional Programming the Norm? – Richard Feldman

Functional programming is actually the earliest programming paradigm, but it’s not the primary paradigm of any of the top ten programming languages that programmers are using in 2019.

Object-Oriented Programming is Embarrassing: 4 Short Examples — Brian Will

In this video, Brian Will — an OO skeptic — takes four examples of “proper” object-oriented code and rewrites them using a procedural approach, resulting in what he considers to be “better” code. He’s not a big fan of the philosophy where data and code grouped together — he says “Let data just be data; let actions just be actions.” I leave it to the viewer to make their own call as to whether he’s right or wrong. (Hey, I figured I should throw in at least one curmudgeon into the list!)

FP vs. OO: Choose Two — Brian Goetz

When it comes to FP vs. OO, I’m of the “Why not both?” school of thought, and so in Brian Goetz.

Categories
Humor Programming

The five phases of software development

It wasn’t the answer the professor was looking for, but I’d have given it at least 6 out of the 10 points the question was worth.

If you search for “5 phases of software development”, you’ll find that there isn’t a complete consensus on what those phases are, or even if it’s just five.

Categories
Programming Video What I’m Up To

Now that I’m getting paid to be a developer again…

…it’s time to revive this video that New Relic put out way back in 2011 to promote their application monitoring service.

Titled We Love Developers, it features some of the brightest lights in the industry:

  • Matz: Yukihiro Matsumoto, creator of the Ruby programming language
  • Guido van Rossum: Creator of the Python programming language
  • Linus Torvalds: Creator of the Linux operating system and the Git version control system
  • DHH: David Heinemeier Hansson, creator of the Ruby on Rails framework
  • Bill Joy: Co-founder of Sun Microsystems and creator of the vi text editor
  • James Gosling: Lead designer of the Java programming language
  • Sir Tim: Tim Berners-Lee, creator of the World Wide Web
  • Marc Andreesen: Co-creator of Mosaic, the first widely-used web browser, co-founder of Netscape, co-founder of Andreesen Horowitz
  • Woz: Steve Wozniak, creator of Apple
  • Rasmus Lerdorf: Creator of the PHP programming language
  • The Gu: Scott Guthrie, creator of ASP.NET, Executive VP of Microsoft’s Cloud and AI group
  • Sergey Brin: Co-founder of Google
  • Dries Buytaert: Creator of Drupal

At the end of the video, they wanted to use the image of a more “everyman” developer to represent you, their customer. Guessed who they picked:

My photographer friend Adam P. W. Smith (my old business partner; together, we were datapanik software systems and we worked on some pretty interesting projects back in the late ‘90s) took the picture back in August when I was visiting him in Vancouver. I’d arrived a day early for the HackVAN hackathon and was sitting in his kitchen getting some work done when he decided to get a couple of shots. He poured me a glass of scotch, set it on my accordion, which I’d set down on the chair beside me, and staring taking pictures.


In case you were wondering, you can find out more about my new gig in the article titled — appropriately enough — The new gig.

Categories
Humor Programming The Street Finds Its Own Uses For Things

ArnoldC: A programming language based on Arnold Schwarzenegger’s movie one-liners

Do you like programming? Do you like Arnold Schwarzenegger movies? If so, ArnoldC is the programming language for you!

ArnoldC will never make the TIOBE list, but then again, no other programming language is based on Arnold Schwarzenegger’s movie one-liners! Better still, there’s an ArnoldC syntax highlighting package for Sublime.

Here’s “Hello, World!” in ArnoldC:

IT'S SHOWTIME
TALK TO THE HAND "hello world"
YOU HAVE BEEN TERMINATED

It compiles down to Java bytecode. Running the program above is as simple as saving it as hello.arnoldc and entering the following on the command line:

java -jar ArnoldC.jar hello.arnoldc
java hello

Find out more about ArnoldC on its GitHub page, and once you’ve been impressed, download it, start coding, and GET TO DA CHOPPA!

Since we’re on the topic of Arnie, enjoy this video:

Categories
Programming

Looking for a great conference on iOS development? Check out RWDevCon!

If you’re interested in iOS development and are looking for a conference to attend next year, I highly recommend RWDevCon, the all-tutorial, mostly-iOS conference run by the fine people at the tutorial site RayWenderlich.com!

It takes place during April 5 through 7, 2018 in Alexandria, Virginia, and will feature…

…four in-depth workshops…

  1. Swift algorithms: build your own collection type, and while doing so, dive into the semantics, performance, and expectations of each Swift collection protocol. Then you’ll explore ways to write your code that takes advantage of this new knowledge.
  2. Machine learning: A hands-on workshop where you’ll harness CoreML and Vision framework and find out what machine learning is, train a model, and then integrate it into an app.
  3. Practical instruments: Finally learn how to use Xcode’s instruments to see how you apps works, find out where the bottlenecks are, and boost your app’s performance.
  4. And finally, the workshop I’m giving: ARKit — where you’ll learn about the features of Apple’s ARKit augmented reality framework, harness data from the camera and your users’ motions, present information and draw images over real-world scenes, and make the world your View Controller!

…and all these presentations…

  • Living Style Guides
  • Swift 4 Serialization
  • Architecting Modules
  • Cloning Netflix: Surely it Can’t be That Hard
  • Auto Layout Best Practices
  • Clean Architecture on iOS
  • The Game of Life
  • Android for iOS Developers
  • The Art of the Chart
  • Spring Cleaning Your App
  • Improving App Quality with Test Driven Development
  • Advanced WKWebView
  • Clean Architecture on Android
  • Getting Started with ARKit (that’s the one I’m giving!)
  • Custom Views
  • App Development Workflow
  • Integrating Metal Shaders with SceneKit
  • Xcode Tips & Tricks
  • Advanced Unidirectional Architecture
  • Embracing the Different
  • Lessons from the App Store

…and a party every night…

…all in a great venue:

Want to find out more? Visit RWDevCon.com!

Categories
Programming

Why “?:” is called Kotlin’s “Elvis operator”

At Victoria Gonda’s presentation on Kotlin at DevFest Florida 2017, she talked about many of Kotlin’s language features. (Be sure to check out the slides from her presentation, Kotlin Uncovered!)

When she got to the “Elvis operator”?: — there were murmurs in the crowd, and I could hear people whispering “why’s it called that?”. Hopefully, the photo above answers the question: it looks like an emoticon for Elvis.

The more formal name for the Elvis operator is the null coalescing operator, and it’s a binary operator that does the following:

  • It returns the first operand if it’s non-null,
  • otherwise, it returns the second operand.

It’s far more elegant to write

val result = value1 ?: value2

than

if (value1 != null) {
  result = value1
} else {
  result = value2
}

And in case you iOS developers were wondering, Swift has a null coalescing operator: it’s ??.

Categories
Humor Programming

Demonstrating map, filter, and reduce in Swift using food emoji

In my last article, I posted this graphic, which uses emoji to make it easier to understand what the map, filter, and reduce functions do:

map filter reduce in emoji

Since then, I’ve been asked by a couple of friends if what’s in the graphic is just pseudocode or if it could actually be implemented. I told them it was the latter, and here’s my implementation in Swift:

// Map

func cook(_ item: String) -> String {
  let cookupTable = [
    "🐮": "🍔", // Cow face -> burger
    "🐄": "🍔", // Cow -> burger
    "🐂": "🍖", // Ox -> meat on bone
    "🐷": "🍖", // Pig face -> meat on bone
    "🐽": "🍖", // Pig nose -> meat on bone
    "🐖": "🍖", // Pig -> meat on bone
    "🐑": "🍖", // Sheep -> meat on bone
    "🐐": "🍖", // Goat -> meat on bone
    "🐔": "🍗", // Chicken -> poultry leg
    "🦃": "🍗", // Turkey -> poultry leg
    "🐸": "🍗", // Frog  -> poultry leg (no frog leg emoji...yet)
    "🐟": "🍣", // Fish -> sushi
    "🐠": "🍣", // Tropical fish -> sushi
    "🐡": "🍣", // Blowfish -> sushi
    "🐙": "🍣", // Octopus -> sushi
    "🍠": "🍟", // (Sweet) potato -> French fries
    "🌽": "🍿", // Corn -> popcorn
    "🌾": "🍚", // Rice -> cooked rice
    "🍓": "🍰", // Strawberry -> shortcake
    "🍂": "🍵", // Dried leaves -> tea
  ]
  if let cookedFood = cookupTable[item] {
    return cookedFood
  }
  else {
    return "🍽" // Empty plate
  }
}

let cookedFood = ( ["🐮", "🍠", "⚽️", "🐔", "🌽"].map { cook($0) } )
// cookedFood == ["🍔", "🍟", "🍽", "🍗", "🍿"]


// Filter

func isVegetarian(_ item: String) -> Bool {
  let vegetarianDishes = Set([
    "🍟", // French fries
    "🍿", // Popcorn
    "🍚", // Cooked rice
    "🍰", // Shortcake
    "🍵", // Tea
  ])
  return vegetarianDishes.contains(item)
}

let meatFree = ["🍔", "🍖", "🍟", "🍽", "🍗", "🍿", "🍰"].filter { isVegetarian($0) }
// meatFree == ["🍟", "🍿", "🍰"]


// Reduce

func eat(_ previous: String, _ current: String) -> String {
  let qualifyingFood = Set([
    "🍔", // Burger
    "🍖", // Meat on bone
    "🍗", // Poultry leg
    "🍣", // Sushi
    "🍟", // French fries
    "🍿", // Popcorn
    "🍚", // Cooked rice
    "🍰", // Shortcake
  ])
  if (previous == "" || previous == "💩") && qualifyingFood.contains(current) {
    return "💩" // Poop
  }
  else {
    return ""
  }
}

let aftermath = ["🍔", "🍟", "🍗", "🍿"].reduce("", combine: eat)
// aftermath == "💩"

I put this into a Swift playground, which you can copy from this Gist or download here.