digitalmars.D.learn - Application settings
- FoxyBrown (8/8) Jul 07 2017 What's the "best" way to do this? I want something I can simply
- Cym13 (10/18) Jul 07 2017 I think you're better off with a simple file in a format like
- Moritz Maxeiner (4/10) Jul 07 2017 "best" always depends on your specific use case. I use json files
- FoxyBrown (3/14) Jul 07 2017 Seems like quite a heavy package for what I need. I just want to
- bauss (5/21) Jul 07 2017 Then I would go with INI, because you'll ultimately just have
- Seb (3/20) Jul 08 2017 There is also inifiled: https://github.com/burner/inifiled (used
- Timothee Cour via Digitalmars-d-learn (9/38) Jul 08 2017 I use protocol buffers (using dproto) for this, storing my settings in
- aberba (4/12) Jul 07 2017 Setting are not kept in binary (usually). Normally the installer
- Jacob Carlborg (21/28) Jul 10 2017 I would say it depends on what kind of application and which platforms
What's the "best" way to do this? I want something I can simply load at startup in a convenient and easy way then save when necessary(possibly be efficient at it, but probably doesn't matter). Simply json an array and save and load it, or is there a better way? Ideally, I'd like to store the settings as part of the binary to keep everything together but that poses a few issues I think.
Jul 07 2017
On Friday, 7 July 2017 at 19:40:35 UTC, FoxyBrown wrote:What's the "best" way to do this? I want something I can simply load at startup in a convenient and easy way then save when necessary(possibly be efficient at it, but probably doesn't matter). Simply json an array and save and load it, or is there a better way? Ideally, I'd like to store the settings as part of the binary to keep everything together but that poses a few issues I think.I think you're better off with a simple file in a format like JSON or INI yeah. Simpler is better. I don't see any easy way to save the configuration in the binary and would find it more troublesome than anything as an user as having the configuration appart means I can easily compare it between computers and track its changes etc. I don't think you need to worry about performances, after all it's only loaded once and the config would have to be *really* big for it to have a noticable loading time.
Jul 07 2017
On Friday, 7 July 2017 at 19:40:35 UTC, FoxyBrown wrote:What's the "best" way to do this? I want something I can simply load at startup in a convenient and easy way then save when necessary(possibly be efficient at it, but probably doesn't matter). Simply json an array and save and load it, or is there a better way?"best" always depends on your specific use case. I use json files via asdf [1] [1] https://github.com/tamediadigital/asdf
Jul 07 2017
On Friday, 7 July 2017 at 20:45:36 UTC, Moritz Maxeiner wrote:On Friday, 7 July 2017 at 19:40:35 UTC, FoxyBrown wrote:Seems like quite a heavy package for what I need. I just want to write a AA to disk and load it, ultimately.What's the "best" way to do this? I want something I can simply load at startup in a convenient and easy way then save when necessary(possibly be efficient at it, but probably doesn't matter). Simply json an array and save and load it, or is there a better way?"best" always depends on your specific use case. I use json files via asdf [1] [1] https://github.com/tamediadigital/asdf
Jul 07 2017
On Friday, 7 July 2017 at 22:52:22 UTC, FoxyBrown wrote:On Friday, 7 July 2017 at 20:45:36 UTC, Moritz Maxeiner wrote:Then I would go with INI, because you'll ultimately just have key-value pairs. https://code.dlang.org/packages/baussini (Pretty old but should still work just fine.)On Friday, 7 July 2017 at 19:40:35 UTC, FoxyBrown wrote:Seems like quite a heavy package for what I need. I just want to write a AA to disk and load it, ultimately.What's the "best" way to do this? I want something I can simply load at startup in a convenient and easy way then save when necessary(possibly be efficient at it, but probably doesn't matter). Simply json an array and save and load it, or is there a better way?"best" always depends on your specific use case. I use json files via asdf [1] [1] https://github.com/tamediadigital/asdf
Jul 07 2017
On Saturday, 8 July 2017 at 05:00:45 UTC, bauss wrote:On Friday, 7 July 2017 at 22:52:22 UTC, FoxyBrown wrote:There is also inifiled: https://github.com/burner/inifiled (used for Dscanner for example)On Friday, 7 July 2017 at 20:45:36 UTC, Moritz Maxeiner wrote:Then I would go with INI, because you'll ultimately just have key-value pairs. https://code.dlang.org/packages/baussini (Pretty old but should still work just fine.)On Friday, 7 July 2017 at 19:40:35 UTC, FoxyBrown wrote:Seems like quite a heavy package for what I need. I just want to write a AA to disk and load it, ultimately.[...]"best" always depends on your specific use case. I use json files via asdf [1] [1] https://github.com/tamediadigital/asdf
Jul 08 2017
I use protocol buffers (using dproto) for this, storing my settings in either text or wire format. Advantages: type-safety with fwd/backward compatibility (unlike json which requires dynamic field access, eg with dproto you get errors at compile time instead of runtime), supports comments (although can be done w preprocessor on json config file), supports more types than json (especially binary without needing to base64 encode). On Sat, Jul 8, 2017 at 11:35 AM, Seb via Digitalmars-d-learn <digitalmars-d-learn puremagic.com> wrote:On Saturday, 8 July 2017 at 05:00:45 UTC, bauss wrote:On Friday, 7 July 2017 at 22:52:22 UTC, FoxyBrown wrote:There is also inifiled: https://github.com/burner/inifiled (used for Dscanner for example)On Friday, 7 July 2017 at 20:45:36 UTC, Moritz Maxeiner wrote:Then I would go with INI, because you'll ultimately just have key-value pairs. https://code.dlang.org/packages/baussini (Pretty old but should still work just fine.)On Friday, 7 July 2017 at 19:40:35 UTC, FoxyBrown wrote:Seems like quite a heavy package for what I need. I just want to write a AA to disk and load it, ultimately.[...]"best" always depends on your specific use case. I use json files via asdf [1] [1] https://github.com/tamediadigital/asdf
Jul 08 2017
On Friday, 7 July 2017 at 19:40:35 UTC, FoxyBrown wrote:What's the "best" way to do this? I want something I can simply load at startup in a convenient and easy way then save when necessary(possibly be efficient at it, but probably doesn't matter). Simply json an array and save and load it, or is there a better way? Ideally, I'd like to store the settings as part of the binary to keep everything together but that poses a few issues I think.Setting are not kept in binary (usually). Normally the installer would take care of creating a folder somewhere with a JSON/XML/SQlite file which stores settings.
Jul 07 2017
On 2017-07-07 21:40, FoxyBrown wrote:What's the "best" way to do this? I want something I can simply load at startup in a convenient and easy way then save when necessary(possibly be efficient at it, but probably doesn't matter). Simply json an array and save and load it, or is there a better way?I would say it depends on what kind of application and which platforms it supports. For GUI applications there's usually a native way to store application settings, which will be different on different platforms. For example, on macOS the NSUserDefaults class (Swift and Objective-C) is used, which will eventually store the settings in the plist format [1]. For CLI tools it seems quite common to store the settings in a file or directory in the user's home directory call .<app>rc where <app> is the name, or short name, of the application. The actual format of these files vary between applications, platforms and which language they're implemented in. For example, it seems pretty common for tools written in Go to use the TOML format [2]. In D, the corresponding format would be SDLang [3].Ideally, I'd like to store the settings as part of the binary to keep everything together but that poses a few issues I think.I would say again that this depends on the kind of application and the platform. [1] https://developer.apple.com/library/content/documentation/Cocoa/Conceptual/UserDefaults/Introduction/Introduction.html [2] https://github.com/toml-lang/toml [3] http://sdlang.org -- /Jacob Carlborg
Jul 10 2017