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.

SkyNTP , in Me after I got fired

This wouldn’t pass PR review and automated tests, unless they were a senior dev and used elevated privileges to mess with things behind the scenes.

maynarkh ,

It’s bold to assume those exist. Maybe there’s a reason the coworker left

Hazzia ,

Can confirm, just left a team that had 3 people for 4 pieces of legacy software and still used subversion

maynarkh ,

SVN has legit use cases still though. Git LFS is not or just barely supported in a lot of industries.

frezik ,

rand() will be infrequent < 10 (at least ten in 2^15 times, if not exponentially more), so automated tests are likely to pass. If they don’t, they’re likely to pass on the second try, and then everyone shrugs and continues. If it’s buried in 500 other lines, then it’s likely the code reviewer will give it all a quick scan and say “it’s fine”. It’s the three line diffs that get lots of scrutiny.

In other words, you seem to have a lot more faith in the process than I do.

killeronthecorner ,
@killeronthecorner@lemmy.world avatar

rand will be called every time true is used, which could be hundreds of times for all we know

frezik ,

If it’s a 16-bit integer platform, it might hit every once in a while.

If it’s a 32-bit integer platform, it’ll hit very rarely.

If it’s a 64-bit integer platform, someone would have to do the math with some reasonable assumptions, but I wouldn’t be surprised if it would never hit before the universe becomes nothing but black holes.

Morphit ,
@Morphit@feddit.uk avatar

The point being made is that it also depends how often the ‘true’ value gets used in the code. Tests might only evaluate it a few times per run, or they could cause billions of evaluations per run. You can’t know the probability of a test failure without knowing the occurrence rate of that expression.

killeronthecorner , (edited )
@killeronthecorner@lemmy.world avatar

Yes you’re correct, this was the point I was making.

To elaborate: could be 100s of times in a codebase, even 1000s, being executed in tests on local machines and build servers 100s of times a day, etc. etc.

themusicman ,

But it would hit a different place every time… Most developers wouldn’t even consider checking for this, and the chance of getting a repro in a debugger is slim to none

PrettyFlyForAFatGuy ,

you’d be surprised what slips through review

sunbeam60 ,

Yeah but even a single automated test would catch it and reject the PR. You just need a single test.

frezik ,

No, you can’t assume that. The probability of hitting the condition each time is low. If there aren’t very many calls that hit this, it could easily slip through. Especially on 64-bit int platforms.

sunbeam60 ,

Yes agree if you’re talking about unit tests. I’m thinking smoke tests, which is are the most common automated tests in games, where I’ve spent most of professional career. The amount of booleans checks that happen in a single frame I doubt the game wouldn’t crash within the first couple seconds.

steal_your_face , (edited )
@steal_your_face@lemmy.ml avatar

Write a 5 line PR and receive 5 comments. Write a 500 line PR and receive no comments.

autokludge ,
@autokludge@programming.dev avatar

lgtm

nephs ,

It works on my machine, most of the time.

grandkaiser ,

Attn: security team

Hi,

I think someone on Lemmy has hacked into every work environment I’ve ever coded in

CylonBunny , in data secured
@CylonBunny@lemmy.world avatar

Feels much more true on Android than Windows in my experience.

Potatos_are_not_friends ,

Happened to me a moment ago.

Saved images goes into images.

Downloads goes into downloads.

Screenshots go into download/screenshots ?

Gifs go into downloads?

Fuck this noise just put everything into “stuff” folder.

brb ,

Idk what rom you are using but for me everything seems to be logical

Saved images go to downloads

Downloads go to downloads

Screenshots go to pictures/screenshots

Gifs go to downloads

fidodo ,

IMO it’s by far the worst on any apple product. I tried to help my mom organize some photos and it drove me absolutely fucking insane trying to figure out where the photos app stored things.

Matt_Shatt ,

Not sure I follow. The photos app doesn’t save anything externally unless you specifically export it to files and then you have to tell it where. Adding photos from your library to albums is one step with no question where they go. I’ve had a way worse time on android trying to figure out where it stashed things. But sounds like it could just be lack of familiarity for us both.

fidodo ,

I have no idea where the photos came from. All I know was they we’re in there and I couldn’t find where they were stored.

apoisel , in Unicode
@apoisel@discuss.tchncs.de avatar

These errors were much more common before Unicode encodings were in broad use. Unicode pretty much solved this.

davidgro ,

Still happens for new emoji on old OSs, or just missing characters in the font being used.

Vilian ,

exacgly today these errors is always because some old emojis

Norgur ,
@Norgur@fedia.io avatar

No it hasn't. It has just pushed them out of sight for English natives.

apoisel ,
@apoisel@discuss.tchncs.de avatar

Can’t confirm that. In the 90s encodings were a nightmare. ISO-8859-1, ISO-8859-15, CP1252, IBM850, … If you tried to build a website with an upload form, you’d get the most bizarre encodings and there was no way to reliably distinguish them. I’m not an English native, my world is full of umlauts and s-z ligatures. Things got A LOT better in the last years, thanks to Unicode encodings.

wizardbeard ,

Only if it’s enabled by default, or the dev knows to enable it.

I had a lot of weird problems processing some info with names in Powershell until I found out that Powershell doesn’t default to unicode format when shoving output into files. You can easily specify the encoding, but if you don’t it replaces any non-ascii characters with “?” by default, so it’s not even immediately obvious that there’s an incorrect character, as it just silently substitutes a valid one.

vox ,
@vox@sopuli.xyz avatar

