Category Archives: Development

Mobile Cross Platform in C++

Will write C/C++ for foodPSPDFKit Blog: “PSPDFKit started in 2010 as an iOS-only project. Back then there was just one person working on it. 6 years later, we’re 28 people, have frameworks for iOS, Android and the Web, and our core framework even runs on OS X and Windows.”

Great piece on cross platform development using C++ and a tool from Dropbox called Djinni to help make things look native.

I’ve been toying with the idea of making RxCalc run on Android and the first thing I want to do is rewrite our Pharmacokinetics Math Library (PkMath) in C++, which ironically began life in C++ and was ported to Objective-C.

Regarding Style

RibbitAs I’ve gotten older my coding style has evolved. I’m a fairly verbose coder which can drive some people absolutely crazy but it works for me. It makes code more readable.

Case in point. Something I get questioned about all the time is why do I write false if conditions like this.

if (nil == thing) {
    // Create a new thing

Instead of doing…

if (!thing) {
    // Create a new thing

Well, that’s easy. My eyes can pick it up instantly. One other thing about that syntax. It’s a hangover from over 20 years of writing C and C++ code. The compiler will bark if you try to a value to zero. In that way it served as a way to make sure you didn’t accidentally make a mistake that could take a while to find. Let the compiler help you where it can.

I really like it more for readability. Opinions vary.

It doesn’t matter

Medium: “It surprised me to find that the vast majority of the apps in the top 100 are still building without any Swift.”

This shouldn’t be a surprise. In the end nobody cares what language you use to build your app, especially if it does what you want, performs well, and has a good design. 

Some may say I’m an old guy, so I shouldn’t be taken seriously. I will tell you this. If it ain’t broke, don’t fix it. That’s the proper attitude to have when developing software. I’m not saying you should never rewrite a section of code. On occasion that’s necessary, but if code works and doesn’t need to be touched as part of a new feature, just let it ride. You’ll be fine. 

In the end it just doesn’t matter.

My Dearest Apple

If you’re a developer in the Apple ecosystem you’ve no doubt heard of Swift, and could be developing with it every day.

I work for a little shop focused on Agronomics Software and Services. Our service is like many gigantor services in thee market; a website with a backing REST based service. It’s a magical cloud! 

We also develop a mobile client for iOS. Our products are Objective-C based but recently we’ve been writing new features in Swift. 

Swift is a really nice language. It takes some getting used to and the syntax is super sugary. As an old C/C++ developer a lot of it feels right at home. We get to trade a dynamic language for strong typing, which doesn’t bother me in the slightest but might bug died in the wool old-time Objective-C developers. Anywho, suffice it to say I’m enjoying it, and I hope to develop in this language for many years to come.

You’re probably saying “What’s your point, man?”

What I’m trying to say is I hope Apple goes whole hog and gives us a new framework for application development. That’s right, leave Cocoa as it is, put it in maintenance mode and do everything from this day forward with a new set of frameworks built entirely in, and for, Swift.

I also hope Apple can bring more of the concepts learned from UIKit back to the Mac. We have a wonderful set or portable API’s with Cocoa, but the Mac feels a bit neglected. If a new set of frameworks were developed Apple could start fresh, leave out the cruft, and give us new frameworks built to take advantage of Swift’s language features.

Get your tools!I would imagine this idea makes app developers cringe. What about all those years invested in Cocoa? For years to come I would imagine Cocoa apps would receive plenty of support and still be first class citizens. Remember what Adobe went through to bring Photoshop to the Mac when Carbon was dropped? Yes, it can be painful, but knowing ahead of time Apple will eventually pull the plug on Cocoa would be helpful, if they ever feel like taking on such an ambitious project.

In 2000 (I think that’s the correct year) Microsoft brought us .Net with the C# programming language at a time when the Windows API (Win32 API) and C/C++ were the primary way to create great native Windows apps. This is what we used at Visio. Lots and lots of C/C++ with the Windows API, later on we introduced MFC into the mix, and finally after bein acquired by Microsoft we integrated Office shared components (MSOx.dll’s.) Microsoft to this day still writes in C++ for its Office apps but most development outside is now done in .Net in C# — I’m sure Microsoft is doing plenty of work in C# and .Net. It’s a very powerful framework and programming language and is getting the lions share of the attention. It was a big risk, but it has paid huge dividends for the Windows ecosystem.

This can be done, is my point. Apple did it with Carbon to Cocoa and Microsoft had done it with the Windows API to .Net Framework. It feels like we are primed for a new Apple Framework that embraces Swift.

Please note, I’m not suggesting that Apple should completely abandon Cocoa. If this type of change happens maybe they can keep parity between the two for a while to give developers time to switch. Remember, Carbon was released in 2000 and finally fully deprecated in 2012, it became way less useful in 2007 when it was not updated for 64-bit applications. Depending how you look at it, Apple supported Carbon for seven, or 12 years. If they allowed for a five year overlap of feature support before fully deprecating Cocoa they could allow developers to move into the new, completely Swift, framework.

Recently we have seen Dropbox fully embrace Swift. With the Dropbox V2 API the Dropbox team has dropped support for Objective-C. That speaks volumes. It’s obvious they feel strongly about the future of Swift.

Is a movement to an all Swift Apple Framework in our future? Your guess is as good as mine, but it is obvious Apple is embracing Swift as its language of choice for future software development.

Work Note – Swift Thoughts

wrongSwiftLogoI’ve been working in Swift more and more over the past couple months. To get started I wrote a simple parsing class for Agrian, the product I work on. More recently, as in this week, we started doing most work in Swift. The syntax is super sugary and will take some getting used to, but I can already see I’m going to love working in it.

It seems if you have a background in C, C++, or C#, you should feel right at home. I wonder how JavaScript developers feel about it? If you have an opinion feel free to leave a comment, or write about it on your weblog. I’m curious what you have to say.

This afternoon as I was working on the app I found myself wishing I could do something like this with Swift.

[swift light=”true”]let textView = UITextView() {
.userInteractionEnabled = false
.font = .defaultFont(14)
.backgroundColor = .yellowColor()

It feels like a natural thing to do, I don’t know why, but it does. We’re working in Swift 2.0, so if there is a way to do this, please let me know, I don’t think we can, but I’m such a noob, I’m not sure about much.

Jeff Hokit’s “Maven”

Jeff Hokit [via Medium]: “I usually reach for the Mac Dictionary application but that day I went for my iPhone, forgetting that there was not a house-made dictionary app there.”

Jeff is the real deal. He’s a long time Mac Developer and one time Apple Employee. He’s very talented and such a great guy. It is so nice to see him start writing about and sharing his code. If you want to learn how to do things the right way look no further, go check out his code base.

While you are at it go download Blossom. It’s a beautifully designed and executed app.

Thanks for sharing, Jeff. 

Native Development on Windows

Yesterday I asked on Twitter…

I got one serious answer and some fun poked at the question, which is fine, but I think it points to a real problem on the Windows Desktop. 

Has Microsoft given up on native applications at a time when native on Apple Platforms and Android have never been more popular?

On Apple Platforms we have clear, well defined, native development tools for creating serious desktop applications. Think of apps like Photoshop, or more modern takes on graphics like Sketch, Acorn, Pixelmator, or OmniGraffle. Most of these applications are written in Objective-C against Cocoa (Apple’s Framework for writing applications.) Sure, Photoshop is the old guy in the mix and is built on a custom framework written in C++ that communicates down to Cocoa (and possibly some Carbon API’s?) also worth noting, with the exception of Photoshop, not a single app mentioned above is cross platform (I’m not including Mac to iOS as cross platform, many of the API’s are the same and the act of going from one to the other is much easier than going to a completely different platform.)

All that brings me back to the question of developing native applications in the vein of Visio or Photoshop on the Windows Desktop. I’ve seen plenty of talk about creating Universal Apps, but those seem geared toward a lighter weight style of application, singular purpose apps focused on lightweight tasks, like Twitter or Facebooks clients, not hard core productivity applications that need to perform well and provide their best experience on the Desktop.

We still have Visual Studio, C++, and the Windows API, as a development platform but it feels somewhat abandoned. I know the folks working on the C++ compiler would probably argue against that statement because Microsoft is definitely investing in C++, but what about OS level API’s? That is the level that sort of feels abandoned. We have WinRT today, which seems like it might be part of the story for native desktop development, but do you mix and match that with the Windows API to build a great native application, do you use WinRT alone, or do you just continue to plug away with the Windows API?

It seems that apps built for the modern Metro look should use WinRT? Based on that it seems the old tried and try combination of C++ and the Windows API would still be the best choice for hard core desktop development.

But what about C# and XAML? Maybe those are a good choice for serious desktop development? I’m unclear on that subject. I’ve heard that the Visual Studio IDE was rewritten in C# for Visual Studion 2012, but I don’t know if that’s true or not. If someone reads this post and can point to MS Office, Visual studio, or Photoshop class applications written in C#/.NET I’d love to hear about them. Worth noting is the wonderful toolset by the folks at Xamarin, it makes C#/.NET app development truly cross platform.

Being a long time C++/Windows API guy I still gravitate toward that toolset. Hey, I have a lightweight class library I wrote in 1993-94 that still works today; it builds with Visual Studio 2015 and runs fine on Windows 10, but it could certainly use some refactoring given the state of modern C++. Think C++14.

I’ve been working on a cross platform project recently using Qt, which has me think about portable C++ for Mac, iOS, Windows, and Android. Given C++14 as a starting point for most OS level services; file I/O, threading and synchronization, etc, what would it take to build a modern C++ library that handled native user interface creation and interaction and didn’t feel too constraining on the platform? Remember, most cross platform tools come at a price. They’re always a little behind, they tend to be least common denominator, and can feel non-native. Qt, for instance, doesn’t use native controls on Windows (NOTE: this may not be true today. This was true around 2008, the last time I looked), I find that terribly annoying. I’m sure any Mac, iOS, or Android developer worth their salt would also find it annoying. 

A nice new C++ framework for building native OS level user interfaces using modern C++ as a base would be great to see. I really wonder how long it would take to build such a thing?

Learning to Code Today

Duct Tape, fixer of all things!
Ken Mazaika [via Medium]: “Problem #1: You NEED to Learn HTML9 Responsive BoilerStrap JS (or whatever JS Framework is trending today on HackerNews)”

Go read the entire article. There is a lot of truth to what Ken says, in particular, ignoring algorithms in favor of the just learn this thing shortcut. That is a disservice to anyone interested in learning to code. If you’re focused entirely on some “stack” of software that’s popular today, but don’t understand the fundamentals, you’re going to hit a lot of brick walls when you need to move to something different. Moving to a new set of tools is difficult enough, not having a firm foundation only compounds the problem.

Here’s an example from my own experience. I’d like to learn Ruby and Ruby on Rails, but I’d really like to learn Ruby first. Rails is full of magic and that doesn’t sit well with me. I need to understand how things work before I’m willing to use them. Same thing goes for JavaScript. It’s why I bought Douglas Crockford’s JavaScript: The Good Parts, so I could focus on understanding the language without all the garbage piled on top of it. 

I’m not recommending you start there, this is what I need to do to learn new stuff, but if you are just getting started you need to learn the basics before learning today’s hot programming language, or the latest “stack.”

Fundamentals matter.

Yes, a Medium API would be great

Cameron Barrett [via Medium]: “I love Medium. It’s a fantastic writing tool. I wish, more than anything else, is for Medium to have an API. This would allow for the development of a WordPress plugin, a Drupal module, etc. that would allow Medium to be “the network” you mention above, while still allowing me (the author and copyright holder) the ability to publish on my site/blog first and syndicate out to Medium.”

I find myself reading on Medium more and more. It’s like a really nice RSS reader in a lot of ways and it gives me the River of News I want without the unread count cruft I hate.

Having the ability to publish from here and have it show up in Medium’s feed would be great. Not reposting, just publishing the title and slug, with a link back here is all we need. 

In fact it would be fine if the article is displayed inside of Medium then you could use all of Medium’s awesome annotation tools. Have you used the highlighter yet? It’s incredible, I love it. How about the inline commenting? (Ok, it’s in a sidebar, but you get the picture!) It’s a wonderful platform, with great tools, and it would be great to be able to flow data into it.

Come to think of it, all the need is an RSS from this site to integrate it, right?