Crystal Style guide

Today I was thinking about optimum number of characters in a line of source code,
and I find this:
https://en.wikipedia.org/wiki/Characters_per_line
I think if we create a style guide for crystal it will have two main benefits:

1- It makes a easier to read codes of other people
2- Some link building for crystal programing language for example adding crystal in:
https://en.wikipedia.org/wiki/Programming_style
https://en.wikipedia.org/wiki/Characters_per_line
Recently I have seen that crystal has been added to some Wikipedia’s page like:
https://en.wikipedia.org/wiki/History_of_programming_languages
https://en.wikipedia.org/wiki/Timeline_of_programming_languages
That is nice and we should keep up the good work

Here’s the existing style guide: https://crystal-lang.org/reference/conventions/coding_style.html

Note that there’s no recommended maximum/optimum number of characters in a line of source code right now, and I’d like to keep it that way. In my opinion breaking a line that’s slightly longer than X chars might introduce reading noise. People usually have good judgement about where to place newlines and when to let a line exceed that length. But it’s just my personal opinion.

8 Likes

My bad, I’ve read that, (anyway I forgot that page exist :upside_down_face:)
I also had no standard for breaking line, I would press enter when I feel that line is long. :slight_smile:
Today I wanted to test flutter, after installing everything when I opened the first dart file
I saw a vertical line in the middle of my vscode editor.
It took a little bit time to figure out how could I remove or change position of that line.
Dart plugin in vscode would put a

"editor.rulers": [80]

in the global config of .dart file
I still try to figure out if is useful or not.

In regards to the line limit, I just saw this the other day: https://www.phoronix.com/scan.php?page=news_item&px=Linux-Kernel-Deprecates-80-Col

2 Likes

The hard part about line length is that it’s completely subjective. Many people don’t find long lines hard to read, but many others (myself included) certainly do. Unfortunately, discussions about it often go nowhere because so any people with either opinion can’t understand the other side because typically whether it’s difficult or not difficult to them, it’s always been that way.

At a previous company, we frequently had lines of code that were 300 characters long. The people that wrote them saw nothing wrong with them and often argued in their favor. I can’t understand that perspective, but I’ve tried.

I imagine other people think it’s annoying for code to be more vertically oriented when you could fit it all on one 120-character line. I don’t know whether there’s a one-size-fits-all solution that is easy enough to read for everyone.

2 Likes