News for hackers. Stuff that matters.
Re:Hero – A handy, fast and powerful Go template engine by junke on Tuesday February 14, 2017 @04:19AM (#13642313)
Ideally, a template should be compiled into native code.
Re:Hero – A handy, fast and powerful Go template engine by masklinn on Tuesday February 14, 2017 @04:28AM (#13642348)
Not necessarily.

1. that requires parsing the template at compile-time (making it non-overridable at runtime) or the ability to generate executable code at runtime which break in NX-mandatory environment (e.g. appstore applications)

2. the runtime version may be much faster than the compile-time one, e.g. the rust Regex crate has both a runtime Regex structure and a regex! compiler plugin, the latter is currently significantly slower at runtime: https://github.com/rust-lang/regex#usage-regex-compiler-plug...

Re:Hero – A handy, fast and powerful Go template engine by junke on Tuesday February 14, 2017 @06:23AM (#13642745)
Yes, "compile/load/execute" can take longer than simply "eval". You have to consider amortized costs: how often do you need to recompile your template (or your regex)? Likewise, are you really going to override the template at runtime or is the variable part of the template already compiled as branches in the resulting code? Whatever needs to be dynamic can be dynamic while compiling as much as possible ahead of time.
Re:Hero – A handy, fast and powerful Go template engine by micmus on Tuesday February 14, 2017 @09:10AM (#13643559)
Elixir's EEx templating engine compiles templates into plain elixir functions, which makes the templates really fast.
Re:Hero – A handy, fast and powerful Go template engine by Zoadian on Tuesday February 14, 2017 @04:43AM (#13642398)
There is a web framework (vibed.org) written in the D programming language that does compile templates to native code.