Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

echo is a builtin #612

Closed
KamilaBorowska opened this issue Mar 6, 2013 · 4 comments
Closed

echo is a builtin #612

KamilaBorowska opened this issue Mar 6, 2013 · 4 comments

Comments

@KamilaBorowska
Copy link
Contributor

The problem is that "The law of minimalism" explicitly mentions "echo" as builtin is one of things fish intentionally doesn't implement. Yet, it does.

Builtin commands should only be created when it cannot be avoided. echo, kill, printf and time are among the commands that fish does not implement internally since they can be provided as external commands. Several other commands that are commonly implemented as builtins and can not be implemented as external commands, including type, vared, pushd and popd are implemented as shellscript functions in fish.

@maxfl
Copy link
Contributor

maxfl commented Mar 7, 2013

That is true.
The problem here is that calling an executable is an expensive or time consuming operation, so it worth implementing some commands to replace executables, if these commands are executed inside the loops or often: like test, echo etc.

@JanKanis
Copy link
Contributor

JanKanis commented Mar 7, 2013

Let's face it: the fish development has stepped away from some of the design principles that the original author Axel had in mind. I don't think this is necessarily a problem, these principles are just human inventions and so they can turn out to be wrong or be in conflict with other principles that are deemed more important in some circumstances. In this case ridiculousfish decided that startup speed was more important than minimalism, and I am not disagreeing with him. (I would also like to see the "Configurability is the root of all evil" rule be overruled in cases where users disagree over what the 'right behavior' is.)

@KamilaBorowska
Copy link
Contributor Author

[glitchmr@pineapple test]$ cat builtin.fish 
#!/usr/bin/fish
for i in (seq 10000)
    echo $i
end
[glitchmr@pineapple test]$ cat command.fish 
#!/usr/bin/fish
for i in (seq 10000)
    /usr/bin/echo $i
end
[glitchmr@pineapple test]$ time fish builtin.fish > /dev/null

real    0m0.346s
user    0m0.317s
sys     0m0.023s
[glitchmr@pineapple test]$ time fish command.fish > /dev/null

real    0m17.844s
user    0m5.023s
sys     0m0.203s
[glitchmr@pineapple test]$

Well, I guess it's indeed slower. Actually, it's 51 times slower (bash somehow does the second test in 13.323 seconds however). Considering it's used in fish_prompt function, I guess it won't change.

@ridiculousfish
Copy link
Member

I changed the law of minimalism. Here's what it says now:

The law of responsiveness

The shell should attempt to remain responsive to the user at all times, even in the face of contended or unresponsive filesystems. It is only acceptable to block in response to a user initiated action, such as running a command.

Rationale:

Bad performance increases user-facing complexity, because it trains users to recognize and route around slow use cases. It is also incredibly frustrating.

Examples:

  • Features like syntax highlighting and autosuggestions must perform all of their disk I/O asynchronously.
  • Startup should minimize forks and disk I/O, so that fish can be started even if the system is under load.

Thanks for reporting this - it would have been embarrassing if we missed it!

3d7ff9f

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 19, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants