Author Topic: Smarty.  (Read 1841 times)

Offline Crazy-T

  • Level 19
  • *
  • Posts: 197
  • Reputation: +0/-0
  • Building Games
    • View Profile
Smarty.
« on: June 07, 2009, 07:38:46 PM »
What do you like about smarty, and how good do you think it is.

I like it because easy to use, does stuff i want it too.
Overall, 9/10. :)
What about you people?
Crazy-T

Offline Harkins

  • Level 28
  • **
  • Posts: 424
  • Reputation: +11/-2
  • Coder, blogger, entrepreneur.
    • View Profile
    • Push CX - Blog
Re: Smarty.
« Reply #1 on: June 07, 2009, 08:07:56 PM »
It's a template language in a template language.

Visit #bbg on irc.freenode.net to talk browser games anytime.

Offline karnedge

  • Level 17
  • *
  • Posts: 170
  • Reputation: +4/-0
  • ctrlHack provides the server, you bring the skill.
    • View Profile
    • ctrl://Hack.game
Re: Smarty.
« Reply #2 on: June 07, 2009, 10:35:27 PM »
It's a template language in a template language.

I feel I'm being as spammy as Color-T even posting this but man did that crack me up.
ctrlHack - Hacking simulation RPG in development.
Latest blog: Back on Track
bbgFramework v0.1.3

Offline JGadrow

  • Level 35
  • **
  • Posts: 1,133
  • Reputation: +23/-2
    • View Profile
Re: Smarty.
« Reply #3 on: June 07, 2009, 10:50:38 PM »
lol I'm glad someone else shares my point of view. I thought I was the only one who thought it redundant! Really, the HEREDOC syntax is all you need. As of 5.3, NOWDOC syntax is added for 'static' (X)HTML segments as well so it will be faster to execute (because it's not parsed for variables).

Hmmm... I'll have to do some performance testing to see what is faster:

HEREDOC with variable expansion or NOWDOC with variables concatenated...
Idiocy - Never underestimate the power of stupid people in large groups.


Offline Harkins

  • Level 28
  • **
  • Posts: 424
  • Reputation: +11/-2
  • Coder, blogger, entrepreneur.
    • View Profile
    • Push CX - Blog
Re: Smarty.
« Reply #4 on: June 08, 2009, 07:17:59 AM »
Makari: Try running YSlow on your game. I'd bet that the amount of time you could save on a given page from changing from HEREDOC to NOWDOC is less than 1% of the total time from request to first browser render, and you could get a 10x larger speedup by doing one of the things it suggests.

I just have a hard time imagining profiling a web application and string interpolation as where your code is spending all its time.

Visit #bbg on irc.freenode.net to talk browser games anytime.

Offline JGadrow

  • Level 35
  • **
  • Posts: 1,133
  • Reputation: +23/-2
    • View Profile
Re: Smarty.
« Reply #5 on: June 08, 2009, 10:46:26 AM »
I have YSlow already and make frequent usage of it :) For anyone who is NOT familiar with it, I definitely suggest you view this presentation as it will help you eliminate MOST of your load times!

And, it's not really about using it but about determining which DOES have the faster behavior. I learn things sometimes just for the sake of knowing. I'm just a curious person like that. You never know when you'll need to know some esoteric bit of knowledge that's overlooked by most.

As my father is always fond of saying, "I can teach anyone anything except a basic sense of curiosity." If you don't find yourself always going, "Hmmm... I wonder why..." Then you're probably not a learning-oriented person. lol

And, yes, I WAS that kid who pestered his parents with questions until they said, 'I don't know.' I'm reaping the fruit of that now with MY kids. lol
Idiocy - Never underestimate the power of stupid people in large groups.


Offline codestryke

  • Administrator
  • Level 33
  • *****
  • Posts: 589
  • Reputation: +22/-0
    • View Profile
    • eXtremeCast Games
Re: Smarty.
« Reply #6 on: June 08, 2009, 01:21:55 PM »
It's a template language in a template language.

As is a "C compiler is written in C". By you analogy then a C compiler should be written in Assembler? Then an assembler compiler should be written in?

Calling Smarty a template language is really not fair, even though they do it on there tag line, but it is much more then that. Most think of a template as pulling in a text file and doing string replacements between special tags in the template file and the variables in memory. Download Smarty, create some templates and look at the template_c folder and see what it's actually doing. You'll quickly learn this isn't just a template system, it's output is PHP code.

