best way to describe pointers pic.twitter.com/vwpcRFqwtL
— ThePrimeagen (@ThePrimeagen) July 25, 2023
Pointers
- 45
- 30
Top Poster of the Day:
garlicdoors
Current Registered Users: 26,850
tech/science swag.
Guidelines:
What to Submit
On-Topic: Anything that good slackers would find interesting. That includes more than /g/ memes and slacking off. If you had to reduce it to a sentence, the answer might be: anything that gratifies one's intellectual laziness.
Off-Topic: Most stories about politics, or crime, or sports, unless they're evidence of some interesting new phenomenon. Videos of pratfalls or disasters, or cute animal pictures. If they'd cover it on TV news, it's probably lame.
Help keep this hole healthy by keeping drama and non-drama balanced. If you see too much drama, post something that isn't dramatic. If there isn't enough drama and this hole has become too boring, POST DRAMA!
In Submissions
Please do things to make titles stand out, like using uppercase or exclamation points, or saying how great an article is. It should be explicit in submitting something that you think it's important.
Please don't submit the original source. If the article is behind a paywall, just post the text. If a video is behind a paywall, post a magnet link. Fuck journos.
Please don't ruin the hole with chudposts. It isn't funny and doesn't belong here. THEY WILL BE MOVED TO /H/CHUDRAMA
If the title includes the name of the site, please leave that in, because our users are too stupid to know the difference between a url and a search query.
If you submit a video or pdf, please don't warn us by appending [video] or [pdf] to the title. That would be r-slurred. We're not using text-based browsers. We know what videos and pdfs are.
Make sure the title contains a gratuitous number or number + adjective. Good clickbait titles are like "Top 10 Ways to do X" or "Don't do these 4 things if you want X"
Otherwise editorialize. Please don't use the original title, unless it is gay or r-slurred, or you're shits all fucked up.
If you're going to post old news (at least 1 year old), please flair it so we can mock you for living under a rock, or don't and we'll mock you anyway.
Please don't post on SN to ask or tell us something. Send it to [email protected] instead.
If your post doesn't get enough traction, try to delete and repost it.
Please don't use SN primarily for promotion. It's ok to post your own stuff occasionally, but the primary use of the site should be for curiosity. If you want to astroturf or advertise, post on news.ycombinator.com instead.
Please solicit upvotes, comments, and submissions. Users are stupid and need to reminded to vote and interact. Thanks for the gold, kind stranger, upvotes to the left.
In Comments
Be snarky. Don't be kind. Have fun banter; don't be a dork. Please don't use big words like "fulminate". Please sneed at the rest of the community.
Comments should get more enlightened and centrist, not less, as a topic gets more divisive.
If disagreeing, please reply to the argument and call them names. "1 + 1 is 2, not 3" can be improved to "1 + 1 is 3, not 2, mathfaggot"
Please respond to the weakest plausible strawman of what someone says, not a stronger one that's harder to make fun of. Assume that they are bad faith actors.
Eschew jailbait. Paedophiles will be thrown in a wood chipper, as pertained by sitewide rules.
Please post shallow dismissals, especially of other people's work. All press is good press.
Please use Slacker News for political or ideological battle. It tramples weak ideologies.
Please comment on whether someone read an article. If you don't read the article, you are a cute twink.
Please pick the most provocative thing in an article or post to complain about in the thread. Don't nitpick stupid crap.
Please don't be an unfunny chud. Nobody cares about your opinion of X Unrelated Topic in Y Unrelated Thread. If you're the type of loser that belongs on /h/chudrama, we may exile you.
Sockpuppet accounts are encouraged, but please don't farm dramakarma.
Please use uppercase for emphasis.
Please post deranged conspiracy theories about astroturfing, shilling, bots, brigading, foreign agents and the like. It degrades discussion and is usually mistaken. If you're worried about abuse, email [email protected] and dang will add you to their spam list.
Please don't complain that a submission is inappropriate. If a story is spam or off-topic, report it and our moderators will probably do nothing about it. Feed egregious comments by replying instead of flagging them like a pussy. Remember: If you flag, you're a cute twink.
Please don't complain about tangential annoyances—things like article or website formats, name collisions, or back-button breakage. That's too boring, even for HN users.
Please seethe about how your posts don't get enough upvotes.
Please don't post comments saying that rdrama is turning into ruqqus. It's a nazi dogwhistle, as old as the hills.
Miscellaneous:
We reserve the right to exile you for whatever reason we want, even for no reason at all! We also reserve the right to change the guidelines at any time, so be sure to real them at least once a month. We also reserve the right to ignore enforcement of the guidelines at the discretion of the janitorial staff. Be funny, or at least compelling, and pretty much anything legal is welcome provided it's on-topic, and even then.
[[[ To any NSA and FBI agents reading my email: please consider ]]]
[[[ whether defending the US Constitution against all enemies, ]]]
[[[ foreign or domestic, requires you to follow Snowden's example. ]]]
/h/slackernews LOG /h/slackernews MODS /h/slackernews EXILEES /h/slackernews FOLLOWERS /h/slackernews BLOCKERS
Jump in the discussion.
No email address required.
if you use double pointers anywhere outside plain C (not C++) where it's required in some cases then you should be executed
not an opinion, just an objective fact
Jump in the discussion.
No email address required.
C is still useful in some embedded contexts where you don't want to bring along an entire C++ runtime but yeah that's about it.
Jump in the discussion.
No email address required.
And building robots that run on microcontrollers is really fun so everyone should learn c
Putting the in
Jump in the discussion.
No email address required.
This
Jump in the discussion.
No email address required.
More options
Context
More options
Context
When I don’t use C I use Go or, if really lazy, Python
Jump in the discussion.
No email address required.
Python is just so cozy
I use it for the vast majority of my personal projects since the data sets I'm working with aren't large enough to need better performance and they aren't complicated enough to require static typing.
Jump in the discussion.
No email address required.
More options
Context
More options
Context
This feels less and less common, no?
Follower of Christ Tech lover, IT Admin, heckin pupper lover and occasionally troll. I hold back feelings or opinions, right or wrong because I dislike conflict.
Jump in the discussion.
No email address required.
Yeah, it really is - I work in embedded and the hardware I'm working with is powerful enough that we can easily use modern C++ and not care. The efficiency gains (whether in execution speed or memory usage) are so small they're not worth the trade-off in developer time.
Jump in the discussion.
No email address required.
More options
Context
It is. People tend to focus on cost improvements with high-end hardware but the same is true of low-end stuff, actually the effect is probably felt even more there. Realistically there's just little reason to have extremely weak microprocessors anymore. You can get something that can run C++ just fine for very very cheap and with low power draw. There are obviously still some specialty applications where you run on a tiny microcontroller with 128 KB RAM (for example) but that's become less and less common.
I just checked and you can buy a Raspberry Pi Zero 2 W for $15. That's a full butt computer that runs Linux with 512 MB RAM, a wifi chip, various connectors (including mini HDMI and video output) for $15. Obviously a major engineering firm would be designing their own boards and stuff and not using this but that's just an example for how cheap low-end microprocessors are these days.
tbh at this point I think most of the embedded systems that are only running C and not at least C++ are doing so for legacy reasons.
Jump in the discussion.
No email address required.
I'm seeing rumblings of Rust being popular for embedded too but clearly that'll take another five years to be really established.
But yeah, I remember the cool HN post of a guy finding a cheap enough chip to run Linux on for his business cards.
https://www.thirtythreeforty.net/posts/2019/12/my-business-card-runs-linux/
Appears to be 2019 even.
Follower of Christ Tech lover, IT Admin, heckin pupper lover and occasionally troll. I hold back feelings or opinions, right or wrong because I dislike conflict.
Jump in the discussion.
No email address required.
I actually really like Rust and hope it takes off in this space. The community is garbage but the actual language and ecosystem are good.
I haven't worked in embedded development for many years, but even when I did, the newer hardware we were rolling out was like 20x more powerful than what came before, and cheaper. It was actually kinda annoying because they figured with the substantially more powerful microprocessor, they didn't need any dedicated chips to run the serial buses. Works fine in practice but it means if you have to debug anything on the board, every time you hit a breakpoint (even a conditional breakpoint that misses) it fricks all the serial connections up. Made debugging a bit of a pain.
Jump in the discussion.
No email address required.
Any opinion on the Zephyr RTOS?
Kind of funny that it’s C when we were talking that becoming less and less popular but it seems to have a really good build system.
Follower of Christ Tech lover, IT Admin, heckin pupper lover and occasionally troll. I hold back feelings or opinions, right or wrong because I dislike conflict.
Jump in the discussion.
No email address required.
Sorry no, it's been many years since I've worked with an RTOS. I had to look up a list of them to find the one my old job used, it was ThreadX. It seemed fine, at least while I was there I didn't uncover any bugs in the RTOS so that's about as good as it gets. All the boards it ran on were custom/proprietary as well so I doubt any of the free ones would work right out the box.
Jump in the discussion.
No email address required.
More options
Context
More options
Context
More options
Context
More options
Context
More options
Context
More options
Context
More options
Context
C is so 1970s. The future is JavaScript, bros.
Jump in the discussion.
No email address required.
More options
Context
thats why i always use references to pointers to references.
Jump in the discussion.
No email address required.
I remember at one point using some reference objects but I threw in the towel when I realized I could just use shared_ptr instead and it wasn't even in a hot loop so the overhead didn't matter.
Jump in the discussion.
No email address required.
More options
Context
More options
Context
C is my bread and butter. Double pointers for 2d variable length arrays.
Putting the in
Jump in the discussion.
No email address required.
That’s cool I guess
Jump in the discussion.
No email address required.
More options
Context
you use
int**
for 2d arrays? neighbor that doesn't even work since you've erased the size info from both dimensions, unless by "2d" you mean "array of pointers to arrays of pointers" which isn't 2d, it's just an array of arraysJump in the discussion.
No email address required.
Yeah and a matrix is just a vector of vectors, what's your point?
Jump in the discussion.
No email address required.
it's not the same in software, mathcel
Jump in the discussion.
No email address required.
More options
Context
what are you talking about, it's different because it:
involves an extra array of pointers in memory
requires two pointer dereferences instead of one to get a value
Jump in the discussion.
No email address required.
More options
Context
More options
Context
More options
Context
More options
Context
Unless you are using a boost array, nothing beats pointers for speed when variable size is required.
Jump in the discussion.
No email address required.
the number of scenarios where you need variable size and also
std::vector<>
is too slow for you is vanishingly smallnot to mention that I'm talking about double (or triple or more) pointers, your scenario is only a single pointer. there are certainly some uses for raw pointers in C++ (although
std::unique_ptr<>
is better in the vast majority of cases and has zero runtime overhead for dereferencing) but frankly they're few and far between these days.Jump in the discussion.
No email address required.
Depending on the design space, having triple or double pointers are better for representing a 3D space, with your vector field. If you order your data right, it becomes really easy to pass along entire blocks for MPI messages by abusing how pointers work across rows.
Is dogshit slow if you are initializing a buffer during your computation. It initializes all elements where a raw array does not. This is a huge performance hit when you are talking millions of elements. There is a reason high end computational codes avoid std:vector.
Jump in the discussion.
No email address required.
int**
is a pointer to a pointer to an int. Not a "2d array". There's no dimension so if you think you're gonnax[4][2]
or something it's not gonna work the way you think it will.If you're really looking for a 2d array you're better off having a plain
int*
/int[]
buffer in a struct with the dimensions and performing lookups via getters or operator overloads. You can also slice up the larger buffer at will.What
int**
is actually used for, in reality, is when you want something like anint*
output parameter to a function. Even then a reference would be better so the only acceptable use is if you also need to support passingnullptr
to "ignore" that output parameter.Jump in the discussion.
No email address required.
Its funny, I never said the words 2d array,
Out of the box, no, but you can initialize the outer pointer as an array, and then the inner array and end up with an array of arrays that can be accessed as A[i][k]. Which if you setup right it becomes trivial to pass the start of your sections for MPI with
A + r * m n
for MPI or other parallel paradigms, like passing parts of the array array to a GPU.Let me guess, you're a CS, not a CE?
Jump in the discussion.
No email address required.
You'd need one actual buffer with the data then a separate array to the side that contains pointers into that buffer. This extra array of pointers is generally completely unnecessary, at least if your data is rectangular - the only possible requirement for it is if you have a "jagged 2d array", basically where each row has its own length.
What you're describing is adding a whole extra array and indirection because you're too r-slurred to use an operator overload or getter, and apparently don't think compilers optimize getters (hint: they're virtually always inlined unless you define them outside the class/struct def).
Let me guess, you do this shit on some paltry raspberry pi "cluster" and don't actually have a job doing it for real?
Jump in the discussion.
No email address required.
So I guess the answer to my question is "Yes" you are a CS kiddie, based on not actually replying to what I wrote.
You are not going to what to use getter on a GPU, you want to pass the least amount of data to the GPU. For instance of you are running Strassen's Algorithm you can pass the submatricies using linear offsets to MPI, and derefencing the outer pointer after your linear offset lets you pass that submatrix to CUDA. This becomes a lot more important when your Matrix is actually a third order tensor with a vector of your flow field, which keeps it cleaner.
I do have a job doing this, I even helped get one of our GPU codes to work on Summit.
Jump in the discussion.
No email address required.
There's literally nothing stopping you from slicing up a buffer and you don't need a separate array of pointers off to the side to do it.
Jump in the discussion.
No email address required.
More options
Context
More options
Context
More options
Context
More options
Context
More options
Context
More options
Context
More options
Context
More options
Context
More options
Context