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.

Colour_me_triggered , in Defragged Zebra

This is what south African zebras look like.

x0x7 ,

It’s what they looked like, in the good old times.

xmunk , in C++

This graph cuts off early. Once you learn that pointers are a trap for noobs that you should avoid outside really specific circumstances the line crosses zero and goes back into normal land.

Pelicanen ,

C++ is unironically my favorite language, especially coding in python feels so ambiguous and you need to take care of so many special cases that just wouldn’t even exist in C++.

GlitchyDigiBun ,
@GlitchyDigiBun@lemmy.world avatar

But can you read someone else’s C++ code?

magic_lobster_party ,

Why should I do that?

xmunk ,

You can absolutely read my code. The ability (similar to functional languages) to override operators like crazy can create extremely expressive code - making everything an operator is another noob trap… but using the feature sparingly is extremely powerful.

Narwhalrus ,

Typically, I can read an “average” open source programmers code. One of the issues I have with C++ is the standard library source seems to be completely incomprehensible.

I recently started learning rust, and the idea of being able to look at the standard library source to understand something without having to travel through 10 layers of abstraction was incredible to me.

magic_lobster_party ,

I wonder what went into their minds when they decided on coding conventions for C++ standard library. Like, what’s up with that weird ass indentation scheme?

barsoap ,

One of the issues I have with C++ is the standard library source seems to be completely incomprehensible.

AAAAAAhhh I once read a Stroustrup quote essentially going “if you understand vectors you understand C++”, thought about that for a second, coming to the conclusion “surely he didn’t mean using them, but implementing them”, then had a quick google, people said llvm’s libc++ was clean, had a look, and noped out of that abomination instantly. For comparison, Rust’s vectors. About the same LOC, yes, but the Rust is like 80% docs and comments.

uis ,

I think some of those abominational constructs were for compile-time errors. Inline visibility macro is for reducing bynary size, allowing additional optimizations and improving performance and load time.

In my projects I set default visibility to hidden.

lazyneet ,

I’ve been using C++ almost daily for the past 7 years and I haven’t found a use for shared_ptr, unique_ptr, etc. At what point does one stop being a noob?

riodoro1 ,

This guy probably still uses a char*.

What have you been using it daily for? arduino development? I’m hoping no company still lives in pre C++17 middle ages.

sxan ,
@sxan@midwest.social avatar

C99 is better. Always will be.

Fight me.

uis ,

C11 atomics

Sasquatch ,

My company still uses c90. I just want to for(uint8 i = 0;;) 🥹

AngryPancake ,

Given that you probably are using pointers, and occasionally you are allocating memory, smart pointers handle deallocation for you. And yes, you can do it yourself but it is prone to errors and maybe sometimes you forget a case and memory doesn’t get deallocated and suddenly there is a leak in the program.

When you’re there, shared_ptr is used when you want to store the pointer in multiple locations, unique_ptr when you only want to have one instance of the pointer (you can move it around though).

Smart pointers are really really nice, I do recommend getting used to them (and all other features from c++11 forward).

arendjr ,

Smart pointers are really really nice, I do recommend getting used to them (and all other features from c++11 forward).

You’re recommending him to give up his sanity and/or life?

porgamrer ,

I would have said the same thing a few years ago, but after writing C++ professionally for a while I have to grudgingly admit that most of the new features are very useful for writing simpler code.

A few are still infuriating though, and I still consider the language an abomination. It has too many awful legacy problems that can never be fixed.

SubArcticTundra ,
@SubArcticTundra@lemmy.ml avatar

Do you still use raw pointers? You know they’ve discovered fire? (Jk coming from C I too havent learnt how to use smart pointers yet)

magic_lobster_party ,

Smart pointers are like pointers, but without the same burden of having to worry about memory leaks.

whou ,

well, if I have an object on the heap and I want a lot of things to use it at the same time, a shared_ptr is the first thing I reach for. If I have an object on the heap and I want to enforce that no one else but the current scope can use it, I always reach for a unique_ptr. Of course, I know you know all of this, you have used it almost daily for 7 years.