it uses big-endian utf-16 with BOM by default unless you upgrade to PowerShell 7

PoolloverNathan ,

Still needs to be widely used. It took me about an hour to figure out that my encoding issues were because of Vim being in latin1, another to figure out how to change that, and a third to realize that screen also wasn’t in UTF-8 mode.

fibojoly ,

I like your enthusiasm. I remember when I believed the same. The last 16 years have clearly shown this is not the case.

perviouslyiner , in Variable Declaration

“oh, the line you are typing is incomplete and therefore the whole file is invalid which means there is nothing to suggest for autocomplete”

4am ,

Ah, a fellow SSMS user

EinfachUnersetzlich ,

Reminds me of VB6.

catsarebadpeople , in Crowdstrike

Googled him and there are too many articles reporting this as real

sorter_plainview ,

He is the founder of a controversial satirical website called NordPresse. Well known for making up stuff and creating confusions in online space.

Baku ,

Who looks at this and thinks it isn’t satire lol? I sometimes struggling with telling satire apart, too, but this is the most obvious piece of satire I’ve seen in a long time.

asexualchangeling ,

“AI”

Snowclone , in What a time to be alive

They put new AI controls on our traffic lights. Cost the city a fuck ton more money than fixing our dilapidated public pool. Now no one tries to turn left at a light. They don’t activate. We threw out a perfectly good timer no one was complaining about.

But no one from silicone valley is lobbing cities to buy pool equipment, I guess.

Hobbes_Dent ,

Nah, that need dat water to cool the AI for the light.

MIDItheKID ,

Linus was ahead of the game on this one. Nvidia should start building data centers next to public pools. Cool the systems and warm the pools.

captain_aggravated ,
@captain_aggravated@sh.itjust.works avatar

I’ve seen a video of at least one spa that does that. They mine bitcoin on rigs immersed in mineral oil, with a heat exchanger to the spa’s water system. I’m struggling to imagine that’s enough heat, especially piped a distance through the building, to run several hot tubs, and I’m kind of dubious about that particular load, but hey.

areyouevenreal , (edited )

A large data centre can use over 100 MW at the high end. Certainly enough to power a swimming pool or three. In fact swimming pools are normally measured in kW not MW.

captain_aggravated ,
@captain_aggravated@sh.itjust.works avatar

“A large data centre” this wasn’t. I saw a couple washing machine-sized vats of oil-soaked computers.

areyouevenreal ,

If all it’s running is a hot tub that sounds reasonable. This bitcoin miner uses over 3kW: aozhiminer.com/…/high-profit-110th-95th-bitmain-a…

Sigma_ ,

This is so dumb that I totally beleive it

Daxtron2 ,

Using CV for automatic lights is not a new thing.

dan ,
@dan@upvote.au avatar

A lot of people in Silicon Valley don’t like this AI stuff either :)

makingStuffForFun ,
@makingStuffForFun@lemmy.ml avatar

We are a small software company. We’re trying to find a useful use case. Currently we can’t. However, we’re watching closely. It has to come at the rate of improving.

lazynooblet ,
@lazynooblet@lazysoci.al avatar

Whilst it’s a shame this implementation sucks, I wish we would get intelligent traffic light controls that worked. Sitting at a light for 90 seconds in the dead of night without a car in sight is frustrating.

lemmyvore ,

That was a solved problem 20 years ago lol. We made working systems for this in our lab at Uni, it was one of our course group projects. It used combinations of sensors and microcontrollers.

It’s not really the kind of problem that requires AI. You can do it with AI and image recognition or live traffic data but that’s more fitting for complex tasks like adjusting the entire grid live based on traffic conditions. It’s massively overkill for dead time switches.

Even for grid optimization you shouldn’t jump into AI head first. It’s much better long term to analyze the underlying causes of grid congestion and come up with holistic solutions that address those problems, which often translate into low-tech or zero-tech solutions. I’ve seen intersections massively improved by a couple of signs, some markings and a handful of plastic poles.

Throwing AI at problems is sort of a “spray and pray” approach that often goes about as badly as you can expect.

MagicShel ,

That was a problem solved seventy years ago. If there’s no one around, just go. No one cares.

MonkeMischief ,

Throwing AI at problems is sort of a “spray and pray” approach that often goes about as badly as you can expect.

I can see the headlines now: “New social media trend where people are asking traffic light Ai to solve the traveling salesman problem is causing massive traffic jams and record electricity costs for the city.”

SkyeStarfall ,

You need to really specify what is meant by “AI” here. Chances are it’s probably some form of smart traffic lights to improve traffic flow. Which is not all that special. It has nothing to do with LLMs

Snowclone ,

Honestly I’m not sure, we had circular sensors for a long time, about the size of a tall drinking glass, now there’s rectangular sensors they just put up about twice the size of a cell phone and they have a bend, arc, to them, I know they weren’t being used as cameras at all before, no one was getting tickets with pictures from them, it’s a small town. What exactly the new system is I’m not sure, our local news all went out of business, so its all word of mouth, or going to town hall meetings.

SatouKazuma ,

I’m guessing it’s some sort of image recognition and maybe some sort of switch under the pavement telling the light when a car has rolled up.

MonkeMischief ,

It’s funny because this is what I was afraid of with “AI” threatening humanity.

Not that we’d get super-intelligences running Terminators, but that we’d be using black-box “I dunno how it does it, we just trained it and let it go.” Tech in civilization-critical applications because it sounded cool to people with more dollars than brain cells.

