4 ms·
Why is it always a bad idea? For example there can be content that is triggered by rules and these rules need to be edited by non-programmers. Furthermore these
by dirtyaura 10y ago
Why is it always a bad idea? For example there can be content that is triggered by rules and these rules need to be edited by non-programmers. Furthermore these rules need to be evaluate in different execution contexts (in our case in Android and iOS) This is a situation that requires describing simple logic alongside data.
- vbezhenar 10y agoIMO it's always strictly better to use something real, like LUA. WoW uses lua as a programming language for user interface and users can make their additions (addons and macroses). A lot of users, who don't know anything about programming, can successfully use those lua snippets. Also when real programmers have to interact with those systems (and my practice shows, that business users don't want to program, they ask programmers to do it), it's so much pain to use those GUI languages or whatever and it's so easy just to write some code in sane language.
- josephearl 10y agoApple has restrictions on downloading executable code, which downloading a Lua script would likely fall afoul of. It's also a potential security risk - the downloaded script could perform things other than logic and so would require sandboxing/whitelisting of commands. Putting logic in JSON avoids both of these issues since the actual handling of the logic is performed by a client-side library.
- jfroma 10y agoSerious question, whats the difference between executable lua and executable json regarding apple restrictions?
- michaelmior 10y agoJSON is not executable. Although I suppose you could argue that embedding an interpreter for a DSL like this inside your app is violating the restriction.
- boomlinde 10y agoLua isn't executable either. The point at which it results in some corresponding machine instructions wouldn't be much different in this case.
- MichaelBurge 10y agoELF binaries aren't executable either: They require the kernel to interpret them, preparing virtual memory and granting it a pid. Alone, they're just sequences of bytes.
- boomlinde 10y agoWhat's your point? That you are willing to extend this principle to ELF binaries doesn't really affect my argument. My point is that for the purpose of letting some non-trusted instructions run safely in a program, encoding them as JSON or Lua will come with the same caveats. Ultimately, they are both interpreted and can be sandboxed thus. Neither contain any code that will be passed off as-is for the CPU to execute. In some cases, neither does an ELF blob.
- dirtyaura 10y agoTo my understanding those restrictions have been lifted years ago. They used them strategically to kill Flash from becoming an app development platform and still probably can use them to kill cross-platform programming kits. But having scripting code in the app is not a problem anymore - they even offer Javascript execution context library in iOS SDK that makes it easy to run Javascript without UI. https://developer.apple.com/reference/javascriptcore/jscontext https://developer.apple.com/reference/javascriptcore/jsconte...