Getting Started with Swift, For NON-Apple Devs

This past weekend I attempted to get started with Swift coding. Since I have not been an Apple Developer for a while, it wasn’t immediately obvious how to get started. But once I fumbled around a few minutes I realized I needed a developer account to get the latest XCode. Jeez, it really shows how much Apple loves to lock you in hard core to their development ecosystem. An unfortunate trait of a company that is actually extremely closed in much of its behavior, while taking advantage of so much of the open source community. But I digress, this isn’t a rant about the unethical behavior of Apple. I’ll reserve that for the novels worth of material it deserves.

One I signed up for the developer program, which costs $99 bucks, I immediately made my first huge mistake. This damnable mistake blew the entire weekend of hacking. I added under “Company” my simple DBA (Doing Business As) name. I already had an account, and because of this change for making this existing account become a developer account from a personal base level account, sprung a red flag. I checked back frequently over the weekend, but it wasn’t until Monday that somebody checked the app, realized the Company name I added was merely a DBA and ok’d my account. So far, 38 hours down the drain for getting started hacking on Swift! Dammit.

However, this morning I was happy to find everything was ok’d, and thus, the remaining bit of this blog entry is a bit more example and a little less story of my day.

Developer @ Apple
Developer @ Apple

Getting XCode 6 beta

I wanted to do Swift hacking, the first step was to download XCode 6 beta. That’s available via download on the iOS Developer page (and I suppose the Mac Developer page). Scroll down on that page until you find the XCode Download button.

The Warnings and the Download XCode 6 beta page.
The Warnings and the Download XCode 6 beta page.

Also note, if you’re looking to do Swift hacking like I’m doing here, I’d actually advise against getting the iOS 8 beta or OS-X Yosemite Developer Previews right now. Best to keep as stable a machine while toying around with a new language. At least, that’s what the conversations have been so far…

OS-X Yosemite & iOS 8
OS-X Yosemite & iOS 8

Once I got Xcode 6 beta installed I dove right into creating a Swift Project. I created a simple new project that is empty to just check out what Xcode 6 provides out of box for the Swift Project.

Selecting an empty Xcode 6 beta project to use with Swift.
Selecting an empty Xcode 6 beta project to use with Swift.

The next dialog is where the Swift magic is selected.

Selecting Swift, entering a project name and other information dialog.
Selecting Swift, entering a project name and other information dialog.

After that I just clicked through on defaults until I got into the Xcode IDE with the project open.

Selecting the appropriate simulator.
Selecting the appropriate simulator.

Next I executed the project. Since I’d had my phone attached it wanted to run it there, but I have 7.1 iOS on it which won’t execute Swift code. I had to select the appropriate simulator then to run the application project. Once that ran, since I’d not done so on this particular computer, I needed to enable developer mode.

Enabling developer mode.
Enabling developer mode.

I did so and the empty application launched.

An empty iOS 8 iPad Retina Application.
An empty iOS 8 iPad Retina Application.

So that’s the basic getting started, no code actually slung. But rest assured I’ll have another post soon detailing some first code snippets. I also hope to get some comparisons written up between XCode with Swift and Xamarin Studio and C#. It’s cool that Apple finally has a modern feature rich language, so it’ll be interesting to see how each stacks up from a language and IDE perspective.

References:

Un-breaking OS-X Mountain Lion

I posted a blog entry about my efforts last week, which included a rather frustrating experience with a freshly loaded OS-X Mountain Lion install. I had installed XCode and eventually got the Command Line Tools installed, which I outlined in the entry. Things seemed to be working ok, and for the most part in doing other things all is good, but when trying to install middleman and by reference blockenspiel I ran into an issue getting the C compiler (or any of the compilers I tried) to build the native extensions that were included in this gem. Here’s what I installed and did to finally – FINALLY – get things running right.

The first thing, since it kept coming up, was to get Homebrew installed.

[sourcecode language=”bash”]
ruby -e "$(curl -fsSkL raw.github.com/mxcl/homebrew/go)"
[/sourcecode]

