This is my attempt to implement the Huffman's data compression algorithm in
my programming language, AEC. A few
years ago, I implemented it in JavaScript, you can see it
here.
This only works in very modern browsers. I'm not too interested in
targeting archaic browsers here. This only works in Firefox 62 and newer or
Chrome 69 and newer (those with support for
WebAssembly.Global). After a few years (if not months), all
JavaScript environments will become as capable as they are, rather than like
Internet Explorer.
AEC program output:
You can see the source code of the AEC program
here.
UPDATE on 13/03/2025: For a reason that escapes me, the Huffman Coding in
AEC and the Huffman Coding in JavaScript don't always output the same
result. For the input TEO SAMARZIJA, they do, but, for example,
for the input HENDRIK WADE BODE, they don't. The Huffman Coding
in AEC outputs:
I have warned about that problem
on Discord. The only potentially relevant difference between the way I implemented
the Huffman's Algorithm in AEC and the way I implemented it in JavaScript is
this: In AEC, I was trying to save a bit of memory by deleting the tree
nodes that have already been used (that is, the two tree nodes with the
lowest frequency in the array) from the array, whereas, in JavaScript, I put
a boolean in the tree node structure indicating whether the node has already
been used in the tree construction. But that shouldn't affect the final
results, should it?