You are viewing a plain text version of this content. The canonical link for it is here.
Posted to websh-user@tcl.apache.org by pongi <po...@pongi.it> on 2004/04/02 12:55:16 UTC

why? (Websh vs. PHP)

I'm a newbie to websh, and I'm feeling quite lost because everything i
used to get from my php scripts easily, seems very much longer and more
complex (causing difficult debug, trying to understand that damned error
log) with websh. I need some motivation, since I have to use websh
("friendly" called WebSh*t by my colleague) for my work.
Thank you



---------------------------------------------------------------------
To unsubscribe, e-mail: websh-user-unsubscribe@tcl.apache.org
For additional commands, e-mail: websh-user-help@tcl.apache.org


Re: why? (Websh vs. PHP)

Posted by "David N. Welton" <da...@dedasys.com>.
"pongi" <po...@pongi.it> writes:

> I'm a newbie to websh, and I'm feeling quite lost because everything
> i used to get from my php scripts easily, seems very much longer and
> more complex (causing difficult debug, trying to understand that
> damned error log) with websh.

Hi,

There are several advantages:

First and foremost, it's done with Tcl, which is a powerful, flexible
language that you can use not just for web programming, but for
anything else.  Guis with Tk (some examples here:
http://dedasys.com/freesoftware/applications.html ), sysadmin stuff,
even some embedded programming tasks.  Tcl is a language that was
designed to be used for all kinds of purposes, even those which its
inventor hadn't thought of.  PHP does web programming, and while it's
not bad at it, that's all it does.

Second, Websh lets you write applications.  PHP is ok for quick hacks,
but if you start to create more complicated systems, you need more of
a framework to back you up.  Websh provides that, and helps you out.
PHP scripts, when they grow, risk getting quite messy without a lot of
discipline.  Websh provides a lot of the structure for your program so
that you just fill in the pieces.

What you probably want to look for are some examples (on the web site)
that give you an idea of what you want to do.

> I need some motivation, since I have to use websh ("friendly" called
> WebSh*t by my colleague) for my work.

Che simpaticone:-)

Ciao,
-- 
David N. Welton
   Consulting: http://www.dedasys.com/
     Personal: http://www.dedasys.com/davidw/
Free Software: http://www.dedasys.com/freesoftware/
   Apache Tcl: http://tcl.apache.org/

---------------------------------------------------------------------
To unsubscribe, e-mail: websh-user-unsubscribe@tcl.apache.org
For additional commands, e-mail: websh-user-help@tcl.apache.org


Re: why? (Websh vs. PHP)

Posted by "David N. Welton" <da...@dedasys.com>.
"pongi" <po...@pongi.it> writes:

> ps. First thing I did was this proc: 
> proc print {string} {
>    web::put "$string\n"
> }
> 
> the word "web::put" is so uncomfortable ;-)

You can also do:

namespace import web::put

-- 
David N. Welton
   Consulting: http://www.dedasys.com/
     Personal: http://www.dedasys.com/davidw/
Free Software: http://www.dedasys.com/freesoftware/
   Apache Tcl: http://tcl.apache.org/

---------------------------------------------------------------------
To unsubscribe, e-mail: websh-user-unsubscribe@tcl.apache.org
For additional commands, e-mail: websh-user-help@tcl.apache.org


Re: why? (Websh vs. PHP)

Posted by Ronnie Brunner <ro...@netcetera.ch>.
> Understanding the error is not so user-friendly: if i make some errs and
> try to load the page I get only a 500, and then I have to look for the
> error in the apache's error_log.

Well this is actually a security issue: you don't want to give the
user any hint about what went wrong, when something did go wrong. 

But what you can do during development:

if {[catch {

  # all your code goes here

} msg]} {

  web::put "<html><body><h1>Oops</h1>"
  web::put "Something went wrong:"
  web::put "<pre>[web::htmlify $msg]</pre>"
  if {[info exists errorInfo]} {
      web::put "additional info:"
      web::put "<pre>[web::htmlify $errorInfo]</pre>"
  }

}

That will give you the answer in your browser.

> I'm not a experienced programmer, so I was bored by the overwhelming
> complexity I just discovered reading how to work with sessions (still
> havent found if a filesession remains across pages (not just
> web::commands), and how to check if a session is set)