I’d already installed RVM, which consists of either the JewelryBox or

[sourcecode language=”bash”]
$ \curl -L https://get.rvm.io | bash -s stable –ruby
[/sourcecode]

After that I installed Ruby 1.9.3p327.

[sourcecode language=”bash”]
rvm install 1.9.3
[/sourcecode]

You can check the RVM and Ruby versions by using the -v switch. Also to verify what ruby versions you actually have installed with RVM you can use the list command.

[sourcecode language=”bash”]
Adron$ ruby -v
ruby 1.9.3p327 (2012-11-10) [x86_64-darwin12.2.0]
Adrons-MacBook-Air-2:~ Adron$ rvm -v

rvm 1.17.2 (stable) by Wayne E. Seguin <wayneeseguin@gmail.com>, Michal Papis <mpapis@gmail.com> [https://rvm.io/]

papis@gmail.com> [https://rvm.io/]

Adron$ rvm list

rvm rubies

=* ruby-1.9.3-p327 [ x86_64 ]

# => – current
# =* – current && default
# * – default
[/sourcecode]

When I ran ‘rvm requirements’ the current readme doc that is displayed covers a lot of the problems I’ve noticed. It seems there is all sorts of stupid issues between the GCC Compiler and XCode and blagh blagh blagh somebody didn’t even check our stuff before we shipped. This actually goes into detail about what the issues could be if you too have run into this problem.

[sourcecode language=”bash”]
To use an RVM installed Ruby as default, instead of the system ruby:

rvm install 1.8.7 # installs patch 357: closest supported version
rvm system ; rvm gemset export system.gems ; rvm 1.8.7 ; rvm gemset import system.gems # migrate your gems
rvm alias create default 1.8.7

And reopen your terminal windows.

Xcode and gcc:

Right now Ruby requires gcc to compile, but Xcode 4.2 and later no longer ship with gcc. Instead they ship with llvm-gcc (to which gcc is a symlink) and clang, neither of which are supported for building Ruby. Xcode 4.1 was the last version to ship gcc, which was /usr/bin/gcc-4.2.

Xcode 4.1 and earlier:
– Ruby will build fine.

Xcode 4.2 and later (including Command Line Tools for Xcode):
– If you have gcc-4.2 (and friends) from an earlier Xcode version, Ruby will build fine.
– If you don’t have gcc-4.2, you have two options to get it:
* Install apple-gcc42 from Homebrew
* Install osx-gcc-installer

Homebrew:

If you are using Homebrew, you can install the apple-gcc42 and required libraries from homebrew/dupes:

brew update
brew tap homebrew/dupes
brew install autoconf automake apple-gcc42
rvm pkg install openssl

Xcode 4.2+ install or/and Command Line Tools for Xcode is required to provide make and other tools.

osx-gcc-installer:

If you don’t use Homebrew, you can download and install osx-gcc-installer: https://github.com/kennethreitz/osx-gcc-installer.

Warning: Installing osx-gcc-installer on top of a recent Xcode is known to cause problems, so you must uninstall Xcode before installing osx-gcc-installer. Afterwards you may install Xcode 4.2+ or Command Line Tools for Xcode if you desire.

** NOTE: Currently, Node.js is having issues building with osx-gcc-installer. The only fix is to install Xcode over osx-gcc-installer.
[/sourcecode]

If you need to uninstall XCode you’ll have to follow the directions for each specific version you may have. However for 4.5.2 the steps are as follows.

[sourcecode language=”bash”]
sudo <Xcode>/Library/uninstall-devtools –mode=all
[/sourcecode]

I wrapped up the current changes and those listed above as follows to see if I could get a good build.

[sourcecode language=”bash”]
sudo chown -R `whoami` /usr/local
brew update
brew tap homebrew/dupes
brew install apple-gcc42
[/sourcecode]

At the end of all this, still problems. Apple completely screwed the Ruby Community on this one. But really, at the end of the day, the message is don’t frikkin’ install XCode before you get an appropriate gcc installer on your machine. At this point…

I did the unthinkable. I gave up and nuked my machine, loading OS-X back on with a completely fresh installation that has now XCode on it. I went through all of these steps again, minus installing XCode out of order and guess what…

Everything worked.

Computers, ugh!

Until next time, good luck with your install.

Apple iOS / OS-X vs. Windows 8 / RT == OS Goulash & Predictions

All These Thoughts Derived at Seattle Coffee Works in Downtown Seattle
All These Thoughts Derived at Seattle Coffee Works in Downtown Seattle, a good place to enjoy the use of an iPad or Windows RT Tablet.

Ok, I’ll admit it, I have a soft spot in my heart for Windows 8. At least in the tablet form. I honestly prefer it over the iPad model of little icons displayed in a grid over a background with the bar of app icons at the bottom. Don’t get me wrong, I find the iPad remarkably usable and will have one for many years to come. I have sketching, drawing, movie making, picture taking, code writing, code pushing, deployment, comic books, books and other applications that I’m not about to just give up. But Windows 8 is very compelling.

I really hope it pushes Apple to make some change with their own UI to update it a bit. The icon placement and icon bar at the bottom is fine, but I’d really like to have more information available to me at a glance, which is something that Windows 8 on a tablet (or phone for that matter) enables in an extremely easy way.

In addition to that information, the stark design colors of Windows 8 are definitely better than the “we’re Apple and make futuristic devices that disrupt the markets but simulate every physical traditional thing we can”. Matter of fact I find Apple’s inane obsession with making accurate recreations of wood, notebooks, calendars, file cabinets and all that absurdly stupid. It’s great that some graphic artist can do that, but jeez, I’d like my interface to be as futuristic and disruptive as my device.

Overall, the two operating systems for tablet devices – iOS and Windows 8 (or RT, whatever they’re going to call it) – are pretty amazing in their own right. As of this moment though, I’ve come to the conclusion that I will very likely be getting at least one Windows 8 device. Emphasis though, on device – singular. If Microsoft has finally cracked that nut (their other hardware isn’t bad) than I might just start buying some Microsoft “device(s)” in the future that would obviously be running Windows OS. If they haven’t cracked the device nut, then it might be a short lived experiment.

I’m wondering, if you’re really not an Apple or Windows fan and you’re going to give either device an honest kicking in the coming months, I’d love to hear your input on the device. I’m sure I’ll hear a whole bunch of arbitrary ad hominem nonsense from the fans of either platform over the next few months. There will surely be a lot of FUD and propaganda thrown out of every media outlet either corporation can get their money funneled into too, I’m however keeping a close eye on blogs and real people providing feedback that have used both. That notice this or that difference, all those little things.

Being that we’re so flippin’ close to the release of Microsoft’s new flagship OS, Windows 8 and Apple, no doubt, will come back kicking with something this competitive cycle is starting to get interesting again!

Meanwhile, the wild card of Android is sitting in the sidelines. Will someone actually make a move and kick it into the fray? It seems to be the lethargic thing with zero marketing budget and zero existence. It’s sad even though it is such a massively robust environment and ecosystem compared to Windows RT/8 and much more open and capable than the iOS ecosystem.

With all that said, those thoughts thought, here’s my prediction. Yes, I’m going to be one of those guys and make a silly prediction. I’m not taking bets but this is it, this is the SWAG. Along with this SWAG though, I’m throwing out a hope. Because I honestly don’t want them to overtake Apple because I’d be absolutely sick if the absurd hubris of Microsoft came back. Nothing was worse during the 90s and 00s than Microsoft’s hubris (yeah, Apple’s was easy to ignore, Microsoft’s was just annoying)

My Windows 8 / Windows RT Tablet Prediction

  • Prediction: 90 million devices in about 2-3 years.
  • My Hope: 45 million devices in 2-3 years, 90 million in 3-4 years.

…and I leave this blog entry with a single question. What is your opinion and what device have you found that peaks your interest the most? Is it Samsung’s devices, Dell’s or simply the Microsoft Surface?

Steve Jobs

I have paid attention to Steve Jobs only in knowing he was producing some pretty sexy products at Apple. I had never owned one until December 23rd of 2011.  I had however respected Apple & Job’s Products. I knew very little about the level of his drive and passion. I also knew little about his rock star attitude, which often cast him as the “asshole”.

It was time to learn more about Steve Jobs. What better way than to give the recent bestseller a read. You know, the one with his face planted right on the front. By the end of the book, I had rooted for Apple far more than I had imagined I would have. I have damned them over the years far more than I should have and I have respected them a little less than is due. Apple with Steve Jobs at the helm has indeed done some amazing and great things.

After reading the book I came away with a new respect for Jobs, more than I already had. I had learned he is not the hippy nut he’s portrayed as, nor some capitalist pig, but all of the above and somewhere in between. I found him to be a dreamer, loves intensely, and is passionate about creating. Something we all could learn from. Creating new beauty, designs, products that enable us is indeed one of the great human achievements.

Some of the key parts of the book include his interactions with his parents, not the blood parents, but his honorable and loving parents that actually raised him. Stood fast beside him and cast aside things to enable and help him learn. One of the quotes that stood out as how awesome his father was, reminding me of my own father, “Paul Jobs told the teachers, his son recalled, “If you can’t keep him interested, it’s your fault.” His parents never punished him for his transgressions at school. “My father’s father was an alcoholic and whipped him with a belt, but I’m not sure if I ever got spanked.” Both of his parents, he added “knew the school was at fault for trying to make me memorize stupid stuff rather than stimulating me.” He was already starting to show the admixture of sensitivity and insensitivity, bristliness, and detachment, that would mark him for the rest of his life.”

He grew into this way of acting, and I really can’t wrong him for it regardless of who he cut down with his wrath, because he knew and wanted people to jump into the fire with him. He didn’t want nor deem that he wanted to waste time with people that couldn’t step right up to a brash, honest, and give 110%. Maybe I related with it too much, I try diligently to avoid such outbursts or other characteristics, but I for one don’t have a problem working with people like that. I want passion for a product. I want love of design. I want an insatiable desire in people around me to create.  I can absolutely understand why he did too.

Late in the book, the reader learns of other battles Jobs had. He saw himself as a person of the counterculture, and thus naturally part of the political left. Even though he throughout life rarely involved himself directly in politics. But because of this, and the views of the counterculture on technology at the time he was often torn. Regarding the counterculture, “Many in the counterculture saw computers as ominous Orwellian, the province of the Pentagon and the power structure.. In The Myth of the Machine, the historian Lewis Mumford warned that computers were sucking away our freedom and destroying “life-enhacning values.” An injunction on punch cards of the period-“Do not fold, spindle or mutilate”-became an ironic phrase of the antiwar left.”

It was something that Jobs, as his life unfolds in the book, just faced up to and dealt with. Eventually the counterculture caught up with the times and became enraptured with technology, in large part because of Apple & Steve Jobs.

Overall I think the book captured Jobs in a realistic way. In the typical Jobs fashion too, the book ends with a segment written by Jobs himself. You’ll have to give the book a read yourself to know what it says, but suffice it to say he managed some amazing things in life. He was also very much more aware of the world regardless of his “Reality Distortion Field” and insanely passionate about insanely great products.

In summary, a great read. Pick it up!

A Few Choice Quotes:

“If you want to live your life in a creative way, as an artist, you have to not look back too much. You have to be willing to take whatever you’ve done and whoever you were and throw them away.”

– In a scary way, this holds to be true, as an artist grows and evolves the previous passion often must be cast aside to find an ongoing and new passion.

“God gave us ten styluses, let’s not invent another.”

– A statement that the purchasers of the iPad, iPod, and iPhone proved through purchasing millions of these devices and turning Apple into the world’s most valuable company. I just found it rather funny myself, yet rings very true.

“Stay Hungry, Stay Foolish”

– Nuff said!

“Simplicity is the ultimate sophistication.”

– Passion embodied in a simple phrase.

“Here’s to the crazy ones. The misfits. The rebels. The troublemakers. The round pegs in the square holes. The ones who see things differently. They’re not fond of rules. And they have no respect for the status quo. You can quote them, disagree with them, glorify or vilify them. About the only thing you can’t do is ignore them. Because they change things. They push the human race forward. And while some may see them as the crazy ones, we see genius. Because the people who are crazy enough to think they can change the world are the ones who do.”

– Yes, it was the ad, but it is one of those times when an ad becomes something a bit more, one could almost say it becomes art.

Reality Distortion Field : 17 Companies’ Sitrep

I’m sitting on the bus this morning. As happens almost every day of the week. I’m flipping pages, sort of, it’s an eBook on my Kindle App. I’m reading about Steve Jobs taking over the Macintosh Program at Apple. How things started to fall into place for Apple, for the Macintosh, and how Jobs saw what could be a pushed for it. Everybody else; Microsoft, Xerox, Canon, and practically every single other company was missing it. Xerox Parc had it right in front of them, the GUI, Mouse, Object Oriented Language, and about every single thing we assume for computer use and development today but wasn’t doing anything with it. They were all missing it, except Jobs. The eccentric, crazed, reality distortion field generating Jobs pushed forward and found those that agreed, this was absolutely the future. Today’s computers owe so much to Jobs efforts to pull these people together, to what he saw as the future, and our modern computing world will forever be indebted to Steve Jobs.

Howard Hues had done this 50 years earlier. He simply stated, “nobody wants to fly on a plane at 10k feet and get shaken to pieces, planes need to fly at 30,000 feet or more where the air is smooth!” He then went about working to get a plane built that could do this! The Government was in his way, the industry was fighting him, everybody said this wasn’t the way to go. Nobody could build a plane that would do that right now! It’s absurd. He did it, and bought every single one of them he could putting the airline (TWA) in hock at the same time! But it paid off, and his airline had the nicest planes, best flight in the world, easily. Today’s airlines are all modeled after this ideal, our modern travel owes a huge debt to what Howard Hughes pushed forward.

The competition, the fighting pushed the envelope, but in both cases a visionary could see the future. To them it was plain as an image on a clear sunny day. To them, the future didn’t need to be tomorrow, it was ready right now. The future just needed dragged kicking and screaming directly into today! They did this, they pulled people together who could make these changes, and they with their teams yanked the future right into humanity’s grasp.

Utility Computing / Cloud Computing

With those thoughts flying around at Warp 10 in my mind, everywhere, at every moment it seemed to occur to me. We’re merely putting the motherboards and cassette tape drives together right now in cloud computing. We have no Macintosh of cloud computing, we have no clear direction, there has to be something bigger, much bigger. At this point we’re merely making small steps, slight little strides toward the future. What we need to do is create the future and pull it directly into now!

There could be more though. Some of these things are being put together by individuals at various companies, oriented toward the platform level. There is, somewhere, a growing movement toward that next big shift in the way things are done. The gap between big architectures, big ideas, and launching these things is decreasing by the day – literally!

With these big ideas and big architectures and all the small steps and small pieces the industry is moving in the right direction. We’ve experienced shifts over the years and some more are definitely coming up very soon!

The Playing Field : Sitrep

With these thoughts racing around I felt compelled to look at where the industry stands right now. These are in no particular order, they all provide some type of building blocks for the next big thing, all in some aspect of the industry.

Amazon Web Services : This one should not need explaining. They’re probably the most utilized, nearly the most advanced, robust, price conscious utility storage, compute, and services provider in existence today. They continue to defeat the innovator’s dilemma over and over again, this company, and the departments in the company are hungry, very hungry and they fight the fight to stay in the lead.

Cloudability : This company is about keeping utility/cloud computing costs in check, and knowing where and when you’re pushing the pricing limits among all the various building blocks. There has been more than a few issues with billing, and people blowing through budgets by inadvertently leaving on their 1000 node EC2 instances and Cloudability helps devops keep these types of things under control stopping overages cold!

New Relic : The key to this offering is monitoring of everything, everywhere, all the time. New Relic offers absolutely beautiful charting and information displays around services, compute, storage, and a zillion other metrics among Ruby, PHP, Python, .NET, and about everything else available.

Puppet Labs : Imagine operations, IT, and systems administration all rolled into a single bad ass company’s product efforts. Imagine ways to automate and monitor ritualized machines, get them deployed, all with elegant and extremely powerful tools. Imagine that power now, you’ll know what Puppet Labs provides.

Opscode : The cloud needs management, hard core powerful management. Opscode and their respective chef product does just that. The influence of chef has gone so far as to influence Amazon Web Services (and others) to design their systems automation in a way as to enable chef usage. The devops community around Opscode is growing, the inroads to systems agility they’re making is getting to a point as to even be considered a disruptive market force!

Joyent : The birthplace of node.js, do I need to add more? Well, ok, I will. Joyent has a host of amazing devs, and amazing ops goals. The advances coming out of  Joyent aren’t always associated back to the company (maybe they should be) but rest assured there is some heavy duty research and dev going on over there. Things to check out would be their SmartDataCenter and of course the JoyentCloud.

MongoHQ : Mongo HQ is one of the distributed cloud hosting provider for Mongo DB. Mongo HQ  is also a supported provider in several of the other PaaS Providers such as Heroku and AppHarbor.

MongoLabs : Mongo Labs, another distributed cloud hosting provider for Mongo DB. Mongo Labs is also a supported provider in several of the other PaaS Providers such as Heroku and AppHarbor.

Nodester : Nodester is a hosting solution for node.js applications beautifully distributed in a horizontal way.

Nodejitsu : One of the leading node.js hosting providers and a very active participant in the community in and around New York.

AppFog : AppFog is a Platform as a Service (PaaS Provider) that is working on providing a cloud based horizontally distributed platform for creating applications with a wide variety of frameworks and languages. Some of those include .NET, Ruby on Rails, Java, and many others.

PhpFog : This is the PHP root of the PaaS Provider AppFog. They have a good history and an absolutely spectacular architecture for PHP Applications with a screaming simple and fast deployment model to cloud/utility based systems. They have a really great product.

Heroku : Deploy Ruby, Node.js, Clojure, Java, Python, and Scala. Probably the leader in PaaS based deployment right now. Got git, get Heroku, get push heroku master is about all the gettin’ for your application to be running there.

EngineYard : Think Ruby, Ruby on Rails, Rubinius, or any other aspect of Ruby and you’ll probably arrive at EngineYard in short order. The teams at EngineYard are heavily active in the cloud & Ruby scene. They are easily one of the leaders in PaaS based git workflow deployment in the Ruby & Ruby on Rails Community. They also, however, support tons of other technologies so don’t think they’re limited to just Ruby & Rails.

AppHarbor : The .NET Framework, often thought to be left completely out in the cold when it comes to serious cloud computing git based agile work flows, finally got included with AppHarbor! With the release of AppHarbor the trifecta of IaaS and a solid PaaS offering were finally available for the .NET stack.

Windows Azure : Windows Azure is Microsoft’s official cloud service, which supports a host of capabilities centered around a mostly PaaS based service. Windows Azure has however spread into SaaS and IaaS also. Some of the frameworks and tools they support include Ruby on Rails, Java, PHP, .NET (of course), node.js, Hadoop and others.

CloudFoundry : Cloud Foundry is an open source PaaS Solution that serves to link up various back end and front end architectures. Currently it is supported by a host of companies including VMWare, AppFog, and others.

Putting the Pieces Together

That’s where we stand in the industry today. We have all the pieces and they need fit together to create something great, something awesome, something truly remarkable. I fully intend to create part of the future, will I see you there? I’d hope so!