There have been multiple accounts created with the sole purpose of posting advertisement posts or replies containing unsolicited advertising.

Accounts which solely post advertisements, or persistently post them may be terminated.

programmer_humor

This magazine is from a federated server and may be incomplete. Browse more on the original instance.

ooterness , in Surely "1337" is the same as 1337, right?

CBOR for life, down with JSON.

0x0 ,

If there are no humans in the loop, sure, like for data transfer. But for, e.g., configuration files, i’d prefer a text-based solution instead of a binary one, JSON is a nice fit.

MonkderDritte ,

What, no! Use TOML or something for config files.

0x0 ,

TOML

Interesting… me likes it.

frezik ,

What I’d like for a configuration language is a parser that can handle in-place editing while maintaining whitespace, comments, etc. That way, automatic updates don’t clobber stuff the user put there, or (alternatively) have sections of ### AUTOMATIC GENERATION DO NOT CHANGE###.

You need a parser that handles changes on its own while maintaining an internal representation. Something like XML DOM (though not necessarily that exact API). There’s a handful out there, but they’re not widespread, and not on every language.

bitfucker ,

JSON5

frezik ,

Is a very good idea providing much needed fixes to the JSON spec, but isn’t really what I’m getting at. Handling automatic updates in place is a software issue, and could be done on the older spec.

bitfucker ,

Hmm, maybe I am missing the point. What exactly do you mean by handling automatic updates in place? Like, the program that requires and parses the config file is watching for changes to the config file?

frezik ,

As an example, Klipper (for running 3d printers) can update its configuration file directly when doing certain automatic calibration processes. The z-offset for between a BLtouch bed sensor and the head, for example. If you were to save it, you might end up with something like this:


<span style="color:#323232;">[bltouch]
</span><span style="color:#323232;">z_offset: 3.020
</span><span style="color:#323232;">...
</span><span style="color:#323232;">#*# <---------------------- SAVE_CONFIG ---------------------->
</span><span style="color:#323232;">#*# DO NOT EDIT THIS BLOCK OR BELOW. The contents are auto-generated.
</span><span style="color:#323232;">#*#
</span><span style="color:#323232;">[bltouch]
</span><span style="color:#323232;">z_offset: 2.950
</span>

Thus overriding the value that had been set before, but now you have two entries for the same thing. (IIRC, Klipper does comment out the original value, as well.)

What I’d want is an interface where you can modify in place without these silly save blocks. For example:


<span style="color:#323232;">let conf = get_config()
</span><span style="color:#323232;">conf.set( 'bltouch.z_offset', 2.950 )
</span><span style="color:#323232;">conf.add_comment_after( 'bltouch.z_offset', 'Automatically generated' )
</span><span style="color:#323232;">conf.save_config()
</span>

Since we’re declaratively telling the library what to modify, it can maintain the AST of the original with whitespace and comments. Only the new value changes when it’s written out again, with a comment for that specific line.

Binary config formats, like the Windows Registry, almost have to use an interface like this. It’s their one advantage over text file configs, but it doesn’t have to be. We’re just too lazy to bother.

bitfucker ,

Ahh, then the modification must be done on the AST level not the in-memory representation since anyway you do it, you must retain the original.

frezik ,

Right.

Michal ,

Yaml is more human readable/editable, and it’s a superset of json!

bob_lemon ,

Yaml is just arcane bullshit to actually write as a human. Nor is it intuitively clear how yaml serializes.

Aux ,

Yaml is cancer.

JackbyDev ,

It’s entirely disingenuous because who the hell is throwing JSON into YAML without converting it? Oh wow, I changed the file extension and it still works. I’m so glad we changed to YAML!

bitfucker ,

Until someone cannot tell the difference between tab and space when configuring or you miss one indentation. Seriously, whoever thinks indentation should have semantic meaning for computers should burn in hell. Indentation is for us, humans, not computers. You can write a JSON with or without indentation if you want. Also, use JSON5 to have comments and other good stuff for a config file.

themusicman ,

If you’re moving away from text formats, might as well use a proper serialisation tool like protobuf…

wtfrank ,

Yaml?

JackbyDev ,

For the love of all things pure, holy, and just, please do not use YAML in your APIs…

wtfrank ,

Fine, and if you don’t use json in your API because of the deficiency highlighted in the meme, what format do you use in your API?

JackbyDev ,

