5 ms·
This was the reply I was trying to prevent by saying "minimal code example". I'm not interested in long theoretical articles. But I would look at a few lines o
by TekMol 4y ago
This was the reply I was trying to prevent by saying "minimal code example".
I'm not interested in long theoretical articles. But I would look at a few lines of code.
Here is an example of some code I recently wrote:
logEvent {
'date': new Date().toISOString(),
'event': 'image_updated',
'value': image['id'],
}
This logs that an image with a given id was updated.
Why would I trade in my single date line for 423 files with 53004 lines of code?
- krainboltgreene 4y agoYou wouldn't. It's not a trade anyone is asking.
- 0xCAP 4y agoThis is only you having super basic date needs, not Day.js being overkill in general.
- TekMol 4y agoAny system, no matter how complex, can be composed of smaller units that only have super basic needs.
- 411111111111111 4y ago*if all complexity has been hidden from the developer which only needs to use a decent puplic API. I'd agree that it feels like that quiet often as a web developer, but that's only because most of our APIs are actually quiet easy to use. The illusion usually falls away if you look at the code of that API, however.
- 9wzYQbTYsAIc 4y ago> I'm not interested in long theoretical articles Those articles are more empirical in nature than theoretical. > This logs that an image with a given id was updated As a thought exercise, imagine that your log trail needed to be created in a distributed system, spanning multiple machine time zones, or that you needed to build a report that is read from browsers in multiple time zones that differ from multiple differing written time zones, and you need to account for human readable things like knowing what day of the week it is and what some given locale calls that day. If you are doing the equivalent of printf debugging with your times, maybe you likely don’t need a time library. If you are using time as a central part of a distributed algorithm, web content, or a business workflow, then you may likely need a time library.
- TekMol 4y agoYou are trying to convince me with the popular "This is not going to work for a much more complex system". I heard it very often. I don't buy it. Any system, no matter how complex, can be composed of small, simple systems. I never ran against a "complexity wall" when writing software in a lean way and suddenly thought "Damn, those tens of thousands of lines of library code now would be the better approach".
- 9wzYQbTYsAIc 4y agoMore power to you if you have the budget to spend time writing code that someone else has already written.
- maigret 4y agoThat’s very true. A colleague recently started using the same method and is achieving bundles and dependencies orders of magnitude smaller. As a result, he has to care less about security, build times and build breaks and spends more time coding. Developers have unlearned to build basic functionality apparently, especially in the front end area.
- 9wzYQbTYsAIc 4y agoIt’s not really a question of unlearning, its more of a question of economics. Sound software construction techniques are one thing, but convincing someone to pay you to reinvent the wheel is another. Especially when you consider that budgets for new, bespoke brand websites can start as low as about a couple of days pay for a senior developer.
- laundermaf 4y agoI think you’re missing the point entirely. If Date has a method that does what you need, by all means use it directly. Libraries come in handy when doing things that aren’t one liners. A colleague thought it was super easy to change that exact ISO string to use the local timezone instead of UTC, against my advice. Guess what. The minus sign broke it and he would have never known because most customers are in the US, then they travel to Singapore and your product is worthless. By the time you hear about it, you lost the customer’s money and time therefore you lost the customer. Moment and Luxon are too heavy, I agree, but date-fns isn’t.
- foota 4y agoMoment and friends shine when you need to display and interact with dates from a human perspective. Calendars, scheduled events, etc., all are hard to do without something like moment.