5 ms·
Everything is a string including the comments -- commenting code actually degrades performance!
by rongenre 7y ago
Everything is a string including the comments -- commenting code actually degrades performance!
- mschaef 7y agoI'm pretty sure this hasn't been true for 20 years. Tcl 8.0 introduced a form of byte compilation. [1] While the comments might slow down the compilation a bit, I doubt they have any impact at runtime these days. 1] https://www.tcl.tk/software/tcltk/8.0.html#What's%20New%20in%20Tcl%208.0 https://www.tcl.tk/software/tcltk/8.0.html#What's%20New%20in...
- pwg 7y agoThis has not been true since the introduction of the bytecode compiler in Tcl 8.4 (well over ten years ago now). Tcl 8.4+ will byte code compile the proc's, and part of that is removing the comments from the code execution path. So comments only get 'seen' once (at byte code compilation time, upon first use of a proc) and then have no effect on execution performance from that point forward.
- ThePadawan 7y agoIIRC this was also the case for node/V8/I don't recall: Whether a function was inlineable was decided based on its size - and that was determined based on size-as-text instead of size-as-AST. This lead to the situation where adding too much comment text (I believe it was 512 bytes total for the function) led to the inliner refusing to inline the code, and thus performance regressions.
- mdaniel 7y agoThis business falls into the "well that's handy" followed by the "who in the world thought honoring continuation characters in comments was a good idea?!" #! /bin/sh # the next line restarts using tclsh \ exec tclsh "$0" ${1+"$@"} This page is just filled with wow: https://wiki.tcl-lang.org/page/comment https://wiki.tcl-lang.org/page/comment with an especial nod toward: set two [1 + 1] ;# line comment needs a statement terminator
- williadc 7y agoOne of the world's largest hardware companies uses the line continuation feature to help make stuff you've almost certainly used today. Whether that is the best way to solve their problem is another story, but that feature does get used.
- lanstin 7y agoAnd the nice thing about TCL as a language is there's just like 3 or 4 rules to remember and then you can embed the parser in your head. # is a command that discards all its arguments. So it's in the normal flow of syntax, so line continuation works. It's odd to see but easy to reason about after you are used to it.