
Tänzer – An industrial web server framework for Tcl - networked
http://tanzer.io/
======
xantronix
Gimme a break I just woke up :D But these sorts of little breakages are
exactly the thing I want nobody to suffer again as much as possible.

And now it seems the world deems it necessary for me to have an HN account!

I'll be here all day, try the veal.

~~~
teh_klev
Well you will go and put something interesting to look at on the web :)

------
mst
Relaying for xan:

Part of my reason for being so hellbent upon proliferating tänzer is to
improve the state of affairs for Tcl's perception by the wider community. It's
a beautiful language, and a well-considered ecosystem. It never really ceased
being that as it aged ever so gracefully, so I figure I shall become some
larger-than-life PARTY HARD AND LISTEN TO BEAUTIFUL MUSIC! figurehead to
spread some cheer and joy in the community and inspire some newfound personal
pride in people's works.

~~~
forkandwait
Tcl is my favorite scripting language for these five reasons:

\+ It combines macro ish text substitution with really, really, really good
scoping and loop constructs.

\+ A built in event handler is awesome.

\+ Tk widgets look just fine for the one off GUI that routinizes a single
repetitive task.

\+ (Surprisingly) I almost never need float math in a script, one of the
things it's not good at.

\+ Tcl doesn't try to provide what should be done in C anyway (Python, Perl,
Ruby I'm looking at you....)

~~~
a8da6b0c91d
> good scoping

Wait, you like the upvar stuff?

~~~
xantronix
It's astounding the crap [upvar] lets you get away with, ESPECIALLY making
your own loop constructs. I'd be boned without it for doing request parsing
without the ability to share a string buffer by name, for instance.

------
barbudorojo
I have just took a quick glimpse and the source seems to be written very
clearly. It is an excellent example of how coding in tcl looks like. Perhaps
this could be used as an example when you are learning to program in tcl.

I don't use tcl neither I know what the actual state of available libraries
the performance is, but tcl honors its fame as an easy to read language, this
is not Perl.

One feature I like a lot is the ability to create secure interpreters that
bypass military specifications.

Perhaps some benchmarks could give us an idea of what is the current state of
affairs in the tcl world, but sometimes the bottle neck code just recurs to
calling C libraries. I didn't see that ffi calling here.

~~~
mst
Relating for xan:

One of the things that keeps my heart beating and my pulse flowing is knowing
that one day, maybe ONE DAY Tcl can take the limelight again on the stage of
web application development and maybe even curl up into a cozy little niche in
the ever privacy-abrogating cabal of IoT stuff, too.

My choice of language for implementing tänzer is not just due to my love for
Tcl's minimalist syntax, but also, as you intimate upon, Tcl's quite lovely
FFI. I mean, that's what it was meant to do from the get-go, amirite???
Anyhow. I'd like to rewrite tänzer's guts in C, in a very mongrel2-like
fashion, but perhaps less featureful but just as kind to binding by other
language FFIs as itself.

~~~
barbudorojo
"One of the thins that keeps my heart beating and my pulse flowing ...". If
you code the way you write anyone could fall in love with your code.
Readability and power, passion when coding, that's a very magical and powerful
tool.

Edited: Grammar.

------
kingmanaz
Tcl is pragmatic. I still use it for one-off projects with simple GUIs via Tk.
I get grief from co-workers for the language, but my projects are typically
done and correctly functioning in a fraction of the time it takes our Java and
C# devs to even prototype a utility.

Below is a walkthrough of Tk which compares identical implementations of
examples in Pearl, Ruby, Python, and Tcl. See if you can spot which of the
scripting languages are more concise. Hell, I'd even call Tcl more readable in
most of the cases:

[http://www.tkdocs.com/tutorial/](http://www.tkdocs.com/tutorial/)

Kudos to the author of Tänzer for doing his part to keep the oft-overlooked
Tcl alive.

~~~
xantronix
Her part =)

