by timeattack · 6y ago · 0 comments
Check this out [1]: kak script evaluating sh script which in turn call perl which constructs kak script commands and output them to stdout to be evaluated by kak.
Or this one [2]: same, as before, but now it's calling awk, which calls `date` binary (so it's kak → shell → awk → date → kak).
It seems that it's done this way because sh is not good programming language to use for manipulating text. Moreover, sh is not good programming language to write complicated programs, which later can be successfully maintained & tested.
For me, kak approach is past the border of unmaintainability.
Also, it raises question of why not to use embedded language like python or lua instead of creating such a limited editor-specific language.
[1]: https://github.com/mawww/kakoune/blob/25429a905b717d29bdf92c... [2]: https://github.com/mawww/kakoune/blob/25429a905b717d29bdf92c...
I do agree that sh is not a nice programing language, and forking programs all the time is not very efficient. I think that there is a tradeoff between the different approaches, and Kakoune's has proven to make quick'n'dirty very easy while being suboptimal for complex tasks.
I am okay with that tradeoff because I still believe most complex tasks do not need to be editor specific, and should be provided by separate tools written in a more maintainable language.
Another reason is that I've been trying to design Kakoune in a minimalistic way, and one thing I tried to unify was the user and scripting interface, which means I needed a command language that was easy to write interactively (`edit filename` vs `edit("filename")`). This is again a tradeoff that helps with simple things (as users already know the scripting language if they know how to use the editor), while making complex things harder.
POSIX shells languages however, are awfully designed (including zsh/fish for historical compatibility with POSIX concepts reasons).
Something close to TCL as a shell would be much better.
They also neglect parallel, concurrent, async programming. Which agan is fine for a shell language. The shell does have use cases for simple parallel processing and you can delegate to dedicated unix tools for that and it works great. If you need more, you're expected to jump into a more powerful environment.
So they're poor in data structure variety, and more interesting (nonsequential) ways of executing programs, which, again, is fine for a shell language, but those were exactly the things I wanted. I wanted to pipe and tee a bunch of programs programs into one "executable graph" a la dataflow programming using bash or something similar, but quickly understood that due to the above reasons I need a different environment. I'm still on the lookout for good dataflow programming environments.
My issue is their tons of subtle points (e.g. behaviour of [ vs [[ blocks), blatant disregard for the principle of least surprise, lack of some very basic items (not parallel, async etc programming -- a mere list and a mere map with an obvious syntax and no BS caveats would do), inelegant ad-hoc accretion of features, bad error handling, and so on. Those things can (and frequently do) trouble programmers even an one-liner.
I don't with e.g. something like bash supports writing a full 10K program with it.
But I wish it didn't make a 100-line shell script so clumsy and frail.
Async:
long_running_cmd & > results.txt
cmd_pid=$!
# other stuff
wait $cmd_pid
# do something with results, if you want
Parallel: for script in "${scripts[@]}" ; do
"$script" &
done
wait
Dataflow: mkfifo my_channel
mkfifo another_channel
my_cmd > my_channel &
tee my_channel \
>(cmd1) \
>(cmd2 > another_channel) &
another_cmd < another_channel
But if you want a useful dataflow environment, I really recommend checking out [Nextflow](https://www.nextflow.io/). I use it at work for constructing bioinformatics pipelines, and it's really natural. The "preview" DSL2 is worth looking at, as well.I don't know which level of intellect is required here for a newcomer to fix a bug.
[1]: https://github.com/zdharma/fast-syntax-highlighting/blob/mas...
c# a viable language with great tooling, and there is a lot of enterprise software available which only runs on Windows.
Even a few big websites are running on it, like stack overflow for example
It was a concious design decision to rely on posix extensively, one reason being that if you do not care about not having posix available, you are probably not that interested in what Kakoune provides.