Some weeks ago, i started (undesired) a discussion[1,2]
about how and why i think the base-files should get
a refurbishment. I send several patches as a proposal,
but it was not possible to apply them - the reasons are:

- the code changed nearly nothing, only the style
- some people mentioned, that the old code was not good,
  but it worked since years and changes in base are risky
- it is not clear, if lowmem-targets are part of openwrt
  (most of the patches uses lower mem and are faster)
- there is no official coding style, that enforces the
  use of specific ways how to do things
- i mixed the reasons, why i wrote the new code

Here some words about this:

I like openwrt. There are many concepts i want to see
in other distros. I'm not satisfied with many scripts
and the way how people make a solution. Ofcourse this
is my personal opinion, but there are good reasons to
speak loud:

- clean code (not obfuscated)

This should be the most imported thing.
It helps to debug.
It lowers the entry-border.
It makes it easier to change the code and do refactoring.
(i have some ideas to modularize the functions/files, at the
moment we often include files which we don't need)

It does NOT help to make a oneliner and 1000 users asks
themself: what does THIS line? [3]

But while we are at it:
- don't fork, if not needed. examples from /etc/init.d/compache:

[ "`cat /proc/swaps | grep 'ramzswap0'`" != "" ] && swapoff /dev/ramzswap0

better use:
fgrep -q "ramzswap0" /proc/swaps || ...

- use function_names to say what you want to do

- use better shell builtins, instead of invoking another language
  (e.g. awk, sed, lua) - only if there is no other option
- using of shell builtins, leads to lower mem usage and are (mostly) faster

In the first discussion, i explained that awk is big and should not
be in base-files. During experiments it turned out, that these are only
some kilobytes. But the real reasons are explained above.

The next step can be:
- make an official coding-style (at the moment much is mixed)
- make an offical way, how to solve typical problems in scripts
- make "base-files (experimental)" which can be selected in menuconfig
  and i will maintain it. if people select it, they know the risk
- vote for or against it
- refactoring/refactoring/refactoring and try new concepts/ideas

Thanks for your time,
Bastian

[1] https://lists.openwrt.org/pipermail/openwrt-devel/2011-January/009171.html
[2] https://lists.openwrt.org/pipermail/openwrt-devel/2011-January/009273.html
[3] https://lists.openwrt.org/pipermail/openwrt-devel/2011-January/009199.html

_______________________________________________
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel

Reply via email to