The adaptation of "indentation languages"
Same here.
Hi. I will not insist on such changes anymore as it is clear that the disapproval is due to the learning curve and middle age effects; Regardless of Lua or Python (and I would not like to take that responsibility if it was assigned to me). I would just really like to know why not integrate micropython with the other ports for symmetry purposes?
Although not insisting, I would like to leave some comparisons I made before giving up that may be interesting; First, Lua is extremely fast.
I honestly don't know if this speed would benefit TinyCore in any way, but in basic synthetic tests, lua managed, again, to surprise me.
One such test I did was a counter up to 1 billion; C finished in 2 seconds, Lua in 9, Micropython (custom) 47 seconds, Micropython (standard) 1:24, Python took about 3 minutes and bash never finished (I canceled about 5 minutes in because I thought it would never finish).
https://pastebin.com/raw/DmEQB95dAbout MicroPython, I started doing, again, what supposedly could be something like tce-size. I had a little knowledge about python, and in these last hours I learned a lot. Here is an (incomplete) example of tce-size for python:
https://pastebin.com/7wLZDmVaAs I mentioned before, the idea is to use a programming language that can be more easily "mastered" by newbies, so that way, community development can maybe move along a bit more. And with that I allow myself to analyze small portions of the three codes (fragmented and unordered, which might look a little messy)
Getting the list and the tree.
SH:
tce-size:
tce-fetch.sh sizelist.gz || exit 1
touch sizelist
tce-fetch.sh "$app".tree >/dev/null 2>&1 || echo "$app" > "$app".tree
tce-fetch.sh:
if [ "$1" == "-O" ]; then
shift
wget -cq -O- "$MIRROR"/"${1//-KERNEL.tcz/-${KERNELVER}.tcz}" <-- (I confess that I still don't understand how this works)
else
F="${1//-KERNEL.tcz/-${KERNELVER}.tcz}"
[ -f "$F" ] && rm -f "$F"
wget -cq "$MIRROR"/"$F"
fi
MPY:
def GetRemoteTextFile(filename):
response = urequests.get(f"{BuildMirror()}/tcz/{filename}")
if response.status_code == 200:
return response.text
else:
print(f"Error downloading file {filename}. Status code: {response.status_code}")
sys.exit(1)
...
sizelist = GetRemoteTextFile("sizelist")
packageTree = GetRemoteTextFile(f"{package}.tree")
Dealing with the .tcz or lack thereof in the package name:
sh:
app=${app%.tcz}
app="$app.tcz"
MPY:
if not package.endswith(".tcz"):
package += ".tcz"
Handling dependencies:
SH:
for F in `sed 's/ //g' "$app".tree | sort -f | uniq`; do
size=`grep -w "^$F" sizelist | awk '{print $2}'`
case $size in
[0-9]*)
sizemb=`Fixed3Div $size $M`
if [ -f "$localtce"/optional/"$F" ]; then
totalsize_installed=$(($totalsize_installed + $size))
echo -n " "
printf "%-40s" $F
printf " %10d, %6.2f MB\n" $size $sizemb
else
echo -n "+ "
totalsize_needed=$(($totalsize_needed + $size))
printf "%-40s %10d, %6.2f MB\n" $F $size $sizemb
fi
;;
*)
printf "%-40s Error, not found \n" $F
;;
esac
done
}
MPY (incomplete):
# Create a dictionary mapping the file name to its size in bytes
size_dict = {line.split()[0]: int(line.split()[1]) for line in sizelist.splitlines()}
# Print the results directly from the list comprehension
print("\n".join(f"{filename:<40} {size_in_bytes:<13} {bytes_to_mb(size_in_bytes):<8.2f}" for filename, size_in_bytes in size_dict.items() if filename in packageTree))
It could be simpler, remembering the lua:
for treeline in packageTree.splitlines():
for sizeline in sizelist.splitlines():
currentSizeLine = sizeline.split(" ")
if treeline.strip() == currentSizeLine[0]:
filename = currentSizeLine[0]
size_in_bytes = int(currentSizeLine[1])
size_in_mb = convert_bytes_to_mb(size_in_bytes)
print(f"{filename:<40} {size_in_bytes:<13} {size_in_mb:<8}")
Just replacing shelling outs with built-in functions, as well as not using regex (or something similar to regex) makes the code easier to understand. This way, half of the code is understandable just by reading it, eliminating (not much) the need to understand things like "\" or "\\" or "\\\" or "\\\\/////" or maybe "||||||||" or rather, why not "\o/\o/\o/\o/\o/"