Flutter is Dart’s Killer App

This past week we started using Google Flutter to build a new mobile app for Invoice Ninja, I thought it may be helpful to share some of the things we’ve learned early on.

What is Flutter?

At a high level it enables building high quality mobile apps for iOS and Android using a single codebase. While this has been possible for a while now with frameworks like React Native the catch is they use a JavaScript bridge which can impact performance. Flutter compiles to native ARM code, in theory it could be considered ‘more native‘ than a native Android app which compiles to JVM bytecode.

For the record, this isn’t the first time I’ve fallen hard for a new Google technology (anyone remember GWT). That said Flutter is receiving glowing praise from the developer community, myself included.

Here are some key points to be aware of:

  • It’s completely open source, you can drill down into the libraries to understand how they work and debug problems.
  • Everything is a widget, the architectural patterns are very similar to Adobe Flex.
  • It’s becoming very popular very fast.
  • It supports hot reloading which applies code changes in real time while retaining the application state.
  • It provides a comprehensive widget library.

And some of the reasons I believe Flutter will succeed:

  • ARM is the future of mobile/mobile is the future of computing.
  • JavaScript isn’t very good, or more accurately it wasn’t initially designed for how it’s being used.
  • Probably most importantly… it’s fun to use.

Setting up a Development Environment

The setup guides are good but I ran into a few problems. I initially started on Ubuntu Linux but in the end wasn’t able to get my test app to build, the details are here in case you have any ideas.

I then switched to my MacBook. After dealing with a Homebrew issue I was able to get it running. The last OS I tried was Windows which worked out of the box.

You can choose between two code editors: Android Studio (which is built on IntelliJ) or Microsoft’s VS Code. I’ve found VS Code runs faster however Android Studio provides a more seamless experience with better debugging tools.

A few points worth mentioning:

  • On first launch I had trouble with the Android virtual machine. By default it uses x86, I needed to download a 64bit version for it to run.
  • I initially started on the beta Flutter channel but after a short while I ran into an issue which forced me to change to the dev channel.

Learning Flutter/Dart

When I learn a new technology I’m a fan of reading a book cover to cover, sadly I wasn’t able to find any Flutter books on Amazon (yet). That said their docs are excellent and there are a fair number of tutorials online.

Here are some standout references.

I’d also strongly recommend installing the gallery app on your phone, it’s a great way to discover all of the available widgets.

Finally, it’s worth mentioning that Flutter recently switched from Dart to Dart 2. A new feature in Dart 2 is the ability to remove the ‘new’ keyword when creating objects, you’ll notice a lot of older examples still include it while newer examples don’t.

Deciding on an Architecture

Probably the biggest decisions you make when developing an app (once the technology stack has been chosen) is deciding on the architecture. It seems the main choice right now comes down to whether or not to use Redux.

While many developers love it there is definitely pushback from others who feel it requires too much boilerplate code. This article by the co-author of Redux does a great job detailing the pros/cons.

The latest advice from Google seems to be to use Streams and BLoCs (business logic components) to create reactive apps, that said it doesn’t preclude also using Redux. I think the co-author of the flutter_redux package explains it well on this Reddit post.

Redux is basically a StreamController sitting in an InheritedWidget at the root of your app. StoreConnector is just a wrapper for StreamBuilder with some helper functionality.

Note: the comment will probably make more sense once you’ve learned what any of those words mean.

Starting to Code

At this point I’ve only been writing Dart/Flutter for a few days but I think I have a reasonable sense for the possibilities it enables.

Live reload is amazing but I should point out it doesn’t always work, it’s useful when fine tuning the style of a screen but can fail when making large changes to the codebase.

And finally, back to Dart. I remember first hearing about it and thinking it looked cool but at the time I had no reason to use it, with Flutter that’s no longer the case.

Continue to part 2 >>

Using a foot pedal for ctrl and alt modifiers on Ubuntu

I’m a big fan of my DataHand (or one of these) but overtime I’ve found the Ctrl and Alt modifiers a bit uncomfortable.

One of my favorite hotkeys is to use the ctrl key with left or right to move between words but that has me regularly holding down the key.

The solution I’ve found is to use a USB foot pedal, here are the steps to set it up on Ubuntu.

