Weekend resources for new Kotlin programmers

by Joey deVilla on February 20, 2016

jetbrainsOver the years, JetBrains have released a number of nice development tools. Many of you from the .NET world live and die by ReSharper, the add-on that supercharges Visual Studio and takes a lot of drudgery and donkey-work out of .NET development. If you’re a Java developer tired of the nightmare of self-flagellation that is Eclipse, you probably use IntelliJ IDEA, which is a far nice environment to work in. And if you’re building Android apps, you probably are still giving thanks for Android Studio, which was built on IntelliJ.

kotlinSix years ago, JetBrains embarked on a project to build a new programming language named Kotlin after an island near St. Petersburg, Russia, where one of their development teams is based. On February 15, 2016, JetBrains announced the 1.0 release of Kotlin, which in their own words, “works everywhere where Java works”:

  • IntelliJ IDEA, Android Studio and Eclipse
  • Maven, Gradle and Ant
  • Spring Boot (Kotlin support released today!)
  • GitHub, Slack and even Minecraft :)

You can try out Kotlin online or on your own development environment:

  • IntelliJ IDEA (Ultimate or Community): just create a Kotlin project or a Kotlin file in a Java project
  • Android Studio: install the plugin through Plugin Manager
  • Eclipse: install the plugin through Marketplace

…then download its documentation from the official site, after which you should check out these perfect-for-weekend-enjoyment resources…

First, a little reading material

why kotlin is my next programming language

Start with Mike Hearn’s essay on Medium, Why Kotlin is my next programming language. It lays out a pretty complete list of reasons why you’d want to take up development with Kotlin. If you’re convinced by the end of the essay, continue with the videos below…

The Fragmented podcast on Kotlin

fragmentedIf you’re going for a walk, run, bike ride, or to the gym, and you’d like to find out more about Kotlin, check out the October 2015 edition of the Android-centric Fragmented podcast in which hosts Donn Felker and Kaushik Gopal talk about Kotlin with Hadi Hariri, JetBrain’s developer advocacy lead. This one’s pretty in depth and runs 1 hour and 25 minutes.

Fun with Kotlin

Eder Bastos, and Android developer at Raizlabs, takes under 8 minutes to provide a nice tour of the Kotlin programming language and why you should consider it for your next Android project. This was published January 14, 2016:

Kotlin: New Hope in a Java 6 Wasteland

Michael Pardo gave a Kotlin talk at Droidcon NYC 2015 on August 27, 2015:

Kotlin: The Swift of Android

Here’s Svetlana Isakova of JetBrains (creator of Kotlin, Android Studio, ReSharper and a whole lot of IDEs) at DroidCon Berlin on June 4, 2015:

Android Development with Kotlin

Presented by Jake Wharton at the AndroidKW Meetup in Waterloo, Canada, December 3, 2015:

You may also want to take a look at these other Android/Kotlin presentations by Jake Wharton:

Functional Programming with Kotlin

Here’s a talk by Mike Hearn (the same Mike Hearn who wrote Why Kotlin is my next programminglanguage) where he shows Kotlin in action, with an emphasis on functional programming. This one was posted November 5, 2015, and he’s demonstrating using a pre-1.0-beta version:

{ 0 comments }

Apple vs. FBI

by Joey deVilla on February 20, 2016

apple vs fbi

{ 0 comments }

Crypto

iphone passcode

By now, you’ve probably heard that the FBI’s current fight with Apple, in which they’re trying to get the company to build workarounds for the phone’s security protections in order to be able to brute-force guess the iPhone passcode used by Syed Rizwan Farook, one of the suspects in the December 2015 San Bernardino shooting. The passcode isn’t just some piece of information you have to provide to gain access to an iPhone; it’s actually part of the key used to encrypt and decrypt iPhone memory contents, as shown in the diagram below:

overview of apple key derivation

Apple key derivation, from Apple’s iOS Security Guide, September 2015.

iOS has a number of measures built in to make brute-force guessing difficult, including an optional setting that disables the phone after 10 wrong passcode entries and a mandatory delay between passcode entry attempts (which, for later phone models, grows in length with each failed attempt). The FBI believe that Farook turned the “ten strikes and you’re out” setting on the iPhone on, which is why they’re demanding that Apple provide a workaround.

Corbató’s Law

password

The FBI/Apple situation may have left you asking questions, but one question you might not have asked is “Who came up with the idea of using passwords to secure access to files?” With computer science being such a young field — the formal definition of computable didn’t appear until the 1930s, and the oldest programming languages are from the 1950s — many of its pioneers are still alive. This is the case with the lock-files-with-passwords creator, Fernando J. Corbató. In a 2014 interview with the Wall Street Journal, he said that the password system has become unmanageable these days.

Corbató has made many other contributions to our field that we benefit from even today, including:

corbatos law

Simply put, what Corbató is saying is that every day, you only have so many lines of code in you. The corollary to Corbató’s Law is that for maximum productivity, you should use a programming language that lets you do things in as few lines as possible — a language that minimizes yak shaving.

Cartoons

The term “yak shaving” was first used in its programming sense at the MIT Media Lab around 2000, and likely comes from this episode of the ’90s cartoon series Ren and Stimpy:

As Jeremy Brown from MIT put it:

…yak shaving is what you are doing when you’re doing some stupid, fiddly little task that bears no obvious relationship to what you’re supposed to be working on, but yet a chain of twelve causal relations links what you’re doing to the original meta-task.

Many programming languages require you to do some amount of yak shaving, but one notorious culprit is also one of the most popular: Java.

Kotlin

kotlin(In case you missed it, I wrote a little bit about Kotlin yesterday.)