I use JSON. I have used Avro for things in Kafka but I’m not sure the benefits outweigh the negatives. Avro is much more complicated than people think and most folks don’t really have a strong desire to learn how it should be used and do stuff incorrectly. Everybody knows JSON and it works with everything though. (Example: so many people just hear that Avro schemas can be backwards compatible but have zero idea that you still need the schema that wrote the message even if you want to read it into a newer one.)

Interestingly, I take the meme as saying a dev is using the wrong types in their serialization format (using strings to store integers) which was my biggest problem with Avro. Mostly from people not using logical types or preferring to use ISO 8601 datetime strings instead of the built-in timestamp-millis type.

bleistift2 OP ,

Hell, no. If I wanted to save bytes, I’d use a binary format, or just fucking zip the JSON. Looking at a request-response pair and quickly understanding the transferred data is invaluable.

douglasg14b , in Implementing RFC 3339 shouldn't really be that hard...
@douglasg14b@programming.dev avatar

Never not UTC Everywhere.

utceverywhere.com

ooterness ,

UTC is better than most, but leap seconds are still awful. Computers should use GPS or TAI everywhere. Dealing with time zones and leap seconds is for human readability and display purposes only.

jerkface ,
@jerkface@lemmy.ca avatar

That’s why I only ever use Seconds Since Epoch.

apprehentice , in Implementing RFC 3339 shouldn't really be that hard...

When the API returns UTC, but the system insists on giving you local time… but there’s an extension method that accepts DateTimeOffset?

agressivelyPassive ,

Or requires a timestamp with zone offset, but ignores the zone offset, so you have to send the timestamp itself with a zone offset of zero relative to the systems timezone, but can’t just omit the zone offset, because it’s required.

bleistift2 ,

When the API returns UTC, but mandates that you give it an offset which it will add or subtract from the UTC time, while still adding the Z at the end.

mox , in Implementing RFC 3339 shouldn't really be that hard...

Wait til you see what’s required to parse HTTP-date fields.

RFC 9110

ik5pvx , in Implementing RFC 3339 shouldn't really be that hard...

There’s an even worse thing: timezone selection UIs that don’t let you choose UTC

Klear , in Average CSS

No! I wanted orange!

nikaaa , in How programmers comment their code

Good code is self-explanatory. You should only comment your code if it does something unexpectedly complicated.

That being said, it’s always a good idea to write a manual, about how to use the code. Don’t document how it works, because those who can code will understand it anyways, and those who can’t, have no need to understand it.

photonic_sorcerer ,
@photonic_sorcerer@lemmy.dbzer0.com avatar

Regardless, comments do speed up understanding.

BorgDrone ,

Good code is self-explanatory. You should only comment your code if it does something unexpectedly complicated.

The code shows what is being done. The comments should explain the why.

independantiste ,
@independantiste@sh.itjust.works avatar

Yes. This 1000x. I hate it at work when I come across code that was written 3 years ago that has literally no traces of why it’s there and a quick summary of what it does. Especially because that code is always the most abbreviated spaghetti you’ve ever seen. People should stop thinking (their) code documents itself because 99.999% of programmers cannot do it right.

I really like the Google way of coding: assume the person reading the code is the most 1337 programmer ever, BUT that this person knows absolutely nothing about the project

BorgDrone ,

Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live.

dan ,
@dan@upvote.au avatar

This is something a lot of people don’t seem to understand. Even if code is self-explanatory, I want to know why it was designed that way.

I’ve fixed bugs where the fix was only a one line change, but it was extremely difficult to figure out, so I left a 10ish line comment above it explaining why it has to be done that way.

potustheplant ,

Hard disagree. It’s a lot easier and faster to understand a function that is prefaced with a small line of text explaining what it does rather than trying to figure it out yourself.

It’s not about whether you can understand the code or not, it’s about efficiency and clarity.

Aux ,

Hard disagree - that’s just dumb:


<span style="color:#323232;">// Calculates tax
</span><span style="color:#323232;">function calculateTax() { }
</span>
uis ,

Hard disagree - that’s very helpful:


<span style="color:#323232;">// Calculates Personal Income Tax by formula from section 1.2.3 of tax code. Other taxes like VAT are not calculated.
</span><span style="color:#323232;">function calculateTax() { }
</span>
potustheplant ,

This guy gets it.

Aux ,

If it calculates personal income tax, just call calculatePersonalIncomeTax.

uis ,

Why not calculatePersonalIncomeTax123 then?

Aux ,

Yeah, why not?

usernamefactory ,

I’m a new developer. Is that referring to page 123 of the in-house documentation? Version 12.3 of the code? I have no clue.

