programming_horror

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

Aatube, (edited ) in C++23 has fixed space!

I forgot the alt text 🤦 here's the markdown (source):

Trimming whitespaces before line splicing

As of C++20, what's the output of the below piece of code (Godbolt)?

int main() {
int i = 1
//  
+ 42
;
return i;
}

Without having seen how the code is formatted I would have said that it's 1 + 42, so 43. And actually, that's the real output. On MSVC. Not on other compilers, such as GCC and Clang.

These latter ones return 1. The reason is that they trim the trailing whitespaces before handling splicing. The new-line character following is a whitespace, it's deleted, therefore + 42 ends up on the same line as // and it becomes part of the comment.

Just for the record, both implementation strategies are valid.

P2223R2 change this situation and set the GCC/Clang implementation strategy into stone standard. This might be a breaking one for code that is only compiled with MSVC, but it shouldn't happen on a big scale.

We might remember Matt Godbolt saying earlier in one of his talks that one of the superpowers of C++ is backward compatibility and here the change potentially breaks code. At the same time, it's worth noting that implementation-defined behaviour would break here and not standardized behaviour.

The reason behind going in this direction is that many IDEs, code formatters and other tools already discard trailing whitespaces as the Google style guide and most of its derivations already forbid them.

I've changed the Godbolt link and code because the original didn't have the trailing whitespace, lol.

Aatube, in C++23 has fixed space!

Just in case anyone asks (they always do):

I use Bionic Reader to bold the start of words so it reads faster.

I also use Toucan.

Oh, and just block that guy. I wonder if lemmy or mbin can implement IP-blocking.

Mikina, in Who needs a commit message, anyway?

I think that there’s one important point to consider that may not be immediately obvious, when deciding about commit messages in FOSS project, even if you are not accepting contributions and just want to share your work for others - auditabilty.

7-zip has been receiving critique for this for a long time - not having commit messages makes it way harder to check what the actual changes were. Sure you can’t trust commit messages during an audit, but it makes it a lot easier - either you immediately notice that they are lying, or they are correct and will help you with understanding the change, so you can decide for yourself whether it’s safe.

Of course, the author is doing a lot of work for free, that he offers to others, so we have no right to blame him for it or demand he changes his approach. I’m grateful for any FOSS project, and demanding from someone directly that he’s doing it wrong and should do it some other way (or belittling him for it) isn’t OK. However, I’d probably be very careful when encountering a repository like this, and reconsider whether it’s worth adopting. Which is absolutely ok and I don’t blame the author for it in the slightest - it’s his repo and his work - but I also think that auditability may be something the author didn’t realize, and assuming his goal was to share his code with others i.e to build a portfolio, may affect his overall adoption rate. But it’s also ok if he simply doesn’t care about that.

But in general, if you’re making a FOSS project, I’d recommend sticking with good commit messages.

Lmaydev,

Commit messages are as much for me as other people tbh. As long as your commits aren’t massive I don’t really think it’s much work either for the benefits.

But like you say we have no right to demand anything from people giving up their free time for us. We can just choose not to use it.

mac, in `float` as table *id*
@mac@programming.dev avatar

Image in the tweet for those who dont want to click

https://programming.dev/pictrs/image/1d1c4dfe-2385-4db1-ae38-ea6aaeb0d56b.png

drsensor, in Who needs a commit message, anyway?

At least it’s better than me messing up with the commit date :v https://github.com/DrSensor/rescript.nix/commits/trunk/

inspxtr,

lol how did u do that?

kryllic,
@kryllic@programming.dev avatar

Don’t commit near a black hole, apparently

wischi, in Who needs a commit message, anyway?

Not really programming horror. Just open source. They did something, are kind enough to make it open, they don’t care about commit messages so what?

Sibbo,

This. Like if they are working for free for the public good, don’t complain if they don’t do it thoroughly enough. If someone volunteers to pick up trash from the park, you wouldn’t complain if he misses some things or stops before the whole park is clean.

ExtraMedicated,

For me, the thing is, commit messages aren’t just for other people. They can be invaluable in case you need to look back for something. I even write them for my personal repos that aren’t even on the internet, because it’s really just kinda dumb not to.

Sibbo,

Yeah, but that doesn’t mean that everyone else has to work as methodical as you do for any project they do. Even if it is more efficient and saves time in the long term.

Maalus,

