4 ms·
I've been talking with a few developer friends about libraries lately, and this one has made me realize what they're saying. As Python developers, DSLs are comp
by StavrosK 11y ago
I've been talking with a few developer friends about libraries lately, and this one has made me realize what they're saying. As Python developers, DSLs are completely not in our DNA, but this library strikes me as something that would look much more Pythonic with a DSL.
Wouldn't it be better to have descriptions of:
Every day at 10:30 do myfunc
Every Monday do otherfunc
Every hour do whatever
Rather than the current .every().day.at("10:30").do(myfunc)?
- gvalkov 11y agoI find it hard to appreciate these inventive types of API design. Something more traditional and boring, like Celery's crontab[1] or dateutils rrule[2] seem quite sufficient. For example: crontab(hour=18, minute=30, day_of_week='*') [1]: http://celery.readthedocs.org/en/latest/userguide/periodic-tasks.html#crontab-schedules http://celery.readthedocs.org/en/latest/userguide/periodic-t... [2]: https://labix.org/python-dateutil#head-470fa22b2db72000d7abe698a5783a46b0731b57 https://labix.org/python-dateutil#head-470fa22b2db72000d7abe...
- StavrosK 11y agoI'm not sure why, given two equally flexible designs, we should choose the least expressive. The fact that cron is sufficient doesn't mean I don't still have to google how to run things every three hours every second Monday, for example.
- draegtun 11y agoI agree. This scheduler dialect for Rebol is pretty much the DSL you describe - http://softinnov.org/rebol/scheduler.shtml http://softinnov.org/rebol/scheduler.shtml
- anentropic 11y agoI'd rather have neither. I particularly dislike the .every().day.at("10:30").do(myfunc) thing where methods and attributes are abused in order to artificially make it read like a sentence. This is not Pythonic at all <troll>it's like some childish Ruby code</troll>