First use evtest to determine the /dev/input/event number and the button codes

evtest
/dev/input/event16: OLYMPUS CORPORATION HID FootSwitch RS Series
Select the device event number [0-16]:
Event: time 1456855230.136267, -------------- SYN_REPORT ------------
Event: time 1456855230.528267, type 4 (EV_MSC), code 4 (MSC_SCAN), value 90011
Event: time 1456855230.528267, type 1 (EV_KEY), code 272 (BTN_LEFT), value 0
Event: time 1456855230.528267, -------------- SYN_REPORT ------------
Event: time 1456855230.872269, type 4 (EV_MSC), code 4 (MSC_SCAN), value 90012
Event: time 1456855230.872269, type 1 (EV_KEY), code 273 (BTN_RIGHT), value 1

Then use evrouter to map the buttons by creating a file called ~/.evrouterrc with the following contents (you’d likely need to update the values).

"" "" any key/272 "XKey/Control_L"
"" "" any key/273 "XKey/Alt_L"

And then run evrouter

evrouter /dev/input/event16

Sites to help predict future trends

One of the challenges working as a programmer is keeping up with new technologies. Although many appear promising if you decide to spend the time to learn something new it needs to pay off in the long run.

There are two sites I primarily use to help decide, I consider both to be good leading indicators of the future success of a language/framework/library/etc.

All technologies will eventually go out of date, the challenge is picking ones that will hang around for a while.

Food For Thought

This post may seem a bit out of place on the blog and I guess that’s because it is. In a nutshell: I got sick, I learned how to eat and I got better. These are my current thoughts on food and nutrition. We’re all different, as always do what’s best for your snowflake of a body.

There’s always talk of low carb or high protein or zero fat or … but they’re missing the point. It’s not one versus the other it’s which of each.

We’ll start with fats. Coconut oil for high heat cooking and olive oil for low heat cooking. We’re starting to accept the myth that saturated fats are bad was just wrong. They’re stable and hold up well to high heat, if your oil is smoking throw it out.

As a questionable runner up I’ll mention Canola oil. It’s low in Omega-6 fats but it’s heavily processed. You get olive oil by squeezing the olives, the process for canola oil is a bit more complicated.

For protein, meat’s important but most of us eat too much of it. Organic makes a lot more sense here as you’re higher up the food chain but it can get expensive.

We’ve been ingrained with the belief that processed foods are bad, but the positive approach is to aim for high nutritional density. Kale gets it’s great reputation because it’s at the top when compared this way.

Eggs got a bad wrap, they truly are a super food. Most of the cholesterol in our blood is made by our body. A far more important indicator is the ratio between the types and densities of cholesterol.

I can always judge how well I’m eating when I’m standing at the checkout lane at the supermarket. The basic idea with shopping is to mostly buy from the perimeter of the store.

What we don’t see when we buy our food is all of the bugs in it. We’ve become a germ phobic society but only 10 percent of the cells in the body are human. I like the quote that antibiotics were the science of the 20th century while probiotics will be the science of the 21st century.

It’s good to eat your vegetables with meals raw, cooked and fermented. Raw sauerkraut and pickles are a great source of natural probiotics.

With fiber it’s important to note the difference between soluble and insoluble fiber, the former slowing you down while the latter speeds you up. Psyllium seed powder is a great natural form of soluble fiber.

Two common food triggers to watch out for are gluten and dairy. The best way to check for a sensitivity is to eliminate it for 30 days and then add it back for a few days in a row.

The trouble with gluten is more accurately an issue with Zonulin (sounds like a bad guy from a Superman comic) which can loosen the gut lining.

Most people can digest dairy when younger but many lose the ability as they get older. It’s akin to losing our hearing as we get older but digestive health and genetics plays a role.

Bone broth soup is one of the single best foods you can eat. Some frozen veg (brocoli, colifower, carrots, etc) boiled in broth and then pureed with a hand mixer makes a great soup. Maybe add a bit of coconut milk and some salt & pepper.

The future of web development is Laravel

PHP is an old friend, going back close to 15 years. It was the first language I used. Back then it was the obvious choice for web development if you were running Linux/Apache, it was free and it was popular.