The problem with humble and beautiful people and things is that, being of such
a disposition, one is often not wont to market and self-promote, something I
find to be quite endemic of the ever decreasing Tcl community. However, since
I've decided to crush my Impostor Syndrome with a pointy heel, I've determined
that there's no reason to be shy any longer.

Nothing good comes of faulty and detrimental meekness. Therefore I am creating
this grandiose and megalomaniac caricature of myself and a web server
framework to show the world that, just because a thing isn't well-marketed,
that it doesn't deserve to exist, by, well, solving the bootstrapping problem
of insufficient marketing. And maybe making some lovely software in the
meantime.

I think I could go on and on for hours about the technical benefits of Tcl,
and even make a non-ironic shit-eating grin through an explanation and
ownership of some of its flaws (for instance, lack of garbage collection in
TclOO), but I'd like to think this whole hootenanny makes a good object lesson
in uniting people and spirits in joyous community and technical excellence.

TkDocs.com is a great resource, by the way, and is something I'm taking cues
from for writing some more in-depth tutorials and "Getting Started" guides and
cookbooks for tänzer. Speaking of which, if you or anyone else you know have
any interest and time in helping me with my honey-do list (because "issue
tracker" doesn't have that "je ne sais quois" I'm looking for here), that'd be
absolutely bloody brilliant.

Thanks for your love!

~~~
helmut_hed
I tried to find you on Twitter, and it corrected my search to "mantronix". No
joke. Anyway thanks for sharing your code!

~~~
xantronix
Hehe, wow. It's actually xan_tronix. I'll update my HN bio!

------
xantronix
Well! I wasn't expecting THAT to happen. Thanks for helping me find a recent
bug, guys! \o/ I'll be cranking out that test suite soon.

Site's back online with lighttpd for now.

------
darka
How prevalent is Tcl usage in the real world? You don't hear much about it,
are there any new startups adopting it? Or is it only used in legacy projects
at large companies?

~~~
lmm
I know a couple of startuppy companies that are still using it, but it
certainly feels like a language in decline. There's a lot that's elegant about
it, but the syntax is awkward in practice, and compared to e.g. Python there
are fewer libraries available and no really compelling advantage, IMO.

It's a language that deserves better than it got - it should've become the
standard for *nix config files (thanks RMS for the mess we have now). It
should've been the language Sun pushed to run everywhere (it even supported
java-style applets in web pages, without the slow vm startup). It should've
filled the Lua niche (to a certain extent it did) as an embeddable scripting
language. It should've filled the perl niche - it had good support for
invoking external executables in a shell-scripting role, and could even be
used as a login shell; it had good regex support, and was a first-class
programming language that could be used for web backends. Heck, it even did
reactive I/O in the very early days (IIRC there was a fantastic server product
that was caught up in the demise of Netscape or AOL or some such) - it
should've been Node too. But it always felt a bit unloved at Sun, especially
post-Java (and to be fair, who can blame them when Java was that popular?),
and it somehow never seemed to reach critical mass.

~~~
jimktrains2
> thanks RMS for the mess we have now

I'm unfamiliar with the history you're referencing. Was it being anti-
executable configs?

~~~
pjmlp
He made a war against it

