Beetl 3.0.0.REALEASE release, Java template engine

Beetl (pronounced with the Beetle) is a high performance, full-featured, easy to use Java template (text processing) engine, widely used in the dynamic pages and static content generation, code generation, rules engines and other fields, since 2011, has been maintained and improved, are made in China have been rare in maintaining and preserving the world's leading personal open source software.

Like significant improvements under 3.0

  • Support for both placeholders and delimiters, making Beetl scripting languages ​​more easily into the template
  • Type inference removed the function template, templates simplify the core code
  • More easily customize the syntax node custom implementation, scribble while (true) infinite loop applications such as online CMS prevent
  • Removed the handwritten reflection bytecode enhancement, switch to ASM, since it is now maven's, no longer just the pursuit of volume jar
  • Other characteristics of small increases, such as cycle dataIndex, includeURL labels, etc.
  • Template is fully compatible as always, we need to adjust some advanced customization package name

If you want to quickly become familiar with Beetl, can be accessed online experience  http://ibeetl.com/beetlonline/

Beetl template (text processing) engine is the world's fastest template engine running, in a timely manner from JDK6 to JDK8, there are some new generation template engine was born, Beetl performance is still king, as a result of JMH can test from template -benchmark

Beetl reason why fast performance, root cause from Beetl team eight years of constant maintenance and the pursuit of technology. Briefly summarized as follows

A: The byte code generation, instead of the reflective overhead, such as the User object property access, generate the following bytecode, providing great performance ( refer to the text )

public Object value(Object obj ,String attr){
   int code = attr.hashCode();
   switch(code):
   case 97: return ((User)obj).getA();
}

II: variables stored in an array, rather than the presence of the Map as a template to other engines, crazy improve performance, the following template

var a = 1;
var b = "hello"+a;

For other templates kernel, it is to maintain a variable table Map

context.put("a",1);
content.put("b","hello"+context.get("a"));

For Beetl core, maintaining an array

vars[0] =1;
vars[1] = "hello"+vars[0];

Three static text template optimization

For JSP or other template, static text does not do optimization, resulting in static text output is also very slow, Beetl will merge static text, binary stream output if allowed, even in advance into a byte stream. As the test does not simulate real-world performance, if the real environment, Beetl performance will be 4-6 times the Freemarker.

Four Beetl script optimization, Beetl analyzes AST, some of the generated class node performs re-optimized to achieve optimal performance, such as, for variable user.name, and user.wife.name execution, all with VarRef, but taking into account the former expression only one property, the cancellation of the cycle, with a similar loop unrolling optimization measures.

//user.wife.name,VarRef.java
Attribute[] local = attr;
int len = local.length();
for(int i=0;i<len;i++){
     value = local.execute(context);
}

//user.name,去掉循环,VarRefOptimal.java
localAttr1.execcute(context);

V: Because int, long, double, etc. string transfer requires a lot of code, as an example of an int, and line 50 will be directed to both frequency and group assignments, Beetl internal optimized, even for 1..1024 int type, direct cache for char array, but also greatly improved performance

For details Beetl performance optimization and optimization far more than that, this is Beetl to go beyond Rocker, JSP compiled into this template (class execution reference third-party testing ), is the world's fastest-deserved template engine, template engine is the coolest .

<dependency>
    <groupId>com.ibeetl</groupId>
    <artifactId>beetl</artifactId>
    <version>3.0.0.RELEASE</version>
</dependency>

Appendix: Beetl first version in 2011 Sourceforge Screenshot

Beetl team has more than 20 developers have contributed to Beetl team, they do not depreciate in Beetl imperfect when no spray, no matter how the circumstances of their lives, are working tirelessly together to improve Beetl, making it open source in China in personal ( in relation to Ali, Baidu, Jingdong invested heavily in open source) excellent open-source base components, I'm not good at expressing, by open-source Chinese to thank them.

Guess you like

Origin www.oschina.net/news/107308/beetl-3-0-0-released