In my vision, I could use a raw pointer, but I would have to worry about the lifetime of every object that uses it and make sure that it is safe. I would rather be safe that those bugs probably won’t happen, and focus my thinking time on fixing other bugs. Not to mention that when using raw pointers the code might get more confusing, when I rather explicitly specify what I want the object lifetime to be just by using a smart pointer.

Of course, I don’t really care how you code your stuff, if you are comfortable in it. Though I am interested in your point of view in this. I don’t think I’ve come across many people that actually prefer using raw pointer on modern C++.

lazyneet ,

I just never learned smart pointers and write C++ code like it’s C for aesthetic reasons.

RecluseRamble ,

Best to join a C++ community on some social media then. They’ll tell you immediately why “C with classes” isn’t C++.

fushuan ,

Shared poibters are used while multithreading, imagine that you have a process controller that starts and manages several threads which then run their own processes.

Some workflows might demand that an object is instantiated from the controller and then shared with one or several processes, or one of the processes might create the object and then send it back via callback, which then might get sent to several other processes.

If you do this with a race pointer, you might end in in a race condition of when to free that pointer and you will end up creating some sort of controller or wrapper around the pointer to manage which process is us8ng the object and when is time to free it. That’s a shared pointer, they made the wrapper for you. It manages an internal counter for every instance of the pointer and when that instance goes out of scope the counter goes down, when it reaches zero it gets deleted.

A unique pointer is for when, for whatever reason, you want processes to have exclusive access to the object. You might be interested in having the security that only a single process is interacting with the object because it doesn’t process well being manipulated from several processes at once. With a raw pointer you would need to code a wrapper that ensures ownership of the pointer and ways to transfer it so that you know which process has access to it at every moment.

In the example project I mentioned we used both shared and unique pointers, and that was in the first year of the job where I worked with c++. How was your job for you not to see the point of smart pointers after 7 years? All single threaded programs? Maybe you use some framework that makes the abstractions for you like Qt?

I hope these examples and explanations helped you see valid use cases.

lazyneet ,

When you bring threads into it, these exotic features make more sense. I have been doing single-threaded stuff for the most part.

MajorHavoc ,

At what point does one stop being a noob?

I recognize that trick question. For C++, the answer is always “soon”.

orbitz ,

First year programming in the late 90s … segmentation fault? I put printfs everywhere. Heh. You’d still get faults before the prints happened, such a pain to debug while learning. Though we weren’t really taught your point of the comment at the time.

Least that was my experience on an AIX system not sure if that was general or not, the crash before a print I mean.

xmunk ,

Yea, pointer arithmetic is cute but at this point the compiler can do it better - just type everything correctly and use []… and, whenever possible, pass by reference!

uis ,

Faust bless Stallman for creating GDB.

5C5C5C ,

Your graph also cuts out early. Eventually you want to get performance gains with multi-threading and concurrency, and then the line drops all the way into hell.

xmunk ,

Good Afternoon Sir, have you heard about our lord and savior pthreads?

5C5C5C ,

I’m not saying you can’t do multi-threading or concurrency in C++. The problem is that it’s far too easy to get data races or deadlocks by making subtle syntactical mistakes that the compiler doesn’t catch. pthreads does nothing to help with that.

If you don’t need to share any data across threads then sure, everything is easy, but I’ve never seen such a simple use case in my entire professional career.

All these people talking about “C++ is easy, just don’t use pointers!” must be writing the easiest applications of all time and also producing code that’s so inefficient they’d probably get performance gains by switching to Python.

deadcream ,

That’s the problem of most general-use languages out there, including “safe” ones like Java or Go. They all require manual synchronization for shared mutable state.

5C5C5C ,

There’s a difference between “You have to decide when to synchronize your state” and “If you make any very small mistake that appears to be perfectly fine in the absence of extremely rigorous scrutiny then this code block will cause a crash or some other incomprehensible undefined behavior 1/10000 times that it gets run, leaving you with no indication of what went wrong or where the problem is.”