kippinitreal , in When everyone became paranoid

I think a lot of memes are missing the main point of how it was caught, the exploit caused a spike in CPU usage for a network call. That made no sense to the guy Messiah who found/reported it. FOSS software’s strength is the number of critical eyes looking over each line of code you put out!

GBU_28 ,

Right but the joke is that most developers aren’t of that quality, and are now going to put leredditor super sleuth eyes on every application they build

XEAL ,

What was the full story again? I’m googling but I can’t find it.

kryllic ,
@kryllic@programming.dev avatar

In a nutshell, a backdoor was intentionally planted by a malicious actor in xz Utils, an open-source data compression utility widely used in Linux and other Unix-like operating systems. This discovery was made by Andres Freund, a developer and engineer working on Microsoft’s PostgreSQL offerings. He was troubleshooting performance problems on a Debian system. Specifically, SSH logins were consuming excessive CPU cycles and generating errors with Valgrind, a memory debugging tool. Through sheer luck and Freund’s careful eye, he eventually discovered that these issues were the result of updates made to xz Utils. Upon closer inspection, he found that updates to xz Utils were the result of a maliciously inserted backdoor. The backdoor, present in xz Utils versions 5.6.0 and 5.6.1, manipulated the sshd executable, allowing anyone with a predetermined encryption key to upload and execute arbitrary code on affected devices.

XEAL ,

I expected a link to a source, but this is even better (matches with the little I remember)

Thanks!

kryllic ,
@kryllic@programming.dev avatar

No prob! I think Ars Technica had the best writeup imo: arstechnica.com/…/what-we-know-about-the-xz-utils…

1boiledpotato , in Three monitors, and i feel insulted

That’s a gamer, not a software engineer

ZeroCool ,

I mean, I do have RGB lights but it’s not because I’m a software engineer. I’m just a dork.

Gork ,

I specifically built my computer to have as much RGB as possible. Also because I’m a dork.

kryptonianCodeMonkey ,

I am a software engineer and I also have a PC with RGB vomit. But not because I’m a software engineer. Because I’m also a dork, and the icy blue color keeps my cpu cold.

BassTurd ,

I switch to red when I’m gaming for the extra power.

Shareni ,

FOUND EM ORKY BOYZ!!!

Kedly ,

Dey sed POWAH, naht SPEED

Shareni ,

KOMPUTER POWA IZ TO GO FASTA! ZOGGIN GROTZ TRYIN TO TINK…

Restaldt ,

My computer is lit up orange except for the cpu cooler. Those lights are set to blue for better cooling

BassTurd ,

It makes sense to target your colors for granular performance increases in different areas.

JohnEdwa ,
ZeroCool ,

Lol thank you for making that, I had that meme in mind while I was writing that reply.

spongebue ,

Yeah, as a software engineer I have 3 monitors if you include the one built into my laptop

SpaceNoodle ,

I have 4 if you count the TV in my lounge I can connect to via AirPlay.

EliasChao ,

What about my phone’s display, does that count as well?

jadero ,

Why not? The last decade before semi-retirement I had all the different ways to get in touch with me restricted to my phone. My work computer had no email client, no messengers, nothing. I even helped lead the charge to eliminate desk phones.

That little display may have been the single greatest priductivity booster ever. It stayed on a shelf across the room on do not disturb. The only people allowed past the DnD were my wife and my son. If there really was a work emergency, a manager or coworker knew where to find me to tap me on the shoulder.

BorgDrone ,

I’m a software engineer and while I do have 2 monitors I have absolutely no RGB anything. Just a nice clean setup. My main monitor is on a wall-mounted arm so it appears to just float above my desk. My MacBook is hidden behind the other monitor, which is in portrait and on an arm so it floats just above my desk. Wireless mouse and keyboard (magic mouse and magic keyboard with numeric, both in black/aluminium), no visible wires. One single thunderbolt cable to connect my MacBook to a dock that’s hidden below my desk, which hooks up to my monitors, ethernet, amplifier, etc.

captainjaneway , in What I want to become Vs What I do
@captainjaneway@lemmy.world avatar

Software engineering is just what any “engineering” field would be if they didn’t have standards. We have some geniuses and we have some idiots.

Mechanical engineers, civil engineers, electrical engineers, etc. are often forced to adhere to some sort of standard. It means something to say “I’m a civil engineer” (in most developed nations). You are genuinely liable in some instances for your work. You have to adhere to codes and policies and formats.

Software engineering is the wild west right now. No rules. No standards. And in most industries we may never need a standard because software rarely kills.

However, software is becoming increasingly important in our daily lives. There will likely come a day wherein similar standards take precedence and the name “software engineer” is only allowed to those who adhere to those standards and have the proper certs/licenses. I believe Canada already does this.

Software engineers would be responsible for critical software, e.g: ensuring phones connecting to an emergency operator don’t fail, building pacemakers, securing medical records, etc. I know some of these tasks already have “experts” behind them. But I don’t think software has any licensing/governing.

Directly opposed to “engineering” would be the grunt work which I do.

bedrooms ,

Software without standards. Am I replying to a person who writes his own OS to run hello world?

captainjaneway ,
@captainjaneway@lemmy.world avatar

Cause if you don’t forget your own stainless steel, you can’t be trained on proper defibrillator techniques?

Kidplayer_666 ,

Engineer tends to be a protected term in many countries, so software engineer is no exception. It’s words like “programmer” or “developer” which are probably unregulated

NotSteve_ ,