When Ramus Lerdorf created PHP it was for templating but it has grown, like the simple web sites he was creating, into something much more. The complexity of web pages now compared to ~10 years ago are leaps and bounds over what he was trying to accomplish. Now from this article if you ask him how sites should be created it is a much different story. Now it's template, template helpers, business logic and finally the C core. Using Smarty is basically doing what he advocates, just alleviating the developer from creating that template helper layer.

PHP is a nice language but it gives the developer the ability to create sloppy unorganized code. You know what code I'm talking about.... lines and lines of PHP logic embedded with HTML output where there is no way to see just the logic or just the output. Go to hotscripts.com and download some PHP scripts to quickly see how few developers understand how to write clean, layered code.

I advocate Smarty because:
a) it's not just a template engine
b) it forces developers to render the logic first and shove that off to the next layer (display).



Creating online addictions, one game at a time:

Offline Harkins

  • Level 28
  • **
  • Posts: 424
  • Reputation: +11/-2
  • Coder, blogger, entrepreneur.
    • View Profile
    • Push CX - Blog
Re: Smarty.
« Reply #7 on: June 08, 2009, 01:34:27 PM »
I wasn't saying that Smarty is bad or shouldn't exist, only that it's a bit redundant in a lighthearted way.

I followed PHP from mid-2001 to until 2007 so I've seen it grow up a lot. I liked Smarty a bit for graphic designers and others who needed to have slightly fewer ways to break things, but otherwise I preferred to just use PHP directly. If your team has the discipline and experience to not start writing SQL queries from view code in the first place, Smarty may be overkill.

Visit #bbg on irc.freenode.net to talk browser games anytime.

Offline Mufasa

  • Game Owner
  • Level 18
  • *
  • Posts: 189
  • Reputation: +3/-0
  • Maniac Developer
    • View Profile
Re: Smarty.
« Reply #8 on: June 08, 2009, 03:14:43 PM »
I wasn't saying that Smarty is bad or shouldn't exist, only that it's a bit redundant in a lighthearted way.

I followed PHP from mid-2001 to until 2007 so I've seen it grow up a lot. I liked Smarty a bit for graphic designers and others who needed to have slightly fewer ways to break things, but otherwise I preferred to just use PHP directly. If your team has the discipline and experience to not start writing SQL queries from view code in the first place, Smarty may be overkill.

Exactly. I prefer my own methods. That's one reason I haven't stuck with RoR. It's faster for basic things, but I'm one who prefers not to just put data in a magic black box and have it spit back everything.

Offline Delifisek

  • Level 12
  • *
  • Posts: 79
  • Reputation: +1/-1
    • View Profile
Re: Smarty.
« Reply #9 on: June 08, 2009, 03:33:29 PM »
And you still use template language in template language.

of course smarty has caching methods.

It just useful only one condition. If you have to use non php template (becasue of some lackluster dreamweaver designer).

Other than this, it just un nececary.

ob_start();
require('template.php');
echo ob_get_clean(); // or store

was best template engine I ever see.

Plus when you do inline templating with opcode cache (APC vs). your templates stroring in memory.

Offline JGadrow

  • Level 35
  • **
  • Posts: 1,133
  • Reputation: +23/-2
    • View Profile
Re: Smarty.
« Reply #10 on: June 08, 2009, 03:59:49 PM »
See... this post was better, Delifisek. It at least offered another method and gave some reasoning behind it. Now if we could just work on your diplomatic approach... :P

Really, though, I think Smarty and similar libraries, languages, etc. have their place in the right niche. For example, if all of your design is being handled by non-developers. Basically, they know XHTML and CSS but they don't care what goes on behind the scenes that's your case for using these sort of systems. However, I'd probably still try and find a way to do it programmatically because I'd wanted it formatted to MY specifications instead of the designer's. I hate when I see XHTML and it's formatted with multiple tags on a line or something like that lol. Makes it harder to see what tag closes where. It'd be the same if someone handed me a piece of code and had written three functions on the same line. Where does one function end and the next begin! It would be hard to tell at a glance.

