The Bad Spelling Divide

Every so often, I accidentally mis-spell something in Elixir.

I get a cryptic message from the bowels of a library.

And spend time, so much time, debugging a stupid spelling mistake in my own code, that gets passed into a third party library and errors.

Often you can catch this with a warning, but the errors from these types of mistakes are often so in-your-face, that you forget about looking at the warnings…

JavaScript is the other notorious ‘bad spelling’ offender.

Many others? Does it really just depend on static type checking?

Somehow I suspect not.

Are there any dynamic languages which catch spelling errors better than Elixir does right now?

Could Elixir do better…

What version of elixir do you use and what do you misspell?

Simply misspelling function names give very good messages ala “did you mean?”

But if you misspell an argument to a function there is nothing elixir can do.

3 Likes

One thing that some (well-written) libraries do, at least in Erlang where I have seen it, when there are more complex functions is to have an internal pass which checks the arguments and generates an explicit badarg error at the top-level call. It won’t really catch spelling errors but it will give a more understandable error than some function_clause error from deep down.

3 Likes

Well, if properly done, the function clause will raise from the same point where you create a badarg.

1 Like

Yep, you nailed it, the last case was an argument to a function

That is a great idea - a way to help people write their libraries defensively like this would be good