avatar

Joshua G. Lock

PhD Student
King's College London
joshua.lock (at) kcl.ac.uk

Reading code

I was reading Bob Nystrom’s recent post about Access Control Syntax and, as is now typical for me as a PhD student researching accessible program editors, thinking about the accessibility—specifically to screen reader users—of the various access control syntax under discussion.

I thought it might be interesting to demonstrate how some of the discussed syntax is narrated by a screen reader. Quote styling in this post shows how the screen reader on my system (VoiceOver on macOS Sonoma with default settings) reads the various syntax forms described in the original post.

Syntax in other languages

Go uses capitalisation for access control, lowercase first character is private and uppercase is public. By default a screen reader will narrate both of these the same way:

func HelloWorld() {}
func helloWorld() {}

are both narrated as:

func hello-world left-brace right-brace

Python and Dart uses underscore prefixes. By default a screen reader will narrate an underscore as “underscore”, which is very verbose compared to the single typed character:

def __hello_world():

is narrated as:

deaf underscore underscore hello-underscore-world

Java and C++ use keywords to declare access modifiers. These are standard words which the screen reader will narrate as expected:

public void HelloWorld() {}

is narrated:

public void hello-world, left-brace right-brace

Oberon uses an asterisk after the declaration:

PROCEDURE*

narrated as:

procedure-star

For screen reader users, Go is clearly not useful. Python’s few keyboard strokes are very verbose when narrated. Oberon syntax seems equally inscrutable to screen or screen-reader users, whereas Java and C++ are verbose for both screen and screen-reader users.

Considered syntax

The last section of the post explores some possible syntax options to modify declarations from a default public visibility to an opt-in private visibility in Bob’s hobby project scripting language.

First, some modifier keywords are explored. private is deemed too verbose, shorter forms of private, pri or priv, or the abbreviation pvt are dismissed. These are narrated, respectively, as:

private

pre

priv

pea-vee-tee

The abbreviation becomes much longer when narrated and the short forms are not immediately associated with the term “private”.

Finally, the post considers alternate keywords with a trailing _ for private declarations: rec_, def_, var_, and val_ which are narrated as:

wreck-underscore

deaf-underscore

var-underscore

val-underscore

Each proposal here is terse to type but much more verbose when narrated by a screen reader.

Suggestions from others

The author’s Mastodon thread has some additional suggestions by Mastodon users. User Almost A Fern proposes hidden with the shortened form hid. These are narrated as expected, because they are both English language words:

hidden

hid

Roger Lipscomb observes that Elixir uses defp and Will Richardson points out that Clojure uses defn-. These are narrated as:

dethp

dethun

I think it would take some practice to mentally match “dethp” to defp and especially “dethun” to defn-.

Which one?

If conciseness is desired for both typing and reading, and if both display users and screen reader users are prioritised equally, hid appears to be the syntactic form which best meets the criteria and feels quite recognisable for a native English speaking programmer (me). However, if this were more than a hobby project one might suggest a more comprehensive study be performed to determine which syntactic form is most comprehensible and concise for different classes of programmer.


Powered by Jekyll and Minimal Light theme.