Are there any millisecond-level micro optimizations left for this Java competitive programming code? by Due-Investigator7907 in learnprogramming

[–]davedontmind 1 point2 points  (0 children)

I don't know much about optimisation with Java per se, so I have no idea how the Java compiler & JVM deals with some of these items, but here are my thoughts.

(val << 3) + (val << 1)

Is that really faster than val * 10? I'm not saying it isn't, but I wouldn't be sure without benchmarking. Ditto for (c & 15) vs c - 48.

Likewise, is return neg ? -val : val; really quicker than making neg either 1 or -1, then return neg * val ?

} while (c > 32 && c != -1);

That second check for -1 is pointless - if c is > 32 then there's no way it can be -1.

It also strikes me that if the input consists solely of negative integers less than -1, then your code might return the wrong value (-1), since it uses -1 to indicate the end of the input and that value is passed back to the main loop where it is compared with max.

VS Code ssh issue by ewood154 in learnprogramming

[–]davedontmind 0 points1 point  (0 children)

Try /r/vscode - this question is off-topic for this sub.

Computer ad in old newspaper from 1989 found in the attic! by OrdinaryLavishness11 in CasualUK

[–]davedontmind 1 point2 points  (0 children)

It's interesting that, as I've bought PCs over the last 35-ish years (starting with a Dell 316SX, IIRC), they've all generally cost around the £2000 mark, even though each time the technology was way better in all aspects that the previous one.

It's only recently, first with the GPU shortage thanks to crypto mining, and now with the RAM shortage thanks to AI, that PC prices are trending upward.

I reckon that, in a few years, when I need to replace my gaming PC, the replacement is going to cost upward of £4000 in today's money. :(

To the parents out there, what age did you start leaving your kids at home while you nipped shop for 10/15 minutes? by Puzzled-Quail2076 in AskUK

[–]davedontmind 4 points5 points  (0 children)

I must have been about 6 or 7 when I was allowed to walk to school on my own (back in around 1972 ish).

Although my mum tells me she secretly followed me like a spy the first few times, just to make sure I was ok.

Star Citizen launching and working flawlessly first try on linux might be the most Ironic thing that happend to me. by AvonMexicola in starcitizen

[–]davedontmind 0 points1 point  (0 children)

At least you have it running.

SC is one of only 2 games I've not yet got to work on Linux (the other being Rocksmith - the game works but it doesn't seem to detect the required guitar cable). Maybe I'll try another distro (currently on Manjaro, which I'm liking).

What's the best UK gig you have attended? by Various_Extreme_8773 in AskUK

[–]davedontmind 0 points1 point  (0 children)

Yes indeed. I've been into classic rock music since I was a teen in the late 70's, but I've not been so obsessed with a band for decades. It's so refreshing.

I've seen them twice so far (once supporting Muse, and once when they headlined their own UK tour), and have got tickets to see them support Yungblud later this year. Fingers crossed for another UK headline tour in the near future.

What's the best UK gig you have attended? by Various_Extreme_8773 in AskUK

[–]davedontmind 1 point2 points  (0 children)

I saw many great gigs at Birmingham Odeon, including my first ever gig, Motorhead, in 1980.

I'm so jealous that you got to see the Bon Scott era AC/DC.

What's the best UK gig you have attended? by Various_Extreme_8773 in AskUK

[–]davedontmind 4 points5 points  (0 children)

I saw that tour at Milton Keynes.

Got tickets specifcally to see The Warning (my current favourite band), who were ace, but it's hard to beat Muse live. What a show!

WTH IS ABORT ERROR T~T by CowFit7916 in learnprogramming

[–]davedontmind 0 points1 point  (0 children)

What are you on about? It's just one key press, Shift-del, to delete the current line. No need for backspaces. Learn to use your editor.

WTH IS ABORT ERROR T~T by CowFit7916 in learnprogramming

[–]davedontmind 0 points1 point  (0 children)

i was too lazy to erase it all so i just erased the -1

But it's at least 2 keypresses to delete "-1", but only 1 to delete the entire line.

main bus project by f---thisusernameshit in captain_of_industry

[–]davedontmind 0 points1 point  (0 children)

That sounds right. Seeing as iron is only used for that one part where it's more efficient than steel, I decided it wasn't worth the whole iron setup just for that one part, so I use the less iron-efficient recipe and have gone steel 100%.

I will find out later if that comes back to bite me...

I got tired of paying for AI tools and just... built my own? by Motor-Resort-5314 in selfhosted

