This is a tiny example of how the little things you learn along the way change how you think about options.
Back around 2022, I’d used a little PHP function to scan a directory and build an index to the files there using scandir. At some point later, I used that to create an “>automated slideshow based on a folder of images.
This example builds on it a bit to spit the index out as JSON, making it a little API. I could set it to run every X hours and cache the JSON to increase speed. I might also make it a bit fancier to add some other key value pairs to allow categorical retrieval etc.
<?php
$data = [];
header('Content-Type: application/json; charset=utf-8');
$files = scandir('imgs');//scan the directory named imgs that's in the same directory as this script
foreach ($files as $key => $file) {
if(strlen($file)>4){
if($file != ".DS_Store"){//I'm lazy and just left the Apple-related files in there so this skips them
$new = ["url" => $file];
array_push($data, $new);
}
}
}
echo json_encode($data);
That PHP makes . . .
[
{
"url": "animatedfish.gif"
},
{
"url": "big_fish_swimming_md_clr.gif"
},
{
"url": "dollarspindownd.gif"
},
{
"url": "ffish.gif"
},
{
"url": "fish_seahorse.gif"
},
{
"url": "ratherfish.gif"
},
{
"url": "swimmingfishtag.gif"
}
]
That JSON can be consumed by this bit of javascript.
fetch('http://multisitetwo.local:10013/extras/images/json.php')
.then(function (response) {
return response.json();
})
.then(function (data) {
console.log(data);
})
.catch(function (err) {
console.log('error: ' + err);
});
Obligatory wondering about the impact of any tech on learning
Knowing that this was possible, and having done it twice now, placed it firmly in my brain as an option. How to do it isn’t that important. What I wonder is that if I was relying on AI as the path to the answer . . . what would need to be in my head to give the right prompts? Would my brain retain the information in the same way so I would have it more readily next time I ran into a similar situation or would I be relying on the AI to get me there as if I was starting from scratch?
Computer coding is different than language in that the code itself is a barrier to what you’re trying to do.1 The question with AI and coding (and AI and writing, and AI and learning, and pretty much any technology . . . ) is “Where is the productive toil?”
I don’t think we’ve answered that question with regard to more basic things like “When should you memorize something?” What should we have in our heads vs being able to look up? How do you know to look up that thing that you don’t know/remember? What do we lose as our ability to memorize things weakens? This isn’t just looking up state capitals. It’s things like having the same stories in our heads for allusions and communication. The difference between having facts and ideas in your head during a conversation vs stopping the conversation and looking them up is significant. My dad used to try to get me to stop fighting the things my k12 teachers required me to do by arguing that having common experiences with certain literary works, memorizing other things, helped people communicate with one another. I think that’s true but it’s also a way of separating people.
In most/all IDEs, things auto-complete. I do not store them in my head and without the IDE, I struggle to remember the particular completion pattern for the particular language or environment. Left to my own (mental) devices with a plain text editor or a piece of paper, I’d have the general idea in most cases but the specifics would be mush. With programming, the auto-completion results in good things around standardization and consistent patterns. Many people use linters to further force as much consistency as possible. In some ways, we’re headed somewhere similar with auto-completion in text and in so many of the spaces where we write. I’m not sure that’s a good thing.
So now we’ve got vibe coding . . . and probably a good bit of vibe writing . . . and likely vibe thinking. There are places where all of that makes sense and much of it doesn’t matter. There are a chunk of other places where it does worry me. That’s mainly because thinking too little about things seems to be a cultural norm. AI makes it so easy for the guru-grifters to expand their games. It makes it effortless. All you need is an ego, a smile, and a total lack of remorse and you can consult on anything! Maybe that’s always been the case but it feels like AI makes it easier. I see those people saying AI makes it easier.
1 Or maybe language is as well, if we could communicate telepathically with clarity then talking would be an obstacle. But we don’t have that option so I’ll leave this as a footnote.