Okay, so how is it possible to make quality open source software, if you don’t expect the programmer to do a good job, and instead you praise them for doing whatever?

Killing_Spark,

Pay. Them.

Maalus,

Yeah, exactly. Which is a completely different beast when the open source project is made by 3 dudes in a basement. So either you get support from a huge foundation like Apache, spend your own money for little gain, or your project is shitty quality-wise

Killing_Spark,

The only way you can start expecting quality is if you start paying for it. Otherwise you are just judging people for how badly they built their hobby project in their free time.

It might currently be complicated to do that but that just means we need infrastructure. Start complaining about that or do something about it if you want more quality open source software.

RonSijm,
@RonSijm@programming.dev avatar

It’s not even the “quality of the project” like suggested in this thread. It’s the quality of the commit messages (meta-data, documentation)

That’s like someone who paints for a hobby, and shows their paints off on the internet, and people would post stuff like “Well cool painting, but you didn’t really explain what kind of paint you’ve used, who your inspirations were” etc etc

When I’m building Open Source stuff as a hobby for things that are useful to me, and also dump them on Github - because it’s a good backup system - I don’t really care whether people might go through the commit history as means to figure out how I’ve build it

Killing_Spark,

I’d say that good documentation is also a part of quality of a software project, more so than in other fields, but I do agree that it is one of the things you can just forget about for personal projects.

pkill, (edited )

market capitalism will prioritize putting most resources into spyware and adware that turns the consumer into a product. Along with that constant reinventing of the wheel in proprietary software in the name of “competition”, even though index/hedging funds oligopoly leads us into stagnation in terms of innovation these days with one ‘next great thing’ after another turning out to be mostly an overspeculated fad. I’d say vote for pirate parties but that’s actually BS as is all parliamentary politics in this quasi-aristocratic system, even if they launch large scale grant programmes they’ll very likely back down on them whenever an economic slump happens.

Sibbo,

Just don’t use it if you don’t like it. And you may not believe it, but there are also OS devs out there that - as a hobby - leave the park behind sparkling clean. It’s not like everyone would produce low-quality open source projects, but no one is entitled to judge a low-quality project.

Mikina,

Well, the first step is to not be an elitist gatekeeper who scares away any beginner who tries to develop open source stuff. Because even if their first few repositories were not exactly good, they may eventually get better, and if their experience with FOSS community was a pleasant one, there is a pretty high chance they will publish their later work too.

If, on the other hand, you publicly shame every mistake a beginner makes in hist first repository, they will probably never publish anything.

It’s important to praise anyone who’s self-less enough to write FOSS. Even if they aren’t exactly good yet, just the fact that they have decided to publish it is really important. I’m not saying that we shouldn’t offer any negative feedback - quite the contrary - but the feedback definitely shouldn’t be public shaming in a meme post on random social network.

Maalus,

Yeah for sure don’t shame them. But also, don’t merge code that is bad. Opensource needs standards too because at the end of the day it’s competing with closed source. Even if it’s a first contribution, you probably shouldn’t merge things without tests, without commit messages, etc

jwaters42,

Eh, I still think it’s worth calling out sloppy practices like this. At a minimum, drawing attention to it is a way to socialize good practices for others and to spark discussions (like this one!) Nobody is saying this person shouldn’t be putting code out there, they’re just pointing out some pretty gnarly code hygiene. One could argue this is actually one of the main strengths of open source development! Consider the parallel of somebody giving away free food- if they are using unsafe practices like not keeping things at proper temperatures or picking their nose while handling food, there’s nothing wrong with critiquing them, even if their intentions are good.

Mikina,

I agree, however I think that we could’ve raised the issue even without directly mentioning the developer or his repository, and could have discussed it without directly pointing at someone who did it.

Because that only derailed the discussion into whether he personally can or cannot do it (which he definitely can), instead of focusing on the best practices about commit messages in FOSS projects in general.

I also think that there’s a pretty huge difference between offering someone advice directly when interacting with him, such as your example about unsafe food practices, and posting a meme post with his name to an entirely unrelated social network.

So, for your example, I think it’s ok to either talk to the guy handing out food, to comment on his post about it. However, if you took a recording of him doing it, and posted it publicly to Facebook while mentioning him by name (and not even tagging him, so he isn’t notified) - that’s not a good way how to give meaningful feedback or critique.

kogasa,
@kogasa@programming.dev avatar