The problem is that session handling is quite a complex thing if you
want to have a flexible framework. I have to admit that the current
solution in Websh is not trivial. (We preferred to be very flexible,
that's why the approach is a bit more complicated.)

Tracking sessions across pages is exactly the same as across
commands. Unsless you use a cookie session, you must create links to
your other pages that include the session id in the query string
Using web::dispatch you have to get this session id from the query
string (even if you don't hve any commands you want to dispatch to:
e.g [web::dispatch -cmd ""] will set up all parameters and form
fields for use with [web::param] and [web::formvar]).
If you don't want to create dynamic links, you must use cookies, (see
cookiecontext) otherwise you cannot track sessions across different
pages (applications).

For more specific answers I would need more specific questions I 
guess... Still hope that helps

> ps. First thing I did was this proc: 
> proc print {string} {
>    web::put "$string\n"
> }
> 
> the word "web::put" is so uncomfortable ;-)

Well, it's TEA compliant: all procs and commands are in the web::
namespace (web::p would not really make a difference, would it ...)
I sometimes do that as well:
proc p s {web::put $s}
proc x c {web::putx $c}


Regards
Ronnie
----------------------------------------------------------------------
Ronnie Brunner                             ronnie.brunner@netcetera.ch
Netcetera AG, 8040 Zuerich   phone +41 1 247 79 79 fax +41 1 247 70 75

---------------------------------------------------------------------
To unsubscribe, e-mail: websh-user-unsubscribe@tcl.apache.org
For additional commands, e-mail: websh-user-help@tcl.apache.org


Re: why? (Websh vs. PHP)

Posted by pongi <po...@pongi.it>.
Understanding the error is not so user-friendly: if i make some errs and
try to load the page I get only a 500, and then I have to look for the
error in the apache's error_log.

I'm not a experienced programmer, so I was bored by the overwhelming
complexity I just discovered reading how to work with sessions (still
havent found if a filesession remains across pages (not just
web::commands), and how to check if a session is set)

Thank you for your advices

Pongi

ps. First thing I did was this proc: 
proc print {string} {
   web::put "$string\n"
}

the word "web::put" is so uncomfortable ;-)


-----Original Message-----
From: Ronnie Brunner <ro...@netcetera.ch>
To: pongi <po...@pongi.it>
Cc: websh-user@tcl.apache.org
Date: Fri, 2 Apr 2004 14:00:42 +0200
Subject: Re: why? (Websh vs. PHP)

> Hi
> 
> > I'm a newbie to websh, and I'm feeling quite lost because everything
> i
> > used to get from my php scripts easily, seems very much longer and
> more
> > complex (causing difficult debug, trying to understand that damned
> error
> > log) with websh.
> 
> You already have plenty of good reasons, why Tcl based Websh as a
> development environment for way more than just Web-Hacking from David.
> 
> In addition: let us know of ideas to improve Websh. There is always
> room for improvement. What would make "that damned error log" easier
> to read? For an experienced Tcl hacker, Websh should be pretty
> straight forward to use (imho) but if we learn more about what's
> difficult to understand we can improve the documentation, the examples
> etc.
> 
> Regards
> Ronnie
> ----------------------------------------------------------------------
> Ronnie Brunner                             ronnie.brunner@netcetera.ch
> Netcetera AG, 8040 Zuerich   phone +41 1 247 79 79 fax +41 1 247 70 75
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: websh-user-unsubscribe@tcl.apache.org
> For additional commands, e-mail: websh-user-help@tcl.apache.org
> 



---------------------------------------------------------------------
To unsubscribe, e-mail: websh-user-unsubscribe@tcl.apache.org
For additional commands, e-mail: websh-user-help@tcl.apache.org


Re: why? (Websh vs. PHP)

Posted by Ronnie Brunner <ro...@netcetera.ch>.
Hi

> I'm a newbie to websh, and I'm feeling quite lost because everything i
> used to get from my php scripts easily, seems very much longer and more
> complex (causing difficult debug, trying to understand that damned error
> log) with websh.

You already have plenty of good reasons, why Tcl based Websh as a
development environment for way more than just Web-Hacking from David.

In addition: let us know of ideas to improve Websh. There is always
room for improvement. What would make "that damned error log" easier
to read? For an experienced Tcl hacker, Websh should be pretty
straight forward to use (imho) but if we learn more about what's
difficult to understand we can improve the documentation, the examples
etc.

Regards
Ronnie
----------------------------------------------------------------------
Ronnie Brunner                             ronnie.brunner@netcetera.ch
Netcetera AG, 8040 Zuerich   phone +41 1 247 79 79 fax +41 1 247 70 75

---------------------------------------------------------------------
To unsubscribe, e-mail: websh-user-unsubscribe@tcl.apache.org
For additional commands, e-mail: websh-user-help@tcl.apache.org