Carbon vs Gist - How to share code examples

The other week I was introduced to Carbon by Matt Bancroft who recently joined our team at Styler. He used Carbon to share code in his Medium article and I really liked the way it looked compared to Gists that I have been using until now. That got me thinking, Carbon Vs Gist, is it time to move on?

Sharing code snippets

There is an ongoing joke that most of the code used comes from Stackoverflow. Though it is a joke, there is truth in the fact that copied code is a large part of any successful application.

Imagine if you had to figure out every single piece of code, configuration, formatting etc for yourself every time. Delivering anything would take ages.

Even if packages are preferable, since they are more often tested and maintained by someone else, code snippets do have their place.

So let’s share some code!

What is Gist

Gists from Github are a type of mini-repositories. They can be created very quickly through the user interface and are well suited for single file sharing. You can fork and version them. You can edit them in place and best of all, you can share your Gist files easily using nice looking embedded iFrames.

A gist embed works by copying the script embed code (or for Medium, just the gist URL) and it looks like this:

Carbon

So what is Carbon then? Rather than being repositories of code, it is focused only on quickly and beautifully sharing snippets of code. It definitely has that more in-the-time feel to it compared to Github’s Gists.

Carbon snippets can be downloaded as SVGs, PNGs or embedded with iFrames (or plain links for use in Medium).

When to use which?

Initially, when I saw Carbon I thought that it would not let a user copy the text. This, for me, is a big no-no as the reason we share code is for others to be able to use it.

However, on closer inspection Carbon allows embedding with iFrame just as Gists do so with that I am happy to move over to Carbon completely.

Gists do still have the benefit of allowing multiple files and a history of changes. So if maintainability or multiple files are needed, Gists still provide a great alternative.

Carbon on the other hand seems more suitable for really short single snippets which you don't have to update or maintain.

A final consideration, however, is one that if anyone well versed in SEO reads this, I would love to hear more about. Does using iFrame-embedded code like this affect SEO?

I have not found a clear answer on how search engines process iFrames and their content. I wonder if Google will properly index the code as well. However, the same issue would apply to both Gist and Carbon.

I have used custom plugins for syntax highlighting in the past and still think script embeds like Gists or Carbon gives a much better user experience so I will stick with this regardless of any potential SEO hit and my verdict: I will start running with Carbon!

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
David Dikman

David Dikman

Active reader, developer, manager, entrepreneur & sporadic writer here and at https://greycastle.se. Currently working at https://styler.link.