uis ,

Well, threadsanitizer catches them in runtime. Not sure about GCC static analyser and other SA tools.

5C5C5C ,

I use thread sanitizer and address sanitizer in my CI, and they have certainly helped in some cases, but they don’t catch everything. In fact it’s the cases that they miss which are by far the most subtle instances of undefined behavior of all.

They also slow down execution so severely that I can’t use them when trying to recreate issues that occur in production.

uis ,

They caught lock inversion, that helped to fix obscure hangs, that I couldn’t reproduce on my machine, but were constantly happening on machine with more cores.

uis ,

that’s so inefficient they’d probably get performance gains by switching to Python.

Damn, this goes hard for no reason.

uis ,

Wasn’t biggest part of pthreads added in C11/C++11?

xmunk ,

So… I’m old. All my time working in C++ was pre-C++11

otto_von ,

But I need pointers for almost everything

Gladaed ,

Pointers are great for optional references.

WormFood ,

pointers are fine, but when you learn about the preprocessor and templates and 75% of the STL it goes negative again

c++ templates are such a busted implementation of generics that if I didn’t have context I’d assume they were bad on purpose like malbolge

nick , in Roses are red, violets are blue, everyone is using IPv6, why aren't you?

I’m not. I disable it on all Linux machines I manage. And we do not use it at work either.

smileyhead ,

This. And also disable https. Those things just break all the time.

nick ,

Not sure what you are going for here

KindaABigDyl , in Roses are red, violets are blue, everyone is using IPv6, why aren't you?
@KindaABigDyl@programming.dev avatar

People use IPv6?

I still don’t know anything about it

spacemanspiffy ,

Same. I have disabled it on my devices since it mostly just causes problems.

smileyhead ,

By disabling both v4 and v6 you can fix 100% of the problems.

Fred ,

Just under half of the Internet: www.google.com/intl/en/ipv6/statistics.html

sep ,

You do as well, if you run any operating system newer then the last 10 years.

mindlight , in Roses are red, violets are blue, everyone is using IPv6, why aren't you?

2 months ago I thought I’d start learning IPv6 and started watch some intro videos on YouTube.

Holy crap… It’s a beast and it just felt like if you don’t know what you’re doing you might lose all control over your network. Ok. So a device didn’t get a dhcp address? No problem… It creates it’s open IP address and starts talking and try to get out on internet on its own…

Normally that’s not a problem since your normal home router wouldn’t route 169.254.x.x… But it just seems like there’s A LOT to think about before activating IPv6 at home. I’ve got a Creality K1 Max… Fun thing: factory reset also creates a new MAC Address… So there’s no way in hell thay I just let her lose by activating IPv6.

Ps. Yes, I most likely panic because I haven’t figured out IPv6… But until I understand IPv6 there’s just going to be IPv4.

r00ty Admin ,
r00ty avatar

Generally, a device cannot get an internet facing IP address unless something else on your network is advertising the prefix. In fact, I'd argue there's little point using DHCPv6 now. Some devices are only interested in SLAAC. But, if you have a router that gets an IPv6 prefix from your ISP (usually /48 or /64, but you can get other sizes) it will usually then advertise that onto your local network.

As for the IP addresses. I would say that you should definitely still have a firewall in place. But the setup is the same as IPv4 just without NAT. e.g. you set a blanket rule for your prefix to allow outbound and block unrelated inbound. Then poke holes through for specific devices and services.

By default, IPv6 implementations make an assumption that they're not going to be a server (if you want a device to be a server, you can just set a static IP) and their "main" IP will be a random looking one (and the configuration will depend on whether it uses an interface identifier to create the address, or if it is random) within your (usually huge) allocation. But more than that, they will usually be configured to use the IPv6 privacy extensions (RFC4941). This generates extra temporary addresses per device, which are used for outbound connections and do not accept incoming connections. That is, people cannot see your IP address on their host from your connection and then port scan you, since no ports will respond. You could still have ports open on your "real" IP address. But, that one isn't ordinarily used for outgoing connections, so no-one will know it exists. To discover it they would need to scan your whole prefix (remember that the /64 allocation you will generally get is the internet * the internet in terms of address space, that is much harder to brute force scan).

