Jump to content

Template Engines?


sequalit

Recommended Posts

I don't have enough of an attention span to read that entire rant, but in general yes I agree. Templating systems can create some overhead. I think the big sell for something like smarty is that it forces it's rules on you (whereas the generic version doesn't), for most things this is good, but for large software applications, not so much. Also, by using a third party templating system like that you can easily develop your system in a way that others can easily replace the theme of the said system. Without something like smarty, it requires someone to first learn the way the said system does it in order to change the presentation. So yeah, smarty provides some interoperability that would not otherwise exist.

 

All that being said, for my little generic MVC framework thingy I built. I built a templating system in place of the view, that works in the same manner that the article displays. It also handles my server side caching.

Link to comment
Share on other sites

I don't mind template engines as long as they use PHP. I find it a bit stupid "inventing" a new language for the sole purpose of that template engine.

 

Even if your code is something like this:

function getTemplate($name)
{
    include 'templates/' . $name . '.php';
}

then it's still a template engine because of what the code do.

Link to comment
Share on other sites

Uhm... there is no difference except for the language used.

 

<ul>
<?php foreach ($users as $user): ?>
<li><a href="/profile/<?php echo $user->username ?>"><?php echo $user->username ?></a></li>
<?php endforeach ?>
</ul>

<ul>
{foreach from=$users item=user}
<li><a href="/profile/{user->username}">{user->username}</a></li>
{/foreach}
</ul>

 

Both of them could be template files thus the code which deals with the template files is a template engine.

Link to comment
Share on other sites

I agree with the author's point. Since I made my first experiences with Smarty, i wondered how people could use it - it's only an overlay for php-amateurs, who aren't aware of the functionalities of PHP.

Link to comment
Share on other sites

Most of the PHP programmers don't know what an O(n^2) algorithm is, or who Donald Knuth is, or why a sorting algorithm can never be faster than O(n log n), or how Dijkstra's shortest path algorithm works.

 

Well I for one don't know any of that. Would anyone like to recommend a book/tutorial?

Link to comment
Share on other sites

Most of the PHP programmers don't know what an O(n^2) algorithm is, or who Donald Knuth is, or why a sorting algorithm can never be faster than O(n log n), or how Dijkstra's shortest path algorithm works.

 

Well I for one don't know any of that. Would anyone like to recommend a book/tutorial?

 

The thing about the O is called Big O notation and is a way of measuring efficiency. E.g. if an algorithm is running at O(n^2) it means that the system resources used or the running time will increase quadratically as you add more data to be processed by the algorithm. Any book about algorithms would probably cover that. I believe "Introduction to Algorithms" is a pretty common one. Otherwise just google it.

 

Donald Knuth is a famous computer scientist. Again, just google him.

Link to comment
Share on other sites

It's mostly rubbish anyways. You can be a good programmer without knowing any of that.

 

Big O notation is just a way to mathematically represent runtimes. In Computer Science, we are usually interested in the worst case. O(n^2) would be like a loop nested inside of a loop... so a single loop would be O(n) or a loop inside a loop thats inside a loop would be O(n^3) etc.

 

No idea who Donald Knuth is... nor do I care.

 

Sorting algorithms can't be faster than O(n log n) because Big O notation considers the worst case... and if you are doing an insert into a sorted list... you can check various points in the array to determine if you need to go up or down... which makes it better than O(n) (completely unsorted)... but... yeah it assumes its inserting into an already sorted list.

 

Dijkstra's shortest path uses a grid/map datatype. Unless you are using those datastructures... which is not applicable for most applications, you don't need to know it.

 

Furthermore, who cares how proven algorithms work. If you need to use them, they're published all over the place why care?

 

Long story short, if you know the stuff great... but you don't need to know it to do just fine.

Link to comment
Share on other sites

At first I didn't think PHP could do half the stuff it can, such as write and read files and such.

 

The more I learn about PHP the more I see its just like any other OO-Programming language out there, and can do all the same stuff, only difference is you have to run a apache server and a web browser haha :P

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.