Something Go and Scala syntax

Adam Ruppe destructionator at gmail.com
Thu Dec 30 05:19:52 PST 2010


bearophile wrote:
> writing "immutable" often is boring and makes code longer.

im<tab>   ->  immutable

Really, I think you *desperately* need to get a better editor. Once
you get one with a decent auto-complete, you'll never care
about typing out 'boring' words again.

=== recommendation and sermon here ===

I personally use Vim for most my D work. http://vim.org The "supertab"
extension script maps autocomplete from the relatively awkward
control-n and control-p to the much easier to reach tab, without
breaking tab in whitespace (so the One True Indentation Character
still Just Works while reaping the benefits of convenient
autocomplete!) It is heaven and I use it.

Best of all it works in regular English just as well as *any* code.
You'll ditch jQuery as a waste of time - typing
document.getElementById will take less time than shifting to hit $.
(d<tab>.g<tab> = win)
You'll use more descriptive variable and function names. No more
cryptic letters to save typing time. You can even hammer out something
like 'Alexandrescu' in an email in no time flat!

You don't even need to remember names. Type the first letter and ask
for completion. It will automatically fill in the first possibility
and give you a list of other possibilities. The first one is often
the right one if it is something you use a lot (the list's ordering
is based on proximity to the cursor).

Once you go automatic, you'll feel naked without it, and you'll
pity the fools who don't use it, worrying over such trivial issues
that you've long since slain.

=== back to the main point ===

Of course, I'm sure there's dozens of editors with a similar feature.
There might also be an existing option or plugin in your current
editor of choice. It's worth investigating.

You may also be able to set up abbreviations in your editor. Vim
can be set to automatically replace "val" with "immutable", so you
type the former yet see the latter. You could use a similar replace
feature in your editor to custom-tailor your environment to your
typing preferences. Personally though, I don't bother with that.
Auto-completition renders it moot.

btw you might say "an editor is no excuse for bad language design"
but this isn't bad language design, it's just a preference on your
part. So it should be fixed on your end.



And if those 6 extra characters when reading (which are significantly
easier to spot than the difference between a 'r' and a 'l' in the
middle of an otherwise identical line!) cause length problems, your
line is likely too long to begin with. Try using whitespace to
break it up into groups or refactoring the initialization into a
function.


> if the "then" clause of the "if" uses {} then the () around the
> test can be omitted:

That looks awful. It seems Go programmers don't care about tidy code.
Languages should avoid such special cases.


More information about the Digitalmars-d mailing list