Thursday, October 17, 2019

The winner is CodeSandbox, Overmind, etc

At last! The holy grail. Or a close approximation.
A while ago I did an assessment of Dev environments in the cloud
Now I’ve settled on one.
My goal was a genuinely frictionless programming environment. One where everything I do happens instantly—or at least quickly.
I want to make a change and see a result.
Just like that.
I also want a sensible methodology for programming. One that organizes code so that I can create it rapidly, maintain it easily, modify it efficiently, test it thoroughly, and deploy it effortlessly.
I’ve got something that’s a candidate.

My programming environment

I’m using:

CodeSandbox

Codesandbox is my development environment. It lets me check stuff out of Github with a Chrome Extension that makes creating a new SandBox a one-click operation.
Once I’ve made my changes, I can commit back to the repository—if it’s mine—or create a new one from the IDE.
CodeSandbox plays nicely with React, Overmind, and Firebase. And with Node Package Manager (NPM), I can grab any library I want with a few keystrokes.
Equally important: if I want to understand how a library works, I can create a SandBox that contains one of the library’s examples. Then I can play with the example it until I’m sure it will do what I want.
When I make a change, CodeSandbox uses Hot Module Reloading (HMR) to only reload what needs to be reloaded. The result is that any change in my code appears in my app more-or-less instantly.
Whatever I commit to Github gets deployed automatically by Netlify.
So my workflow looks like this: checkout, modify, modify, modify, modify, commit, then automatic deploy.
If I want to save an intermediate state, I can fork my SandBox, and if I’m headed in the wrong direction, I can go back to an earlier version.
I can organize SandBoxes in directories, and if I have one that I like, I can turn it into a template.
And CodeSandbox lets me work on the entire app or just one module. Which is kind of awesome.

Building with Overmind

I build an application by creating a data model using Overmind in a SandBox, testing it, then connecting the model to a user interface built with React.
Overmind is my data modeling and state-management tool.
I define a JSON object that represents my application’s state, a set of actions for modifying the state, and a set of effects that interact with the outside world.
Overmind delivers state, actions, and effects anyplace I need it,
I can write scripts invoking actions and effects and verify that the scripted code transforms the state the way I want. I can confirm that by observation (Overmind has a development tool that displays state and a record of actions) or by writing tests that verify.
State contains explicit values and values derived from other parts of the state. Overmind magically updates the derived values when the values on which they depend are updated. Just like a spreadsheet.
Later, when I hook Overmind to React, Overmind will magically tell React to rerender any part of the UI when the state on which the UI depends changes.

UI components

Once the state works the way I want it to, I use a CodeSandbox feature that lets me work on one UI module at a time.
I write a UI module and tell it which state variables to render, and Overmind and React re-render components when values change.
As I’m writing my code and change the code for UI component, it gets rerendered in well under a second.
Then I hook user interactions in the UI to the actions and effects I created. User does something, action or effect fires, the state gets updated, UI gets rerendered, just like that.
As I finish my lower-order components, I combine them into larger components. As far as CodeSandbox is concerned, a component is a component is a component. So as I tweak a higher-level component, everything within it that needs rerendering just does.
If I discover a problem in action, I can change the action and try it again.
Since the state is just a plain old Javascript object, I can save it and restore it any time I want.
When I’m done, I commit, and deploy happens automatically as I go on.

What’s next?

Next, I’m going to make a series of videos to show all this stuff

Sunday, June 9, 2019

Dev environments in the cloud

I’ve been experimenting with cloud development environments.
Here are the ones I’ve been using and what I’ve learned about them.
TL;DR
Cloud development environments are so capable now that it hardly makes sense to install a development environment on my computer. At least for that kind of development.
CodeSandBox.io is going to be my primary environment for a while. It’s got what I need. I may also use Scrimba.

JSFiddle.net

This is the old school JavaScript sandbox. This is the one that things off it all and the first one that I used. Today it seems well behind the times. I have also used some others, like JS Bin, Fiddle Salad, and repl.it

Plunkr

I used it when I was messing around with Angular and facebook. I’ve still got a couple of Plunks in my library.

CodePen.io

I used it for a bunch of client-side experiments. The great thing about it was instant response and excellent editing experience.

Glitch.com

Glitch was the first environment that I used that handled both client side and server side. So It was a complete node development environment, and I did some exportation into Google’s APIs with it. Its user interface is a little funky and weird. I don’t think it compares well to the alternatives below.

Google Cloud Console

Google gives you your own Linux Docker container, freshly provisioned each time you use it. That’s a problem because it takes a lot longer to spin up than some of the other environments. You can also define your own customized VM, so you have a degree of flexibility that you don’t get elsewhere.
Also, there’s an elegant tool for building your own tutorials.
The editor is pretty crappy, and it keeps disconnecting, so not so much.

Gitpod.io

Lets you clone any Github repository, branch or commit into a VM that it provides for you. It even has a browser extension that puts a GitPod button on your Github pages. Click and get a gitpod. But it takes a while to spin up your VM. There’s got to be a better way because everyone the others do it better.
Unlike Google Cloud console’s VMs, these persist. But each Gitpod is independent of the rest.

CodeSandBox.io

CodeSandbox is really fast. You can embed CodeSandbox apps in your web pages (or blog posts) I’ll post at length, later.

StackBlitz.com

StackBlitz is the runner up. Maybe more to come later.

Bit.dev

An excellent environment for finding and tuning up pre-made React components.