Here’s a simplified version of the dreaded class example you’re likely to find in a programming textbook: the Person class. It’s a data class — we’re really using a class as a structured record type, since Java doesn’t have any. This one has two fields that won’t change once instantiated: name, a string, and age, an integer value. Here’s the Java implementation:

Here’s a Kotlin Person class that does everything that the Java Person class above does, but in one line as opposed to ten:

Kotlin lets you specify a primary constructor on the very same line as the class keyword, and you can specify other constructors within the class with init. The val keyword defines name and age as write-once properties, which automtically provide getter methods. By annotating the class with the data keyword, you add all sorts of data class goodies like equals, hashCode, toString. Simply put, using Kotlin in place of Java means less yak shaving. I’m a little more interested in Android development now.

{ 0 comments }

current side projects february 2016

tampa ios meetup buttonFor “Get Your Game On”, my recent presentation at the Tampa iOS Meetup, which I run with mobile designer extraordinaire Angela Don, I put together a “Frogger”/“Crossy Road”-style game. I’ve continued tweaking it and have got the basic game mechanics up to the point where I’m pretty pleased with how they’re working. Now comes the hard part: all the polish, which may take a while. Here’s what it looks like on the iOS simulator — it runs a lot more smoothly on an actual device:

aspirations winery

I’ve also taken the basic game code from the “Cookie Crunch” tutorial on Ray Wenderlich’s site, updated it to work with Swift 2 (it’s written for Swift 1.2, and won’t work in current Swift without some tweaking) and to make it more my own, and turned it into a game for Aspirations Winery, which I’m hoping to release soon. It won’t make me any money, but it’ll help fatten my App Store portfolio, and it’s already landed me lots of free wine:

kotlinAnd finally, on the Android front, I’ve been giving Kotlin a try. If Java drives you crazy and have wished for am open source, Swift-like language for Android development, the folks at JetBrains (the people behind the so-much-better-than-Eclipse Android Studio) have created the Kotlin programming language, and it’s so much more nicer to program in. There’s so much less “yak shaving”:

java

Kotlin 1.0 was just released, and you can get the plugin for your preferred Java/Android IDE at the Kotlin site. You can also take it out for a spin at the Try Kotlin page. Give it a try — I think you’ll like it!

{ 1 comment }

The Facebook logo, explained

by Joey deVilla on February 10, 2016

facebook logo explained

Makes sense.

{ 0 comments }

2 additional gb
It’s happening today only — Wednesday, February 10, 2016 — but if you’ve got a Google Account, they’re offering 2 GB of free additional space on your Google Drive, just for double-checking the security on your account. Who these days can’t use an additional 2 GB of online accessible-anywhere storage space and the peace of mind from an account whose security credentials are up to date?

To take advantage of this offer, point your browser to Google’s Security Checkup site (if you’re not already logged into a Google account, you’ll be asked to do so). You’ll be taken to a page where you’ll be asked to confirm three different categories of security information:

  1. Your recovery information. This is used in those hopefully-rare cases where Google detects suspicious activity on your account and wants to reach you or when you’ve forgotten your login credentials.
  2. Your connected devices. You’ll be presented with a list of devices connected to your Google account, and if you see any you don’t recognize, you can take steps to fix the problem.
  3. Your account permissions. You’ll see a list of applications, sites, and devices that have permission to access your Google account. You can disconnect any that you don’t want to let into your Google account.

I went through the process just now, and for less than half a minute’s worth of effort, I walked away with an extra 2 GB of cloud storage. Kudos to Google for incentivizing good security on online accounts. Now go, secure your Google account, and get some extra free storage!

this article also appears in the GSG blog

{ 0 comments }

rey and bb-8
iron yard logo

Tonight, as part of Tampa Bay Startup Week, Anitra and I will be helping the people from the coding school The Iron Yard Tampa Bay with their Hour of Code event! It’s an hour-long training session where kids ages 8 – 12 and teens ages 13 – 17 can get a quick, fun introduction to coding with the help of Rey and BB-8 from The Force Awakens and Princess Leia and R2-D2 from the original trilogy.

Here’s a quick video intro to what the Star Wars Hour of Code’s all about, courtesy of Star Wars: The Force Awakens’ producer Kathleen Kennedy and Rachel Rose, lead engineer for Star Wars’ animation and creature development team…

The programming interface that Hour of Code participants use is delightfully simple and fun. They drag and drop “blocks”, which represent calls to functions, to move the droid characters like BB-8 and R2-D2 around, arrange them into sequences which function as programs, and then click the “Run” button to see if their code worked.

It starts off with the simple task of moving BB-8 towards a single piece of scrap metal:

star wars code 01

Click the screenshot to see it at full size.

…but about a dozen lessons later, you’re writing considerably more complex stuff that includes concepts like variables, branches, and loops, and changing droid characters:

star wars code 02

Click the screenshot to see it at full size.

tampa bay wave

If you can make it to tonight’s Hour of Code…

The event takes place tonight at Tampa Bay WaVE, 500 East Kennedy Boulevard, Suite 300 at 6:30 p.m.

If you’d like to have your kid or teen participate in tonight’s event, go to Tampa Bay Startup Week’s event schedule and sign up for the appropriate event. You’ll need to bring a fully-charged laptop (and it’ll be a good idea to bring its power cord) or tablet with working wifi and browser in order to work on the code. It can run Windows, Mac OS, Linux, iOS, or Android — as long as it’s got a relatively recent browser and can connect wireless to the internet, it’ll work for this class.

If you can’t make it to tonight’s Hour of Code…

…you can still code your way through the galaxy by visiting Code.org’s Star Wars site!

code.org star wars

Have fun, and may The Source be with you!

{ 0 comments }