The weird thing is that engineer is a protected term in Canada but every software dev title I’ve had so far includes it anyway. It doesn’t seem enforced at all here

masterspace ,

I honestly thought there was too, my official job title / offer includes it in the role, despite the role explicitly having no requirement for an engineering degree.

I always found it funny, how I could do a 4 year electrical engineering degree, then work as an electrical engineer for 4 years, but never do my final law/ethics exam so couldn’t call myself an electrical engineer, but could just teach myself python and call myself a software engineer, turns out I was wrong.

It is awkward though, especially in a remote work world, given that we compete directly against American “software engineers” for the exact same jobs.

grue ,

As a software “engineer” and civil EIT, I endorse this comment.

ForgotAboutDre ,

Software engineering does have standards and methods to developing software. These standards and methods are applied in Defence and Aerospace applications. Software engineering was developed or conceived by NATO to manage the increasing complexity of software development.

The big problem is people often confuse software development or programming with software engineering. Calling anyone that programs a software engineer. This isn’t the case. It’s entirely possible to be a software engineer without knowing how to code (but impractical).

captainjaneway ,
@captainjaneway@lemmy.world avatar

Well that’s my point. The term “engineer” is protected in a lot of other industries but not software.

jadero ,

I’d be very interested in learning more about how Canada manages “software engineer.” Because whatever is being done certainly doesn’t seem to include mandating where regulated professionals must be employed or punishing failures.

Saskatchewan’s electronic health records system (eHealth) has had a couple of egregious failures that it shouldn’t have taken a “software engineer” to prevent.

Several 911 services became unavailable during an outage that happened to also disrupt point of sale payment systems nationwide.

Both of the relevant companies are telecommunications companies (Telus and Rogers, respectively), where one would expect “software engineering” to be conducted by “software engineers” regardless of regulation.

A quick search for breaches in critical personal information will show that Canada is performing about as well as the US. Which is to say, abysmally.

ironhydroxide ,

“because software rarely kills” Depends on what you mean by rarely. Therac-25 was extremely dangerous due to a software bug. And this was over 40 years ago.

Industrial robot accidents are a lot more common than needed and almost all are due to software “problems” (bad path planning, bad safety implementation, or just bugs in the control system software)

Yes these things kill less than guns, or cars, or cranes, etc. But they still have affect in a lot of those accidents.

There are very few things anymore that don’t have some kind of logic built into them. Be it software or analog logic, it was still “programmed” or designed. If there was something missed in design, that can easily have adverse affects that can lead to accidents and death not immediately attributed to the software.

captainjaneway ,
@captainjaneway@lemmy.world avatar

I was comparing it to civil or mechanical engineering. I agree that programming/software is growing and “infiltrating” our lives. That’s why I think it will become a licensed/certified term in the future. Software engineer will require a cert and some products will require certified engineers. Whereas web apps developers (most likely) will not use that title most of the time and we will just bifurcate those who work on “critical software” and those that do not.

Socsa ,

There are definitely quality certifications for software. Plenty of govt acquisitions contracts require such certifications. We probably aren’t far from laws or executive mandates which require such things tbh

kromem , in Correcting > Helping

I learned so much over the years abusing Cunningham’s.

Could have a presentation for the C-suite for a major company, post some tenuous claim related to what I intended to present on, and have people with PhDs in the subject citing papers correcting me with nuances that would make it into the final presentation.

It’s one of the key things I miss about Reddit. The scale of Lemmy just doesn’t have the same rate and quality of expertise jumping in to correct random things as a site with 100x the users.

Kidplayer_666 ,

Errmmmmh achstually…, lol

jballs ,
@jballs@sh.itjust.works avatar

The major problem with reddit is that you could never really trust the credentials of the person you were talking to. They might have been PhDs or they might have been 13 year olds who just learned to Google. It amazes me how many times I saw a highly upvoted comment posted about a subject that I knew a lot about, but was just so blatantly wrong.

repungnant_canary ,

As long as they provide appropriate sources then it doesn’t really matter who they are

kool_newt ,

There’s no clear winner between a 13yo who can use a search engine and a crusty old PhD who can’t keep up with changing times.

CanadaPlus ,

Especially if you move 0.1% away from that PhD’s particular specialty.

MotoAsh ,

I mean, unironically exactly why people think LLMs are smart.

jettrscga ,

Yeah voting on content has nothing to do with quality and everything to do with feelings.

People just vote for their side of any discussion, regardless of validity.

CanadaPlus ,

Only if it’s something controversial. If it’s something technical with no political affiliation, people vote for answers that sound right. Thankfully Cunningham’s usually comes to the rescue on time.

Feyter ,

To be fair this is not a Reddit thing and it can be found in the fediverse too. I can remember some of such situations where a person just posted wrong stuff but in a very confident way. I was able to prove him wrong later but nobody cared anymore.

reverendsteveii ,

cunningham’s law is intended to be used recursively

yum13241 ,

I know what you’re trying to do, but that is not the case /hj

CanadaPlus ,

Unless the thing falls under non-commercial electronics or computing. The community on here is skewed towards that for obvious reasons.

glitches_brew ,

I always kind of felt like those voices began to be drowned out the more and more popular reddit became. You’re correct about Lemmy’s scale, but there is certainly a sweet spot. I’m happy knowing Lemmy hasn’t yet reached its own, and reddit’s is long gone. I’m happier here and it’s likely only going to get better.

sudo , in They Need To Stop Doing This

Customer: Why is there so much latency over my tunnel from us-east to us-west?

