Learn X in Y minutes – Tcl
learnxinyminutes.com
learnxinyminutes.com
Jokes aside, TCL was for a long time my goto language for anything quick and dirty. As a result, I don't mind TCL at all. I still use Tk quite often. It might not look pretty, but it works and more crossplatform than other ui toolkits.
Which facilities are those ?
> many other advanced facilities for parsing
Be curious to hear what those are, but note that Tcl is hilariously simple to extend and build up custom constructs to suit ones needs.
You can have unicode procedure names, if that was your fancy.
Note: If you read that post and think, "Wow, Perl requires a lot of setup for unicode and TCP doesn't require nearly as much" without understanding the specifics of why each step is there, and how TCL handles the same issue, you are likely underthinking the issue.
1: http://stackoverflow.com/questions/6162484/why-does-modern-p...
proc with {file as name block} {
uplevel 1 [list set $name $file]
uplevel 1 [list eval $block]
uplevel 1 [list close $file]
}
with [open foo.txt w] as file {
puts $file "Hello, World!"
}
I'm sure it's possible to do it in a cleaner way without [set], but my Tcl is a bit rusty.While it would be nice if this were baked into the language, it's pretty astonishing how extensible Tcl is without even having to touch the realm of C extensions.
proc withOpenFile {filename channelVar script} {
upvar 1 $channelVar chan
set chan [open $filename]
catch {
uplevel 1 $script
} result options
close $chan
return -options $options $result
}So: What language(s) did you have in mind that do this right?
sub do_stuff {
my $thing = Thing->new; # no need to manually destroy thing. Its DESTROY method will be called at the closing brace.
}In the end, they all make trade offs depending on the "whim" of the language designer.
> Many scripting languages in practice do reference counting GC that will reliably and deterministically clean up resources other than memory.
When challenged, you offered one. So, is this a Perl-only thing, or can you give other examples?
As others have mentioned, they are very, very not "native UI" friendly - OSX is an especially bad instance - but they do run on all of Git's platforms without a 20MB runtime to go along with them. If Tk's widgets were just a little less harsh, those two would absolutely be my go-to graphical git clients.
Dont worry to much though, the syntax grows on you :)
I've already sent one on a minor formatting issue, but about one third into that article, the formatting goes permanently haywire.
Weird how no one has noticed until now?
That said, the document needs work - the syntax highlighting got very confused at some point, and a bunch of the lines are much longer than the width of the document, and don't wrap.
Tcl looks like a nice little language that makes it really easy to write really horrible code. Probably with some discipline you could keep it tidy and comprehensible though.
Talking about Guile, lots of fun things happening there lately. wiki.tcl.tk is a lot of fun too.
Could you please explain why some languages are better at being "embedded and/or extended"? Why would Guile be simpler to embed than Ruby?
This is called apartment model [0] threading.
[0] https://msdn.microsoft.com/en-us/library/aa261361(v=vs.60).a... (this is a Microsoft VB article, with nothing to do about Tcl specifically, but does nicely explain the apartment threading model)
Edit: s/let's/lets/
My comment was more about the state then than the state now. At that time few, if any languages were designed from scratch to be extended and embedded. Tcl and Guile, to my knowledge were among the first. Tcl interpreter is a library. IMO Guile has grown beyond that charter and is more of a stand-alone Scheme now, but one that can be easily embedded / extended, but so is Chicken I guess.
That said, Tcl is the worst parody of a programming language since the invention of BASIC and Brainfuck. All you need to know about it is two words: Stay away.
http://www.sqliteconcepts.org/THManual.pdf
The entire implementation's about 4k lines of code.
I think many people have trouble with TCL because it looks a lot like C and so they expect it to behave roughly like C. But TCL is a fundamentally different language. It is better to think of TCL as LISP with C-like syntax. Once you grok this difference, TCL becomes a very elegant language.