[plug] Hacker challenge ends in feuding

Onno Benschop onno at itmaze.com.au
Thu Jul 10 11:42:39 WST 2003


On Thu, 2003-07-10 at 10:42, Derek Fountain wrote:
> > On a semi-serious note, has anyone else noticed that there is nothing
> > new under the sun? I mean, when I wrote software for my VIC20, bytes
> > mattered, these days I have 512Mb of RAM, vs. 3.5Kb of RAM, but writing
> > web-apps, my code still runs rings around the opposition because bytes
> > still matter.
> 
> Can you elaborate on that a bit?

Me, elaborate on anything - why sure :-)

> I started learning PHP a few weeks back in order to write a web based database 
> app. Browser front end, MySQL and XML at the back, and PHP/Apache in the 
> middle. (Is that the sort of thing you're refering to?)

It is. Although my comment does also refer to any other way of writing
software, I was thinking HTML/Web/PHP when I was typing.

> I found the 
> technology very straightforward since PHP is a great language - simple, tuned 
> to what it does, and highly effective.

I agree.

> However, actually implementing the code to build HTML pages is a discipline 
> which I'm having to learn. Although it shares a lot of the basic tradecraft 
> of general software development, there's quite a bit of new thinking to do as 
> well.

Don't we all...

> So I'm interested in all aspects of this. In particular, what byte-saving 
> techniques do you employ which make a difference to web based apps?

Here goes - some with more and less impact.

The simplest way to increase the speed at which your web-app appears at
the users' browser is to buffer the output and gzip it - given that the
browser supports this. This is cheating IMHO, but it works.

Reducing the number of bytes in your HTML, eg, using style-sheets as
linked files, not embedded, re-using graphics, reducing the number of
line-feeds/tabs/spaces, all help to make your page come down faster.

My designers generally use WYSIWYmG HTML editors, and their code is very
bloated with little or no advantage. I generally go through their
supplied templates and clean them up.

When you first start using PHP, you're likely to write code that is
basically a HTML page with some embedded PHP, like this:

---Start #1---
<html><head><title>Hello World</title></head><body><h1><? echo "Hello
World" ; ?></h1></body></html>
---End---

And while this works, you've basically made something that is really
hard to maintain, and updating the look of your application/page is a
real nightmare.

Your next step will likely look like this:

---Start #2---
<?
	echo "<html><head><title>Hello World</title></head><body><h1>" ;
	echo "Hello World" ;
	echo "</h1></body></html>" ;
?>
---End---

While this also works, you've only marginally improved anything here
because the code and the interface are still in the same file.

The next step - abbreviated here - will likely look like this:

---Start #3---
<html><head><title>Hello World</title></head><body><h1><?= $myVar
?></h1></body></html>
---End---

You'll do some calculations elsewhere, then include this file after
you've setup $myVar. This is a huge improvement, because now you can
separate the code from the interface.

Finally you'll likely come across all manner of template tools. I've yet
to find one that doesn't use the basterdised OOP that PHP uses. I don't
like any of them and don't use them.

I'm currently experimenting with a similar setup as #3, but the data
comes from a database rather than a file and is maintained in such a way
that the end-user can maintain their own templates - it's not finished
yet and still quite ugle - not for looking at yet.

I'm sure there are better ways, but I'm not a designer, I'm a developer
and I really don't want my designer anywhere near my code, this gives us
the best solution so far.

Any other questions?

Onno Benschop 

Connected via Optus B3 from S33:37'33" - E115:07'30" (Dunsborough, WA)
-- 
()/)/)()        ..ASCII for Onno.. 
|>>?            ..EBCDIC for Onno.. 
--- -. -. ---   ..Morse for Onno.. 

Proudly supported by Skipper Trucks, Highway1, Concept AV, Sony Central, Dalcon
ITmaze - ABN: 56 178 057 063 - ph: 04 1219 8888 - onno at itmaze dot com dot au



More information about the plug mailing list