3 ms·
The biggest gripe I have with modern (ie. the post-Sun era) Tcl is the steaming mess that are channels and their encodings. Good luck trying to do anything 8-bi
by themadsens 6y ago
The biggest gripe I have with modern (ie. the post-Sun era) Tcl is the steaming mess that are channels and their encodings. Good luck trying to do anything 8-bit clean with those.
For a simpler, cleaner alternative, you might want to take a look at antirez's jim tcl
- dvdkhlng 6y agoI have the exact opposite experience WRT Tcl channels when compared to other languages. Handling binary data is pretty trivial, e.g. to read a full binary file into a binary string, you do: set h [open "filename.bin" r] fconfigure $h -encoding binary -translation binary set data [read $h] Then you even have a fantastic way to operate on low-level binary data of any endianness using Tcl's binary scan /binary format instructions [1] (basically what Javascript later invented as DataView). Tcl was one of the first languages I knew that properly and consistently supported multibyte text throughout the full language, including in Tk GUIs. I.e. writing a cross-platform GUI that could handle Japanese character input/output basically "just worked". You could even read ShiftJIS or ISO encodings of japanese text, which was at the time a prerequisite as Japanese Windows versions were non-unicode (everything done in ShiftJIS AFAIR). [edit] here is a real-world example of a trivial script handling binary data [2]: reading binary RGBA 4 bytes/pixel image data and outputting RGB 3b/pixel into a pipe that finally outputs a .PNG image. It's difficult to find a programming language that can do that in less lines and with more clarity. [1] https://wiki.tcl-lang.org/page/binary+scan https://wiki.tcl-lang.org/page/binary+scan [2] https://stech.muecke.pw/opensvn/free/trunk/dkbin/nn-fbtopng https://stech.muecke.pw/opensvn/free/trunk/dkbin/nn-fbtopng
- themadsens 6y agoYes, I see your point. I can't remember the context that bit me anymore, but I think it had to with being unable to change the defaults with fconfigure for some reason, the channel being implicit or somesuch .
- marttt 6y agoI got curious, so here's a link to Jim Tcl: http://jim.tcl.tk/index.html/doc/www/www/ http://jim.tcl.tk/index.html/doc/www/www/