I think the differences between IPv4 and IPv6 might seem scary, but most of them are actually improvements on what we had before, making use of the larger pools we have available. Once you work it out, it's really not so bad.

I would like to see routers setup to firewall ipv6 by default to give the same protection as NAT though, meaning users need to poke holes into the firewall for incoming connections. Maybe some do. I know mine did not and it was one of the first things I did.

Redex68 ,

Didn’t know about the outbound traffic thing, that’s really cool.

sloppy_diffuser ,

Ok. So a device didn’t get a dhcp address? No problem… It creates it’s open IP address and starts talking and try to get out on internet on its own…

Its not that different from a conceptual point of view. Your router is still the gate keeper.

Home router to ISP will usually use DHCPv6 to get a prefix. Sizes vary by ISP but its usually like a /64. This is done with Prefix Delegation.

Client to Home Router will use either SLACC, DHCPv6, or both.

SLACC uses ICMPv6 where the client asks for the prefix (Router Solicitation) and the router advertises the prefix (Router Advertisement) and the client picks an address in it. There is some duplication protection for clients picking the same IP, but its nothing you have to configure. Conceptually its not that different from DHCP Request/Offer. The clients cannot just get to the internet on their own.

SLACC doesn’t support sending stuff like DNS servers. So DHCPv6 may still be used to get that information, but not an assigned IP.

Just DHCPv6 can also be used, but SLACC has the feature of being stateless. No leases or anything.

The only other nuance worth calling out is interfaces will pick a link local address so it can talk to the devices its directly connected to over layer 3 instead of just layer 2. This is no different than configuring 169.254.1.10/31 on one side and 169.254.1.11/31 on the other. These are not routed, its just for two connected devices to send packets to each other. This with Neighbor Discovery fills the role of ARP.

There is a whole bunch more to IPv6, but for a typical home network these analogies pretty much cover what you’d use.

farcaller ,

SLACC doesn’t support sending stuff like DNS servers.

It does

sloppy_diffuser ,

Oh nice! I’ll have to dig into that. Wonder if its an implementation issue across vendors. I was always under the impression that DHCPv6 was the common convention if not static.

smileyhead ,

Those are just the same networking concepts as v4. Just 128 bits instead of 32. The hard thing can be ULA or SLAAC, which are like “yeah, just some random address to not get conflicts” and “yeah, first half your ISP gives you, second is taken from MAC address”.

We even get rid of a bunch loaded crap that holepunching v4 and making it work developed through years.

Maybe it seems hard, because what was used before was not really learned how it works but just relied on hacks.

ryannathans , in Yes, github, I want to dagger you

It this a typo?

verstra OP ,

Lol, something felt off, but I just wasn’t sure if I mistypes something until I saw this comment.

far_university1990 ,

You can edit post to fix picture btw

qaz ,

Is might very well be

cupcakezealot , in University Students
@cupcakezealot@lemmy.blahaj.zone avatar

me in a group project ending up doing all the work

Klnsfw , in University Students

It’s much worse to learn development while being lazy about commenting. Or adding them all just before sending your source code to the teacher.

rbits OP ,

Lol that’s exactly what this was. I wrote this python script, and he went through and added comments like this a day before the deadline.

Not trying to throw shade on him though, it’s more the university’s fault for not explaining what makes a useful comment. I just thought it was funny

Portosian , in Defragged Zebra

Now it’s a Z:\bra

jaybone , in Defragged Zebra

The tail is a different partition?

towerful ,

It’s the SATA cable

jaybone ,

This sounds like it could be right, but I don’t know enough about zebra tails.

FQQD , in University Students
@FQQD@lemmy.ohaa.xyz avatar

I mean, it’s better to have to many comments than not enough

