...
those representations or handlers are implemented by scripts (quick and cool) or plain old Java servlets (IDE support + managed code)
(scripts can be in many popular languages (javascript, ruby, python, etc.) - sling as it is written in Java uses the Java Scripting framework (JSR-223))
handle.selector.extension...
...
for a GET:
GET.1) sling determines the representation wanted and finds the handler (script/servlet)
GET.2) this is done by looking at sling:resourceType (an attachement to the JCR node) and calling "resourceresourceType/<extension>.js" (.js could be .py, .rb, whatever scripting language is available)
GET.2) handler runs with full access to its resource (JCR node)
...