You’d have to call it something like calculatePersonalIncomeTaxPerTaxCodeSection1_2_3, but I get exhausted just looking at that. There comes a point where the cognitive work of reading crazy long camel case names is more trouble than it’s worth.

An explanation of what specification a function was written to implement is a perfectly appropriate comment. Could be improved by a direct link where possible. But it’s worth noting what that comment isn’t doing - specifying any implementation details. For that, I really can just read the code.

plecks ,

Is that state, federal, or combined?

Aux ,

Add a flag.

weststadtgesicht ,

If done right, the “what it does” is in the method name. If your method is too complicated to summarize in its name, chances are good you should split it up or extract parts of it.

Aurelius ,
@Aurelius@lemmy.world avatar

Yeah, just 15 seconds and jot down a comment. Whenever I’m even hesitant, I just leave a comment. Doesn’t hurt anything and it can always be removed if not needed

Easier to remove later rather than add it after the fact

TORFdot0 ,

This is true, but it’s easier and faster to parse plain English and so if I don’t adequately comment my code the first time. I will be commenting it when I have to return to it for whatever reason. Honestly the second round of commenting is more verbose and clearer than the function x does y style of comments I tend to make when coding the first time

tiredofsametab ,

Asinine business logic can still make some things very hard to read and digest no matter how well-planned and well-written it is (particularly if it is rushed by the business meaning that engineers don't have time to do it well). As such, there are places where code can't/won't be self-documenting to a useful degree.

FlyingSquid , in Mcafee accidentally made users call the devs of SQLite and complain.
@FlyingSquid@lemmy.world avatar

I used to tell people that John McAfee always exited a room by jumping through a window while yelling, “MCAFEE RULES!” Which he didn’t, but maybe he did? Anyway, I miss that crazy motherfucker. Sometimes nuts make the world more fun.

Buddahriffic ,

He was an interesting one but not a good one.

bleistift2 , (edited ) in Mcafee accidentally made users call the devs of SQLite and complain.

Forgive my ignorance. SQLite is a database software. Why would McAffee create lots of database files?

[Edit:] I’m not asking why a program needs to store data. I’m asking why that necessitates many files. One database file (or one per table) should be enough, right?

Zorsith ,
@Zorsith@lemmy.blahaj.zone avatar

Virus definitions?

bleistift2 ,

Does sqlite create a file for every page in the table or what?

Shadow ,
@Shadow@lemmy.ca avatar

No, but developers are free to implement things in whatever crazy way they can dream up.

Zorsith ,
@Zorsith@lemmy.blahaj.zone avatar

Nobody ever accused McTrellix of being efficient software 😆

qaz ,

Many programs use SQLite internally and McAfee decided to store the database files in C:/Temp

7uWqKj ,

No, these are sqlite temp files, not the database files. McAfee had no control over the temp files.

towerful ,

Sqlite is a great embedded database.
If you are storing lots and lots of information in a JSON file, CSV file, or coming up with your own serialisation… Chances are, sqlite is going to do it better.
I know loads of android apps use sqlite for storage. I’ve also managed to open quite a few programmes “proprietary” file format in sqlite.

anton ,

A yes, the two genders of binary file formats: renamed sqlite file and renamed zip folder.

ElderWendigo ,

Aren’t sqilte files themselves (like most other things) just fancy text files?

FooBarrington ,

Nah, only actual string data is stored as text. Everything else is stored as binary: www.sqlite.org/fileformat.html#record_format

The file also isn’t written sequentially, it’s stored in blocks (pages), where sometimes later data can be inserted in the middle (e.g. when data was deleted).

ElderWendigo ,

I did say fancy.

FooBarrington ,

Then I guess my laptop is just a fancy boat.

tofubl ,

Haven’t seen your laptop, but if it’s anything like mine it’s a very lousy boat.

Laser ,

Ahoy sailor

sunbeam60 ,
shotgun_crab ,

Don’t forget renamed and compressed xml + zip

GBU_28 ,

Al sorts of applications would enjoy a database to log all sorts of stuff, store results, capture events, etc.

SQLite is great because it doesn’t necessitate another infra dependency as it is stored to file

Michal ,

The program needs to store multiple temporary files (one per virus definition update, or scan results or whatever purpose).

It looks like they simply picked sqlite as a format because the data has a structured format and that way they leverage databases robustness, easiness to read and query the data.

The comment appears to be from 2006. Sqlite mightve had some limitations then that necessitated creating a new (temporary) database file as a subset of larger database for performance reasons or to allow multiple processes to read/write them and then consolidate data back into the single database.

laserm , in Old timers know

I deploy my apps with SFTP command line .

livingcoder , in Mcafee accidentally made users call the devs of SQLite and complain.

I love how the solution didn’t involve changing the prefix to “mcaffee_”. Now users don’t know who to blame. Great. That’s so nice of them.

camr_on ,
@camr_on@lemmy.world avatar

Then mcaffee_ would be appearing in unrelated sqlite-using applications

livingcoder ,

Oh, I thought that the temp files were named by the user. If that’s not the case, that these are not databases created specifically by McAfee in the temp directory, then I’m not sure what the appropriate solution should be. Obscuring the file type and how the file is used from users is still a bad practice.

Daxtron2 ,

Why would sqlite put references to an unrelated product in their codebase?

Hawke ,

The same reason that McAfee did?

dgriffith ,

McAfee wrote a program that used the Sqlite library for database storage.

When going about its data storage business for McAfee’s program, the Sqlite library was storing files in C:\temp with prefixes like sqlite_3726371.

Users see that and get angry, and bug the Sqlite developers.

Now probably when initialising the Sqlite library McAfee could have given it the location of a directory to keep it’s temp files. Then they could have been tucked away somewhere along with the rest of the McAfee code base and be more easily recognised as belonging to them, but they didn’t.

So because of a bit of careless programming on McAfee’s part, Sqlite developers were getting the heat because the files were easily recognisable as belonging to them.

Because the Sqlite developers don’t have control of what McAfee was doing, the most expedient way to solve the problem was to obfuscate the name a bit.

livingcoder ,

Yeah, if it’s purely a Sqlite implementation detail to create temp files, that’s on them to own and fix. I thoroughly dislike that the files are obscured from users.

dan ,
@dan@upvote.au avatar

McAfee might be doing something weird with the database, for example not closing it properly.

Daxtron2 ,

McAfee didn’t, sqlite produces that name on its own. Its McAfee that stored them weirdly

SwordInStone ,

the solution is not on the mcafee side but on sqlite

MostlyBlindGamer , in Mcafee accidentally made users call the devs of SQLite and complain.
@MostlyBlindGamer@rblind.com avatar

Wasn’t there a story about people calling curl devs because of car issues?

For what it’s worth, I’m sure the SQLite devs could help somebody clean up their temp files. They just really shouldn’t have to.

ABasilPlant OP ,

Are you talking about this: I have toyota corola?

MostlyBlindGamer ,
@MostlyBlindGamer@rblind.com avatar

Yes! Hahaha, it’s so good.

Number 2 needs to flick the little switch on the SD card.

where_am_i ,

and so the internet wisdom has solved the person’s problem. Alas they will never find out

DogWater ,

Their issue is that the card has the physical lock switched on on the SD card?

MostlyBlindGamer ,
@MostlyBlindGamer@rblind.com avatar

Chances are, right? At least it’s the first thing I’d check.

DogWater ,

Ha that’s a good point.

RedStrider , in Average CSS
@RedStrider@lemmy.world avatar

the userstyle experience:

Ephera ,

Yeah, userstyles are wild. You learn so many ways how to not use CSS. Everything is !important and rather than adjusting the HTML to change the structure, you get to do it all in CSS. 🫠

RedStrider ,
@RedStrider@lemmy.world avatar

flex-direction:row-reverse; my beloved

zerofk , in How programmers comment their code

Our code base is filled with “//constructor”, “//destructor”, “//assignment”, or the ever enlightening “Foo GetFoo(); // GetFoo”.

This is not what they mean by self-documenting code.

dohpaz42 , in Mcafee accidentally made users call the devs of SQLite and complain.
@dohpaz42@lemmy.world avatar

Hm. The first hit on DuckDuckGo is a single entry for a guy and all it says is Contact the Business Inquiries.

You would think a better solution to this problem would be to put a message on that page stating that if you’re a McAfee user looking for information about SQLite files in your temp folder, to call the McAfee support line.

But hey what do I know, right?

Killing_Spark ,

Did you just expect people that call random devs at random times to actually read any information on a website?

dohpaz42 ,
@dohpaz42@lemmy.world avatar

If that information said something like “McAfee users concerned about temp files, call (800) 123-4567”, then yes. Did I suggest anything more than that? No. 🙄

cm0002 ,

Lol you never worked customer service or hell desk have you?

The kinds of people who need this message, you would have lost the second you said “temp files”

tyler ,

Well these people making these calls are finding the temp folder

cm0002 ,

Irrelevant, these people will find their way into folders they have no business in and no idea what it’s doing and break shit

It’s a big reason MS started hiding the windows folder after Win 98 (maybe 95)

dohpaz42 ,
@dohpaz42@lemmy.world avatar

How is that irrelevant? The folder is literally called Temp. Doesn’t matter anything else. You said, and I quote, “The kinds of people who need this message, you would have lost the second you said “temp files”.”

Obviously not sure, given where the files were located. 🤦‍♂️

And of course they didn’t know what the files were for; probably why they went searching for it, and eventually found the contact info for Richard Hipp.

Me thinks you just want to shit on people for no other reason than to make yourself feel superior to them. 👏 Congrats!

T156 ,

Assuming that they went out to look for it, and didn’t just poke google with (“sqlite hacked my computer”) until they found a phone number.

If they had gotten the phone number for a company called Super Queasy Lite and Easy/SQLitE instead of the developers, the company might well have received the calls instead.

tyler ,

Assuming that they went out to look for it, and didn’t just poke google with (“sqlite hacked my computer”) until they found a phone number.

and how in the world did they know to type the word “sqlite” in. Dude, the files are in the temp folder. The only way they know the name “sqlite” is if they literally visited the folder and looked there.

T156 ,

Error message? McAfee can’t write to the drive because it’s full of photos of their grandchildren and dogs, so it clicks up “can’t write to c:\temp\sqlite_arcane_computer_magic.log: Disk is full”, and it goes from there?

dohpaz42 ,
@dohpaz42@lemmy.world avatar

You do realize that these people were looking up contact info from a company they found because they were … wait for it … looking at files inside the temp folder … otherwise known as … are you sitting down? You really should sit for this … temp files!

Imaging that. 😳 🤣

By the way, I worked technical support for my local dialup ISP, Adobe, Best Buy (before they were called Geek Squad), and OnStar.

But sure, what you said… 😉

relevants ,

looking at files inside the temp folder … otherwise known as … are you sitting down? You really should sit for this … temp files!

The point OP is making is that those people would not put 2 and 2 together to understand that the files they were looking at are called temp files, just because that’s the folder they found them in. They may not even remember the name of the folder, only that it contains a bunch of files with a prefix they’re now googling.

Not sure why I’m bothering explaining this to you, the way you responded makes you look absolutely insufferable, but maybe someone else who comes across this will find it useful.

randint ,
@randint@lemmy.frozeninferno.xyz avatar

hell desk

Brilliant.

ricecake ,

Yup, you found the developer. That’s his phone number.

It’s not exactly a new change either. In 2006 people weren’t going to the specific page from duckduckgo, they were probably finding the sqlite homepage, and then tracking down the contact info.

20 years later it’s probably better to maintain consistency with the prefix than to change it even if it’s weird.

poke ,

Update the site with mcafees phone number and only have the real one behind a click through you have to read

ricecake ,

So, sure that might work. More likely they forgot this bit is even here on account of it being 20 years old.

Also, never doubt the persistence of a sufficiently motivated and impatient user. I don’t think needing to read something has ever stopped one.
You can literally put animated flaming text and people will click right past.

mr_satan , (edited )
@mr_satan@monyet.cc avatar

During my time in a call center people would often call for invoices or messages they received. Most of my work there was reading the thing together with them. Nothing more was necessary, I just read alound their itemized invoice that they had received and it would solve their problem.

Click through pop-ups are even worse in this regard. I myself usually just automatically click No before I understand what just happened.

ricecake ,

I worked for a developer at a Web hosting company for a while. I really wish my story about flaming text wasn’t true, and that the words weren’t “permanent unrecoverable data loss”, and the audience wasn’t internal support technicians.

Gotta have a way to delete a vps, and there’s only so much you can do to get someone to check that they have the right one.

vcmj ,

The way I understand the users didn’t necessarily realize McAfee is responsible, just that a bunch of sqlite files appeared in temp so they might not connect the dots here anyway. Or even know McAfee is installed considering their shady practices.

dohpaz42 ,
@dohpaz42@lemmy.world avatar

Fair point about not knowing McAfee if involved. But at the same time, it beats having your dev getting phone calls at all hours because McAfee’s devs were to lazy to ready the source file and learn how to change the freaking prefix of the file.

  • All
  • Subscribed
  • Moderated
  • Favorites
  • [email protected]
  • random
  • lifeLocal
  • goranko
  • All magazines