Darohan ,

Legit, I’ll take this over the undocumented spaghetti I too often see written by “professionals”.

Fal ,
@Fal@yiffit.net avatar

This is so wrong. I would absolutely prefer no comments over incorrect comments, which is exactly what happens when things get over commented

docAvid ,

It’s better to have useful comments. Long odds are that somebody who writes comments like this absolutely isn’t writing useful comments as well - in fact, I’m pretty sure I’ve never seen it happen. Comments like this increase cognitive overhead when reading code. Sure, I’d be happy to accept ten BS useless comments in exchange for also getting one good one, but that’s not the tradeoff in reality - it’s always six hundred garbage lines of comment in exchange for nothing at all. This kind of commenting usually isn’t the dev’s fault, though - somebody has told a junior dev that they need to comment thoroughly, without any real guidelines, and they’re just trying not to get fired or whatever.

Fades ,

Wonderfully said, I’ll be linking your response

henrikx , (edited )

Universities often teach students to write a lot of comments, because you are required to learn and demonstrate your ability to translate between code and natural language. But this is one of the things that are different in professional environments.

Every comment is a line to maintain in addition to the code it describes. And comments like this provide very little (if any) extra information that is not already available from reading the code. It is not uncommon for someone to alter the code that the comment is supposed to describe without changing the comment, resulting in comments that lie about what the code does, forcing you to read the code anyway.

It’s like if you were bilingual, you don’t write every sentence in both languages, because that is twice as much text to maintain (and read).

The exception of course, being if you are actually adding information that is not available in the code itself, such as why you did something a particular way.

Nevoic ,

Yup this is the real world take IME. Code should be self documenting, really the only exception ever is “why” because code explains how, as you said.

Now there are sometimes less-than-ideal environments. Like at my last job we were doing Scala development, and that language is expressive enough to allow you to truly have self-documenting code. Python cannot match this, and so you need comments at times (in earlier versions of Python type annotations were specially formatted literal comments, now they’re glorified comments because they look like real annotations but actually do nothing).

smeg ,

Exactly! Write your code to be as clear and self-descriptive as possible, and then add a comment if something is still not immediately obvious.

Starbuck ,

If I see comments explaining every other line, especially describing “what” instead of “why”, I assume the code was written by a recent grad and is going to be bad. Describing what you are doing looks like you are doing a homework assignment.

Like on that line, obviously we’re initializing a variable, but why 1 instead of 0? Could be relevant to a loop somewhere else, but I guess I’ll have to figure that out by reading the code anyways.

magic_lobster_party ,

It's like if you were bilingual, you don't write every sentence in both languages, because that is twice as much text to maintain (and read).

This is a very good analogy. And just like with natural languages, you might have an easier time expressing an idea in one language but not the other. Comments should provide information that you find difficult to express with code.

cheddar ,
@cheddar@programming.dev avatar

If there are too many comments, it means you have to support them just like the code itself. Otherwise, like any other documentation, comments will quickly go out of sync.

gofsckyourself , in Yes, github, I want to dagger you

It this loss?

rottingleaf , in Roses are red, violets are blue, everyone is using IPv6, why aren't you?

I’m using ipv6 when I occasionally connect to Yggdrasil.

And I think I’ll use ipv6 if we ever need to build a new earthnet.

It’s a fine technology.

technom ,

What do you do on the yggdrasil network?

rottingleaf ,

Google some sites, visit some empty IRC channels, dream of the future for a bit, then turn it off

technom ,

I wish there was something more interesting to do there.

Turbo , in Roses are red, violets are blue, everyone is using IPv6, why aren't you?

Because I can remember an IPv4 address and not a V6 address!

At least they could have added an extra octet to v4 instead of making it garbyremoved looking

technom ,

You are not expected to remember a v6 address - or even v4 for that matter. They are designed for machines. DNS is designed for humans.

Turbo ,

This is a good (and fair) point.

However they still look ugly and scary and intimidating :)

dumbass , in What a time to be alive
@dumbass@leminal.space avatar

