I have a full time job and also maintain another significantly large open source project solo (Kuberhealthy), so my flags package for Go was often neglected despite having 850+ stars and being used in lazydocker and others. I had a lot of guilt about this, but now that I've been getting used to using AI, returning to this project to add the features I always wanted it to have (completion for shells) was doable from my couch with family and kids as a constant distraction.
I am optimistic that AI is a good thing for software and it's certainly made it possible for me to stay on top of my open source projects for the first time in many years.
I used Codex mostly, but my CLI Codex would run out of quota after an hour or so because I only have the OpenAI Plus plan.
That said, when I used the agentic version on the website, the quota currently seems to be infinite. I could get 10+ agents running and work for hours without a mention of quota limits. I'm guessing this is a temporary business maneuver to help Codex catch up on market share.
That said, the online version was pretty good. I found myself building out code and docs from my phone sometimes.
I was using "just git" until I realized I've started writing a whole bunch of scripts of various types to recreate ("ad-hoc, informally specified and bug-ridden...") functionality that chezmoi offers out of the box and has already tested in the field.
The post does say exactly how to do that. Just init your homedir as a repo, add a remote, and pull. Your dotfiles come right down on top of your new machine's home directory.
Call me crazy, but I don't like any of this. Make more named functions. Keep your logic flat and explicit. I believe go wants you to code this way as well. Imagine the horrors this kind of function chaining creates. Actually, you don't have to. It's JavaScript.
This sort of “chaining” syntax is pretty standard in many languages (Java, JS, Elixir, etc). Especially for streams/iterators/lists. You can have pretty well named and flat logic too. I think it’s just poorly written demo code. To me, this “functional” style of chaining is great. It highlights intent when reading the chain (you read “filter” as a step instead of a for loop with a conditional inside). It’s also really easy to recompose or reorder, and the code-review diffs are super easy to reason about when that happens.
I don’t think it really generates anything conventionally called “horrors” either - you can still use named functions and everything you love, this just makes it easier to use. It may encourage more well-written code too.
Imagine a simple example - get all files in some directory, filter out non-json files, perform some name-manipulation (map) function, and then return a new list. The “old” way would require a series of for loops that make and fill slices passed to each. You then wrap that whole thing in a new method called “GetRenamedJsonFiles(path string) []File”.
With the iterator chaining, you can still wrap it in a named method, but now you can replace the repeated for loops and intermediary slices with: “return GetFiles(path).Filter(isJsonFunc).Map(updateFileNameFunc).Collect()”. It’s probably easier to read, easier to change up later if requirements change, and easier to validate intent when reviewing, etc. It even encourages smaller, dedicated, easy to update or share methods - it encourages named methods for the intermediary steps (getFiles, isJson, updateName).
In fact, a long chain of function calls is often hard to read and has to be splitted into several parts anyway. I can even claim that this "old" style forces you to name the outcome of each step. Also it is unclear whether `GetFiles` returns a lazy iterator or a plain slice from its name (I guess it's lazy, but only because you have said `Collect()` there).
It is not even like that "map" and "filter" don't have their places in this style. In fact function chaining is just a concise way to rephrase that! You can write in a functional style without having any function chaining, because the style is all about immutability and resulting composability. Mutability tends to not mix together---any such combination results in something more complex. As long as that can be eliminated, anything would work.
One potential downside I see with this approach is that it forces you to store and name intermediate results which may or may not be meaningful on their own.
Consider a slightly more complicated example that filters on multiple conditions, say file type, size, and last modified date. These filters could be applied sequentially, leading to names like jsonFiles, then bigJsonFiles, then recentlyModifiedBigJsonFiles. Or alternatively, names which drop that cumulative context.
Of course that can be extracted out into a standalone function that filters on all criteria at once or we can use a combinator to combine them or apply any number of other changes, but generally naming intermediate states can be challenging.
Your presented alternative is basically the same thing with named step outputs. I don’t see how chaining is something crazy or problematic in comparison. The only difference is chaining reduces syntactic “noise”. It’s easier to read.
One-time use variables that are consumed on the next line aren’t valuable. Chaining exists as a widely used pattern because it’s useful to not generate a ton of intermediary variables.
In fact, the typing point you bring up is actually less clear. In the iterator chain, the type is “iterator”, which is a standard type that can be produced from many sources as business requirements change. In your example, the types need be compared to the function parameters and methods need to be written explicitly use the same types.
Sometimes naming intermediate steps makes code easier to read. Sometimes it doens't. It depends a lot if the intermediate step has a semantic meaning or not, if you want the reader to pause and do a mental checkpoint or if it makes more sense to keep going. Kind of like when you are writing English, and you decide to stop a sentence, or keep going, you don't want your sentences to be too long, but also not too large. That's why good code should follow guidelines, but not hard rules. The programmer should write it in a way that is easier for the reader to understand, and that depends on the context of what is being done.
Since you asked, I find the terse version to be completely unreadable*. If I wanted to understand it, I’d end up writing out all the steps for myself anyway.
There’s an asterisk here because you cherrypicked a function that is already widely known and understood. All we really need to understand that function is its name. If you chose complex niche business logic, or The Wave Function, it would have made for a more fair and instructive example.
Even JS doesn't really use functional styles that much. In fact, the whole reason for functional styles is the decomposability: any language with easy function chaining like `x |> f |> g |> h` will also have an easy extraction of any part of the chain (say, `x |> fg |> h where fg = f . g`). It is not a good idea to use chaining when the language supports no such feature, as it would be much harder to work with such chains then.
You're right, this functional style 'clever' programming is exactly what Go discourages (or did discourage... historically...) This is the exactly the kind of code I don't want to see. I want to see clear, easy to read, obvious functions that do exactly what they say on the tin.
For lots of people, unnecessary for loops makes the code less readable. When using filter and map, all the looping is abstracted out so the reader can concentrate on what's being filtered and transferred. The loops and their temporary variables just clutters up the code.
LINQ is a very dense syntactic sugar for some selected `IEnumerable` methods. It will surely look like chaining in typical uses and thus is useful, but different from an arbitrary chaining.
I had COVID at the end of 2022 and became deeply and severely depressed right after and for the first several months of 2023. It was terrible. I was shaking uncontrollably for days, I never slept for more than a few minutes at a time, I didn't eat, and I had panic attacks constantly. I really thought that it would never end and that my brain had somehow broken.
I did have stressful events I was dealing with in life before this occurred, but I was managing. While I had COVID, I realized that I would get very unexpectedly sad and sometimes cry for no reason. As COVID got better, my depression symptoms stayed and got worse.
I ended up sick with something that required antibiotics and within a week of taking those, my symptoms started to ease up. A month later I was doing much better. A few months later and I was back to normal. I also started therapy during this depression event and continue it today just in case.
I really don't have a way to prove that it was connected to COVID or the antibiotic use, but I can tell you that my mind was not functioning correctly during this. I could mentally know everything was totally fine, but my body would still decide to dump adrenaline and fear on me unreasonably. It was like being trapped in a broken body that was torturing me. People would try to tell me that everything was fine, and I would explain that I knew that, but my brain chemistry was still on fire and logic didn't help.
Anyway, I fought hard, I reached out to friends, I did therapy as often as I could, I started exercising, did breathing exercises, took lots of walks outside, and I eventually got through it. It felt hopeless but I just did those things anyway through sheer force of will. Eventually I got through it and that hell is only a memory now that continues to fade with time.
I believe this was related to some kind of inflammation somewhere that was linked to a very bad COVID infection.
Not necessarily, if you try to see things as a whole. It's like the wallstreetbets reddit. You don't give them redditors information/knowledge on how to evaluate a stock, you give them an opportunity to jump onboard to by XYZ share. So in essence it is gambling. Put blind hope into a faceless entity that what it says is true and not malicious.
So if you want to uplift people from povery don't give them food, give them the means to create their own food. The moment you start to do that, you gonna anger the "colonists" quite quick.
Seems like you're suggesting that private security should be an expected cost because the state will no longer protect you like they have been for many years...
To make an analogy, my dad worked at a large chemical factory. It had its own full service fire department. This department also participated in mutual aid with the surrounding town. One thing they could do was provide services that would normally not be a consideration for a sleepy suburb, such as a bomb squad.
I think if your business is particularly security intensive, I don't see a reason not to supplement the basic services provided by the government. There have always been railroad police, armored car services, and so forth.
I don't think moving random manufactured products from point A to point B should be considered "particularly security intensive". This is just basic commerce and logistics.
Some of the largest battles of World War II involved nothing more substantial than moving goods from point A to point B, or stopping the other country from moving their goods from point A to point B.
Logistics is the lifeblood of society and cannot be taken for granted even in a civilian sphere.
UP has its own police with full law enforcement powers. I would be curious to know if that force has been downsized. They did abandon the police headquarters building at the western edge of the LA yard.
They can arrest but they cannot prosecute. The state needs to try the suspects and enforce any penalties. UP police cannot do the latter -they can only arrest.
Maybe they can seek trial in a different locale if the railroad right of way has different jurisdiction.
The only other option the UP police have is asking a federal prosecutor to take the case. And that's only if there's some credible evidence of a federal law violation.
I'm not generally one for expanding federal jurisdictional reach, but there's a much clearer federal connection for: internationally imported shipping containers leaving a federal port facility on a (primarily) federally regulated mode of transportation devoted (primarily) to interstate commerce... than there is for 90% of what legally gets classified today as federal jurisdiction.
> Why bother investing in more, if none of the arrests result in charges?
UP is not complaining that none of the arrests result in charges. (They are complaining that the DA is settling for plea deals to lesser charges than they would prefer and not trying to employ cash bail as pre-conviction punishment for disabling [by incarceration of those who can’t afford it] suspects and deterring potential future criminals instead of not using it when it is not necessary to secure appearance of a suspect legally presumed innocent.)
Also, it's well known that sufficiently visible security is a deterrent to crime, which is better than after-the-fact arrests, so an eruption in undeterred crime is evidence of a need for more and more visible security.
Let's be specific about what UP is complaining, then:
"But even with these expanded resources and closer partnerships with local law enforcement, we find ourselves coming back to the same results with the Los Angeles County criminal justice system. Criminals are caught and arrested, turned over to local authorities for booking, arraigned before the local courts, charges are reduced to a misdemeanor or petty offense, and the criminal is released after paying a nominal fine. These individuals are generally caught and released back onto the streets in less than twenty-four hours. Even with all the arrests made, the no-cash bail policy and extended timeframe for suspects to appear in court is causing re-victimization to UP by these same criminals. In fact, criminals boast to our officers that charges will be pled down to simple trespassing – which bears no serious consequence."
You are perfectly correct in the pedantic sense, but the spirit of their complaint is much closer to the GP's post than to what you represent.
How much protection of their property can the average American expect from the state? Very little.
The only thing you can expect of the police will do for you if you get burglarized is a signed police report, and if you're lucky, unsolicited advice to move to a better part of town.
My wife's workplace gets stolen from fairly regularly. It's not located in one of those 'liberal' cities that allegedly don't enforce any laws.
Despite that, the police have yet to do anything about it.
The primary function of the police is not, and has never been protecting your property. The primary function of the police is protecting the upper classes from you.
> The primary function of the police is protecting the upper classes from you.
i no longer buy that at all, i use to but not any longer. The whole "make police the bad guy" thing is over and done with. If police are not enforcing the law then how are they protecting anyone from anyone else regardless of class.
But in this case they are enforcing the law. The prosecutors and courts are the ones not putting them in prison.
And to the people saying UP just needs more cops, they wouldn't need more cops if as criminals were caught they were taken off the streets by prosecutors. If someone is successful at stealing from trains, but gets caught every 10th time and has to spend 4 hours in a holding cell, why would they quit stealing from trains?
I would wager, but cannot prove, that if an LA politician's (extra points for being a congresscritter) home was burglarized that it, and the perpetrator, would get more action taken than one of us mere peons.
I certainly did not expect the libertarian ideal of depending for protection wholly on private security, instead of on the state, to be first implemented in Los Angeles, of all places.
UPs police force is not private security in the usual sense. Those in CA are California peace officers, and all of them are also specially federally empowered for interstate operations.
And this isn't new, major railroads have had these publicly-empowered police forces since the late 19th century.
Private security is an expected cost for any business (or homeowner for that matter). Even if the local police department is fully staffed, they certainly can't be everywhere at all times, respond instantly to a report of crime, or deal with issues that it is not staffed for such as rampant technology-enabled crime.
So, maybe the security is an investment in new cameras. Maybe it's a better lock that can't be bypassed. Maybe it's an investment in network security personnel or systems. Maybe it's a doorman at the apartment building, or a security guard serving as "eyes and ears" for the police.
My question earlier is how much UP - a publicly listed company with $20B in revenue in 2020 - has increased security expenditures to keep up with traffic, theft, and other potential threats to its business.
Camera's not going to do anything by itself if you can't actually stop the person who is on the camera, and it's a lot harder to stop that person if they're never going to jail even when they're caught red-handed and arrested at the scene.
I mean, heck, if it comes down to it, Private Security can also mean that UP just gives up on Los Angeles and its eponymous port entirely.
Cameras provide evidence that is far more reliable and simpler to present than testimony from a railway security guard. This evidence could even be shared publicly to support their case.
> So, maybe the security is an investment in new cameras. Maybe it's a better lock that can't be bypassed. Maybe it's an investment in network security personnel or systems. Maybe it's a doorman at the apartment building, or a security guard serving as "eyes and ears" for the police.
All of the things listed are simply deterrents, that would not stop a criminal knowing that he would not get prosecuted from taking the extra time to bypass them. Cameras can be evaded with masks, locks can be grinded down (see lockpickinglawyer), security is pointless if they know they cannot be detained.
Insane that this discussion is happening like this. Depending on the state for property protection is a basic facet of a functioning government. Literal organized stage coach robbery is not an issue anywhere else in the US, and it is not UPs responsibility to deal with it, unless we want to return to a period of private armies.
> Then the DA is not doing shit to charge those arrested
They are being charged and convicted, and UP explicitly acknowledges this.
UP is complaining that the convictions are based on plea deals to charges less severe than UP would prefer, and that cash bail is not being unconstitutionally abused (I mean this is pretty much black and white in their letter) as pre-conviction punishment of the legally presumed-innocent rather than bail terms being set based on what is necessary to secure appearance at subsequent court hearing.
You’re asking a great question, but at the end of the day, if criminals have no fear of repercussion, the “security” investments are almost equal to throwing money away.
They can’t be everywhere at once but they should be apprehending repeat offenders it sounds like they are arresting plenty of criminals they just aren’t being prosecuted so they continue to rob and pillage.
I wrote my own flags package called flaggy and think its the easiest to use and makes the most sense! Up to 600 stars om github now.
https://github.com/integrii/flaggy
I am optimistic that AI is a good thing for software and it's certainly made it possible for me to stay on top of my open source projects for the first time in many years.