DEV Community

Jesse Phillips
Jesse Phillips

Posted on

The Uncanny Valley

I had a conversation related to programming language and attempting to match English. Artists have this concept of the "Uncanny Valley" and I think it applies to our choices in language design.

I would claim that the issue is the same as the uncanny valley except for code.

It is what I was actually going for in my response to regex.

Why do people defend the regex syntax?

10

There is a similar question going around, but it just got the same old answers that people always give about Regex syntax, but that's not the point here, so please try to not knee jerk the same old answers about regex syntax. Try to be a little more original and…

</p>
Enter fullscreen mode Exit fullscreen mode



Well the uncanny valley is the idea that the closer you are to realism, or in this case English, the harder it is for people to believe it when things are still inaccurate. (You mentioned a compiler, maybe some synthetic examples could help in this discussion.)

Let's consider Javascript and some of its evaluation.

if(4 == "4") 
Enter fullscreen mode Exit fullscreen mode
if 4 equals "4" begin
Enter fullscreen mode Exit fullscreen mode

That is nice but why not

when 4 is equal to "4" execute 
Enter fullscreen mode Exit fullscreen mode

Clearly we would want a subset of the English language.

if(4 === "4")
Enter fullscreen mode Exit fullscreen mode
if 4 same as "4" do
Enter fullscreen mode Exit fullscreen mode

It is not like Javascript is clear on by its choice but does follow some really really normal emphasis convention. But I don't even know where to go with English. Sure maybe Javascript should have use like in the first one, but hindsight is 20/20.

What about some bash

if 5 -gt 9 then
Enter fullscreen mode Exit fullscreen mode
if 5 greater than 9 start
Enter fullscreen mode Exit fullscreen mode

It could be argued that gt is close enough, but that isn't English what if it means 'goes into'

if 3 gt 9 run
Enter fullscreen mode Exit fullscreen mode

Sure we don't know of a language with this semantics, but if someone wants that maybe that is what they believe 'gt' to stand for.

And while we're at it, what are these quotes and what is a string.

if the writing "foo" is the same writing as "bar" follow these steps
Enter fullscreen mode Exit fullscreen mode

But I've included 'as' after 'writing' how does the language know which articles to expect when? Maybe we don't need the articles.

if writing "foo" same writing "bar" steps
Enter fullscreen mode Exit fullscreen mode

Well that isn't English. We've hit the uncanny valley. If we don't handle all of English we will come up with our own language which looks like English but does not live by English rules.

Top comments (0)