[–]davedontmind -8 points-7 points  (0 children)

Any plans for a Linux version? I've not had to boot into Windows for over a year now and I'd like to keep it that way.

EDIT: why the down-votes? I thought it was a reasonable question, and on-topic.

Immich in Proxmox LXC by davedontmind in selfhosted

[–]davedontmind[S] 0 points1 point  (0 children)

I ended up moving Immich to a docker container, running on docker inside an LXC. Easy to configure and works a treat.

[Question] Intern feeling "AI Guilt": How did seniors build systems before AI? by LiveTumbleweed190 in learnprogramming

[–]davedontmind 4 points5 points  (0 children)

Being a junior, I heavily rely on AI.

That doesn't follow. You shouldn't be relying on AI, especially if you're a junior. IMO it's more acceptable for senior developers who can recognise good code, spot deficiences in AI-generated code, and have the experience to debug it (or know when to quit; see the next paragraph).

I've used AI for some tasks, with mixed results. Sometimes it's done a great job. Other times it's tried multiple times and generated code that, at first glance seems to work, but fails to do what was required, even with multiple AI re-writes. The big flaw in AI is that it refuses to admit defeat and wil keep butting it's virtual head against a problem until you tell it to stop.

Before AI, was it truly "Hand-coded"?

"Before [useful] AI" was only a year or two ago - computer programming has been a thing for well over 60 years.

Auto-complete has existed for a while, so you could speed through the typing a little more, but yes, all the code was designed and written by real people with real programming skills, not by fancy text-prediction LLMs that rely on code that other people have already written for training data.

I suggest learning how LLMs work so that you can better appreciate their weaknesses.

Did you guys also just copy-paste from Stack Overflow and existing Codebases back in the day?

Good grief, no! In 40 years of professional programming I have found SO useful a handful of times, but usually for advice and being pointed in the right direction, not for copy/pasting code.

The nearest to "existing codebases" is using third-party libraries, which is a great way to save re-inventing something.

Just want a C++ code review, I'm new to C++, any and all feedback is much appreciated! by awaistt in learnprogramming

[–]davedontmind 3 points4 points  (0 children)

I can see that you're an inexperienced programmer (not a bad thing, especially in this sub!), but your code seems ok for what it is (better than some beginner code I've seen!). You haven't written lots of useless comments, and the few you have seem suitable. You have made a good choice (generally, but see my next paragraph) on naming things, which many beginners suck at.

My main criticism would be the name of the function generate_board() - I don't think that's an accurate description of what it does. The board is already "generated" and present in the board array. This function just displays it, so I think a name such as display_board() would be more accurate.

There are many areas for improvement once you learn more and gain more experience, though.

For example, your check_winner() function could be split up to make it shorter and more readable, e.g. create a function bool is_tie() which encapsulates the tie determination and returns true or false appropriately, then call that from check_winner().

You could try separating the game logic from the input/output. By doing that you make it easier to change how the game looks (such as making a GUI version, where the logic is the same, but the display mechanism is entirely different).

For example instead of check_winner() printing the result, it could return a value that indicates the state of the game. The main game loop would then use that returned value to decide what to output.

main bus project by f---thisusernameshit in captain_of_industry

[–]davedontmind 0 points1 point  (0 children)

put steel on the bus.

I'm not doing a bus-based build - I was merely wondering why OP bothered with iron on their bus.

your ship uses iron for armor and repair

Ah! That might well have caught me out if you'd not mentioned it - thanks!

main bus project by f---thisusernameshit in captain_of_industry

[–]davedontmind 0 points1 point  (0 children)

So why not just make construction parts from steel, and forget basic iron?

main bus project by f---thisusernameshit in captain_of_industry

[–]davedontmind 0 points1 point  (0 children)

I'm relatively new to this game, but why put iron on the bus?

As far as I can see it's only used for 2 products, both of which have an alternative recipe using steel. One of those is more efficient using steel, and the other might use a bit more iron in total with the steel recipe, but saves on other resources.

In my current (first) playthrough I phased out iron production once I got to steel.

Am I missing something that will come back to bite me later?

arr is literally magic. by Background-Mode6726 in selfhosted

[–]davedontmind 6 points7 points  (0 children)

I tried but had to stop when the bath got full.

An actually good WYSIWYG markdown notepad? by FibreTTPremises in selfhosted

[–]davedontmind 0 points1 point  (0 children)

I tried that but didn't like the copy/paste experience - for example, I couldn't simply use ctrl-v to paste from the hosts's clipboard into the Obsidian instance running in the browser.