The #nosyntax movement

Part I
======

_DESTRUENS_

what’s syntax highlighting after all?
————————————-

I’m a long time `vi` fan, but more than it I like `nano`, which is in turn
surpassed by the glorious `MS-DOS` `edit`. The reason is simple, they just
work: “no-fluff, just stuff”, as they say.

On the other hand what I’ve been told and taught[^1] over the years was that my
editor is my toolbox, it should be the extension of my arm, the center of my
life as a programmer.

Now’s the right place and time to say no to all this nonsense, in Melville’s
own words:

> I tell you, the sperm whale will stand no nonsense.[^2]

Let’s face it, we don’t challenge these common beliefs as we ought. We’ll
maybe discover that the impositions we suffer about syntax and tools are
something that can be overcome by progress.

[^1]: E.g. in “The Pragmatic Programmer” by A. Hunt and D. Thomas –
http://pragprog.com/book/tpp/the-pragmatic-programmer
[^2]: http://www.online-literature.com/melville/mobydick/46/

are colors that great deal?
—————————

I’ll skip at once the whole color blindness problem to concentrate on something
that I feel being much more important. Has been noted elsewhere that colors in
software are broken[^3]. Although I want to remark here that is not enough,
bluntly said colors are YAGNI[^4].

[^3]:
https://medium.com/@MrJamesFisher/your-syntax-highlighter-is-wrong-6f83add748c9
[^4]: to be clear, I’m not against colors in general, but I have very strong
feelings about how they’re used to discriminate parts of other’s code

should somebody else decide for you what’s important?
—————————————————–

Everybody seems concerned on telling you what to do, what’s right, what’s
wrong, and even who’s right and wrong in saying who can talk about right and
wrong.

All just to tell you that you are right anyway (the secret here is that you are
already abiding to their views, hence you are right). I know this is a bit of
a broad concept, but you know, you need to start small.

All in all I think we, the developers, should start to put our brains to good
use and refute the kool-aid of mainstream development practices.

Therefore I’ll end Part I issuing the following statement:

*** I don’t want anymore an unknown theme author to dictate the visual
hierarchy of my code ***

Part II
=======

_CONSTRUENS_

readable code
————-

TBH, I’m really tempted to leave this title as is, no explanation. Mary
Poppins would surely agree[^5].

The one thing that I found really heartening is that having no syntax colors
gives you freedom. The feeling is similar to having less stuff in your pockets.

Try it for 5 minutes straight and let your eyes start processing spaces,
sentences and shapes. Set them free from preordered “parsing”. Spot by
instinct places where the shapes alone act as code smells.

Don’t forget that similar techniques were adopted in the ‘70, for example the
SmallTalk community used to write their programs in variable-width fonts[^6].
Say that to one of your colleagues and check out their response[^7].

[^5]: https://www.youtube.com/watch?v=E6ADGIHIKnI
[^6]: http://typophile.com/node/13090#comment-75514
[^7]: another example on how the current generation is biased:
https://groups.google.com/forum/#!topic/mailing.postfix.users/6Kkel3J_nv4 (via
@steveklabnik)

short code
———-

Needless to say, migrating to this style will have a number of benefits on your
coding and on how you perceive code in general. You’ll be forced to write
smaller methods with cleaner syntax that will truly enable literate
programming[^8].

Don’t be fooled though. It won’t be easy, especially at first, your old habits
will try to survive, you’ll often find yourself longing for the old colors.
More on that in the next sections.

[^8]: https://en.wikipedia.org/wiki/Literate_programming

y-spacing
———

If you ever felt that vertical spacing deserves more attention than it
receives, be reassured, you’re not alone.

Start a #nosyntax life today, and rejoice by looking your code get in shape on
both the axes. “30-days money back guaranteed” because I already know you’re
gonna love it <3 <3 <3

b/w is always cool but…
———————–

As I said before I’m not against colors in general (I would be a stupid, or a
troll). It may seem trivial but I think it’s worth pointing it out: you’re not
confined to black and white, there are plenty of colors out there, new patterns
could emerge. Just think of how cool would be to have a different color for
each file type or role (e.g. light-blue views, grass-green models, warm-orange
controller, etc.)

get priorities right
——————–

You are in control. Really. Get used to it.

No editor color scheme will be able to hide bugs and comments from your sight.
No tool producer will have the chance to influence your thoughts anymore.

_tools for tools’ sake_

No, thanks.

better judging your language’s syntax
————————————-

This the final note of Part II. This the final alert.

The real measure of the goodness of your programming language will surface. A
good language will shine in its full clarity and expressiveness. The bad ones
will be unbearable. The really bad ones will hurt your eyes at once.

Conclusion
==========

don’t haste
———–

I know that all this seems weird and even difficult, habits are a powerful
weapon. Having been through it myself I’ll give just this piece of advice:
take your time.

For example you can switch to monochrome scale for a while. Plan ahead the
switch to full #nosyntax style and you’ll do great!

get your own pace, but don’t stop
———————————

There’s no manifest, even if everyone now has a manifesto[^9]. As said you’ll
need to find your own pace, but please don’t stop. This is a movement, it is
not meant to be stopped.

