Kiwi Dev Journal Day 13 - One step forward. Two steps back.

  • After getting bitten for the bajilionth time by Javascript’s lack of any typing I’ve decided to experiment with some of the bolt-on type systems to see if can help me out. It almost goes without saying, but in JS-land there seem to be two options to choose from:

    • no types at all: classes are the same as floats are the same as arrays –
    • STATIC TYPE CHECK ALL OF THE THINGS!!!
  • After many years in Obj-C with a very mature, very flexible, dynamic type system, moving to either strict typing or no typing both feel like a serious step down — when it comes to build apps.

  • No typing at all leads to some pretty weird bugs. I recently found that I was, in a corner case, storing a view into a generic Object instead of the class proper class for the view. Everything carried on fine… for a while. It only really got weird when I asked another view to display it. 🤪🙃

Make a Plan

  • So here’s the plan: set aside 3 days (where “day” is actually an evening hobby-coding session) to integrate tools, experiment, then convert code.
    • Tools: TypeScript or Flow?
      • I started with TypeScript. It seems to be the most popular, Microsoft is pushing it, and it’s really well integrated with VS Code. But I found the default behaviors a bit over-rigorous. All of a sudden it’s as painful as writing Swift — which is exactly what my evening coding it trying to escape. After a couple hours I was doubting my plan.
      • Flow clicked for me quite a bit better. The default behavior of applying it only to some files seems like a real bonus. If I want some of my code to be more dynamic or if I use a library that doesn’t mesh well it should be easy to bridge the gap. After a couple hours I’ve got a few files converted and feel like it’s already helping out.
      • /Result: Flow — at least for now/
    • Experimentation: setting up my workflow and annotating a few files. Overall I found it very frustrating getting any text editor to show the promised syntax checking.
      • Sublime: My current go-to editor. But I just could never get it to do anything with the flow add-ons. They said they were installed but… nothin. I’m really bummed out about this. Sublime had never let me down in this way before.
      • VS Code: I did manage to get this one installed. Yeah! But it didn’t work right. Something was clearly wrong – whenever there were too many syntax errors it would crash the syntax add-in and poof, no more error checking until a restart. I don’t really need this sort of extra hassle in my life.
      • Atom: I had initial trouble getting it to find the binary – but after finally finding the magic path that it wanted all is awesome. Works great. Fast too! It abused all 12 processors in my Mac Pro. That’s a big win. The compile and syntax checking are basically instantaneous. Also: since the last time I tried Atom they have a totally new vi-keybindings add-in. It is the best vi-mode in a modern text editor – EVER. SOLD!!!!
      • /Result: In a surprise come-from-behind finish: Atom!!/
    • Conversion: I’m a good chunk through existing code. I’m cheating a bit when it comes to some of the libraries I’m using. You can annotate just about anything as “Object” and it just ignores that thing. It’s actually a heck of lot like “id” in Obj-C. I know Swift devs will probably think I’m nuts, but I actually really like NSObject and the “id” ambiguous type. While they can be the source of many bugs if abused, when used wisely they can help to create some powerful idioms and patterns that are very difficult to recreate in a strictly typed language.
    • /Result: I’m liking Flow more and more. So, it would be a good time to sell-short if you’re heavily invested in Flow. I Always back the wrong horses./

I love strong typing when doing systems programming and other lower-level code. But I’m still not entirely sold on using it to assemble apps. It often feels like a lot of busywork that has little benefit to the day to day tasks of attaching list-views to controllers. I don’t need more busywork, or anything really, to complicate that task — just let me do it in the least keystrokes possible. I’m finding Flow a very mild form of type annotation that’s much more flexible than I anticipated. I think I’m going for it. Cross your fingers for me. I’ve got a lot of annotations to write.

#dotblog #devjournal

What is this: these are random snippets from my dev journal working on a simple client app for fun. This is a non-serious side project, progresses very slowly, and will probably never see the light of day. The images may not perfectly correspond to the journal entry. In most cases I’ve added them later based on the relative time of git checkins.

isaiah @isaiah