[http://www.vanderburg.org/OldPages/Tcl/war/0000.html](http://www.vanderburg.org/OldPages/Tcl/war/0000.html)

~~~
jimktrains2
Thank you for the link.

------
freyfogle
Does the name imply it's influenced by Perl's Dancer framework?
[http://perldancer.org](http://perldancer.org)

~~~
networked
That's right. The developer has commented about it at
[http://wiki.tcl.tk/40701](http://wiki.tcl.tk/40701):

>xan 2014-10-12: It sure is named after Dancer! However, one of the big draws
of tanzer is that it doesn't expect a request handler to read the entire
request nor response in one single go, which should hopefully allow for much
better performing web applications without standing in one's way much.

~~~
mst
Forwarding for xan due to HN new account comment limits:

Yes indeedy! Although as my rather more florid verbiage points out, I do
endeavor to make it as anti-framework as possible and more like a library. But
then I suppose the only difference between a framework and library, one might
posit, is often the presence of an event loop or some damned thing.

As part and parcel to a super ultra mega marketing blitz to remind people of
the existence of Tcl and indicate to the world that it never really died, it
is my solemnly sworn duty to help plant the seeds of a small ecosystem which
unifies the divergent elements of the Tcl web framework ecosystem into one
that rather more resembles Perl, in that there are so many wonderful
middlewares to bridge gaps everywhere.

I developed tanzer to try to be the least common denominator of them all, and
to somewhat offend (but in a polite way) Node.js' dominance by forcing the
agenda of a language that already has a quite nice event loop and asynchronous
I/O built in, thank you very much. :D

------
yummyfajitas
Well now I feel old. I remember writing a web app in Tcl way back in 2000 or
so right after I graduated. From what I recall, AOLServer was not as fun to
program as this appears to be.

[http://aolserver.github.io/](http://aolserver.github.io/)

TCL was actually a pretty OK language. I do remember that aolserver was a
major improvement over CGI scripts.

~~~
pjmlp
I joined a Portuguese startup in 1999 that had an in-house Apache module for
TCL, an application server similar to AOLServer in design.

With an abstraction layer similar in capabilities to what people know Rails
for. With lots of C plugins as well.

Being part of the core developers meant I was a regular reader on tcl/tk
forums, eagerly looking for the upcoming TIPs, following ActiveState work in
the community and so on.

It was also the last time in my career that I used C on the job, instead of my
then favourite C++.

I learned lots of stuff while there, but two important things in terms of
programming languages were:

1 - scripting languages are great for prototyping

2 - if you ever plan to scale, use a compiled language for the get go instead
(JIT/AOT)

On our case, due to certain circumstances, we were part of the .NET alpha
program and started moving part of architecture to C#/Managed C++.

~~~
davidw
> 2 - if you ever plan to scale, use a compiled language for the get go
> instead (JIT/AOT)

Like Facebook?

I don't think that's good advice, for several reasons:

* Everyone dreams about scaling. For most, it's just not a pertinent reality. It's easy to prematurely optimize.

* Scripting languages will let you iterate faster, and find some kind of product-market fit. Think about Twitter: I love Rails, but ... no, Rails is not a good fit for what Twitter is. And yet they managed to right the ship and move on to more appropriate systems. If you've got a viable business, you can find the money to improve.

~~~
pjmlp
Many of the improvements Facebook has brought into PHP eco-system is because
the code base is so big, that it is worthwhile to invest so much money into
research about PHP native code generation that re-write the whole stuff.

I get your point, but there are many languages that offer the rapid iteration
of dynamic languages, while offering native code.

And monkey patching just doesn't scale across teams.

------
holtbp
Tänzer is 'dancer' in German, btw. Looks like it was inspired by Perl's
Dancer.

~~~
xantronix
tänzer also listens to loads more industrial music than Perl's Dancer, but
will often be caught listening to Björk when she's hiding.

One thing I'm particularly keen on, with tänzer, is making it possible to
easily swap in any ol' static file filtering mechanism by way of
::tanzer::file::handler callbacks. Without even necessarily having to write
one's own request handler, one can simply filter the files before serving
without any heavy lifting. A few examples would be transparent static asset
minification, and template processing. Speaking of which, one of my next
priorities is finishing up code and docs for teaspoon (whose file extension is
.tsp; HA! HA!) so we can have a demonstrably straightforward set of swappable,
pluggable web components in our little Tcl world.

[http://tanzer.io/git/teaspoon.git](http://tanzer.io/git/teaspoon.git)

------
networked
tanzer.io is taking a while to respond. Here's a CoralCDN mirror:
[http://tanzer.io.nyud.net/](http://tanzer.io.nyud.net/).

~~~
xantronix
I was wondering why I woke up to a 500 Internal Server Error, and why I had
ran out of fds. That explains it!

Having said that, I'm very keen these days on the idea of implementing usage
of libevent into core Tcl 8.6, which would be a fact that tanzer itself would
be entirely oblivious to.

------
cestith
Xan's face lights up talking about tänzer like you may expect from her
writings here. It's not hard to see why. This is impressive work.

~~~
xantronix
Thanks! You are very sweet. I sincerely hope tänzer sets the right tone for
not just the Tcl community, but also so many others that appear to be aging
only on account of lacking an influx of new (young) developers. Writing
quality code seems to be a pleasant side effect of that.

And now, to have a celebratory time over some beer and Dr Pepper and Cajun-
flavored wings.

------
estrabd
Very well done, xantronix. Your enthusiasm is infectious.

------
tnzr
Well this is awkward.

------
rurban
Beautiful code, beautiful layout. Great, xan

------
vahidR
500 Internal Server Error The server was unable to fulfill your request.
Generated by tanzer/0.1

~~~
xantronix
Try again! Given that this thing is very much a work-in-progress, and I
certainly wasn't ready to submit to HN (don't look at me like that! It wasn't
me), I suppose one can forgive a little web framework that could of this sort
of thing.

I've got lighttpd in front of the site for now until I figure out what broke.
:)

~~~
vahidR
Yeah, it works now. I just wanted to notify you though..

------
general_failure
site is dead

~~~
xantronix
Really? Lookin' at it right now. Got a screenshot?

------
biomimic
if {[llength $argv] < 1} { puts "Usage: ./joinmods3 <\\[file\\].joinmods2>
\n\n" exit }

set HOME [pwd] set DATABASE [lindex $argv 0] set DIM 10000

proc CalcLine {line} {

    
    
        set termData [lindex $line 1]
        set termDataLength [llength $termData]
    
        foreach {x y} $termData {
            set score1 0
            set score2 0
            set score3 0
            foreach sData [split $y {:}] {
                set sd [split $sData {,}]
                set score1 [expr {$score1+[lindex $sd 0]}]
                set score2 [expr {$score2+[lindex $sd 1]}]
                set score3 [expr {$score3+[lindex $sd 2]}]
            }
            lappend newLine "$x [format %.4f [expr {($score1+$score2)/$score3}]]"
        }
    
        set returnVal "[lindex $line 0] [list [string map {\{ "" \} ""} [lsort -real -index 1 -decreasing $newLine]]]"

}

proc Invoke {} { global HOME global DATABASE

    
    
        set lCount 10
        set wCount 0
        set wData ""
    
        set f1 [open $DATABASE "r"]
        set f2 [open ${DATABASE}.j3 "TRUNC CREAT RDWR"]
    
        while {[gets $f1 wordByte] >= 0} {
            incr wCount
    
            append wData [CalcLine $wordByte]\n
    
            if {$wCount >= $lCount} {
                puts -nonewline $f2 $wData
                set lCount [expr {$lCount + 10}]
                set wData ""
            }
        }
    
        puts -nonewline $f2 $wData
    
        close $f1
        close $f2

}

Invoke

~~~
xantronix
Please explain for the masses!

~~~
biomimic
AI preprocessing ai priori code. I found that Tcl is the best for this. It
includes some efficient structures acute to Tcl. I use Tcl as a rapid
application programming and proof of concept language. I find it to be the
best at it. Used to use it for chip design too. After that at Berkeley Lab for
knowledge discovery and gene discovery.

------
moonstruck
500 Internal Server Error The server was unable to fulfill your request.
Generated by tanzer/0.1

------
digital-rubber
Seeing it works really well, :o) gotta love http 500 errors before you can
love the framework i guess,

500 Internal Server Error The server was unable to fulfill your request.

~~~
xantronix
Well, I certainly wasn't expecting the HN crowd. :)

~~~
ashley_willis
Nobody expects the Hacker News crowd!

