105 lines
5.0 KiB
XML
Executable File
105 lines
5.0 KiB
XML
Executable File
<chapter id="ljp.styles.compare">
|
|
<title>Comparing Style Systems</title>
|
|
<para>When we designed S2, there were specific features that we had in mind
|
|
that would fix certain design flaws inherit with S1. The table belows
|
|
explains some of the reasoning behind these changes.</para>
|
|
<informaltable frame='none'>
|
|
<tgroup cols="3">
|
|
<thead>
|
|
<row >
|
|
<entry>Feature</entry>
|
|
<entry>S1</entry>
|
|
<entry>S2</entry>
|
|
</row>
|
|
</thead>
|
|
<tbody>
|
|
<row valign="top">
|
|
<entry>Flexible & Extensible</entry>
|
|
<entry><simpara>S1 forces users to define a template for each new type
|
|
of view: recent entries, friends page, day view, calendar, etc. If
|
|
we want to add a new view type, users have to basically write their
|
|
style again.
|
|
</simpara></entry>
|
|
<entry><simpara>In S2 you describe the formatting of objects, not the
|
|
formatting of views. Thus, we can easily add new views in the future,
|
|
and making a <quote>recent</quote> view pretty much makes all your
|
|
other views automatically.
|
|
</simpara></entry>
|
|
</row>
|
|
<row valign="top">
|
|
<entry>Safety</entry>
|
|
<entry><simpara>S1 is completely safe. It's so brain-dead that it
|
|
can't be anything but but safe. You have to have some intelligence
|
|
to be harmful.
|
|
</simpara></entry>
|
|
<entry><simpara>The new style system is its own language that gets
|
|
compiled into another language, and run on the webserver. Letting
|
|
users run code on the server is inherently dangerous... it obviously
|
|
has to be free of things like
|
|
<command>rm</command> <option>-rf /</option>, but also, it has to be
|
|
free from infinite loops, and anything that could consume large
|
|
amounts of resources.</simpara>
|
|
<simpara>The S2 language does not have while loops, gotos, or any
|
|
other control construct that would permit an infinite loops. It only
|
|
has if/else blocks and foreach over finite lists.</simpara>
|
|
<simpara>There is also a limit on execution time of a resulting style,
|
|
to avoid situations we can't easily trap such as functions calling
|
|
each other in cycle, or badly-written recursion.</simpara>
|
|
</entry>
|
|
</row>
|
|
<row valign="top">
|
|
<entry>Speed</entry>
|
|
<entry><simpara>S1 is a CPU hog, doing tons of parsing, text munging
|
|
and substitutions and run-time.
|
|
</simpara></entry>
|
|
<entry><simpara>In the new system, S2 code will be parsed, checked, and
|
|
compiled before the page is loaded. When a page is loaded in the
|
|
future, the code will just be run, which will already be in the
|
|
language that the LiveJournal server runs on. At the moment
|
|
this is Perl but in the future we could write a PHP or Java servlet
|
|
backend to the S2 compiler.
|
|
</simpara></entry>
|
|
</row>
|
|
<row valign="top">
|
|
<entry>Internationalizablilty</entry>
|
|
<entry><simpara>S1 can support non-English languages and locales, but
|
|
hardly:</simpara>
|
|
<itemizedlist>
|
|
<listitem><simpara>The server injects a lot of English into S1
|
|
variables, especially in dates.</simpara></listitem>
|
|
<listitem><simpara>The calendar always begins weeks on
|
|
Sunday.</simpara></listitem>
|
|
<listitem><simpara>The system to make nouns plural (2 Comments, 3
|
|
Replies) is very English-specific.</simpara></listitem>
|
|
<listitem><simpara>Porting a style to a new language involves
|
|
forking the style and modifying away, losing all future changes
|
|
to the original style. S1 forces users to define a template for
|
|
each new type.</simpara></listitem>
|
|
</itemizedlist>
|
|
</entry>
|
|
<entry><simpara>The new style system has been designed for
|
|
internationalization. One of the S2 layers is an
|
|
<quote>i18n layer</quote>, which overrides English method definitions
|
|
from the core and sets properties, like the day weeks start on.
|
|
</simpara></entry>
|
|
</row>
|
|
<row valign="top">
|
|
<entry>Ease of Use</entry>
|
|
<entry><simpara>S1 was never designed to be easy. It was designed for a
|
|
few administrators to make styles, which would then be made public.
|
|
</simpara></entry>
|
|
<entry><simpara>Wizards and tools generate S2 behind the scenes for
|
|
most users. The hard-core users can write their own layouts and overlay
|
|
other layers in the raw S2 language.
|
|
</simpara></entry>
|
|
</row>
|
|
</tbody>
|
|
</tgroup>
|
|
</informaltable>
|
|
</chapter>
|
|
<!--
|
|
Local Variables:
|
|
mode:sgml
|
|
sgml-parent-document: ("index.xml" "part" "chapter")
|
|
End:
|
|
--> |