[^9]: http://www.reactivemanifesto.org

_Trolly_ Yours,
Elia

Pimp my TextMate2 — Ruby edition

Here at Mikamai It’s no secret I’m a happy TextMate user and early TM2 adopter. I’m always there if either an editor war is catching fire or if someone needs help setting up his editor.

Above all I still find that TextMate is the best choice for a Ruby developer, even if SublimeText, emacs and vim seem more fashionable these days. Even if I’m saving the full list of reasons for another post I’ll tell just this one: TextMate relies on Ruby for a big part of its implementation that has always been opensource*.

Of course I’m talking about bundles, if you’re not convinced look at the code used to align assignments (⌥⌘]) from the source bundle (which is responsible for actions common to any programming language).

Just to be clear I would still use SublimeText if I were to program from Linux or (ugh!) Windows.

That said I want to gather here some of the stuff that makes using TextMate2 for Ruby and Rails development so awesome.

* Of course I know about redcar (which seems quite dead, but I didn’t tried it recently) and other TM clones err enhancements like Chocolat

ALERT: shameless self promotion follows

The Bundles and Settings parade

1. Effortless opening of Bundled Gems ⌥⌘O

This I do all the time, opening the source of bundled gems. Please behold and don’t be horrified. Especially in Ruby-land the source of gems is the best source of documentation, and as explained by Glenn Vanderburg) there’s probably a good reason for that. Also the README and specs are included most of the time and reading other’s code is a healthy activity.

Needless to say that the best place to read source code is your editor.

⌥⌘O will present the complete list of gems from your Gemfile.lock, start typing the first letters of a gem and use arrow if you don’t want to touch the mouse (or trackpad).

opening gems from the current bundle

Source: https://github.com/elia/bundler.tmbundle

2. Beautiful Markdown rendering

No README.md reading activity would be on par with a the GFM rendered version without code blocks highlighting.

This bundle almost looks like GFM while typing, press ⌃⌥⌘P (the standard TM key equivalent for preview) to get it rendered to the HTML window.

Redcarpet Markdown Bundle in action

Bonus Install the Scott Web Theme from Preferences → Bundles for a nice looking preview

Source: https://github.com/streeter/markdown-redcarpet.tmbundle

3. Restart Pow! in a single stroke ⌃⌥⌘R

Restarts the current app detecting a tmp/ directory in current project or in a parent dir.

Falls back to /tmp

Source: https://github.com/elia/pow-server.tmbundle

4. Open the terminal in your current project folder

Works with both Terminal and iTerm, just press ⌃⌥⌘T from a project.

Source: https://github.com/elia/avian-missing.tmbundle

5. Trailing whitespace fix, cross-tab completion and more…

Command Description
⌃⎋ Cross tab completion
⌃⌥⌘T Open Project directory in Terminal
⌃⌥⌘L Keep current file as reference

Source: https://github.com/elia/avian-missing.tmbundle

Installing the whole thing

Download the latest version of TextMate2 here: https://api.textmate.org/downloads/release

mkdir -p ~/Library/Application Support/Avian/Bundles
cd ~/Library/Application Support/Avian/Bundles

git clone https://github.com/elia/avian-missing.tmbundle
git clone https://github.com/elia/bundler.tmbundle
git clone https://github.com/streeter/markdown-redcarpet.tmbundle

# Activate the system ruby (if you're using a Ruby version manager):
type rvm &> /dev/null && rvm use system # for RVM
export RBENV_VERSION="system"           # for rbenv

# Install the required gems
sudo gem install redcarpet -v 2.3.0
sudo gem install pygments.rb

# Trailing whitespace
defaults write com.macromates.TextMate.preview environmentVariables -array-add 
    '{ "enabled" = YES; "name" = "TM_STRIP_WHITESPACE_ON_SAVE"; "value" = "true"; }' # enable trailing whitespace removal and EOF fix

echo <<-INI >> ~/.tm_properties
[ "*.y{,a}ml" ]
# Disable trailing whitespace fix for YAML 
# files that can be broken by this feat.
TM_STRIP_WHITESPACE_ON_SAVE = false
INI

The following will set the tabs/file-browser/html-windows to my current taste, I don’t pretend it matches everyone prefs but can still be useful for cherry-picking.

# File browser fixes and general UI fixes
defaults write com.macromates.TextMate.preview fileBrowserStyle SourceList       # lighblue file browser background
defaults write com.macromates.TextMate.preview fileBrowserPlacement left         # keep it on the left
defaults write com.macromates.TextMate.preview tabsAboveDocument -bool YES       # no tabs above the file browser
defaults write com.macromates.TextMate.preview allowExpandingLinks -bool YES     # make symlinks expandable
defaults write com.macromates.TextMate.preview htmlOutputPlacement right         # place the html output to the right
defaults write com.macromates.TextMate.preview disableTabBarCollapsing -bool YES # keep the tab-bar alway visible
defaults write com.macromates.TextMate.preview scrollPastEnd -bool YES           # give me some air after the file ends