As with everything else in programming it has its place. But, I've yet to belong to an atmosphere where I've needed something like this. Unfortunately I usually have to do the design AND the development. lol
Idiocy - Never underestimate the power of stupid people in large groups.


Offline travo

  • Level 18
  • *
  • Posts: 186
  • Reputation: +2/-0
    • View Profile
Re: Smarty.
« Reply #11 on: June 09, 2009, 01:29:14 AM »
Ive just used smarty because it was already made, I could work on the bits of projects I wanted to work on...
But Ive had a thought, I dont use some of its features, so a system without these features would be quicker... So Im gonna create my own smarty for my own purposes  :D

Offline Crazy-T

  • Level 19
  • *
  • Posts: 197
  • Reputation: +0/-0
  • Building Games
    • View Profile
Re: Smarty.
« Reply #12 on: June 09, 2009, 01:42:47 AM »
Ive just used smarty because it was already made, I could work on the bits of projects I wanted to work on...
But Ive had a thought, I dont use some of its features, so a system without these features would be quicker... So Im gonna create my own smarty for my own purposes  :D
Quote
So Im gonna create my own smarty for my own purposes  :D
Very good idea :P lol.
Crazy-T

Offline Chris

  • Game Owner
  • Level 35
  • *
  • Posts: 2,217
  • Reputation: +28/-1
    • View Profile
Re: Smarty.
« Reply #13 on: June 09, 2009, 01:28:37 PM »
As is a "C compiler is written in C". By you analogy then a C compiler should be written in Assembler? Then an assembler compiler should be written in?
Assembler is written in machine code :) And the machine code is entered via inbuild "monitor" software (resident in ROM). Of course modern computers do not have monitor anymore, the assembler is written usually on PC via emulation software.

In 80's there were plenty of computer magazines with listings including machine code, you were entering it to your computer (usually via BASIC since most cheap computers then didn't have proper monitor) and... you could play your brand new game :D

Offline codestryke

  • Administrator
  • Level 33
  • *****
  • Posts: 589
  • Reputation: +22/-0
    • View Profile
    • eXtremeCast Games
Re: Smarty.
« Reply #14 on: June 09, 2009, 02:16:31 PM »
Assembler is written in machine code :)

I think you should do a couple of Google searches, the compiler itself is not written in machine code. I actually just looked at one popular open source x86 ASM compiler and it is was written in C.

Though I do remember back in the day typing lines of numbers from Byte magazine into my C64 :)


Creating online addictions, one game at a time:

Offline Mufasa

  • Game Owner
  • Level 18
  • *
  • Posts: 189
  • Reputation: +3/-0
  • Maniac Developer
    • View Profile
Re: Smarty.
« Reply #15 on: June 09, 2009, 02:17:20 PM »
You guys make me feel so young  ;D

Offline Chris

  • Game Owner
  • Level 35
  • *
  • Posts: 2,217
  • Reputation: +28/-1
    • View Profile
Re: Smarty.
« Reply #16 on: June 09, 2009, 02:29:44 PM »
Assembler is written in machine code :)

I think you should do a couple of Google searches, the compiler itself is not written in machine code. I actually just looked at one popular open source x86 ASM compiler and it is was written in C.

Though I do remember back in the day typing lines of numbers from Byte magazine into my C64 :)
I'm not talking about modern assemblers, since you can write them in anything you want, if you are desperate you might even try PHP :D I was reffering to the first Assambler written on a certain machine (of course there always could be a madman who first write C in machine code and then Assembler in C :D)

In my country there was one guy who wrote a whole BASIC (advanced version, a very good one) in machine code. Imagine this, pages of numbers after numbers. He said he was able to see asm commands by looking on mere numbers by the end of the project (which I find quite belivable :)). Yeah, these were fun times :D


Offline tokyoinflames1

  • Level 4
  • *
  • Posts: 11
  • Reputation: +0/-0
    • View Profile
Re: Smarty.
« Reply #17 on: April 21, 2010, 08:18:06 PM »
I could never figure out how to use Smarty.  It's frustrating

Offline Andy

  • Level 7
  • *
  • Posts: 31
  • Reputation: +0/-1
    • View Profile
Re: Smarty.
« Reply #18 on: June 08, 2010, 09:54:44 AM »
I use smarty and don't have many complaints!

 


SimplePortal 2.3.3 © 2008-2010, SimplePortal