josevalim

josevalim

Creator of Elixir

Proposal: IEx hints

In Elixir we are continuously trying to improve the experience for developers learning the language. However, there are still common road blocks users run into, despite of the tips and warnings put into the learning materials.

This proposal is about a hints mechanism for IEx that will allow us to print some information and guidance to users in common situations.

As an example, imagine the situation where IEx prints a list as a char list for the first time, a situation newcomers often find themselves in:

iex(1)> Enum.map([0, 1, 2], & &1 + 10)
‘\n\v\f’

In such cases, we could print hints, such as (don’t worry about the hint content for now):

Did you expect a different result than '\n\v\f'?

By default Elixir prints a list of ascii characters in single quotes.
Since [10, 11, 12] is a list of characters, you saw the '\n\v\f' result
above.

Whenever you are in IEx and you are not sure about what a data type means,
use the `i/1` helper to give you more information:

    i('abc')

Each hint will be show only once. There will also be a function to disable all hints.

Before moving forward, the Elixir team has two questions:

  1. Would such hints be generally helpful?

  2. More importantly, which hints do you believe we could show on IEx? Hints should be valid language idioms that may be confusing when you first experience it. If an invalid construct is confusing, let’s say it has a poor error message, then we should improve the error message instead of adding a hint.

Please let us know when the hint should trigger and what we should suggest.

Thank you.

Note: This is an on-going discussion. Before joining the thread, please check the current discussion and see if your feedback and concerns haven’t already been brought up.

Most Liked

OvermindDL1

OvermindDL1

I’d personally think that would be greatly useful for new people yes.

OvermindDL1

OvermindDL1

Maybe instead of ‘default’ persistence it defaults to per-session, but at the bottom of each it says to run ‘some’ command to disable globally, which would add some kind of flag or so into the ~/.iex.exs or whatever file that disables globally.

I can very much see it being slightly irritating on new installs, but something like that would make it very easy to disable.

Neurofunk

Neurofunk

something great would be to be able to invoke a hint, independently of the context :slight_smile:

josevalim

josevalim

Creator of Elixir

Thanks everyone for the feedback.

I am closing this proposal until we are aware of more places where a potential hint system would be helpful. Once we have enough hints, then we can discuss display mechanisms, enabling/disabling, etc.

dimitarvp

dimitarvp

I’d like to see hints about the “no function matches…” once in a shell session. Having a better-communicated lack of matching function is IMO paramount in a language with pattern matching.

Imagine I have a function that accepts either map or list, and somebody tries to pass a tuple to it. The default message was confusing to me the first several times.

I realize we’re talking rookie mistakes, yes, but there’s nothing wrong to hold the hand of the people here and there. It’s also nothing major, but IMO worth a once-in-a-session hint.

Where Next?

Popular in News Top

Elixir
1. Enhancements Elixir [Kernel] Raise when U+2028 and U+2029 characters are present in comments and strings to avoid line spoofing attac...
New
josevalim
Hi everyone, I am really happy to announce Plug v1.4.0-rc.0. It has many improvements and bug fixes: Multipart support is now implem...
New
Elixir
This release includes type inference of patterns to provide warnings for an initial set of constructs (binaries, maps, and atoms). It al...
New
Elixir
Elixir v1.18 is an impressive release with improvements across the two main efforts happening within the Elixir ecosystem right now: set-...
New
josevalim
The goal of private modules is to define a module that cannot be trivially accessed by other modules where they are not visible to. In t...
New
josevalim
I hereby officially announce the Elixir type system effort is transitioning from research into development. Read the full-announcement he...
639 11510 165
New
Elixir
1. Enhancements Elixir [File] Support distributed File.Stream [Module] Add Module.get_last_attribute/3 [Task] Reduce footprint of tasks ...
New
Elixir
This release includes type inference of patterns to provide warnings for an initial set of constructs (binaries, maps, and atoms) within ...
New
josevalim
Hello everyone, A vulnerability has been disclosed to Plug. All applications that set cookies based on user input is vulnerable. The vul...
New
Elixir
Official announcement: Elixir v1.16 released - The Elixir programming language 1. Enhancements EEx [EEx] Include relative file informat...
New

Other popular topics Top

sorentwo
Hello! tl;dr Announcing Oban, an Ecto based job processing library with a focus on reliability and historical observability. After spen...
977 41022 311
New
sergio
I couldn’t find any guides that worked well with Phoenix 1.6.0 and esbuild. I hope this helps people test the waters and eases you into t...
New
sergio_101
I am VERY much an elixir newbie. I have taken one elixir course and one phoenix course on Udemy. During that course, I saw the instructor...
New
fireproofsocks
I’m working on defining a simple Ecto schema for a table (in PostGres), but I don’t see where I can define a column as NOT NULL. Conside...
New
polypush135
As many of you may have realized by now (sorry for all the posts here) I’ve been working on a db problem where I’m trying to aggregate a ...
New
aadeshere1
I have a another noob question about loop. Since elixir is immutable, while loop is not directly possible. total = 10 while total != 0 ...
New
vonH
When I run the Plug and I recompile I wind up having to use Ctrl C to quit iex and start again. Witht the help of rlwrap I can use the cu...
New
WestKeys
Currently suffering from paralysis by [HTTP client] analysis. This is rather unusual in Elixirland as there tends to be consensus on the ...
New
romenigld
I am trying to run a deploy with docker and I successfully runned with this command: docker build -t romenigld/blog-prod . but when I t...
New
aesmail
Hello guys, I have finally made it. I created an admin interface for a framework. It’s been on my todo list for years and with the curre...
New

We're in Beta

About us Mission Statement