The following is a Coderland presentation
about our newest attraction, the Compile Driver.
[Doug] Hello! This is Doug Tidwell for Coderland, and
we are thrilled to have with us our good friend Don Schenck.
Don wrote the cool parts of the Compile Driver
sample that we published recently.
Don's part was the React-based front end that makes
the demo scenario much easier to use.
As you know if you've gone through the Compile Driver
- AND IF YOU HAVEN'T, WHAT ARE YOU WAITING ON? - If you've been through the Compile Driver,
the heart of the code does image manipulation via JSON;
with Don's code, you can see those results instantly on the screen.
Fabulous piece of work, check it out if you haven't seen it. So Don, welcome, how's it going?
[Don] Good, thank you, it's good to be here, everything's going fantastic.
The app is done and shipped, so
I'm thumbs up. [Doug] Yes, life is good until the next project starts. So there we go.
Tell us a little bit about how you worked with the camera. Because that was one of the things going into this
that I thought might be a hassle. Somehow getting access to the webcam,
from a web app...was that a big hassle? [Don] Well, it
wasn't a big hassle, but there were some interesting things.
So like anybody else, I used my web search Kung-Fu and
found a library for React, and that was simple enough.
It was a little bit challenging to figure out exactly what some of the settings were, but like any developer, you just start hacking
away, playing, and see what happens. But what I found interesting was that
running things became a problem because you can't use the camera
over an unsecured connection. In other words, you have to use TLS. If you just run straight HTTP,
the camera doesn't work. And you cannot, in Chrome, you cannot unblock it.
It blocks it. You don't have a choice, it doesn't even come up and ask you. You go to settings and it says, "Nope, you can't do this."
So you have to use TLS, HTTPS, to allow the camera
to be unblocked. Which I understand, I mean, it kind of makes sense so people aren't eavesdropping on you, I guess. [Doug] Reassuring, yes.
[Don] But you know how it is, you're a developer, and you get all this stuff and you think, "Oh, it's going to work," and then you find out, "Oh,"
"now I have to install a certificate on my server." So now you're going down these rabbit holes, like any other development project.
But in the end, I found a library that uses the HTML 5 Canvas, which allows you to use
the camera, and I found a really good Base64 encoding library to
send files back and forth, so I was off and running. [Doug] There you go. Cool. Base64
was one thing I thought from a Java perspective (the image manipulation code is a SpringBoot app)
and didn't really know what I was in for in terms of JSON mangling and
working with Base64. Base64 is baked into Java,
to my delight, I had not worked with those libraries before,
and there's a cool library called Jackson that works with JSON. So it automatically
serializes, deserializes as JSON, made
my life easy. Other things, as you know, did not make our lives easy [laughter]
as projects will. Tell us a little bit, and
your opinion, be as diplomatic, or not, as you care to be,
your opinions of Knative versus OpenWhisk, which I know you've used OpenWhisk quite a bit.
What are your thoughts on Knative as sort of an emerging thing
that seems to have a lot of momentum behind it.
[Don] Yeah. So there are two answers, or two parts to it.
So first of all, as a front-end developer, I don't care, because I'm not dealing with it. So there's that answer. But,
having dealt with, or put up with you dealing with it,
Knative got to be frustrating. So, comparing the two, and I don't want to
go too much into it, because I actually wrote a blog post that addresses this,
but OpenWhisk had all the plumbing, if you will, for RESTful interfaces
built into it. You don't have to code anything to handle HTTP requests. It's built in to OpenWhisk.
Creating a function is like, you write a file and you run a command and you have a function.
Knative is, what Knative has done is made
microservices into functions because they scale to zero.
And it has other, it has eventing, serving, and building,
and it works better for monitoring and
Istio is built into it. But Knative is going to win,
I think. There was some frustration dealing with it,
it's not as slick, I don't think, from a strictly developer's
first glance at it, but I guess like anything else, once you get used to it, it's fine.
From my standpoint as a front-end developer, it was just a URI.
But we did...yeah, it got to be a challenge.
It was fun. [Doug] I'll just share this for our millions of viewers tuning
in, the issue with Knative
is that to send requests to it you have to use the HOST header.
And an XHR, such as would be emitted by Don's React application,
can't modify the HOST header, so nothing would work.
Ultimately I hacked together a little proxy to get around that,
your code calls my code, I fix the header, and off we go.
But that was a weekend I'd just as soon forget.
[Don] If anybody comes up with a solution that works, we accept pull requests. That would be
slick if somebody went, "Oh, you know what it is?" And you know it's going to be,
"Oh, there's this one little thing. A semicolon
and a plus sign over here will fix it," and we'll go "Of course."
[Doug] I will be thrilled to get that PR, and I will
merge it instantly. That will be a fine thing.
I will be happy to delete my proxy repo from
GitHub, destroy it forever if that happens.
[Don] Yeah, so one of the things, another way you could get around it,
is, instead of my code calling the back end,
is, the camera would write a file
and then the back end could be watching the directory to pick up the file.
There are some benefits to that, one of which is, once you write the file you have it
in perpetuity, or until you delete it. Whereas in ours, we're not,
as soon as I get the base image, we're
overlaying it. So there's no record of what was first, so to speak. [Doug] We're stateless.
[Doug] We're twelve factor. [Don] Basically, yeah. That's a good way, that's one way to look at it. Although in real
life you'd still have to write it somewhere. But the point is, that is another option, was to
write it to a file. And I've worked on systems where that's what we did. So like every other decision in IT, it depends,
your mileage may vary.
[Doug] Yeah, because one of the things we did to keep it simple was, we did not use Knative eventing.
which is something, you know, we talked about this before, that we could have done,
have Knative eventing set up to watch,
you know, an S3 bucket or something, so that if your code writes a file,
and event kicks off, and...[Don] So we kept it simple and only used two weekends
trying to get Knative to work rather than using Eventing and spending an hour and being done with it. [Laughter]
We were really smart, Doug.
[Doug] In retrospect, it was a real genius effort all around.
Your Knative Brain Trust is here.
[Don] But what developer hasn't gone through that? And hindsight's always 20/20
so we did it folks, so maybe you can, like, not do it, or
do a better job, right? [more laughter] [Doug] Do as we do, not...no.
that's not right.
[Don] But it was a good project to get into it, so to speak. It works well,
It works well. [Doug] Yeah, and especially if you're
running your stuff, it doesn't really matter if you go,
you don't have to go through Knative to use this
code, with the React front end, use the webcam, take a picture, click a button.
And there you go. [Don] You know what I didn't
do? I just now realized it. I didn't even try this
on a mobile device. I'm gonna see what happens.
I guess by the time you're all watching this I will have done it, but
go try a mobile device and see what happens. [Doug] It'll be a
follow-up podcast later or something. [Don] Probably be a PR, too.
A pull request to make it responsive. I did use,
I think I used Bootstrap. Anyway, we'll see what happens.
[Doug] Yeah, I did not try it on anything but my laptop, I couldn't tell you.
All right, anything else you'd like
to say about the code? It was a real pleasure working with you. It wasn't always
pleasure, but it was a lot of fun getting this thing knocked out with you.
[Don] No, other than just, keep in mind, everyone, that the underlying languages
can be Java, Node, all that...you can do what you want. So you could write
.Net, you could do the front end in Angular,
that's what's really cool about working with Knative and containers in general. It's that you have all this
freedom. For example, before this interview,
I was running COBOL in a container,
just because you can [laughter]. [Doug] That is perverse.
[Doug] What is wrong with you? [Don] Well, it's gonna be a small blog post,
just to prove a point. But GNU COBOL in a container, yes sir, it's there.
It's coming. So the next project, I'll probably give it to you in COBOL.
[Doug] Okay, looking forward to that. [laughter]
I'm gonna go update my resume and LinkedIn profile now.
[Don] Down-dated would be a better word than updated.
[Doug] All right, well, Don, it was great working with you, I hope we do many
Coderland-related things in the future. This has been a lot of fun.
and I think people will get a tremendous amount of benefit out of
your examples. It really made the project much better.
[Don] Thanks for the warning. [laughter] [Doug] Well, there you go.
[Doug] All right. Well, thank you brother, I appreciate the time. [Don] Thank you.
[Don] See ya. [Doug] Bye-bye.