hacker-news-custom-logo

Hackr News App

Hi HN!

I built NaturalCron because I was tired of writing and debugging CRON syntax like:

/5 * * 5

Now you can write something human-readable in .NET:

var expression = new NaturalCronExpression("every 5 minutes on friday");

Or use a Fluent Builder for strong typing and IDE support:

var expression = NaturalCronExpressionBuilder .Every().Minutes(5) .On(DayOfWeek.Friday) .Build();

Great for: - Code-based scheduling in .NET apps - Overriding schedules from configs or databases - Displaying easy-to-read rules in UIs

NuGet: https://www.nuget.org/packages/NaturalCron GitHub: https://github.com/hugoj0s3/NaturalCron

Would love your feedback on syntax, builder design, and what features you'd like to see next!

13 comments

  • joshstrange

     

    1 hour ago

    next

    [ - ]

    How does it handle “bi-weekly”?

    At the end of the day, anyone using cron-type things should just learn cron syntax, it’s really not that difficult and there are a number of websites that you can use to assist or spot-check your work.

    I’m always incredibly resistant to “human readable” for things like this because there is just too much ambiguity.

    reply
  • easygenes

     

    2 days ago

    prev

    next

    [ - ]

    I think this is good for people who only have occasional need for scheduling. I’ve used cron enough that I appreciate its compactness and would find this cumbersome and difficult.

    reply

    herbst

     

    1 day ago

    parent

    next

    [ - ]

    [ x ]

    <@easygenes> I find Cron to be one of the clearest and most elegant Syntax solutions out there. Like you only have to understand it once and can assume the rest from looking at it. That's super elegant

    reply
  • teapot7

     

    1 day ago

    prev

    next

    [ - ]

    Cron is definitely not the biggest problem in my life. I've never had a problem with its format. I think this is a solution to a problem I don't have - and I tend to find that "English like" formats don't do me any favours.

    reply
  • BryanLegend

     

    2 days ago

    prev

    next

    [ - ]

    How flexible is the syntax? Can I write whatever and have a chance it parses correctly?

    reply
  • lr0

     

    23 hours ago

    prev

    next

    [ - ]

    That's nice but I don't think Cron syntax is a big of a problem, most of the time.

    reply
  • loloquwowndueo

     

    2 days ago

    prev

    [ - ]

    > Because memorizing 0 18 * * 1-5 is harder than understanding every day between monday and friday at 6:00pm

    Really? Does “Every day between Monday and Friday” include Monday and Friday? One could think the days between Monday and Friday are Tuesday, Wednesday and Thursday.

    Why people don’t just learn cron syntax is beyond me.

    reply

    perching_aix

     

    2 days ago

    parent

    next

    [ - ]

    [ x ]

    <@loloquwowndueo> > Why people don’t just learn cron syntax is beyond me.

    Maybe the better question to ponder is why is it something that needs explicit learning. It's a basic task scheduler.

    The *nix format hell in general drives me insane. Immensely glad for the recent-ish trend of lots of applications at least slowly adopting JSON and others as both config and output options.

    reply

    zipping1549

     

    1 day ago

    root

    parent

    next

    [ - ]

    [ x ]

    <@perching_aix> > why is it something that needs explicit learning. It's a basic task scheduler.

    You still have to learn what exactly this sort of software can understand and that is, imo, no less of a time/effort needed to learn cron.

    reply

    serf

     

    1 day ago

    root

    parent

    prev

    next

    [ - ]

    [ x ]

    <@perching_aix> essentially the answer is that after 40 years of polishing a 'basic' thing it's realized that there is near infinite nuance in use cases and workloads, even without feature bloat.

    reply

    jiggawatts

     

    2 days ago

    parent

    prev

    next

    [ - ]

    [ x ]

    <@loloquwowndueo> > Why people don’t just learn cron syntax is beyond me.

    Because it looks like line noise, is unreadable to anybody not a UNIX/Linux admin, and is a standard in the same sense that the directory separator is the backslash on the majority of deployed desktops and servers.

    More importantly: It’s also not extensible without being completely changed, which makes it a poor design.

    Fluent builders can be trivially expanded to support new capabilities without breaking existing code or configuration.

    Cron’s syntax was likely a quick and nasty thing thrown together by some student at Berkeley or wherever in the stone ages of computing. We shouldn’t be bound by these accidents of history in the same way we shouldn’t keep using Roman numerals these days.

    reply

    loloquwowndueo

     

    2 days ago

    root

    parent

    next

    [ - ]

    [ x ]

    <@jiggawatts> > It’s also not extensible without being completely changed, which makes it a poor design.

    Fair enough but let’s please not replace it with something where the literal first example in the GitHub read me is ambiguous.

    reply

    wordofx

     

    2 days ago

    parent

    prev

    [ - ]

    [ x ]

    <@loloquwowndueo> Cron syntax sucks. Cron is good for a few small use cases but sucks for real world scheduling.

    reply