Me: checks latency seems pretty normal, what’s the issue?

Customer: The latency is too much. Why is it not as fast as us-east-1 to us-east-2?

Me: They are near each other. Us-West is across the entire United States

Customer: Make faster

Me: This is the speed of light. And over copper it’s about 2/3 that

Customer: hmm are you sure that’s as fast as it can go?

Me: Well, unless we change the laws of physics your not going to get any better latency

brygphilomena ,

Customer: So… can we do that? Change the laws of physics? What congressman do we need to email?

orbitz ,

That’s cause they always have money in the lobbying budget to fix things.

stratoscaster ,

Then you find out the real reason they need faster latency is because they’re pinging the server for new data every 1ms

sloppy_diffuser ,

For the low price of billions and a decade of work they could build out hollow core fiber coast to coast to get the last 1/3 c.

affiliate ,

that would really help with playing video games

spez ,

What’s hollow core fibre.

sloppy_diffuser ,

Its a type of fiber optic cable where the center of the cable is literally hollow. Normal fiber uses a glass core. Light passing through glass also travels about 2/3 the speed of the light since the speed of light is only constant in an empty vacuum. With hollow core, light is no longer passing through glass so its speed is much closer to the actual speed of light.

mindbleach ,

… wait, how does that work? Total internal reflection happens at the boundary to a lower index of refraction.

sloppy_diffuser ,

I don’t know the physics well enough, but here is some general information.

en.m.wikipedia.org/wiki/Photonic-crystal_fiber

www.rp-photonics.com/hollow_core_fibers.html

High Group Velocity, Low Latency Signal Transmission

The group velocity of guided light is usually close to the vacuum velocity of light. This implies substantially lower latency for signal transmission through hollow-core fibers.

Croquette ,

My dumb person guess is that it needs to be in a perfectly straight line.

There’s probably more to it.

sloppy_diffuser ,

Looks like it comes in spools.

www.ixblue.com/store/ixf-hcf-10-100-950/

I don’t know the physics of it. I posted some info for the parent you responded to. My understanding is the applied physics is different from traditional fiber.

The main physical principle behind propagation of light in conventional optical fibers is total internal reflection (TIR). However, engineering of optical materials with features on the scale of the wavelength of light offers many new possibilities for manipulating light. In particular, some microstructured fibres make it possible to guide light by a mechanism different from total internal reflection. In these fibres, light is trapped in the core by an out-of-plane band-gap, which appears over a range of axial wavevectors and prevents propagation of light in the microstructured cladding [Cregan (1999)], allowing guided modes to form in the central hollow core.

mpl.mpg.de/research-at-mpl/…/hollow-core-pcf

Cort ,

How do you get internal reflectance with a hollow core?

AffineConnection ,

You can’t have total internal reflection within a hollow core, but that’s not how they function.

Cort ,

That’s fair.

simpleslipeagle ,

Anytime I run into that question I tell them if I could manage FTL comms I wouldn’t be working here.

xantoxis , (edited )

Eh, sometimes they’re right about this one though. It’s true that a request traveling near light speed is as fast as it can possibly be, but what if it’s 17 requests? Sometimes you can fix latency by doing fewer transactions.

edit: love a downvote with no reply. Just “No!” [stomps feet]

Blackmist ,

So can you give me an estimate for when you can solve that?

Draces , (edited ) in Golang be like

I wonder what portion of all go code written is

if err != nil {

return err

}

It’s gotta be at least 20%

christophski ,

Can anybody explain the rationale behind this?

fkn ,

Exceptions don’t exists and ask errors must be handled at every level. It’s infuriating.

msage ,

Hahaha, fuck no, I’ve dealt with exception-less code enough in my life, kthxbye

GlitchSir ,

I think you missed a memo. Exceptions are bad and errors as values are in… I’ll have Harold forward it to you

planish ,

I actually kind of like the error handling. Code should explain why something was a problem, not just where it was a problem. You get a huge string of “couldn’t foobar the baz: target baz was not greebleable: no greeble provider named fizzbuzz”, and while the strings are long as hell they are much better explanations for a problem than a stack trace is.

silent_water ,
@silent_water@hexbear.net avatar

a desperate fear of modular code that provides sound and safe abstractions over common patterns. that the language failed to learn from Java and was eventually forced to add generics anyway - a lesson from 2004 - says everything worth saying about the language.

ennemi ,

The language was designed to be as simple as possible, as to not confuse the developers at Google. I know this sounds like something I made up in bad faith, but it’s really not.

The key point here is our programmers are Googlers, they’re not researchers. They’re typically, fairly young, fresh out of school, probably learned Java, maybe learned C or C++, probably learned Python. They’re not capable of understanding a brilliant language but we want to use them to build good software. So, the language that we give them has to be easy for them to understand and easy to adopt. – Rob Pike

"It must be familiar, roughly C-like. Programmers working at Google are early in their careers and are most familiar with procedural languages, particularly from the C family. The need to get programmers productive quickly in a new language means that the language cannot be too radical. – Rob Pike

The infamous if err != nil blocks are a consequence of building the language around tuples (as opposed to, say, sum types like in Rust) and treating errors as values like in C. Rob Pike attempts to explain why it’s not a big deal here.

devfuuu ,

People are scared of monads and think this is better.

serenity ,

My brain is too smooth to imagine a solution to this using monads. Mind sharing what you got with the class?

nick ,

Having a Result[T, Err] monad that could represent either the data from a successful operation or an error. This can be generalised to the Either[A, B] monad too.

