How I Built a Serverless Function Without Knowing It, I Think*
Tags: serverless, javascript, api
Published: 2017-04-09 15:06:29

---
title: How I Built a Serverless Function Without Knowing It, I Think*
published: true
description: 
cover_image: https://thepracticaldev.s3.amazonaws.com/i/6554q8e972c2pim8vjvg.png
tags: serverless, javascript, api
---
It’s the weekend after a week full of exams. I’m exhausted and am just waiting to graduate high school. But, like any other developer I feel the urge to go ahead and start another weekend project. I’m learning some pretty interesting stuff in AP Calculus, but I get tired of doing algebra during homework at times. I think to myself: *Why not build something that does my math homework for me?*  

![Not a Bad Idea](https://cdn-images-1.medium.com/max/1600/1*-70TkZq3o32UoAbYzpXwdA.gif)

That’s where I got the idea to build Newton, [a really micro micro-service for math](https://newton.now.sh/). I wanted to make it easier for developers to do math without being constrained by codebase sizes or non-existant APIs in their preferred language.  

![Newton API Front Page](https://cdn-images-1.medium.com/max/1600/1*T-e_QTO3qzrBBr004w55Yw.png)

**So what makes it interesting?** Other then being super cool and functional, of course, Newton requires no storage space other than its source files. It doesn’t access or modify a database, and it doesn’t even dynamically create configuration files or any of the matter. Each request and response is protected by [Zeit Now’s](https://now.sh/) HTTPS encryption. Plus, it runs solely on simple GET requests.  

I didn’t think much of those characteristics, but after a bit of interaction with the tech community I think Newton is a serverless function.  

<blockquote class="twitter-tweet" data-lang="en"><p lang="en" dir="ltr">Explain &quot;serverless architecture&quot; to me like I&#39;m five years old. <a href="https://twitter.com/hashtag/DevDiscuss?src=hash">#DevDiscuss</a></p>&mdash; The Practical Dev (@ThePracticalDev) <a href="https://twitter.com/ThePracticalDev/status/849427700192342018">April 5, 2017</a></blockquote> <script async src="//platform.twitter.com/widgets.js" charset="utf-8"></script>

<blockquote class="twitter-tweet" data-conversation="none" data-lang="en"><p lang="en" dir="ltr"><a href="https://twitter.com/ThePracticalDev">@ThePracticalDev</a> Very small machines on a network; LOTS of them work at the same time. But their brains are very small, they can&#39;t remember what they did!</p>&mdash; Eric Elliott (@_ericelliott) <a href="https://twitter.com/_ericelliott/status/849431273865084928">April 5, 2017</a></blockquote> <script async src="//platform.twitter.com/widgets.js" charset="utf-8"></script>  

Eric Elliott gave an unexpected yet informative response. Newton fits those characteristics. Zeit abstracts global hosting for Now, so that satisfies the machines on a network. Newton is a relatively small package (~3.3kB), so that fits the small brain, and like I said it doesn’t access or process persistant memory. Seems like serverless to me.  

![Shoulder Shrug](https://cdn-images-1.medium.com/max/1600/1*cklQSFmsnnxoq6a4q2vJHw.gif)

Anything else?  

<blockquote class="twitter-tweet" data-lang="en"><p lang="en" dir="ltr"><a href="https://twitter.com/ThePracticalDev">@ThePracticalDev</a> Write code as a bunch of function and then pretend infrastructure doesn&#39;t matter.</p>&mdash; Elliot Blackburn (@elliotblackburn) <a href="https://twitter.com/elliotblackburn/status/849559703520780288">April 5, 2017</a></blockquote> <script async src="//platform.twitter.com/widgets.js" charset="utf-8"></script>

That seals the deal. I use Now, because I don’t have to worry about anything other than how my code runs. And, *Newton does one thing: math.*  

Wait, math is a lot of things.

![Hmm...](https://cdn-images-1.medium.com/max/1600/1*B5F6wHEB1ggA-teT8DhgsA.gif)

We get the point. But just to be sure, I took to [r/serverless](https://www.reddit.com/r/serverless/).  

![My Reddit Question](https://cdn-images-1.medium.com/max/1600/1*CTh4EJi0b8a_pBh1Nhnfxw.png)

Eh, that answer is good enough for me.  

![Why not?](https://cdn-images-1.medium.com/max/1600/1*5z9WhbaPEGmuwzvg1Ymb1g.gif)

So, in the end I built a small serverless function as a weekend project to help me do my math homework and help others make cool things. Newton has [grown to become more popular than I initially expected](https://github.com/aunyks/newton-api), and I‘d love to witness its expansion and see what others make with it.  

And don’t forget: **it’s serverless, I think.**  

![You're Awesome](https://cdn-images-1.medium.com/max/1600/1*ooNmdP20-7HGbe0-Lzbqfw.gif)

Thanks for reading! As always, you’re awesome.  

*For more information on serverless architecture, start [here](https://aws.amazon.com/serverless/).*