Closed wokalski closed 6 years ago
It’s not so much faster from the look of it? https://github.com/threepointone/bs-nice/issues/3 And I want to keep this as pure reason, will it affect how I do builds for native?
@threepointone you currently can't use JS API for native build.
yes, it won't work on "native" (as in if you compile it down to native machine code). It is a tradeoff however, it's easily swappable. You might as well use functors to make it backend-dependent. In any case string_of_float
prints 100
as "100."
so that's a possible bug (i.e. 100.%
is invalid, right?) and Printf is quite heavy.
It's up to you, and ultimately the perf hit is not huge but printf is definitely a big runtime/size cost (it's a complicated beast). So I'd opt in for either string_of_x
or js string interpolation. It depends on your future plans and how really feasible it is that it'll run on native any time soon.
I'm going to punt on 'pure' native for now, and revisit later. so you're saying I can basically replace Printf.sprintf("%f", x)
with {j|${x}|j}
?
replaced printf with string interpolation
Js string interpolation is much much faster than string_of_whatever/Printf built ins.