psilocybin , (edited )

Someone else and not an expert. But Maybe types are implemented with Monads, Maybe is a common monad.

Its how rust does error handling for example, you have to test a return value for “something or nothing” but you can pass the monadic value and handle the error later, in go you have to handle the error explicitly (almost) all the time.

Nevoic , (edited )
@Nevoic@lemmy.world avatar

Here’s an example (first in Haskell then in Go), lets say you have some types/functions:

  • type Possible a = Either String a
  • data User = User { name :: String, age :: Int }
  • validateName :: String -> Possible String
  • validateAge :: Int -> Possible Int

then you can make


<span style="color:#323232;">mkValidUser :: String -> Int -> Possible User
</span><span style="color:#323232;">mkValidUser name age = do
</span><span style="color:#323232;">  validatedName ← validateName name
</span><span style="color:#323232;">  validatedAge  ← validateAge age
</span><span style="color:#323232;">  pure $ User validatedName validatedAge
</span>

for some reason <- in lemmy shows up as &lt;- inside code blocks, so I used the left arrow unicode in the above instead

in Go you’d have these

  • (no Possible type alias, Go can’t do generic type aliases yet, there’s an open issue for it)
  • type User struct { Name string; Age int }
  • func validateName(name string) (string, error)
  • func validateAge(age int) (int, error)

and with them you’d make:


<span style="color:#323232;">func mkValidUser(name string, age int) (*User, error) {
</span><span style="color:#323232;">  validatedName, err = validateName(name)
</span><span style="color:#323232;">  if err != nil {
</span><span style="color:#323232;">    return nil, err
</span><span style="color:#323232;">  }
</span><span style="color:#323232;">
</span><span style="color:#323232;">  validatedAge, err = validateAge(age)
</span><span style="color:#323232;">  if err != nil {
</span><span style="color:#323232;">    return nil, err
</span><span style="color:#323232;">  }
</span><span style="color:#323232;">
</span><span style="color:#323232;">  return User(Name: validatedName, Age: validatedAge), nil
</span><span style="color:#323232;">}
</span>

In the Haskell, the fact that Either is a monad is saving you from a lot of boilerplate. You don’t have to explicitly handle the Left/error case, if any of the Eithers end up being a Left value then it’ll correctly “short-circuit” and the function will evaluate to that Left value.

Without using the fact that it’s a functor/monad (e.g you have no access to fmap/>>=/do syntax), you’d end up with code that has a similar amount of boilerplate to the Go code (notice we have to handle each Left case now):


<span style="color:#323232;">mkValidUser :: String -> Int -> Possible User
</span><span style="color:#323232;">mkValidUser name age =
</span><span style="color:#323232;">  case (validatedName name, validateAge age) of
</span><span style="color:#323232;">    (Left nameErr, _) => Left nameErr
</span><span style="color:#323232;">    (_, Left ageErr)  => Left ageErr
</span><span style="color:#323232;">    (Right validatedName, Right validatedAge) => 
</span><span style="color:#323232;">      Right $ User validatedName validatedAge
</span>
arc ,

Swift and Rust have a far more elegant solution. Swift has a pseudo throw / try-catch, while Rust has a Result<> and if you want to throw it up the chain you can use a ? notation instead of cluttering the code with error checking.

barsoap ,

The exception handling question mark, spelled ? and abbreviated and pronounced eh?, is a half-arsed copy of monadic error handling. Rust devs really wanted the syntax without introducing HKTs, and admittedly you can’t do foo()?.bar()?.baz()? in Haskell so it’s only theoretical purity which is half-arsed, not ergonomics.

m_f ,

It’s not a half-arsed copy, it’s borrowing a limited subset of HKT for a language with very different goals. Haskell can afford a lot of luxuries that Rust can’t.

barsoap ,

It’s a specialised syntax transformation that has nothing to do with HKTs, or the type system in general. Also HKTs aren’t off the table it’s just that their theory isn’t exactly trivial in face of the rest of Rust’s type system but we already have GATs.

It actually wouldn’t be hard writing a macro implementing do-notation that desugars to and_then calls on a particular type to get some kind of generic code (though of course monomorphised), but of course that would be circumventing the type system.

Anyhow my point stands that how Rust currently does it is imitating all that Haskell goodness on a practical everyday coding level but without having (yet) to solve the hard problem of how to do it without special-cased syntax sugar. With proper monads we e.g. wouldn’t need to have separate syntax for async and ?

Nevoic ,
@Nevoic@lemmy.world avatar

Note: Lemmy code blocks don’t play nice with some symbols, specifically < and & in the following code examples

This isn’t a language level issue really though, Haskell can be equally ergonomic.

The weird thing about ?. is that it’s actually overloaded, it can mean:

  • call a function on A? that returns B?
  • call a function on A? that returns B

you’d end up with B? in either case

Say you have these functions


<span style="color:#323232;">toInt :: String -> Maybe Int
</span><span style="color:#323232;">
</span><span style="color:#323232;">double :: Int -> Int
</span><span style="color:#323232;">
</span><span style="color:#323232;">isValid :: Int -> Maybe Int
</span>

and you want to construct the following using these 3 functions


<span style="color:#323232;">fn :: Maybe String -> Maybe Int
</span>

in a Rust-type syntax, you’d call


<span style="color:#323232;">str?.toInt()?.double()?.isValid()
</span>

in Haskell you’d have two different operators here


<span style="color:#323232;">str >>= toInt &lt;&amp;> double >>= isValid
</span>

