Hello World

Posted Jan 25, 2020 (updated Oct 16, 2021)

Hello World

Hello and welcome.

I’ve been working on some projects that use Gatsby and I wanted to try using it in my own website. Not much change from before, in terms of the colors and typography. Just some minor tweaks here and there.

Gatsby

A big part of the reason why I choose to learn Gatsby instead of some other library is mostly because of it’s popularity. You get a lot of resources (guides, tutorials, and StackOverflow posts) when you choose to use a popular tool.

Is it the right choice, though? I’m not yet sure.

My overall impression of Gatsby is still mixed and it’s probably because I’ve yet to explore even a quarter of what it’s capable of. Of that small nugget that is my knowledge of Gatsby, I can form a preview of what I like and don’t like about it.

On the one hand, I like Gatsby because it helps me avoid doing things that are easy to get wrong.

The developer experience is superb—it has good defaults when building a static website, it comes with hot module replacement out of the box, Webpack is already useful without tweaking a config somewhere, adding support for popular tools is just a plugin away, and, to top all that, the documentation is a great read.

You’ll get “smaller” bundles, progressively enhanced images, and ultimately, a fast loading website. All with little to no effort, especially if you use a starter repository.

But, on the other hand, it’s just too magical and very tedious to configure.

First, what do I mean by “magical”?

I don’t like that everything is abstracted away from me. It reminds me a lot, when I was using jQuery when I was just a wee coder lad. I didn’t like jQuery then because I felt like it was hindering my ability to learn JavaScript. Maybe this aversion to magical tools is just a remnant of that experience.

When you use Gatsby, you have to use React, too. It is what it is. Now you have two black boxes (one box enclosing the other box) in you codebase. That is the case, at least for me. Someday, I’ll take a peek at the codebase to improve my appreciation for these tools.

Using pre-configured starter repository is not bad practice in any way. In fact, you can go from zero to deploy, quickly, if that’s your goal. But when you need to reach for a complex feature, things start to get a little hairy.

The number one thing that irks me when configuring Gatsby, is the lack of native TypeScript support. Sure, you can write React with TypeScript but it’s not possible to write Gatsby configuration files in TypeScript without some hacky work-around. They’re working on it now because this issue (gatsbyjs#18983) is still open and has some recent activity.

And that’s mostly what I mean when I say it’s tedious to configure. You have to use JavaScript.

TypeScript

One thing I tried to do before starting the re-write is to determine if I can work on this project with only JavaScript.

It’s quite resonable to use just JavaScript for small projects like this. Using the latest JavaScript specification is actually better compared to when I was first starting to learn.

But I realized, it’s not going to work for me.

I just can’t go back to using vanilla JavaScript after using TypeScript for so long. JavaScript’s weak dynamic types is just too…weak. My brain will never keep up with taking note of what possible values a variable might have.

VS Code will do it’s best to show me the properties of a object or signatures of a function. That could mean, every field will show a property to have a primitive JavaScript type (i.e. string, number, etc.) or another object that is similarly expanded.

It’s not pretty to look at sometimes but that’s JavaScript for you.

Regardless, I still use JavaScript if it’s only one file but I am more likely to introduce TypeScript very early in the project, especially for React projects.

In summary, using TypeScript with Gatsby is okay. It’s well documented in the Gatsby website. But as I mentioned earlier, Gatsby does not native support for TypeScript, so all its configurations must be written in JavaScript.

End

I don’t mean to sound like Gatsby is poor software because it lacks a certain thing that I want to use. It is wonderful, for the most part, and I would still keep using it as long it doesn’t constantly push breaking features.