Over the years other languages/frameworks have appeared which have definitely captured the “cool” factor. The two obvious ones are Ruby on Rails and Python/Django. It’s possible to argue that Ruby and Python are more aesthetically pleasing languages to code in but their real draws are the MVC implementations of Rails and Django.

From a business stand point PHP makes a lot of sense. The more recent versions are dramatically improved and it’s incredibly well supported. There are far more PHP developers which helps keep costs down and it scales. If it’s good enough for Facebook chances are it’s good enough for you.

The challenge has always been finding the right MVC framework. Laravel solves this problem. It provides a best-in-class MVC implementation for PHP.

Reading the tea leaves it’s clear that I’m not the only one who feels this way. This is from Google Trends and leanpub.com. It feels good to be excited about PHP again.

As a side note, using puPHPet, Vagrant and VirtualBox to create virtual machines to play with Laravel makes me feel like a programming super hero with the power to create worlds.

A programmer’s attempt at marketing

I’ve always believed that if you create an amazing app people will find you. While I still think that’s true, what if you simply don’t have the time, resources or ground breaking idea to create an amazing app. If you’re just experimenting with a new framework you might be limited to creating just ok apps. Apps which may offer a novel experience but don’t have the same level of polish as apps by big name publishers.

This is where I found myself a few months ago. I’d like to share with you my successes and failures thus far. If you have suggestions for things to try in the future please post your suggestions in the comments below.

First a brief explanation of the app. It’s called Music Maker Pro and is available for 99 cents in the Apple App Store. It enables you to easily create music by tapping a few boxes. In an effort to increase awareness of the app I created a free browser-based version which you can try at http://mscmkr.com.

On to the traffic… the graph shows the number of new users per day over the past three months to both the free and paid versions. It can be roughly divided into four sections.

Stats

  • Paid advertising (blue) To get started I used a combination of AdMob and Facebook ads. While paying money definitely got me traffic the conversion rates were way too low for this approach to be profitable.
  • One big tweet (red) My next tactic was to try to get well-known people to spread the word. Scott Hanselman was kind enough (thanks again Scott!) to share the link on Twitter and Google+, the results speak for themselves.

  • Letting time do it’s thing (yellow) Here again the results speak for themselves. Doing nothing achieves nothing. I may have posted to the app’s Facebook group or sent some random emails but I clearly didn’t do anything to move the dial much.
  • The Chrome Web Store (green) I wasn’t expecting much but this has turned out be my best move to date. The app is now available here and so far has generated decent growth in traffic.

As I opened with, I think a key determinant of the stats is the app itself. While mine isn’t total crap it probably won’t win any design awards either. The competition in the app market is pretty intense. With the advent of in-app purchases, publishers can spend millions of dollars developing apps which they release for free.

Any time I read a random article on a developer’s download stats I’m always hoping to get a dollar amount. On average I sell about one or two apps a day. While it’s not a lot it pays for the server costs and definitely beats my last two mobile apps for which I’m still in the red :/

Secure password primer

More and more these days I’m getting “I was hacked… ignore my emails” emails from friends and family (I won’t get into the inherent paradox which exists here). I thought it might be helpful to write a short post explaining the rules to follow to help prevent this from happening.

  • It can’t be too simple
  • It needs to be unique

There are two main ways by which evildoers get your password: they try to guess it or they steal it. Choosing a complex password makes it far more difficult for your password to be guessed. Here’s a good site with instructions on choosing a password as well as a great xkcd comic on the subject.

The problem we’re now faced with is making sure it’s unique. Although you can probably trust Amazon to securely store your password the same may not be true of some other random site you use. If they get hacked (and they didn’t store your password encrypted) bad guys now have your email address and password and will try it on other sites. A good password is harder to remember than “1234” so it’s clearly a challenge to remember a unique password for every site you use.

Here are two ways around this problem: You can use a tool which will store your password for you such as lastpass. Although they offer browser plugins to make entering your password easier you should keep in mind that this can be inconvenient when using a friend’s computer or Safari on your iPhone. The other option (which is especially useful for sites you rarely check) is to use a random string of characters and simply use the “forgot my password” feature when you need to log into the site.