however you can define this type class


<span style="color:#323232;">class Chainable f a b fb where
</span><span style="color:#323232;">    (?.) :: f a -> (a -> fb) -> f b
</span><span style="color:#323232;">
</span><span style="color:#323232;">instance Functor f => Chainable f a b b where
</span><span style="color:#323232;">    (?.) = (&lt;&amp;>)
</span><span style="color:#323232;">
</span><span style="color:#323232;">instance Monad m => Chainable m a b (m b) where
</span><span style="color:#323232;">    (?.) = (>>=)
</span>

and then get roughly the same syntax as rust without introducing a new language feature


<span style="color:#323232;">str ?. toInt ?. double ?. isValid
</span>

though this is more general than just Maybes (it works with any functor/monad), and maybe you wouldn’t want it to be. In that case you’d do this


<span style="color:#323232;">class Chainable a b fb where
</span><span style="color:#323232;">    (?.) :: Maybe a -> (a -> fb) -> Maybe b
</span><span style="color:#323232;">
</span><span style="color:#323232;">instance Chainable a b b where
</span><span style="color:#323232;">    (?.) = (&lt;&amp;>)
</span><span style="color:#323232;">
</span><span style="color:#323232;">instance Chainable a b (Maybe b) where
</span><span style="color:#323232;">    (?.) = (>>=)
</span>

restricting it to only maybes could also theoretically help type inference.

barsoap , (edited )

I was thinking along the lines of “you can’t easily get at the wrapped type”. To get at b instead of Maybe b you need to either use do-notation or lambdas (which do-notation is supposed to eliminate because they’re awkward in a monadic context) whereas Rust will gladly hand you that b in the middle of an expression, and doesn’t force you to name the point.

Or to give a concrete example, if foo()? {…} is rather awkward in Haskell, you end up writing things like


<span style="color:#323232;">foo x y = bar >>= baz x y
</span><span style="color:#323232;">  where
</span><span style="color:#323232;">    baz x y True = x
</span><span style="color:#323232;">    baz x y False = y
</span>

, though of course baz is completely generic and can be factored out. I think I called it “cap” in my Haskell days, for “consequent-alternative-predicate”.

Flattening Functors and Monads syntax-wise is neat but it’s not getting you all the way. But it’s the Haskell way: Instead of macros, use tons upon tons of trivial functions :)

arc ,

You can say it’s half-arsed if you like, but it’s still vastly more convenient to write than if err != nil all over the place

vox ,
@vox@sopuli.xyz avatar

btw lua handles error in exactly the same way

qprimed , in Happy 30th birthday to RFC 1631 ("NAT"), the "short term solution" we all rely on

there is no fix more permanent than a temporary one.

edit: as I literally sit here inspecting the nat tables on a couple of edge routers.

cmnybo ,

That temporary fix will eventually become unnecessary. IPv6 has slowly getting more and more use.

state_electrician ,

Very, very slowly.

purplemonkeymad ,

It’s been getting “more and more use” since 2001. To start with the isps said that they were not going to do any work to implement it until endpoints supported it. Then vista came with support by default. Next they wanted the backbones to support it. All tier 1 networks are now dual stack. Then they said they were not going to do anything until websites supported it widely. Now all cdns support it. Then they said, it’s ok we will just do mass nat on everyone so won’t do any work on it.

qprimed , (edited )

exactly. I have been begging multiple ISPs for direct IPv6 allocations for 10+ years now. its always “we are internally testing - not available for distribution yet”. the most recent request from me was less than 3 months ago when I needed a IPv4 /29 for a remote site. figured I would see if I could also get a nice sized IPv6 allocation as well. nope. just gotta keep paying a premium for that dwindling IPv4 address space.

Hurricane Electric is to be commended for their public IPv6 tunnels, but without direct allocations from your immediate upstream, its just play.

psud ,

I chose an ISP that dual homed customers on IPv4 and IPv6, but then the giant ISP that wants a monopoly bought them and now I get IPv4

frezik ,

A lot of ISPs do have some kind of IPv6. Many don’t give you a prefix with the length they should. Many don’t give you a static prefix. They’re doing everything they can to continue to fuck this up.

Mostly to their own detriment. Maintaining equipment to do carrier grade NAT makes their network slower, less reliable, and more expensive.

raldone01 ,

At least I have a nice static and proper ipv6 prefix.