It’s certainly not as if anyone is entitled to anything better. It’s just bad practice. I wouldn’t want people critiquing me based on the work I do for free either, though.

wischi,

And that’s the issue I have with that. Imagine you are fabricio and you find this post. Next time you probably won’t make it public even if there is a remote chance, that it might help someone else.

Mikina,

I agree, the post shouldn’t have called him out directly by name. It should’ve been a post of just a screenshot with the commit messages, and not mention the repository or the person. It’s definitely not nice, and may even affect the person - I mean, if I was called out like that somewhere and seen people laughing at my practices, I wouldn’t be exactly happy.

On the other hand, I think that raising the issue in itself - FOSS repositories without commit messages - is a pretty good discussion that fits here well. It’s just a shame that it had to be at the expense of some FOSS developer, because it also derails the discussion into talking more about the guy and whether he can or cannot do it (such as your comments, which I agree with), instead of focusing on what are the issues with FOSS projects without commit messages in general. Because there are many arguments why it’s important, and a few arguments about why it shouldn’t matter, which makes for an interresting discussion about best practices and why they are important.

InEnduringGrowStrong, in Who needs a commit message, anyway?
@InEnduringGrowStrong@sh.itjust.works avatar

‘commit 1’

throwafoxtrot,

This is unnecessary. There is a tool that makes the commit hashes themselves numeric and monotonicity increasing.

kevincox, in PSD is not my favourite file format.
@kevincox@lemmy.ml avatar

It appears that the original repo may be lost to time. But here is an archived copy:

web.archive.org/web/…/XeePhotoshopLoader.m#104

CodexArcanum, in Almost had to mark this one NSFW

Trivially, could also just be a retVal.map(self.cleanupMetadata)

kevincox,
@kevincox@lemmy.ml avatar

But it can’t! (Maybe)

calling map(obj.func) will pass func but won’t set the this parameter correctly. If the called method uses this you will have a bad time.

The code you actually want would be retval.map(v => self.cleanupMetadata(v)) or the old-skool retval.map(self.cleanupMetadata.bind(self)).

Also the first version reuses the Array which may be important, but even if not will likely result in better performance. (Although this is likely mitigated by making the array polymorphic depending on the return type of cleanupMetadata and the overhead of forEach vs map.)

Wow, isn’t JS a great language.

orclev, in Almost had to mark this one NSFW

Entire block could literally be replaced with arr[index] = self.cleanupMetadata(subValue).

charolastra,

What about figuratively?

orclev,

Figuratively the block could be replaced with a roll of duct tape and some chewing gum.

thedirtyknapkin, in PSD is not my favourite file format.

i mean shit, it’s a legacy code issue. they made that format in the ninties to work with the limitations of 90s computers. since then they’ve just kept adding features and not starting over. it’s the same reason the davinci resolve has better color tools and is way less crash prone than premiere. premiere can’t do direct color manipulation, it does some kinda weird simplified math based on some kind of analogous curve or something like that. 90s computers simply couldn’t handle the amount of color calculations needed to do it properly. resolve just uses your modern system to do the direct calculations. idk, i barely understand it and I’ve only ever met like 2 people that could tell me more about it…

xoggy, in PSD is not my favourite file format.
@xoggy@programming.dev avatar

When they say writing code comments is important this is what they mean. This is how we programmers pass on important life lessons that save the next dev weeks of heart pain and hair loss.

kryllic,
@kryllic@programming.dev avatar
HelloHotel, in case when horror then omg else jfc end fml
@HelloHotel@lemmy.world avatar

What idiot wrote that one by hand

NerdyPopRocks, in Wikipedia's "official" newspaper's formatting

But does it work? XD

Aatube,
Aatube avatar

yes

Robmart, in as a Jeff I find this extra concerning [x-post]

Are they using the names as the keys?

  • All
  • Subscribed
  • Moderated
  • Favorites
  • programming_horror@programming.dev
  • kavyap
  • ngwrru68w68
  • tacticalgear
  • DreamBathrooms
  • mdbf
  • magazineikmin
  • thenastyranch
  • Youngstown
  • Durango
  • slotface
  • everett
  • vwfavf
  • rosin
  • anitta
  • Leos
  • khanakhh
  • GTA5RPClips
  • cisconetworking
  • InstantRegret
  • ethstaker
  • osvaldo12
  • tester
  • provamag3
  • modclub
  • cubers
  • normalnudes
  • megavids
  • JUstTest
  • All magazines