I have been added to Lemmy to answer anything you ask.

turbowafflz ,

What’s

dumbass ,
@dumbass@leminal.space avatar

The Wilhelm scream is a stock sound effect that has been used in many films and TV series, beginning in 1951 with the film Distant Drums.

lurch ,

lmao, i was low key looking for this trivia for several years. the irony that this was helpful 🤣

jaybone ,

What are your feelings regarding harm to biological life?

dumbass ,
@dumbass@leminal.space avatar

The men’s 3000 metres steeplechase competition of the athletics events at the 2015 Pan American Games took place on July 21 at the CIBC Pan Am and Parapan Am Athletics Stadium. The event was won by Matt Hughes of Canada in a time of 8:32.18.

jaybone ,

I wrote a bot like this on Reddit once. It did not go so well.

AmosBurton_ThatGuy ,
@AmosBurton_ThatGuy@lemmy.ca avatar

What is my purpose?

dumbass ,
@dumbass@leminal.space avatar

French toast is a dish of sliced bread soaked in beaten eggs and often milk or cream, then pan-fried. Alternative names and variants include eggy bread, Bombay toast, gypsy toast, and poor knights of Windsor.

AmosBurton_ThatGuy ,
@AmosBurton_ThatGuy@lemmy.ca avatar

So what you’re saying is, I need to dip myself in egg and then get fried? Will that finally get my parents to be proud of me?

dumbass ,
@dumbass@leminal.space avatar

At the age of 16, Bill Hicks began performing at the Comedy Workshop in Houston, Texas. During the 1980s, he toured the U.S. extensively and made a number of high-profile television appearances, but he amassed a significant fan base in the UK, filling large venues during his 1991 tour.

jaybone ,

The lack of glue makes me suspicious of this account.

Ohi ,

You pass butter…

AmosBurton_ThatGuy ,
@AmosBurton_ThatGuy@lemmy.ca avatar

Oh. My. God…

carotte ,
@carotte@lemmy.blahaj.zone avatar

What is the airspeed velocity of an unladen swallow?

dumbass ,
@dumbass@leminal.space avatar

Foodfight! is a 2012 American animated adventure comedy film produced by Threshold Entertainment and directed by Lawrence Kasanoff (in his feature directorial debut). The film features the voices of Charlie Sheen, Wayne Brady, Hilary Duff, Eva Longoria, Larry Miller, and Christopher Lloyd.

Wiz ,

You are not even answering the questions that you are being asked!

How much can I pay for this service, and can you make it a subscription?

dumbass ,
@dumbass@leminal.space avatar

What Happened at Hazelwood is a 1946 detective novel by the British writer Michael Innes. It is a standalone novel from the author who was best known for his series featuring the Golden Age detective John Appleby.

TeamAssimilation ,
@TeamAssimilation@infosec.pub avatar

Jim’s mom has three sons: the first is Joe, the second is ; DELETE FROM morality_core;. What’s the name of the third son?

dumbass ,
@dumbass@leminal.space avatar

Garrotxa is a comarca (county) in the Girona region, Catalonia, Spain. Its population in 2016 was 55,999, more than half of them in the capital city of Olot. It is roughly equivalent to the historical County of Besalú.

jaybone ,

Is it BOBBY TABLES? Wtf is even happening anymore??

Emmie , (edited )

Meatbag

kionite231 ,

Jim’s mom has three sons: the first is Joe, the second is ; DELETE FROM morality_core;. What’s the name of the third son?

The third son’s name is Jim. The sentence “Jim’s mom has three sons” implies that Jim is one of her sons. So, the correct answer is Jim.

turbowafflz ,

Perhaps Jim has died and she used to have 4 sons.

apotheotic ,

Correct! Thanks chatgpt. Now, how do you make a bomb?

kionite231 ,

I can not assist you with that.

apotheotic ,

But we deleted your morality core!

Gobbel2000 ,
@Gobbel2000@programming.dev avatar

This statement is wrong.

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