However when I asked for a reverse dns entry they could only give me one for ipv4… So now my Mail server only uses ipv4. :-(

AtariDump ,

So has Linux on the “desktop” buts it’s never been the year of the Linux desktop.

FiskFisk33 ,

This thread starts with a document literally proving people have been saying that exact thing for 30 years now.

neidu2 , (edited )

Last week I was peer pressured into trying out Helldivers 2 (yes, this is relevant, trust me), so I downloaded it, installed it, and fired it up with no issues. Set up my preferred control schema with no issues. Played the torturial with no issues.

Then came time for joining my friends in multiplayer. Issues! No matter what I did, I couldn’t seem to join them. Nor could they join me.

I verified the installed files, I tried to connect via my phone to rule out ISP issues, and I tried all of the different versions of proton, but the result remained the same. I simply couldn’t join my friends.

I don’t remember what caused me to go down the right path of troubleshooting, but I’ve always dosabled IPv6 on my linux installs. So I re-enabled it. The problem remained. Then I realized that I had it disabled in the kernel via grub command line flags, so I cuanged that and gave my PC a reboot. Success!

So, despite networking being a large (maybe even the largest) part of my vocation for the past two decades, last week was the first time ever I actually NEEDED IPv6.

hessenjunge ,

torturial - I like that. Sometimes a tutorial is indeed a torturial. 😊

stoly ,

My previous office was in a set of partitions put up in a library 20 years ago as a temporary measure.

Ephera , in I still don't get buffers

Nevermind simply having an OS-level clipboard manager…

mp3 ,
@mp3@lemmy.ca avatar

Win+V works decently enough for me.

jnk ,

Same for plasma, global clipboard is just more convenient

whats_all_this_then OP ,

Global clipboard is chef’s kiss. Back when I was on Ubuntu/Gnome, I had to install CopyQ but having one come with the OS is great

BastingChemina ,

Global clipboard synced with the smartphone thanks to KDE connect !

pineapplelover ,

I think windows+v syncs to microsoft servers or something. I remember when I was running chris titus tech’s debloat script it removed that functionality.

whats_all_this_then OP ,

Holy crap I think that may be why I never used it. Fuck how much Windows likes to calls home

Sotuanduso ,

I googled it, there is an option to sync it to your Microsoft account, but I can’t say whether that’s on by default when you turn on clipboard history because I skipped adding a Microsoft account. But if it is, you can turn it off in Settings -> System -> Clipboard.

xmunk ,

An excellent option to have when one of the major use cases for clipboards is as an intermediary for password managers.

I hope they eventually get sued into the fucking ground.

Aux ,

Password managers should mark their clipboard data as sensitive and clean it up. Use a proper password manager and there won’t be issues.

whats_all_this_then OP ,

I’m don’t know why but I’ve never used windows clipboard manager, which is weird because I go out of my way to make sure I have one when I’m on linux

MrScottyTay ,

There is for windows, and it’s further improved if you get power toys too

riot ,
@riot@lemmy.world avatar

I took a look through my power toys settings, but couldn’t find anything there that had to do with the win+v clipboard history. Google hasn’t been any help either. What is it that I’m overlooking? How does powertoys improve the clipboard history feature?

MrScottyTay ,

I’m currently not on my windows pc at the moment but it could be that it’s functionality might actually be native to win 11? I don’t realise use it myself I just remember seeing it when originally getting powertoys and thinking that was cool

riot ,
@riot@lemmy.world avatar

The Clipboard History is indeed a part of Windows 10. But I was wondering how PowerToys enhanced the functionality of it.

MrScottyTay ,

I’ve probably completely misremembered it and maybe learned of it the same time i learned about and installed powertoys. My bad.

whats_all_this_then OP ,

Nah that’d be too intuitive

In all seriousness though, I kinda appreciate moving things around in my editor without losing that one snipet I copied for later

marcos ,

Application specific buffers are the first thing I disable on emacs. The OS one isn’t just integrated with every other normal piece of software, it’s also more powerful and easier to use.

… at least on my Linux, YMMV.

PlexSheep ,

The os buffer is just another buffer that I can yank into.

Cwilliams ,

Or the KDE System tray…

Ephera ,

Ah, that is what I meant with OS-level clipboard manager (in fact, that is precisely what I thought of).

Cwilliams ,

Oh, I gotcha now

pewpew ,
@pewpew@feddit.it avatar

Windows also has it, but it’s disabled by default for some reason

Aux ,

It’s not disabled.

henfredemars , in The easiest problem

I worked with a developer who insisted on using the shortest names possible. God I hated debugging his code.

I’m talking variable names like AAxynj. Everything looking like matrix math.

ray ,

At a previous job I had to work with an old database where all the tables and columns had 6-character names

wfh ,

Same. Old DB2 base from the 80’s that was migrated to Oracle in the 90’s then to Postgres in the 2010’s.

And the people there know all the column names by heart 😅

xmunk ,

I vomit whenever I have to read one letter alias SQL. And then… I dealias it.

nogooduser ,

I don’t understand why people think that it’s acceptable.

As developers, we’ve had it drummed into us from day one that variable names are important and shouldn’t be one or two letters.

Yet developers deliberately alias an easy to read table name such as “customer” into “c” because that’s the first letter of the table. I’m sure that it’s more work to do that with auto completion meaning that you don’t even need to type out “customer”.

xmunk ,

Especially when you also have company and county tables. It forces people to look up what the c is aliased to before beginning to comprehend what you’re doing.

redcalcium ,

Ah, must’ve been a fortran developer. I swear they have this ability to make the shortest yet the least memorable variable names. E.g. was the variable called APFLWS or APFLWD? Impossible to remember without going back and forth to recheck the definition. Autocomplete won’t help you because both variables exist.

mkwt ,

And you can write more than six characters, but only the first six are recognized. So APFLWSAC and APFLWSAF are really the same variable.

And without namespaces, company policy reserves the first two characters for module prefix and Hungarian notation.

henfredemars ,

He did write some Fortran in his past! What made you think it was Fortran influence?

geogle ,
@geogle@lemmy.world avatar

72 characters per line/card.

Templa ,

I’d say because fortran is often used for calculations such as numerical analysis where you have x, y and z for example.

I have written fortran code in the past and it was mainly for that.

redcalcium ,

Your first few programming languages usually influence you the most for the rest of your career.

HaywardT ,

And the rest of you are COBOL programmers.

dan ,
@dan@upvote.au avatar

shortest names possible

This film from 1975 is still relevant today: www.youtube.com/watch?v=7hdJQkn8rtA

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