Follow Slashdot blog updates by subscribing to our blog RSS feed

 



Forgot your password?
typodupeerror
×
The Internet

What Are Good Web Coding Practices? 269

brink asks: "Recently it's seemed as if, due to larger and faster computers, lean and mean code isn't such an issue. However, it occurs to me that there's an overlooked area where there's little or no mention of the importance of efficient code: Web sites. This isn't so much in terms of HTML (I know that webmonkey had an article about efficient tag layout), it's more in terms of Perl, PHP, or whatever. It seems to me that the fact that your code has the potential to be executed in thousands of instances concurrently doesn't impress on anyone the necessity for uberefficient programming. Dynamically generated pages and DB querries are good examples, or just plain memory usage of your code. So my question is as follows: are there any good works to read which focus on programming for the Web, as in avenues the programming medium affords? Have I just been oblivious and missed them?"
This discussion has been archived. No new comments can be posted.

What Are Good Web Coding Practices?

Comments Filter:
  • by Anonymous Coward
    I write code. Do best to make efficient, but people steal code then remove Sergio's name. Well done code attract thieves. Previos poster right. Credit is all Sergio want, but thieves don't give credit.

    Sorry for Enligh.

  • by Anonymous Coward
    most of the people selling themselves as "web programmers" are undegreed kids

    Degrees are meaningless. The best web designers I know, none of them have degrees. The people with degrees I know are idiots who practically need someones help to tie their own shoelaces.

    Degrees just prove you can recite stuff parrot fashion and remember it for exams. I've yet to meet one person with a degree who actually seemed to have a superior amount of ability compared to anybody else I know.

    Degreeless kids... Idiot.

  • by Anonymous Coward
    • Turn buffering off whenever possible (e.g., $|++ in perl).
    Actually, this may make the response time a bit faster for the user, but the script will run slower because it has to do more system calls instead of filling buffers.
    --
    I support anonymous posting.
  • The Microsoft tool is pretty Mickey Mouse in comparison to the stuff I mentioned. They think 100 threads per client machine is a lot, where the other tools generally run 1000 threads per client box. The Microsoft tool works fine if you're running a small site, but if you're Lycos, Yahoo, or Slashdot, you need serious tools.
  • This is why the company I work for sells big expensive software for testing websites. For a mere (insert insane sum here) you can get Compuware, Mercury, or a few other companies to tell you what will happen when a few thousand users try to access your system all at once and how to fix it.
  • Hey there, I'm an undegreed kid. No green hair or tongue stud, but I don't have a degree. I've got 30 credits at RPI, and I have 25 at Penn (not Penn State). I've worked a couple years in the real world with amazing programmers. You know the reason I don't have my degree? it'd waste my time. No, this isn't my arrogance. I arranged for tuition reimbursement and sat down with two coworkers who had spent a lot of time teaching me advanced programming topics and they determined that I already knew and was practicing the things I'd learn in further undergrad education. So yes, I could get a degree, and have the highest credentials. I could buy a suit and pretend to be well groomed. But would it make me a better asset to a company? not really, no.
    ----------------------------
  • Some people are confused about stored procedures. You can write stored procedures in C, C++ and other languages. Oracle also supports stored procedures in Java, it even has its own embedded JVM that optimizes everything.

    If you are doing lots of updates and such it is easier to do them with stored procedures in the database because the database can cache and optimize and doesn't require the latency and overhead of the network layer.

    You also can centralize your business logic this way.
  • Ok, the smart way to do this is to have a reverse proxy setup in front of your web server. This will do much better optimization than you could do by hand and it takes 2 minutes to setup.
    However, there are a few things one can do to improve performance:
    • Filter out all white-spacing a comments before sending down a web page. This can improve download times signficantly.
    • Serve up compressed HTML files (.gz) to Netscape and any other browser that supports it.
    • Specify image and table sizes in your HTML tags so that a browser doesn't have to load the whole thing to calculate a layout.
  • I agree with the above. In some benchmarking I did on the "life" algorithm, using exactly the same method to solve it (as best as the languages allowed), Java was 200-400x faster than Perl, depending on what JVM I was using. It was even faster than C sometimes (just compiled with -O though, but to be fair, I didn't use any optimisations for either...)
  • The point is well taken, but it's also pretty extreme. I'm just saying that bloatware follows more easily when there are copious resources to waste. When there's not enough memory to do the job properly, bad hacks become the norm. But in the middle, there is a sweet spot where there's enough resources (memory, speed, UI) to do the job properly, but not so much that the system is too big (physically, as in the case of the palm) or overpowered for the task at hand. Balance is a good thing!
  • Another area where elegant coding still matters *a lot* is on handheld computers and devices such as cellphones and net appliances. Palm is doing well because they started fresh on a new platform, and the platform (nice form factor and sw, but limited memory and cpu) encourages compact, elegant code. Whatever you think of the various Win32 platform interfaces, it's pretty clear that the UI on WinCE devices is a limiting factor, and the underlying Win32 legacy does not encourage compact or particularly efficient coding.

    Can you imagine what a Palm device could do with the power they're throwing at WinCE these days? 32mb Ram? 150MHz? Of course, the downside of Palm's current advantage is that they're becoming complacent and slow. I'd love to see Palm/Handspring maintain their business focus on that sweet spot where the form & function is more than adequate, but doesn't encourage programmers to take the attitude of "aw, hell, we've got cpu to burn!" But I fear they will not. The more things change, the more they stay the same.

    Jon
  • Yeah, Netscape 4.x is a bit stupid, but it doesn't help that Slashdot sticks things in a table for no reason at all.
  • How about security [w3.org]?

    If you program in Perl, do you know what -T means?

    If you program in C, have you carefully considered buffer overflows?

    etc?

    Regards,
    Ben
  • Well, most web serving is still towards content serving.. usually a database, some formatting, and maybe some templating to drop into place. Even if you make it as unoptimized and cruddy as possible, it still takes negligible processor power.

    Unless you're doing something really wicked, I doubt optimization will get you much. Just document what your functions do in some kind of header file and try to make it readable (don't use perl *cough*). Your code may be brilliant, but you want to know what you wrote after you sober up, right? :)

  • yah, good point.

    One could also write all their cgi proggies in a compiled language, and avoid the whole interpreter overhead.
  • Oh, I love my company and will be the first to defend it. I have total access to the owner, and nobody who isn't really good at what s/he does survives very long.

    The downside is that with a loose structure comes heavy responsibility. But with that comes the opportunity to do a great job and earn the warmth and affection of the employees, which makes it a really fantastic environment if you can cut it in the first place.

    Of course if you can't, it's a real nightmare. The BOFH wasn't fired; he quit because his stress level was way too high. Saved us the bother of firing him.

    D

    ----
  • I'd love to make money off this idea, but I really don't think it's a patentable process :-).

    To be safe, call it something other than the red button, maybe the green cube or something.

    It's worked out really well at our company.

    Enjoy!

    D

    ----
  • Most databases have indexes, which can be thought of as pre-computed sorts. These are used to both retrieve and sort data.

    If your SQL database uses indexes effectively, it should be many times faster than perl because much of the sorting has been pre-done for you.

    Since I'm writing a response to this already, a few thoughts:

    I don't doubt that Oracle is a fine database product, but it's also ruinously expensive and has sluggish connection speed. With mySQL, I can open and close the database in each script I run without significant performance penalty; with Oracle, I'd have to change this and most likely make my code more complex and therefore more bug-prone.

    I use C for my CGI scripts primarily because most of them are exceedingly complex, and I feel better using a "real" programming language with low function calling overheads and a syntax that's clean and easy for me to understand later on. I may be paying a performance penalty for keeping things in CGI, but I feel the extra reliability created by the self-contained nature of the programs is worth it. In addition, because I know this stuff cold (thanks to doing it for years), I can crank stuff out extremely fast. If you're starting out, though, you're probably better off using mod_perl or equivalent, unless you have multi-thousand line CGI programs like I do.

    D

    ----
  • I try to use "lite" JavaScript, sticking to core functions that are pretty consistent between platforms. For instance, sometimes it's handy to open new windows for things like comment screens or email messages; this can be done effectively with very tiny JavaScript programs that have a significant positive effect on usability. For instance, on the web site I've developed for my employer, both employees and the public can "Press the red button" at any time if they have questions or concerns. The red button is far more effective in a new window, since users can check out their problems in the other window while writing the message.

    I'm sorry to say I've never heard of XHTML before - care to enlighten me?

    D

    ----
  • Our company hired a fellow as our network support guy who had ample credentials and was determined to get even more.

    Turns out his entire life goal was to get more credentials. When we discovered that they hid a surprising lack of knowledge and a deep-set hatred of users, his days were numbered.

    I'm not convinced at all that finishing a structured program (which this guy loved) is good preparation for a business environment - at least not at our mid-sized, free-wheeling, vaguely unstructured company.

    D

    ----
  • By your logic, a 19 year old kid who might have spent the last 7 years working on Apache would be unqualified to be a web developer!

    I agree with most of your post, but the above statement is interesting...

    For there to be a 19 year old with 7 years working on Apache, she must have started as a 12 year old with 0 experience with Apache. Such a person was definately not a web developer at that time. It's an extreme example, but that may be where the original poster's bitterness about "undegreed" web developers comes from.

  • Buy those novices a WYSIWYG true blue HTML editor, Office apps produce horrible code because they are trying to preserve the exact look of the document. Most good editors let you see the code and add as much whitespace and comments as you'd like.
  • 200x is a hell of a speed improvement. Java and Perl (when done right) are both JIT compiled languages with similar language complexity. I fail to see precisely how switching similar code from Perl to Java could alter your speed by 200 times. Are you sure you did not alter the order of algorithm complexity? That is the only thing I could see causing such a radical difference in speed.
  • Since when do you need to have multiple server architectures run the same code?
    Ever since there was more than one server architecture to choose from. Solaris, Linux, AIX, Windows...
    PHP does that. Perl does that (I think.) Cold Fusion does that.
    I doubt PHP has the CORBA and Microsoft COM support Java has. (E.g. does Microsoft provide tools to wrap COM/Java around Java/COM? Didn't think so.) ColdFusion is in a different class of solution altogether, it doesn't compete with Java on the large application scale, and coming to think of it, neither do Perl or PHP.
    Java IS slow.
    I never said otherwise.
    I'm on a AMD K6-2 350 and a Java Hello World took about 3 seconds to respond to a "destroy" request. Most programs take around 1 second. A slightly larger program is slow enough to be unusable.
    Java JVM startup time is completely irrelevant to this discussion. We are talking server side, where you startup the JVM once. Java still has problems there, but you are speaking of startup time as a big deal, and it is simply not an issue on the server.
    ----------
  • Just because it can be done doesn't mean it should be done. :)

    I've done web sites in Perl. Any language can be abused, but for large systems, it is much, much easier to write hideous spaghetti code in Perl than it is in Java. And I hardly call Perl's object oriented "features" (i.e. hacks) appropriate for larger systems, especially when compared to Java, which may not be perfect, but it's certainly a big improvement.

    I love Perl, and think it's the greatest thing since sliced bread. But right before a big marathon, I'm going to need a heck of a lot more than sliced bread...
    ----------

  • Java is great server side because:

    • Much, much easier and robust than C or C++.
    • Cross platform. Yes, on the server, the cross platform promise of Java works.
    • Integration with other languages and platforms, such as CORBA, Microsoft COM, etc.
    The Java performance problem is usually not such a big deal on the server, and is addressed by throwing more hardware at it. For well-funded companies racing against Internet time, the above advantages make the extra money thrown at hardware a no-brainer decision.

    Note that I'm not comparing Java to PHP or Perl, because the category of problems each is suited for is different. For large enterprise systems, C, C++, and Java are your choices. For smaller, script-driven type sites, PHP and Perl are more appropriate.
    ----------

  • I thought it was just because the code was poorly written. Have you looked at it? :-)
  • Netscape 4 is horribly slow at rendering nested tables. It's not the web designer's fault that HTML was never designed to do what we expect of it today (and nested tables are one way to get a lot of stuff to lay out right). Netscape 3 is much faster, so it's clear that the problem is in the browser. But Netscape 4 has always sucked from day 1. How well Mozilla will do remains to be seen (it's horribly slow now, but I'm told that's because so many debug checks are still in there).

  • Isn't module's own include feature enough for that purpose?

    No, because the designers are not going to be editing or creating pages using tools that understand the module's include feature.

  • The difficulty I find with Text::Template and it's ilk is handling includes. Many designers (rightly) use server side includes to handle incorporation of form elements that are used reptitively into their documnents. The template modules that I have looked at do not parse the SSI include directives resulting in an incomplete output file. If anyone knows of a template module that correctly handles SSI virtual and file, I'd be quite interested.

  • sigh, the old perl vs java debat again (zillionth time?).

    "Since when do you need to have multiple server architectures run the same code?"

    No vendor lock in. Ability to move your stuff to bigger platform should you need more horsepower. A

    "PHP does that. Perl does that (I think.) Cold Fusion does that."

    So, I bet you can list a number of other languages that can do that as well.

    "Java IS slow. I'm on a AMD K6-2 350 and a Java Hello World took about 3 seconds to respond to a "destroy" request. Most programs take around 1 second. A slightly larger program is slow enough to be unusable."

    So, buy some decent hardware, get the right JVM (and OS) and make sure you have enough memory (128 should be enough). Since we are talking webservers here there really is no excuse for crappy hardware and outdated software. Probably development/maintenance cost is much higher than the cost of the needed hardware for a website of decent size.

    I worked with Java years ago on 66 Mhz HP-UX machines. I once managed to load and run the corel office demo on it. That was slow (and ugly). But hey, we are talking about a really crappy port of a 1.02 jvm here. I'm currently running JDK 1.3 Beta on my computer at work (PII350, 192 MB, winnt) and rarely have performance problems running such programs as TogetherJ, Forte and JBuilder.
  • Ever wondered why slashdot has been looking the same for years? It's probably not because the owners don't want to change it but because their perl code base grew too ugly to change it radically.

    Perl is good for shortlived projects (most websites change every few months). Since it is possible to produce code fast in perl it is ideal for the fast paced internet world where time to market is everything.

    In an enterprise situation websites are complex, need to be reliable and contain lots of stuff that really does not change very much over time.

    For such systems, you don't want to use ducktape type of languages like Perl. You want to use a language and development environment that helps you address these issues.
  • I think you might have missed a buzzword or two in your post.

    No... wait... I can't think of any other buzzwords... maybe you did use them all. You must be a manager.
  • Servlets are incredibly fast. Especially if you're good at optimizing concurrent programs, the threaded process model of Java smokes just about anything out there. Persistent sessions can be utilized to save even more time for apps that use a database. Even FastCGI has a hard time competing with servlet engines built in to the webserver core like Netscape Enterprise 4.0 does.

    I recently wrote a replacement for an online retirement plan management system that handles over 12,000 transactions an hour.

    I replaced nearly 80,000 lines of Perl with only 20,000 of Java, and even when you include the database time in the total, the Java solution is an order of magnitude faster under no load. Under load, it's 40 times faster and still scaling linearly when Perl has started to cause a cascade overload of the server.

    When we don't have to hit the database, our servlets are over 200 times faster than the same page built by our Perl CGIs.

    While you could theoretically write something faster in C++, you'd have to go to all the trouble of implementing the equivalent of a servlet engine yourself to start competing for speed with Java's lightweight process model. With Java, you can just start writing your app.

  • write in C or C++, and compile server loadable modules and you will be measurably 10x faster. Don't take my word for it, do the testing yourself. Modperl? 5x slower, without even trying hard.

    So what if its 5x slower. CPUs and Memory is cheap, web developers are not. I would rather have a slightly slower site in a month than a lightning fast site in 6 months that slowly leaks memory because someone forgot to unallocate a buffer somewhere. Perl (VB, Python etc) are muchmuch faster to develop, easier to debug and less likely to have memory holes than a C/C++ module. For most applications the server is waiting for a database far more than it is crunching data in the module, and for the sort of processing most web apps do there is not much benefit from using C (its not like many people are calculating Pi to n places on a website, its mostly text processing and database accessing).

    --
    ...in fact msot serious hacking is done by UNIX, and UNIX based systems such as Linux or C++...

  • Bah! To do it right, I'd think you'd need more than two.

    Graphic designer for logos/appearance/layout

    HTML monkey for layout production

    User interface designer (NOT the same as graphic design)

    Backend programmer (CGI/PERL)

    Database designer (MIGHT be same person as above)

    Evil overlord/overseer/webmaster (to keep the VISION of the sight clear and crack the whip on the rest)

    Skippy

  • XHTML? Some combo of XML and HTML?
  • True. This is what I do all day. The advantage of the 3 tier system is that you can prototype the code early on in the scripting language and after testing, move those algorithms to the second tier.

    Its all a system of tradeoffs. The advantage of using a scripting language is rapid development and debugging at the cost of the richer functional libraries and preformance of a compiled language. Another advantage for project managers is that they can use junior programmers for the first tier and spare the attention of senior level developers on the second and third tier.

    This makes planning essential. If you identify what pieces will be written on which tier, your life will be easy or a living hell. Most techniques in web application programming are found in articles. Even if you're programming in PHP, look at ASP websites as they'll often have extremely helpful article on using components, how to structure your database, caching tricks, and other information which is platform independent.

  • (flipped through replies but didn't find too much on this)

    As far as possible, stick to occasional generation of static web pages, rather than generating them on the fly with mod_perl or mod_php or CGIs or whatever. With clever design, I think a huge number of websites can be converted to a statically generatable version, escalating performance in a big way. You can run the html generator (which could be just CGI >foo.html) using either a cron job, or run "make" whenever you update any content.

    As an example, I've always wondered why /. doesn't do static page generation - people's user profiles comprise a fairly small set of look-and-feel options. Apart from that "page generated for Mr. Foo Bar by a marauding flock of random geese" thang, there are only so many combinations for the rest of the page, and generating them in one shot would make /. pages *so* much quicker to load. Likewise, regenerate only the required pages on every update (article or comment). You don't lose any customizability that way, and gain hugely on response time and webserver throughput.
  • And even if you can't detect any increase in speed, it's still faster

    ???

    If it's not noticably faster, then what's the point spending 3 hours optimising the code? How is that being efficient? (think efficiency of programmer time, not just of cpu cycles)

    i'm not advocating writing 90% sloppy code and 10% fantastic code... it should be 90% good code and 10% very good code.

    It's simply that "good" code isn't always the fastest. Good also means "readable", "maintainable", "simple" -- things which aren't always possible with an optimised solution, or at least tend to be harder. And when optimisation isn't going to make any useful difference, then sacrificing those other aspects for it is The Wrong Thing.

    Most code, especially for CGI scripts, is so time critical that obfuscating it is a real benefit. If you've got the spare time, sure, go ahead, optimise every single byte of code you write. Where I work, I don't get that luxury - and fair enough, why should I get paid if 90% of my time is spent doing something that gives no real benefit?

    Remember, everything in moderation, and that includes optimisation.

    -Spiv.

  • Read his first paragraph again:

    There is a classic CS quote that says that a program spends 90% of its time in 10% of its code. Make this code run twice as fast and you will nearly double the speed of your program. Optimise everything else and you won't see any difference at all.

    You could optimise the other 90% - but why? Programs tend to do alot of looping over a very small percentage of their total code. Most of the statements in your code will get executed only once, but a small chunk of it will get executed 100s or possibly even 1000s of times.

    If you can figure out where most of the time is being spent in your code, and optimise that, you'll be much better off than simply optimising some random parts. If you can somehow shave 50% of the speed from a part of the program which is only taking 10% of the total time, you've saved 5%. If you can shave a mere 20% from the part taking 90%, then you save 18%.

    It's not a matter of being half-hearted... it's a matter of being intelligent. Why optimise and possibly obfuscate most of your code, when doing it to a carefully chosen section is so much more effective?

    -Spiv.

  • In my experience, and most will agree, you should always write code to execute as effeciently as possible. I doubt Rob, years ago, when first designing Slashdot had effeciency at the top of his list. He couldn't forsee the millions of hits the website would take. As a web contractor, I've learned the hard way to always comment code, and use objects/classes. Most of us when doing contract work, never think about who/what is going to maintain it after we leave/job is done. I often look back at old projects and wonder "What the hell was I thinking", or maybe even question what the program does, even though I wrote it. I've encountered the slashdot effect a few times on our server, and wished I had written the code better. Just my 2 cents
  • As with everything else, a degree is what you make of it. While I was getting my degree, I saw ALOT people coast through, taking the courses that required the least amount of work. Not coincidently, those courses were the ones that provided the least benefit to the students, but they were the ones with the highest attendence.

    So I don't think that anyone can say with absolute conviction that a coder with a degree is better than one without - simply because there are a lot of slackers and guys who see that CS is going to pay them $40k/yr out of college.

    On the other hand, I believe that taking the courses required for a degree is important. Computer science theory, although boring in general, is almost a necessity to achieve a thorough understanding of what you're doing. With the background in theory, you can quickly and easily apply techniques in any language, because you know why the techniques exist. I think you'll find that one common attribute of the authors of the most common computer languages - higher education.

    To say that you don't need formal training is arrogant and short sighted.

    Some people have stated that owning a degree shows that you make a good parrot - being able to recite word for word what was shoved down your throat. I would suggest that the lack of a formal education makes it very difficult to truly learn and utilize differing techniques. I think that you'll that alot of people without the benefit of a degree fall into the trap of seeking out someone else's solution to a problem they have, but never fully understanding the solution. If they don't understand the solution, they attempt to apply that solution everywhere they can, because that solution is "in their toolbox". These people expand their abilities by acquiring more and more code from other people, filling their toolbox but never fully understanding these new tools.

    With the formal training and the expose to the theory, a person is more able to develop their own solutions and to fully understand someone else's solutions. This, I believe, would make that person a better programmer.
  • PHP 4.0 and the latest version of ASP (don't use it don't know the version #) are both compiled to bytecode (very much like Java). JSP is *parsed* by the servlet is been run under, translated to a plain Java file and then compiled to Java bytecode (maybe newer JSP engined compile directly to bytecode, I am not sure, this is the case with JServ 1.1 + GnuJSP).

    Now, stored SPL procedures (which is not the same thing as SQL --SQL is the root of most SPL languages, but pretty much each vendor has their own) are also compiled to bytecode and stored within the DB structure.

    So far, if we're comparing the two schemes, we've gained nothing in comparison: both language genres compile to some machine-independent bytecode that's supposedly slower than assembly and faster than interpreted languages.

    Under this layer is where things get interesting: how does SQL/SPL access the data structure? through a proprietary, vendor specific library. How do PHP/ASP/Java? thru SQL. That's where the performance difference comes in.

    What would you rather code in? SQL or PHP? Java or some vendor specific stored procedure language? (which not only locks you in, it probably has less features and is not as robust). What would kick some major ass, would be to circumvent SQL and access the data structures *directly* from PHP/Java. SQL is not the end-all, be-all of data access. It's just entrenched, and the lowest common denominator (you can always figure a way to do anything in SQL).

    The other layer you're missing is the data-structure itself: the DB vendor (Oracle in our case) doesn't know what you're gonna end up doing with the DB --thus, they lock you in to certain type of data structure (and no, not all DB data structures are created equal). That's really the reason we now have really fast-read RDBMSs like MySQL that suck for transactions, cool OOP-like ORDBMS like Postgres that suck for reads, and a multitude of commercial DBs that each have their niche.

    But the end-developer (the PHP author here) *does* know what each data structure will end up doing. So, if you can have a common API from PHP that can access several types of data structures *directly* (NOT thru SQL), and you could specify what you want (fast read, object-store, transactions), all the advantages of a proprietary RDBMS go away. That's where OSS could kick ass: write the structures and the libraries to read them and use a common, rich language to access them *directly*.

    We're not really disagreeing; C++ will always be faster on the server side. But the server side is controllable by the developer/deployer: you can always add more muscle to your servers. Development time, flexibility and robustness are more important.


    engineers never lie; we just approximate the truth.
  • Errr... Stored procedures in DBs are basically compiled to bytecode that has faster access to the DB structure (i.e. probably a C library).

    Now, contrast this to a modern scripting language (PHP4, ASP) or Java --a high level language (not unlike a SPL) that also compiles to bytecode. The performance difference here is access to the data structure: in all the languages above (ASP, PHP, Java) the way the DB is accessed (i.e. the speed of the JDBC, ODBC driver or PHP module) is what determines the speed of access to the DB.

    In other words, there really isn't much of a difference between using an SPL in a DB or an external scripting language that has fast access to the DB data --e.g. the PHP module for MySQL. I think what confuses you here is that Oracle has *never* given a C library (or anything similar) for access to the DB structure, forcing everybody to use their proprietary SPL.

    IMHO, the future lies with highly developed, open and popular languages (PHP and Java being my favorites here) that have C-level access to data structures *directly*. I.e. you could potentially get rid of SQL (or make SQL another language with access to the C library) and, more importantly you could have different types of data structures in the same application: e.g. a very fast read-only DB file (think MySQL) and a robust object-store DB (think Postgres) that look and feel the same to the end developer (the PHP dude). If anybody wants to start an OSS project like that, count me in ;-)...



    engineers never lie; we just approximate the truth.
  • My employer [retek.com] does a lot of data-mining at a very low level: we have one of the most complex read *and* write data-mining applications out there, and yes we do a lot in SPLs, and SQL and C++ and even our own in-house languages. I am confident (in fact, I know) that you can considerably out-perform SQL if you write "to the metal", in this case the data-structure itself.

    Knowing this, and the problem I laid out before (that the DB developer doesn't know what the application developer needs) I have personally started to question the need for an RDBMS, particularly in the case of Web applications.

    Let's face it, a full RDBMS for a data-store of a few TBs makes perfect sense, but for a website of a few pages (even a few hundred pages) it's overkill, especially, as a lot of posts have said so far, since that's where your bottleneck is in dynamic sites. So why are we running full RDBMS, or even low-powered clones of such (i.e. MySQL)?

    I am willing to bet performance would go wayyy up, if you could have a relational data structure directly available from PHP (a basic B* tree, for example). Why?

    One factor: PHP does caching; but it can't cache an *external* data source, such as a DB table, because it can't be sure that it was not modified by someone else; but, if the datasource was *internal* to PHP, caching of records, queries or whole tables would be simple: less disk/data access = more speed.

    If you are not familiar with the wonders of PHP4 (not 3.x), check out php.net [php.net] (and the best online manual in existence) and the now private company behind their engine, Zend [zend.com]. The Zend folks have recently got together with the MySQL folks, to further integrate the two platforms; there is a chance they will end up with a direct access scheme --and that's the main reason I am betting on PHP...


    engineers never lie; we just approximate the truth.
  • HTML files with PHP are read and evaled every time they are called. With mod_perl handlers, the scripts are compiled when Apache starts up and then never gets recompiled until you restart the server. That is the difference. The same thing goes for ASP scripts, and other embedded scripting languages (this actually includes things like ePerl, Embperl, and other embedded Perls). So, PHP is fast (no spawning a new interpreter), but the pages need to be read every time they are called.

    I believe that PHP4 will have the option to compile HTML/PHP pages, so this will not continue to be an issue.

    darren


    Cthulhu for President! [cthulhu.org]
  • I'm only very familiar with Microsoft SQL server,
    (if you have to use this product I'm sorry for you, but sometimes you have to learn about it anyay)

    I'm not certain of the support in other sql servers (although I'm sure major servers such as Oracle include server stored procedures).

    Essentially what happens in Microsoft SQL server
    is that you can create certain scripts in T-sql (transact-sql) which can be run as queries or within triggers (scripts that execute on insert, update, or delete).

    The cool thing about stored procedures is when you're using ODBC, which can be incredibly slow, especially with large recordsets. You can move large updates (things like updating the dates on all records in a query) onto the server, where its caching and local data makes it MUCH faster.

    Doug
  • > It's true that "universities tend to concentrate the best of the best and put them within talking distance of each other", but the brightess minds tend to be anti-social.

    This is not what I have found. The smartest people I know are all quite social. They aren't social around morons but arround their peers is a diffreent thing. Maybe your focus is on too small of the little bit of the world you've had to deal with so far.
  • Don't use Session variables, ever, they'll kill performance and give you scalability problems.

    I find programming ASP and databases a doddle: what I do is have my own include file inc_ado.asp which contains only the ADO constants I ever use (which is only about 5 to 10% of the original adovbs.inc file), and then add one extra constant which contains the DNS-less connection string [learnasp.com] to the database, e.g.:

    Const DB_ROOT = "driver={SQL Server};server=db.my-domain.com;uid=myuser;pwd=myp wd;database=mydatabase"

    Make sure that connection pooling is on! (see the links below to find out how to do that.. it's a registry setting, as simple as that).

    Then open the database connection as late as possible, and close as early as possible, and use adOpenForwardOnly whenever possible, because it's by far the fastest cursor (there's only about 5% of the cases where I have to use adOpenStatic in order to be able to jump to the end and walk backwards). E.g.:

    Dim rs

    Set rs = Server.CreateObject("ADODB.Recordset")
    rs.Open query, DB_ROOT, adOpenForwardOnly
    [ ... ] ' do your stuff
    rs.Close
    Set rs = Nothing

    With Windows 2000 / IIS 5 there are also quite a few parameters within the properties of a website that can have dramatic effects on the performance: the most important one is to make sure you've got "Enable client side script debugging" turned OFF. Having it turned on will have your website run in single-thread mode which is extremely crap in a live environment.

    Optimizing ASP: a very good link is here [microsoft.com], also worthy to note are here [asptoday.com], here [learnasp.com], here [microsoft.com], here [microsoft.com], here [microsoft.com] and here [microsoft.com].

    Loz

  • IMHO execution time and efficiency on the server side is not a big deal at this time. The problem is the (usually vast) amount of html tags, text, and binary data (usually animated graphics) that are being forced through the Internet, squeezed through ISP/LAN/Modem bottlenecks, and rendered on inefficient browsers.

    Your (php,mod_perl,compiled CGI) code can be beautiful, elegant, optimized, efficient, easy to understand, and simple to edit/extend, but it makes little or no difference whatsoever if 100K still has to be delivered to the client, interpreted, and displayed. I think the quantification of 'good web code' should be dominated by "bang per byte the client has to deal with" rather than more traditional programming standards. Subjective, I know, but I think given the current constraints of the medium more attention needs to be paid to what happens on the client end (end-user available bandwidth id not increasing as fast as processing power does {not Moore's law!}).

  • Umm, for sql server, look at msdn... Oracle calls 'em something similar. I'm sure you can find stuff on other sites. Sorry, my SQL experience is limited to those two (and very little of the latter.) I know personally you can do a lot with TSQL on m$ offering. Plus, even a select query is good in a SP if you use it all the time, 'cause the execution plan is pre-compiled and the overhead is lower. Plus, if you want to change the damn query, you just change it once. SP's and the like (I think just about any decent RDBMS will have 'em) get you a lot of the benefits of 3-tier (offload CPU/Disk access off web server, logic only in one place) without the complexity.
    ---
  • "Why use HTML when javascript, cascading style sheets, java, cookies, imagemaps, and shockwave will do?"

    The problem isn't the new technologies, it's people who use those technologies without following the standards. If you read and follow the standards put out by the W3C [w3.org], you'll find that the standards are very much geared towards the creation of webpages that are accessible to all clients, whether they be text only or graphical.

  • That's all nice, but there was one thing about your priorities in creating code that was blatantly missing. It is the one thing that I did manage to learn in school, that was hammered in hard, and that I consider the defining element of who I want to work with for long stretches of time, and the thing that I see many people who just rolled into this job firmly lacking.

    Maintainability.

    6 months from now, can the author undertsand the code? Can the other programmers? Can the project manager? Well enough to be able to make an informed decision whether it can be moved forward in a certain direction?

    Maintainability. It's not just about writing comments, it's about clean design, a sense of what separation, encapsulation, and inheritance truly is for. It isn't just to debug better, and certainly not to make faster code (but code faster, maybe).

    Maybe your code is perfect now. But it won't be 6 months from now. That's what my degree taught me, and boy am I grateful.

    It's why I dare call myself a software engineer. Maybe I am a lousy engineer, but at least I understand the priorities involved in that word.

  • Until employers value experienced professionals with the proper credentials (instead of thinking that every kid with green hair and a stud through his tounge is a web expert), there's little hope for a standard of quality on the web.

    Please, insist on hiring only the most credentialed, and best groomed crap out there.

  • I don't really [dev] see many examples of HTML abuse [mailto], and I think that most of what you hear about
    • bloat
    • poor FORMATTING
    • and
    • other
      abuses of the WWW and HTML, CGI and other such slashdot propogated nonesense is
    simply myth

    Y M M V

  • It's important to differentiate

    Make stored proceedures for your SQL, so it will run faster
    from
    Make everything a stored proceedure so it will run faster

    You seem to be saying the second. But only the first is true. There are better ways of optimizing non-SQL logic, than to bog down your database server with it.

  • I apply what I know about algorithms and data structures to make my code as maintainable as possible.

    I hate to be crass.. Did you read what I wrote dude? Ive been doing this for two years.. Ive learned a lot the hardway about maintaining my code. Let alone someone else who did not READ my post moderated you up. Ive spent countless hours doing stupid things like commenting and making variable names make sense and code layout make sense..

    And I dare call myself a programmer...... Did you see that part of my post?? Seriosuly..Yes I combined a couple of thoughts since algorithms do not apply to code maintenance its more common sense. But yes it is something I strive for since *I* have and do support contract work on occasion. Which means going back over my code. Like I said ive learned the hardway. Im glad you got to learn about it in college.. I learned about it working.
  • Some tips for database-driven sitedevelopment:
    • Optimize your queries. Don't use more queries than you absolutely need to. For instance, a lot of people show the latest n items and also show the latest date the page was altered. Instead of querying twice, just use the date on the most recently dated item in the recordset the first query got you (assuming it returns the adddate.)
    • Use cache. When someone requests your page, simply check if the database changed since the previous hit - if not, then show him cache you generated.
    • Use your database. I've seen loads of sites using very advanced database-software that supports stuff like stored procedures, triggers and views, but the developer only uses it for raw SQL-querying. Stored procedures for instance do wonders for performance.
    So the best thing to do first when building a high-performance database-driven website is contemplate and set up a datamodel. It's essential (get some books)
  • CGI? and Perl?

    Not if you want to handle millions of transactions, you won't.
    Distributed N-tier architecture, scalable and capable of handling serious loads. Good load balancing in software and hardware. Distributed databases, LDAP for user reg's, cache for the data. Batch processes that run when there is not too much traffic to update and clean your cache. Transaction management, distributed transaction management on different systems.
    Resource management, memory, RAID systems, caching, HD space.

    If you want to be multiplatformed and n-tiered, go here: http://divya.com/pubs/ejb/ [divya.com] and here: http://www.javaworld .com/javaworld/topicalindex/jw-ti-ejb.html [javaworld.com] Or here: http://www.cs.rutgers.edu/~shklar/isas98/ [rutgers.edu]

    And all this is just a beginning of understanding. You actually need a good Software Architect(s) in order to optimize your performance under heavy loads, good Interface Designer(s) to optimize the user interface, good graphics designer(s) to be efficient and good looking, coder(s) who do your *ml work

    here [davinci.ca]is what I do for living, just click on 'Product' there.
  • Hey, it's Ok to be out there in the workforce, doing the best you can and getting paid for it. You don't have to prove anything to anyone.

    Going to a University should not be considered a prerequisite for getting a job. In fact most people never go to any University and at best they have some college diploma.
    I went to the University of Toronto (I am in my fourth year) and I have being working for the past three years as well (found a programming job after completing one year of the University.) However I don't look at my University experience as at some kind of a higher prerequisite that is necessary for my work. On the other hand I view my education as a tool for educating myself more in the future. In my four years of UofT 1/3 of the classes that I took had nothing to do with Computer Science nor with Math nor with Engineering. I took classes in subjects that I was interested in (Astronomy), classes that provided me with knowledge on subjects that can be even useful in my everyday life (Philosophy of Sexuality - very good course, incredible prof), language courses that allow me to improve my communication (German, French, English Literature) and in the summer I'll be taking intro to Economy, Sociolgy, Management, which hopefully will allow me to understand these subjects enough even for the real world.

    I believe that formal education allows a person to fill in the gaps in his/her knowledge and build a better character, especially if he or she enjoys and desires to learn. Well, as my prof says: -You don't need to come to the University if all you want is 100 grand a year salary, only if you want to know what to do with 100 grand salary and do it gracefully.
  • Most of the more experienced engineers I've worked with tell me that a lot of the math and advanced theory they learned in school hasn't been used since then.

    That is a bad thing. A lot of that is useful. A database administrator that doesn't make sure her/his databases are normalized is doing a grave disservice. Conversely, normalized databases are much nicer to deal with. It is not just a theoretical consideration.

    Also, good programming design principles are important. It really does make a difference. But you need to know that it is important and have the skill to do things the right way. Hacking something together without any background can be cool, but I wouldn't want to run a business on something that was poorly designed because someone didn't understand the concepts that were required to know how to do it right.

    I dislike the implication that many here make that those of us that sought, and obtained degrees (such as myself) wasted our time. I earned my degree and am proud of it. The stuff I learned has proved useful on the job.

  • Of course it should be noted that some degreed professionals also have green hair and/or studs through their tongues.
  • One of the most important aspects of any optimization process is profiling. Unfortunately profiling is also one of the hardest tasks to accomplish when it comes to web development. If you can't identify where your bottlenecks are or where the most time is spent, you can't optimize very well.

    The fact that it's fairly common these days to find that a web request lands on a load balancer which forwards it to a webserver which may dynamically generate a page which makes a call to an application server which may execute a stored procedure by going through some sort of middleware database connector to a RDBMS on the backend means that there are a lot of different things that have the potential to be optimized.

    I think some of the most important advice to keep in mind is that generally the optimization technique which yields the best results are architectural redesigns. If your architecture is inherently slow or imposes inherent limits on your performance, it doesn't matter how much you tweak the individual components.

    Once you have an optimal architecture, each component in the architecture needs to be examined discretely. For example, there are a lot of optimizations that can be done to perl code that don't apply to Java at all, and vice-versa. Once you get to this stage, read every article, buy every book, etc. that you can regarding your specific technologies.

    Our company is developing search technology using Java and by following the java-specific advice in the 'Java 2 Performance and Idiom Guide' we were able to reduce the time it took to do an average search from 10-30 seconds down to 100 to 300 milliseconds.
  • /** If you see this comment twice, its because I was a dumb ass and accidently posted a reply in the wrong thread the first time, doh! **/

    I too am a professional PHP developer. I have found that planing ahead is the best way to write good code.

    I always try to build small functions, that can be re-used and generate clean and quick code.

    However, as a coder, you need to be aware what the design team is doing. I fortunately do a lot of my own design, and
    am aware of how large file sizes and extraneous "extras" like javascript buttons, popups, etc waste resources.
    Unfortuately the majority of designers I have worked with have been paper publisher, who have only recently started
    producing layouts of the web.

    I am contantly telling them to avoid things like background gradients, and lots of images fading from one to another.
    Sure it looks good, but doesn't lend itself well to scaling.

    On some projects it is frustrating to have to deal with browser incompatibilities, resulting in extraneous code, to use
    one block for Netscape, and another block of code for I.e., and maybe a third for Lynx. This scenerio doesn't happen
    too often, as planning inadvance helps alot, as does design for the lowest common denomiator (I usually target a 3.0
    browser at 640x480).

    Sometimes you're lucky and the project is for a local intranet. Those are the best because you can design for the
    standard browers (usually a I.e 40 or 5) and can rely on a fast connection.

    My list of things to keep in mind when coding for the web:
    1. target audience, (what do we expect the clients to have)
    2. Do I need a database to store my dynamic content, where is that machine at in relation to the web host? What
    can I do to cut down on database transactions?
    3. How many of the viual elements can be reused. I try to break down the site into sections, a header section,
    footer, navigation, body, etc. the more these peices can be reused the faster, your site will be, and the easier it
    will be to maintain.
    4. Graphics effientcies? Where can I subsitude background colors in tables for an image. If there is an
    animated image, can I chop it up so that the animated portion is as small as possible, and store the image layout in a
    table? (.GIFs are bad, and animations are annoying, but sometimes the client insists) What format is the smallest .PNG
    or .JPG.
    5. Maintainability. This includes this liek a meanful directory structure, consistent capitalization, comments,
    etc. While it is important to do things the right way up front to save time in the long run. I have found that when i
    start off quick and dirty, the project stays that way. You almost never go back and add comments or clean the code once
    it works, you only will do so if there is a problem. So I feel it is important to address as many issues as you can
    upfront. Plan for easy maintainability. If your logic is easy to follow, it will be easy to maitain (and therefore
    there will be less temptation to put inefficient band-aids in place.)
    6. Testing. Make sure you test your site and application on as many browsers and at as many resolutions as
    possible. And even if you have a DSL or CAble modem, get a dial-up account to test the access. (A ppp link over a null
    modem with the speed turned down also will work for this. . .)

    For references I use a pretty standard HTML syntax book, an Older version of Javascript Unleashed (sams), I also highly
    recommend the MySQL mSQL by Reese and King (O'Reilly) and The PHP on-line anontated manual (http://php.net/ docs.php3).
    When I get stuck, or what advice I always go to the mailling list archives at
    http://www.progressive-comp.com/Lists?I=php-genera l

    -MS2k
  • I too am a professional PHP developer. I have found that planing ahead is the best way to write good code.

    I always try to build small functions, that can be re-used and generate clean and quick code.

    However, as a coder, you need to be aware what the design team is doing. I fortunately do a lot of my own design, and am aware of how large file sizes and extraneous "extras" like javascript buttons, popups, etc waste resources. Unfortuately the majority of designers I have worked with have been paper publisher, who have only recently started producing layouts of the web.

    I am contantly telling them to avoid things like background gradients, and lots of images fading from one to another. Sure it looks good, but doesn't lend itself well to scaling.

    On some projects it is frustrating to have to deal with browser incompatibilities, resulting in extraneous code, to use one block for Netscape, and another block of code for I.e., and maybe a third for Lynx. This scenerio doesn't happen too often, as planning inadvance helps alot, as does design for the lowest common denomiator (I usually target a 3.0 browser at 640x480).

    Sometimes you're lucky and the project is for a local intranet. Those are the best because you can design for the standard browers (usually a I.e 40 or 5) and can rely on a fast connection.

    My list of things to keep in mind when coding for the web:
    1. target audience, (what do we expect the clients to have)
    2. Do I need a database to store my dynamic content, where is that machine at in relation to the web host? What can I do to cut down on database transactions?
    3. How many of the viual elements can be reused. I try to break down the site into sections, a header section, footer, navigation, body, etc. the more these peices can be reused the faster, your site will be, and the easier it will be to maintain.
    4. Graphics effientcies? Where can I subsitude background colors in tables for an image. If there is an animated image, can I chop it up so that the animated portion is as small as possible, and store the image layout in a table? (.GIFs are bad, and animations are annoying, but sometimes the client insists) What format is the smallest .PNG or .JPG.
    5. Maintainability. This includes this liek a meanful directory structure, consistent capitalization, comments, etc. While it is important to do things the right way up front to save time in the long run. I have found that when i start off quick and dirty, the project stays that way. You almost never go back and add comments or clean the code once it works, you only will do so if there is a problem. So I feel it is important to address as many issues as you can upfront. Plan for easy maintainability. If your logic is easy to follow, it will be easy to maitain (and therefore there will be less temptation to put inefficient band-aids in place.)
    6. Testing. Make sure you test your site and application on as many browsers and at as many resolutions as possible. And even if you have a DSL or CAble modem, get a dial-up account to test the access. (A ppp link over a null modem with the speed turned down also will work for this. . .)

    For references I use a pretty standard HTML syntax book, an Older version of Javascript Unleashed (sams), I also highly recommend the MySQL mSQL by Reese and King (O'Reilly) and The PHP on-line anontated manual (http://php.net/ docs.php3). When I get stuck, or what advice I always go to the mailling list archives at http://www.progressive-comp.com/Lists?I=php-genera l

    -MS2k
  • Being a rather intellegent 14 year old, I'm amazed at how many people on slashdot are actually bashing the younger generation for being idiots, and how a stereotypical bad web designer is gothic with green hair and a tongue piercing.

    I know and enjoy reading quite a bit of literature and writing as well, so in sixth and seventh grade I got the wonderful opportunity to visit a young writers/readers convention. You would be amazed at the number of teens that are gothic or do have green hair. If you can actually see through the outside and the green hair you realize that some people are incredibly smart. On the flip side, some kids that look like idiots have talents that would amaze any intellectual person.

    If you go through life thinking that everyone younger than you is stupid, you need to rethink your ideas. Be it generation X, the baby boomers, whoever was a teen when you were maturing, remember that someone though the same thing as you. Do you like that feeling? How many people who cruise slashdot did amazing things as kids/teens, whether it had anything to do with the internet/computers or not?

    How many of you were harassed or beat up at school because you looked different? Reread the hellmouth threads. I know several goths and it has nothing to do with psychotic devil worshiping. It's about being different.

    I built my own site, using no my fat brain. Go ahead, www.nerdnetwork.net [nerdnetwork.net], look at all the meta tags, you won't find a meta name=creator m$ frontpage, or anything else.

    Don't let a stereotype get the best of you.
  • If your bottleneck is the scripting language, i suggest getting something besides a 286 for your webserver. Although that Cray that's running your RDBMS must be pretty sweet :)
  • That all depends where the degree comes from. If the school had a good CS program, you will end up with someone who should be able to pick just about anything up and learn it quickly because they have a good background in theory. If the school had a bad CS program, they learned how to program well in one language on one platform and will be unable to learn anything else since they do not understand the underlying theory.

    Perhaps I'm biased because I think my own CS degree has been extremely helpful in my career. I have worked in a research job as well as a development job and been successful in each.
  • Well Bob, it doesnt look like I'll be coding for your company any time soon, as I only have 90 something credit hours.

    However, last time I checked there were 3 IT jobs unfilled for every filled position. In some areas the ratio is 6:1.

    A smart company IMHO would try to recognize actual talent than be swayed by that degree, or certification for that matter. By your logic, a 19 year old kid who might have spent the last 7 years working on Apache would be unqualified to be a web developer!

    Luckily, there are many companies who don't use this retarded logic when hiring.

  • I'm wondering what has been done in the area of using Java serverside.

    Java is notoriously slow. It's bad enough on the client side in an applet but it seems like a tremendous waste of cycles to use it on the server side. Granted (afaik) each instantiation of a servlet doesn't bring with it another VM process but the performance hit is still there. How does Sun get away with this?

  • Here are a few ideas that I've come across in my years of coding for the web.
    1. Design your external site to be as code-light as possible. Resist the urge to make a table within a table within a table, especially if each table has complicated formatting. Resist large images that take a long time to render. You're much better off going for a simple layout that may not look as nice, but loads a lot faster, because in many cases it's the client that causes the slowdown in delivery, not the server.
    2. Use an open web server where you can build the binary yourself, and build the interpreters into httpd. On the number of servers I administer, the ones with specially-built httpd's run light years faster than the ones with generic httpd's. Put in the effort of learning how to build your httpd with support for your scripting languages built in, and things will run much faster.
    3. Experiment with your data storage. For a number of problems, I've found out that grepping and/or parsing a preformatted text file is the fastest storage route (as compared to MySQL, PostgreSQL, etc.), especially on slower machines.

    These are just a few things I have observed that may help.

  • What's more, the rendering task is distributed, while the generation is centralized at the web server (and associated applications). Thus, the effect of code inefficiency is magnified on the server side.

    Optimization of server-side web code isn't really that different from the general problems of parallel-process and database-access optimization. There's nothing magical about the fact that the front end is a web server rather than (say) a 3270 or the like. All the usual problems are there -- resource shared vs. exclusive access, race conditions, process model tuning, and so forth -- and all the usual solutions apply.

    Many companies go astray when they fail to realize that a web app is just a traditional app with a particular front end. This leads them to believe that the rules of good enterprise software development don't apply, and 99% of the time disaster ensues, either immediately, or when they attempt to scale the system up or add/change features.

  • by Matt Lee ( 2725 ) on Friday April 21, 2000 @11:34AM (#1118845) Homepage

    Philip and Alex's Guide to Web Publishing is a great book, but it's not a good reference if you're looking for nitty-gritty coding knowhow. It seeks to avoid that stuff, since you should be able to think about building web sites on a higher level, where the particular language doesn't matter.

    However, if you'd like to be a web coding ninja, do problem sets 1-5 on this site [photo.net]. If you don't have the exact environment in which to complete them (AOLserver, Oracle, CyberCash account), improvise. After completing those, you should be able to tackle anything, and you'll know how to code a great site.

  • by Communomancer ( 8024 ) on Friday April 21, 2000 @09:08AM (#1118846)
    Well, I guess they get away with it because, simply put, Java works on the server-side. Time to post the standard response to this sort of thing...if minimal waste of cycles is _all_ that mattered, we'd all be coding in assembly, or be wiring the code into hardware. We don't, so obviously Sun 'gets away with this' because they offer a fine product that panders to such banal needs as "maintainability", "time to market", and "reusability".

    And, BTW, there is a difference between Java being notorious for being slow (which it is) and Java being actually notoriously slow (which it isn't).

    Back to the topic, as far as website coding is concerned, most of the best practices having to do with any complex software system also apply to website development. If you're doing object-oriented development, I especially recommend practices such as:

    1) Learning and utilizing established Design Patterns where appropriate. Don't forget that they've become "established Design Patterns" because over time, they have demonstrated their value again and again. There are plenty of books on the topic, the most famous (and IMO useful) of which is Design Patterns: Elements of Reusable Object-Oriented Software

    2) Refactoring. Essentially, this is going through code that has already been written and aggressively removing duplication. This results in a cleaner system implementation that is far easier to identify bottlenecks in and tune. There is a good book on that by Fowler that is just called Refactoring.

    3) Where possible, avoid "new" in favor of "proven" technologies. "New" always implies risk. Credit is often overly awarded to those who "invent" or use "novel" solutions to problems when other, time tested solutions might have done the job better.

    4) Try to build a clean separation between your data, your logic, and your presentation. This will greatly help with code maintainability.

    It's important to note that not all of these solutions will have an immediate, positive impact on the performance of your website. In fact, in many cases it is just the obvious. However, if rigorously implement these solutions, you are likely to build a website that is easy to optimize, and that scales very well with more hardware.
  • by Kaufmann ( 16976 ) <rnedal&olimpo,com,br> on Friday April 21, 2000 @09:43AM (#1118847) Homepage
    Two things: first, Perl isn't really slow; when you run it, most of the time is spent running Sarathy's heavily optimised code to handle things like hash lookups and regexes, not your punny little userland code ;) It only _seems_ slow because of the overhead imposed by having to spawn a new interpreter and recompile the script into bytecode every time the script is run. But most of the problem is easily fixed by mod_perl.

    Second, yes, the perlcc utility is able to compile a Perl script... but not by translating it to native code. No, that would be just too easy... :) Instead, perlcc embeds an entire copy of the Perl interpreter, plus a shitload of unnecessary modules, along with your program in bytecode-compiled form. The result is bloated, buggy, ugly and generally not much faster than just running your script. So it's not of much use, but if you really want to do it, you get to.

    (P.S.: Cool username... I've always preferred post-Syd Floyd myself, though.)
  • by Plasmic ( 26063 ) on Friday April 21, 2000 @09:21AM (#1118848)
    "Undegreed" is the most worthless term I've ever witnessed the application of in reference to the ability of an individual to write quality code.

    I'm not going to purvey any content in this post other than the degree to which I am dumbfounded by this assertion: VERY.

    Wow, Bob. You're astonishing.
  • by Greg@RageNet ( 39860 ) on Friday April 21, 2000 @09:07AM (#1118849) Homepage
    "Why use HTML when javascript, cascading style sheets, java, cookies, imagemaps, and shockwave will do?"

    Why do web developers feel the need to use every technology available on a website when they usually didn't need anything more complicated then plain-ole HTML? I dono how many times I've seen implemented in javascript the meta refresh tag!

    Add on to the fact that most sites have become unnavigatable by text browsers and their users (such as the blind). My old boss used to have a saying: "A picture is worth a thousand words, unless it's a picture of a word".

    All this 'rich content' that is arguably unnecessary and excessive means that the web is just that much slower, needing even more bandwidth to get anything done.

    And my last gripe is about modifying HTML that was created in a HTML editor. Did any of the programmers who coded up these editors ever hear of wordwrap?? Every time I edit a file I have to re-format the whole thing to make it inteligable.

    Yes, I'm griping. You can think of me as the crotchety old man who sits on the porch "Yeah, I remember the good old days, back when people edited HTML with 'vi' and we didn't have all these fancy-pants 'wizards' to generate webpages; you could search the web then and find the information you were looking for instead of a bunch of infomercial-like websites with too much animation hawking things. Why it must have been waaaay back in 1995, yeah, Yahoo was still a stanford tilde account back then."

    -- Greg
  • by dlc ( 41988 ) <(dlc) (at) (sevenroot.org)> on Friday April 21, 2000 @10:01AM (#1118850) Homepage

    A lot of people have said that the bottlenecks tend to be generating output, making database connections, and the like, but that is often not true. Generally, the bottleneck is the network connection. The way I often think of pages is in terms of the connection speed of the server. I have done work for people with slow connections from the server to their backbone, and in cases like this, connection time becomes less important than network speed. So I send the header, send some content for the top of the page, and then make my database connections, and do my calculations.

    Even though it's often frowned upon, I like to use a lot of includes that are generated by the client whenever possible. That way, the multiple hits to the server (i.e., more network traffic) can make a slower server seem faster. When it comes down to it, when poeple say they want the web to be faster, they mean a fast experience, not a fast server.

    Just something to keep in mind.

    darren


    Cthulhu for President! [cthulhu.org]
  • by pkj ( 64294 ) on Friday April 21, 2000 @11:35AM (#1118851)
    Sheesh, in nearly 200 messages so far not a single person has mentioned the importance of profiling!

    There is a classic CS quote that says that a program spends 90% of its time in 10% of its code. Make this code run twice as fast and you will nearly double the speed of your program. Optimise everything else and you won't see any difference at all.

    The important thing is to write clean, readable, code. Do not be overly concerned about going to great lengths to improve speed during development. As soon as you have a working system, build a set of automated testing tools and generate some benchmarks. Determine where the bottlenecks are and try to fix them. If you don't know what is really slowing down the system, you will waste many hours optimising code that has no need to be optimized!

    This is a trivial operation when using a language such as C with no threads and/or accesses to remote resources. (Although despite this fact, I still see people trying to write optimized spagetti code and never touch a profiler.) Things get a little more difficult when you start talking about database-driven web pages since there are so many more pieces to analyze.

    In addition to analyzing the execution time of your script, you must also look at the execution time of database queries. Unfortunately, it is not always possible to profile individual queries, and some databases such as Oracle are highly tunable (i.e. you can tune the system to acount for perhaps poor database design.) When dealing with databases, you are often disk-bound as well, so applying the same profiling techniques to your hardware will often provide good results.

    When your database and web server are on the same machine, just using ps or top will give you a good idea of where your cpu time is going. And don't forget to make sure that you aren't swapping. If you are swapping, optimise for memory use or buy more ram. If you've maxed out the RAM on your machine, consider splitting the application onto multiple machines. Sometimes it is cheaper to solve a problem by throwing more hardware at it, but this should only be considered as a last resort.

    BTW, I'm assuming you've already done the obvious and are taking advantage of the best technologies such as mod_perl or Java servlets. Forking several copies of Perl just to generate one web page just isn't terribly smart...

    -p.

  • by jallen02 ( 124384 ) on Friday April 21, 2000 @10:14AM (#1118852) Homepage Journal
    Of course, since most of the people selling themselves as "web programmers" are undegreed kids with little formal knowledge, there's a lot of crap floating around. Until employers value experienced professionals with the proper credentials (instead of thinking that every kid with green hair and a stud through his tounge is a web expert), there's little hope for a standard of quality on the web.

    YIKES big guy back yer arse up please. You have got a chip on your shoulder about undegreed programmers.

    Ten years ago, that attitude would have worked.

    Let me tell you a little about myself.

    I am 19 years old and I DO consider myself a web developer and a pretty damn good one.

    No I do not know everything about computer science. No I dont know a WHOLE lot about math and the nitty gritty details of algorithms and all that. I DO make it something I work very hard to understand. I strive to improve my code and my level of professionalism ALWAYS. I study algorithms, and programming a LOT.

    I try and give clients or my work VERY debugged code with no errors, make it look professional and make it work in an intuitive and effecient manner for them.

    Effciency of my code is ALWAYS a concern to me and I try my best to make optimized code. I apply what I know about algorithms and data structures to make my code as maintainable as possible. I dress in casual business clothing and I in NO way claim to know it all. And if imasked if I can do something and I cannot I say NO I can't do that right now, I am capable but I would have to learn how. That is my business philosophy and its gotten me a lot of work and me and the clients have been very pleased with the results.

    In your mind I am a 'kid' but I am a professional and I attempt to also incorporate ethics into my code use and my business practices and manners.

    And something people do NOT like to admit.. Some people my age are VERY capable of fulfilling senior web development positions No I do not match some god forsaken profile for education nor experience.

    The sadder part is I have met people with CIS, and CS degrees who are just absolutely clueless. They needa be beaten to DEATH with the cluestick. It causes me great pain because I know they make a lot more than me and here I am training them. Yeah I know a degree says something about a person and that they were abble to attain it.. But open your mind a little.

    There are some of us that are professional and professionals.

    So I am 19 with two years of 'paid' experience. Does that make me less of a professional if I admit my limitations and am constantly expanding my knowledge and limitations to beyond even my expectations?

    I was stuck into a huge business APP and I worked my ass off.. but I groked it and was a productive member of the team. *shrugs* Your comment was very crude and not well thought of.

    Yes I understand your viewpoint but you can say the same about ANYONE who claims to be a programmer.

    Jeremy
  • by michajoe ( 124916 ) on Friday April 21, 2000 @08:58AM (#1118853)
    Phillip Greenspuns work is highly recommended: Go check it out! [photo.net]
  • The problem is that most dynamic web pages (Active Server Pages,php3,Cold Fusion,perl,whatever) are produced with scripting languages that pale in speed and functionality when you compare them with a compiled piece of executable code or a highly optimized SQL stored procedure.

    Also, code is just plain ugly in ASP or those other scripting languages. You don't want to cram a lot of logic in there, because it's hard to maintain

    So, the solution is to remove as much functionality as possible from your server-side scripting language. Put all of your buisness logic and CPU-intensive operations in SQL stored procedures, compiled code, or some other equivalent.

    In industry buzzword-speak that's 3-tiered architecture. (Tier1: ASP,php,etc. Tier2: SQL stored procedures,compile code Tier3: the database

    The end result is that your web site is
    a. easier to maintain and
    b. you're reaping the performance benefits as well :)

  • by XScott ( 169201 ) on Friday April 21, 2000 @02:32PM (#1118855)
    Don't optimize a single thing until you find there is a problem! Instead, write clean readable code that you can work on later if you need to.

    I've spent the last couple months fixing and replacing a bunch of web code written by a guy who thought performance was everything. You have to get it working first. His code does the wrong thing incredibly fast. Bloody Fucking Useless (TM). I'll spare you the details of his N-Tier Network with Application Servers and crap. I've rewritten half of it in plain old (slow) ASP, and I'm getting much better performance and an easier time fixing bugs.

    Once it works, evaluate whether you have a performance problem. If you don't, then leave the damned thing alone.

    If you do, start profiling. It's not wasting time where you think it is, guaranteed. Ask the super dawgs of optimization (the John Carmacks, Michael Ahbrashs etc...) how many times they just "knew" where the problem was only to be totally surprized once they broke out and profiled it.

    Anyone complaining about how Perl, Python, ASP, PHP or whatever is so much slower than C/C++ is really missing the boat. Web pages spit text out the front door, and talk to files or database through the back door. There is seldom an algorithm to be seen, and most the of processor time is spent doing something other than interpreting your script.

    It's a lot easier to optimize a query, add an index, put more memory in the server, disable the screen saver, whatever than it is to rewrite everything in C++ using ODBC.

    Once you do rewrite it in C++, you're back to where you started. It's still too slow, and now you need to restructure the query, add memory, turn off the screen saver or whatever...

    One other thing, don't believe the hype. Everything latest and greatest is not necessarily fastest and best. Microsoft get's paid when you replace your old perfectly good stuff with whatever they've just released. No one is ever going to convince me that ADO is faster than ODBC when ADO uses ODBC to do its work. What the hell is MTS good for? It's a solution to a problem I haven't seen.

  • by jaga~ ( 175770 ) on Friday April 21, 2000 @08:59AM (#1118856)
    bob you sound bitter. some kid steal your job?

    last time i was in college, i missed the html degree signup sheet....damn.
  • by Matt Welsh ( 11289 ) on Friday April 21, 2000 @08:58AM (#1118857) Homepage
    One of the reasons why information on this subject is not widespread is that the answer is really very complex. Most Web sites simply code their stuff and hope that it can deal with the traffic they get to their site --- in most cases this is not going to be a problem. But take a site like Slashdot, for example. Undoubtedly there are things about the way it is built (using Perl, some files or databases for state storage, etc.) which make it less efficient than it couuld be. What can you do?

    In most cases the easiest thing to do is simply buy more hardware and replicate. This is easy to do if you're serving up static (or even dymamic) web pages that don't need to share any state across multiple web servers. This is feasible because in many situations the bottleneck of the site is the web server and dynamic page generation itself, not access to the back-end database. For really large sites, a replicated/clustered database is going to be needed, not just a single machine running MySQL.

    The Application Server industry has started to provide some solutions for building scalable web sites -- for example, IBM WebSphere, BEA WebLogic, and other systems provide a platform for building web-based applications, which generally consist as a middleware layer between an HTML/presentation 'front end' (i.e., a web server) and a database 'back end'. These middleware systems support replication and clustering to increase efficiency. Replicating the front-end web servers is easy, and many products support this. You can even buy fancy network switches which load-balance HTTP requests across multiple web servers. Replicating the back-end database is much harder, but that's how companies like Oracle earn their money.

    Not surprisingly nearly all heavily-loaded Web sites have to do a huge amount of work to get all of this working right. One thing you might ask is whether the process of building a scalable Web site could be made simpler. That's the goal of the research project I work on at UC Berkeley, called Ninja [berkeley.edu].

    Matt Welsh, mdw@cs.berkeley.edu

  • There are books written on how to optimize code in general:

    -Code Complete by Steve McConnell, Microsoft Press

    -Writing Efficient Programs by Jon Bentley, Prentice Hall

    -Flooring It: The Optimization Challenge by Michael Abrash, from PC Techniques 2, no. 6 (February/March 1992)

    But code tuning can have varying results under different languages and environments. A lot of people seem to think that code optimization is unstable and difficult to maintain.

    There is sometimes a difference between "efficient code" and "good code". Code may be efficient, yet hard to read and maintain.

    To know what techniques are the best, a lot of experimentation is in order. It is also a good idea to become part of a community of experienced web developers, and learn from their experiences.

    The greatest boost in performance I have seen in my web experience has come from using the mod_perl module for Apache, not necessarily because of anything I did in the code itself.
  • by Hard_Code ( 49548 ) on Friday April 21, 2000 @08:50AM (#1118859)
    In dynamic sites the bottleneck is generating the content (running servlets, accessing databases, etc.), so it makes sense to optimize there. Unless your pages is /really/ complex, or the browser /really/ stupid, rendering time is negigable. And in any case, you can't do much about it even if you /do/ have the best code. Pure HTML just isn't that much of an issue. Moving into XML and XSL, and DOM manipulations, though, client-side performance may become more of an issue.
  • by vanguard ( 102038 ) on Friday April 21, 2000 @08:52AM (#1118860)
    I've always like Phillip's Greenspun's ideas on web development. In a nutshell, he preaches reliable and efficient code/tools. He can be a bit biased but mostly his ideas are good (according to me).

    His book is available online for free. [photo.net]
  • That's so true.

    My old company assumed that just because someone was a "web designer" and maybe knew a little javascript, they were qualified to do programming on complex web sites (e-commerce, etc.) They're not anymore qualified to do database work than any old artistically inept programmer is qualified to design a new logo for a company.

    Companies need to wake up and realize that it takes two types of people to build the web: "real" programmers, and graphic designers. Of course some sites only need one or the other, and some people are talented enough to fall into both categories... but don't assume that Joe the Graphic Designer can code a linked list or a SQL statement...

  • by imagineer_bob ( 163708 ) on Friday April 21, 2000 @08:47AM (#1118862) Homepage
    It really depends on what you mean.

    As far as HTML on a page, I found that you should optimize for Rendering Time, which isn't always the smallest page, esp. when it comes to tables.

    For server side programming, unless every page is generated dynamically, you should program it the easiest way possible and throw some CacheFlows in front of it.

    Of course, since most of the people selling themselves as "web programmers" are undegreed kids with little formal knowledge, there's a lot of crap floating around. Until employers value experienced professionals with the proper credentials (instead of thinking that every kid with green hair and a stud through his tounge is a web expert), there's little hope for a standard of quality on the web.

    --- Speaking only for myself,

  • by ChrisRijk ( 1818 ) on Friday April 21, 2000 @09:15AM (#1118863)
    I've been doing web/CGI programming for 5 years, and haven't really seen any books on good programming practices for web programming, but I haven't really looked. To some extent, these would be similar to good practices in general.

    However, some specific things I can think of are:

    Seperate out HTML/text and code as much as possible. Ideally, there should be no, or almost no, HTML in the code. This makes life easier for the HTML designers, and also means you get bugged less to alter the code to alter the output.

    Make it as simple/easy/reliable/quick/painless as possible to stop/start any server processes. I've worked on a project where we had a perl process, but stopping/restarting had some unpleasant side-effects, meaning we had to restrict doing such an operation to the quietest hours.

    Make sure you have a good and accurate test environment. Having some tools to help you debug the running site itself is very usefull - retesting doing a whole load of operations by hand is very labourious.

    Test and code for both availability and scaleability. You want good resiliant code with minimum service downtime (which means using reliable OSs and development enviroments - don't just choose the latest).

    Make sure you can say "no" to the management. You *will* get PHBs trying to force new features on you when the current ones aren't even working right yet. Make sure your code is flexible though as it'll be changing/evolving a lot anyway. Also make sure you don't get stuck doing fire-fighting - ie stamping out so many little bugs that you can't fix the fundamental problems. (this is the kinda problem M$ has with it's code development...)

    Personally, I wouldn't say that C, C++, Perl and PHP promote good programming practices. Java's certainly much better here. I'm not sure about other development environments. (don't worry about server side Java's speed as on a good server, it'll be close to C/C++. I'm not kidding.)

  • by Ed Avis ( 5917 ) <ed@membled.com> on Friday April 21, 2000 @08:52AM (#1118864) Homepage
    Most scripting languages like Perl or Python need to be compiled into bytecode, and then executed. The overhead of compiling the program every time it is executed can be quite a burden, especially for applications like CGI programs where the program is started very frequently but runs only for a short time.

    Even if you can cache the compiled bytecode (as Python does), there is still the overhead of starting /usr/bin/perl for each hit. Again, this becomes significant once you start getting lots of hits.

    The best thing you can do is use something like Apache's mod_perl which avoids the overhead of starting a new perl process for each page, and also the overhead of compiling the program each time. Similar features exist for all popular scripting languages and Web servers.

    Once you've done that, you may find that there are other startup costs you can factor out. For example, does each hit make a new connection to the database? Depending on your application you may be able to get away with some sort of local cache, either on disk or cached in memory in some way.

    Finally, you can make your site faster to _use_ and save the user's time if you make your pages appear gradually. If you're churning out a long, complex page, try to make it appear as it is computed, so the user can start reading immediately. This is partly a matter of choosing layout that web browsers can render incrementally, and partly of how you write your program. (Slashdot's comment display, at least in Minimalist Mode, is very bad at this. In Netscape 4.x you have to wait for the whole 100Kbyte or so before seeing any of it.)
  • by Raul Acevedo ( 15878 ) <raul&cantara,com> on Friday April 21, 2000 @09:03AM (#1118865) Homepage
    A lot of Internet companies don't focus on making their code as super efficient as possible because it is far more important for their code to be completed as quickly as possible. To deal with performance, it is easier to throw hardware at it.

    Yes, it is more expensive. But, many companies are racing to be the first for survival, and they have been blessed with enough VC money, so that it is irrelevant that it takes hundreds of thousands of dollars to pick up the performance. Time to market is much more important, and having programmers spend time performance tuning takes away from that.

    One clear example here is Java vs. C++. Sure, Java is much slower than C++; but developing something in Java takes orders of magnitude less time than in C++. So, it is better to throw money at hardware to cure the performance problem, but will get you to market sooner, than code in C++, which results in faster code, but takes much longer.

    Of course it's not quite this simple. You can't just throw hardware and money at every problem. Obviously your application can't be so slow that no one will use it. And key performance problems are first at the high architecture level, which are mostly language and platform independent. You will always have to spend time performance tuning at some point. But initially---even long term---time to market is more important.
    ----------

  • by Roundeye ( 16278 ) on Friday April 21, 2000 @10:29AM (#1118866) Homepage
    And hence the immediate stream of replies from the green-haired /. crowd ensues to let us all know that any attempt at certification, any actual experience, or the actual effort at making one's self appear professional are not only unimportant but most likely a strike against the potential employee.

    I went through so many hairstyles, fashions, music trends, the occasional piercing and tattoo that my family started referring to me as Rodman a number of years ago. However, I've been writing code for 16 years now. And I'm good. I'm good enough that now I also get to see the streams of applicants coming in and get to decide whom to hire and how to put together the teams.

    Get this straight:
    If I get a group of "green-hair"s in, I'll hire the ones that can code, work together, and who won't steal from the company.
    If I get the GH's and some poindexter's, I'll hir the ones that can code, work together, and who won't steal from the company.
    If I get a group of poindexter's, I'll hire the ones that can code, work together, and who won't steal from the company.

    Part of the problem in hiring is knowing whether or not the prospective (green haired or not) can code, work with others, and won't steal from the company. Your credentials, I'm afraid to say, are what get you in the door. [ If you know someone who can recommend you, that can get you in the door as well, but I really consider that a social credential more than a side-stepping of the system. ] If you've never done anything productive, you could very well be the best programmer in the world, but you've never worked on anything. This means (to me) that you probably don't know how to work with people, or how to pursue joint code development, or what deadlines are, or why tasks are prioritized, etc.

    A degree, certification, or award, is an indication that you have completed some structured program designed to increase or test your assimilation of a body of knowledge. Are there people with the proper certifications who aren't qualified to work in this industry? Certainly. Are there people with the proper certifications who are able to work? Certainly. Are there people without those certifications who can do the work? Certainly.

    So, certifications are worthless then. Bullshit. Like I said before, they are an indication of completion of a structured program. Given two applicants for one position whom I judge to be of equal capability, willing to work for the same pay, I'm generally going to hire the one with more certification -- primarily because I know that person is more likely to be able to work under deadlines and prioritized sets of goals.

    Similarly, given a set of qualified applicants (can do the work, can work together, won't rob us blind, have the same relative qualifications) and too few positions, I will often favor the applicants who put the most effort into applying: well written resume/cover letter, well-dressed, punctual, polite, aggressive (no there's no contradiction there), excited, motivated, etc. These people are more likely to work hard, stay with the company, act on their own initiative, and so on.

    The perceived tightness of the job market (and, actually, it's not quite as tight as has been made out) has brought to the average technophile an attitude that not only are they in high demand, but also that their intrinsic coolness, which derives from often dubious technical ability, is a substitute for proof of ability. Only one component of employability is technical competence, the other more important ones include social maturity, dependability, commitment, responsibility, ambition, and respect. Some will certainly whine that technical ability is the most important, but in this day (contrary to what many of you seem to believe) that's simple to find. If that's all you have, you lose out, because the next person in the door has the others too.

  • by account_deleted ( 4530225 ) on Friday April 21, 2000 @08:44AM (#1118867)
    Comment removed based on user account deletion
  • by dlc ( 41988 ) <(dlc) (at) (sevenroot.org)> on Friday April 21, 2000 @10:14AM (#1118868) Homepage

    Some techniques that are essential to web development are:

    • Write clean code. Straigtforward code that doesn't pull in a lot of extre libraries and functions will run better than spaghetti code.
    • Use persistent database connections whenever you can, or use a small fast rdbms like MySQL [mysql.org].
    • Caching, caching, caching!
    • Turn buffering off whenever possible (e.g., $|++ in perl).
    • Use compiled modules/languages whenever possible. Languages and environments like Perl (CGI, not mod_perl), PHP, ASP, and the like are *slow* in comparison to compiled C modules and things like mod_perl [apache.org], mod_pyapache [apache.org], and mod_dtcl [apache.org]. As much as people like embedded scripting languages, the fact is the page has to be parsed every time it is run (PHP folks, I mean you!) This makes for fast development (which is definitely important), but not so great for running.
    • No JavaScript, no DHTML, no animated GIFs. Yeah, this goes against what a lot of people have been taught about the web, but they slow it the fuck down. A browser having to parse 300 lines of JavaScript (half of which is "if(userAgent == "Mozilla")" crap anyway) is going to be very slow, even on a BFM.
    • And, dammit, write good HTML. In fact, don't write HTML, write XHTML. Nothing ruins the effect of a well-thought-out dynamic page than HTML that the browser has to re-render 6 times to lay out correctly. You may think this is not a big deal, but it is, it really is. Take the time to learn XHTML, and your pages will be better for it.

    Often, the speed of the web is, in reality, how fast the pages appear to be. This is the most important thing to remember when designing pages that are supposed to be fast.

    darren


    Cthulhu for President! [cthulhu.org]
  • I don't know of any books, but here's what I do...

    I work for a fairly large software company and we use a Linux/Apache/MySql system to dynamically track and record our production. This database/machine is getting hammered on the backend (data importing) and on the front end (our web/perl interface).

    How do we tweak this datatabase to run 5 different programms and still output 1.5 million transactions a day on a 200Mhz machine with 32Mb of ram?

    Efficient code!

    Nothing different than you would do with your C code, just use smart programming. With perl, use the 'strict' module. Always destroy database handles as soon as you can, don't try to do complex sorts in your code, that's something the database is capable of.

    Static if you can...If there is a page on your site that doesn't change very often (ie. it chagnes less than half the amount of times that it is accessed per day) generate it with a server daemon, and then let users access it has a regular html file. This saves CPU time and decreases latency of accesses.

    A lot of the web programming starts with good database design. There are countless books about this. If your databse is optimized so that there are no full table scans and relationships are tightly bound, then writing efficient code is fairly simple.

    Overall, just keep it simple and efficient.

  • by sphix42 ( 144155 ) on Friday April 21, 2000 @08:45AM (#1118870) Homepage
    I am a professional PHP developer and I personally put quite a bit of thought into the code as I write it. I think a very good set of articles which help with the problem you mentioned, at least from one angle, are the Cached Dynamic Module [phpbuilder.com] articles at php builder.
  • by G Neric ( 176742 ) on Friday April 21, 2000 @08:53AM (#1118871)
    write in C or C++, and compile server loadable modules and you will be measurably 10x faster. Don't take my word for it, do the testing yourself. Modperl? 5x slower, without even trying hard.

    Don't moderate this as a Troll or a Flame, I write in Perl most of the time myself. But I've recoded some stuff and tested it, and blew the doors off.

Genetics explains why you look like your father, and if you don't, why you should.

Working...