Oops! Something went sideways.

Looks like the styling got goofed up. Sorry about that, unless it's what you wanted. If this isn't what you were looking for, try force refreshing your page. You can do that by pressing Shift + F5, or holding Shift and clicking on the "reload" icon. (It's the weird circle arrow thing "⟳" just above this page, usually next to where it says https://blog.unitedheroes.net...)

isn't quite ashamed enough to present

jr conlin's ink stained banana

:: Con-frigguration

If it’s a static value, it probably belongs in a configuration file.

That’s one of my golden rules of programming, and it’s generally saved my ass. Mostly because someone else sometime else decides that something isn’t quite as permanent as they said it was and it changes. (That was for the benefit of the two or three folk out there that don’t use config files.) Still, after nearly half a century of coding, we still have terrible ideas about configuration files.

The worst offender, by far, is the horrible programming language masquerading as a config file. These seem to be en vogue again. Such as “yaml” format:

  - alias: "Morning kitchen on"
        platform: time
        at: "06:45:00"
        condition: and
          - condition: time
               - mon
               - tue
               - wed
               - thu
               - fri
          - condition: sun
            before: sunrise
        service: homeassistant.turn_on
            - group.lights

That’s from my Home Assistant configuration file to turn the lights on in the morning if they need to. Home Assistant is written in Python, and i don’t really want to pick on it because it’s really good. If anything, the config system being bad just stands out that much more. i can’t tell you how much easier it would have been to just code up the python function.

import time
def MorningLight():
    now = time.localtime()
    if (now.tm_wday in range(1,6) and 
            (now.tm_hour == 6 and now.tm_min in range(45, 59)) and
            time.time() < homeassistant.sensor_state("sun.sunrise")):

Hell, make some convenience functions and it's shorter.

def MorningLight():
             "06:45 AM",
             homeassistant.sensor_value("sun.sunrise")) and

Yes, this proposes that the individual know python. They’re programming. It’s ok to use the same language you’re using. Forcing the user to learn some convoluted semi-language syntax that is even more alien, doesn’t have countless free tutorials and books, and a vibrant support system, isn’t helpful.

There is literally zero difference between the above yaml version and this:

♥️alias🍳"Morning kitchen on"

Actually, i’d argue that it’s clearer because the “🐸” are visibly defined rather than just whitespace (tabs? spaces? tabs+spaces? 🤷‍♀)

We keep insisting on doing this. Sure, that wheel is pretty and all, but what we really need is to make something that rolls on the ground around an axis.

What’s frankly hilarious to me is that programmers have even beaten multiple paths to the “give the customer a simple programming language” route (Lua, Javascript, Visual Basic, etc.) and STILL we come up with crappier solutions. Hell, at one point i was writing a shopping site in a custom XML based language. Someone, quite possibly multiple people, not only thought that was a good idea, but took a significant amount of time to prototype, develop, implement, test, and document that.

Stop it. Just, stop it.

Stop trying to shoe horn a horrible solution to an obvious problem.

If you’ve got static values you need to set, use a simple key-value config system. Maybe allow for sections if it’s super complicated, but also consider that perhaps divvying things up might also be a viable solution. Windows, Unix, and yeah, even Macs all do this, and they work pretty well for exceptionally complex systems. (i’ve got my complaints about Windows Registry tables cross references, but at least i’m not writing XML if statements.)

If you need templates, use an established template system. HTML is no party, but it works, and there’s library support for it. If you want to grant programmatic access to users, give them a damn programming language. And not one that you created in your Junior systems class and got a “C-“.

Granted, if you’re building a complex virtual machine like a web browser, then rules are quite different. Chances are exceptionally good, though, you’re not.

Yes, this means trusting your users. Yes, this also may mean giving up the dream of providing a configuration system safe for 6 year olds. Granted, you could also give them Scratch, so there’s that.

(Dammit, now this means i need to submit a patch to HomeAssistant that actually replaces the crappy config system with an actual programming system, doesn’t it?)

Blogs of note
personal Christopher Conlin USMC memoirs of hydrogen guy rhapsodic.org Henriette's Herbal Blog
geek ultramookie

Powered by WordPress
Hosted on Dreamhost.