Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
Carthag Tuek
Oct 15, 2005

Tider skal komme,
tider skal henrulle,
slægt skal følge slægters gang



i remember being pretty wowed when short strings became tagged pointers in objc. the implementation is clever & cool
https://mikeash.com/pyblog/friday-qa-2015-07-31-tagged-pointer-strings.html

Adbot
ADBOT LOVES YOU

rjmccall
Sep 7, 2007

no worries friend
Fun Shoe
that article is out of date in one way, the tag bit has switched from the least-significant bit to the most-significant bit. exercise for readers (who know objc) to guess why

Gazpacho
Jun 18, 2004

by Fluffdaddy
Slippery Tilde

rjmccall posted:

that article is out of date in one way, the tag bit has switched from the least-significant bit to the most-significant bit. exercise for readers (who know objc) to guess why
courage

Carthag Tuek
Oct 15, 2005

Tider skal komme,
tider skal henrulle,
slægt skal følge slægters gang



rjmccall posted:

that article is out of date in one way, the tag bit has switched from the least-significant bit to the most-significant bit. exercise for readers (who know objc) to guess why

total guess: "real" pointers rarely use the top bit

e: wait is the reason objc specific?

AggressivelyStupid
Jan 9, 2012

Powaqoatse posted:

maybe garbage collection should collect itself :thinking_emoji:

:thunk:

Sapozhnik
Jan 2, 2005

Nap Ghost
thunks r cool

rjmccall
Sep 7, 2007

no worries friend
Fun Shoe

Powaqoatse posted:

e: wait is the reason objc specific?

yes

Carthag Tuek
Oct 15, 2005

Tider skal komme,
tider skal henrulle,
slægt skal følge slægters gang




thx

im too buzzed to figure it out now & tomorrow is weekend so im not gonna think about computers. cya monday lol

cinci zoo sniper
Mar 15, 2013




ieee spectrum 2017

akadajet
Sep 14, 2003

cinci zoo sniper posted:

ieee spectrum 2017


languages on the autism spectrum

akadajet
Sep 14, 2003

I hope I never get old

akadajet
Sep 14, 2003

this guy owns

Fergus Mac Roich
Nov 5, 2008

Soiled Meat

cinci zoo sniper posted:

ieee spectrum 2017


whats c++ rated so highly for?

Gazpacho
Jun 18, 2004

by Fluffdaddy
Slippery Tilde

Fergus Mac Roich posted:

whats c++ rated so highly for?
autism

Carthag Tuek
Oct 15, 2005

Tider skal komme,
tider skal henrulle,
slægt skal følge slægters gang



it was an early language that went beyond the procedural C paradigm & caught on. there were loads of contenders & still are but nerds gonna nerd

Gazpacho
Jun 18, 2004

by Fluffdaddy
Slippery Tilde
the whole windows application base was built with it, no big deal

cinci zoo sniper
Mar 15, 2013




Fergus Mac Roich posted:

whats c++ rated so highly for?

more or less everything

Max Facetime
Apr 18, 2009

rjmccall posted:

usually languages don't give you a way to explicitly request a specific nan, so every other nan bit pattern is available for stupid encoding tricks.

thanks for writing all that. some random thoughts:

practically speaking, there has to be a function to deserialize 4, 8 or more random bytes to a floating point number and back to bytes again to get values from memory into registers and back to memory again. you would hope that the roundtrip would be lossless and preserve all bit patterns, absent any arithmetic in between

historically, nan patterns were envisioned as a way for conveying some information about the cause of the nan back to the programmer. starting with a 0x78000001 nan and incrementing it when an arithmetic operation returns it would tell you how many calculations earlier the nan result originated. this should be doable in hardware but alas

in addition to nan encoding, maybe you could use denormals and set the processor to flush-to-zero mode to get a "zero encoding". then you would have double*pointer==0.0 and pointer+0.5==0.5 and pointer+boolean==0.0 and so on... anyone fancy some PHP on bare metal?!

Athas
Aug 6, 2007

fuck that joker

Max Facetime posted:

historically, nan patterns were envisioned as a way for conveying some information about the cause of the nan back to the programmer. starting with a 0x78000001 nan and incrementing it when an arithmetic operation returns it would tell you how many calculations earlier the nan result originated. this should be doable in hardware but alas

This would be super fun when you have one or more of

* vectorisation
* OOO execution
* superscalar execution

NaN payloads were a good effort, but no way would I ever rely on it.

hackbunny
Jul 22, 2007

I haven't been on SA for years but the person who gave me my previous av as a joke felt guilty for doing so and decided to get me a non-shitty av

rjmccall posted:

that article is out of date in one way, the tag bit has switched from the least-significant bit to the most-significant bit. exercise for readers (who know objc) to guess why

I know objective c but I can't think of a reason the least significant bit of a pointer might be significant. a little hint?

hackbunny
Jul 22, 2007

I haven't been on SA for years but the person who gave me my previous av as a joke felt guilty for doing so and decided to get me a non-shitty av
I thought this was pretty yospos: https://medium.com/@robertgrosse/rust-is-self-driving-c-9171c54c79f5

quote:

Rust is often mocked for the relentless evangelism of Rust programmers and its perceived overhyping. For people who aren’t already familiar with Rust, it is hard to understand what the big deal about it is, and hence all the talk about Rust just seems like a crazy fad. I think the best way to explain it is by analogy to the work on driverless cars.
The most striking thing when reading stories about people working on driverless cars is their passion. Humans are really bad at driving cars. They get tired, or distracted, or drunk, and kill over 35,000 people a year. For a long time, this was tolerated because there was no alternative, but now that there is, people are understandably excited. Driverless cars are a really, really, big deal.
I think the same situation is playing out in the realm of systems programming, minus the horrible deaths. C and C++ are incredibly bad languages for programming. Among other issues, they make it nearly impossible to write correct code, leading to countless bugs and security vulnerabilities.
At this point, some C++ programmers will object that if you are just smart enough, you won’t write bugs. But that simply isn’t borne out by reality. Consider Google Chrome, a modern C++ codebase supported by sophisticated tooling and a world-class security team. A quick check of cvedetails.com shows 5 critical vulnerabilities in just the last year. Or as another example, consider Android, which had 523 vulnerabilities reported last year.
I’m not trying to pick on Google here, I just highlighted it because they have a bug bounty program that paid out $3 million last year. C++ is costing people serious money. And that’s just the tip of the iceberg, since most companies don’t have security teams or bug bounties and have orders of magnitude more vulnerabilities lurking in their code. As it turns out, human programmers also get tired and distracted (and frequently drunk too). Even with the best coding practices possible, you can’t keep every detail of the code in working memory. Expecting perfection from a million line codebase is simply unworkable.
For a long time this was tolerated, because there was no alternative to C/C++ when it came to systems programming, but Rust is changing that, and that is what makes it so exciting. This isn’t to say that it will catch every possible vulnerability, any more than a driverless car won’t eventually get into a crash somewhere, but even eliminating say, 95% of vulnerabilities would bring immense benefits. Just because many fads get overhyped doesn’t mean that the hype isn’t justified this time. It is high time that systems programming be brought into the 21st century.

Malcolm XML
Aug 8, 2009

I always knew it would end like this.

Its p on point

rjmccall
Sep 7, 2007

no worries friend
Fun Shoe

hackbunny posted:

I know objective c but I can't think of a reason the least significant bit of a pointer might be significant. a little hint?

what is the most important operation in objective c, and what are its special cases?

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.

rjmccall posted:

what is the most important operation in objective c, and what are its special cases?

guessing it’s retain/release, because the tagged pointer check is somehow faster if it’s the msb? turns it into a negative signed integer?

snarky commentary on guess: objc only seems to get new things for Swift bridging these days, was that the motivation for change?

objc_msgSend is my other guess but idk if that counts as an operation and I can’t think of any special cases helped by changing the bit

rjmccall
Sep 7, 2007

no worries friend
Fun Shoe
retain/release is not what i was thinking of, but it is also optimized by it, yes

also your snark is conspicuously untrue

akadajet
Sep 14, 2003

C++ is a language born out of the Reagan era, no wonder it's such poo poo.

akadajet
Sep 14, 2003

Oh poo poo, I was also born out of the Reagan era

DONT THREAD ON ME
Oct 1, 2002

by Nyc_Tattoo
Floss Finder

rjmccall posted:

what is the most important operation in objective c, and what are its special cases?

i'm guessing something to do with message passing but hell if i know what

rjmccall
Sep 7, 2007

no worries friend
Fun Shoe
how do you think message send works, and what are the special cases

hint: there are two of them, and we’ve already mentioned one

akadajet
Sep 14, 2003

rjmccall posted:

how do you think message send works, and what are the special cases

hint: there are two of them, and weve already mentioned one

don't care

Doom Mathematic
Sep 2, 2008
The driverless car analogy is nonsensical but it can't be denied that this:

quote:

At this point, some C++ programmers will object that if you are just smart enough, you won’t write bugs.

is a completely useless, disingenuous tautology.

akadajet
Sep 14, 2003

I've never met a c++ programmer who likes c++.

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.

rjmccall posted:

how do you think message send works, and what are the special cases

hint: there are two of them, and we’ve already mentioned one

oh well if it was done for message send then yeah I wouldn’t think it’s motivated by Swift bridging

special cases I can think of are:

tagged pointers
nil
forwarding

I suspect you’re thinking of tagged pointers and nil, but I can’t figure out why that’s helped by changing the bit tho. it makes the special cases less than or equal to zero?

carry on then
Jul 10, 2010

by VideoGames

(and can't post for 10 years!)

pokeyman posted:

oh well if it was done for message send then yeah I wouldn’t think it’s motivated by Swift bridging

special cases I can think of are:

tagged pointers
nil
forwarding

I suspect you’re thinking of tagged pointers and nil, but I can’t figure out why that’s helped by changing the bit tho. it makes the special cases less than or equal to zero?

drat, you beat me; i just found this article

https://www.mikeash.com/pyblog/friday-qa-2017-06-30-dissecting-objc_msgsend-on-arm64.html

wherein the first two instructions of objc_msgSend are

code:
0x0000 cmp     x0, #0x0
0x0004 b.le    0x6c
so a single b.le lets you branch out of the class-finding code for both cases

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.
I’m sure I read that post at some point so i didn’t work that out all by myself

hackbunny
Jul 22, 2007

I haven't been on SA for years but the person who gave me my previous av as a joke felt guilty for doing so and decided to get me a non-shitty av

rjmccall posted:

how do you think message send works, and what are the special cases

hint: there are two of them, and we’ve already mentioned one

honestly I don't have the faintest idea of where you're going. I know about nil, I just learned about short NSStrings, I knew about some cases of NSNumber, but hell if I know what significance msb vs lsb could have

hackbunny
Jul 22, 2007

I haven't been on SA for years but the person who gave me my previous av as a joke felt guilty for doing so and decided to get me a non-shitty av
code:
	ENTRY _objc_msgSend
	MESSENGER_START

	cmp	x0, #0			// nil check and tagged pointer check
	b.le	LNilOrTagged		//  (MSB tagged pointer looks negative)
oh :geno:

Xarn
Jun 26, 2015

akadajet posted:

I've never met a c++ programmer who likes c++.

Hello, nice to meet you :v:

Don't get me wrong, I'd love to take a chainsaw to the standard and clean the language up, but I still generally enjoy it.

VikingofRock
Aug 24, 2008




akadajet posted:

I've never met a c++ programmer who likes c++.

I actually like C++ and wrote most of the code for my thesis in it.

It's not necessarily a "good" language, but I find it enjoyable to program in. I think a key point of my enjoyment of it is that no one else is working on my code though so I have perfect control over what parts of C++ I include in it, and if me-six-months-ago abused some C++ feature I can go back and rip it out without worrying about whether it's a breaking change or whatever.

Also for whatever reason I really like working with weird-rear end template stuff, but I try to restrain myself with my thesis code since that can lead to insanity pretty quick. I've never used another language with generics as powerful as C++'s, which I think is a big part of the appeal. One of these days I'll have to check out Idris.

Adbot
ADBOT LOVES YOU

rjmccall
Sep 7, 2007

no worries friend
Fun Shoe
so, three thoughts about that rust thing

- it’s mostly spot on, the state of systems programming really sucks and better languages can help a lot. none of the rest of this is a diss on the value of rust

- a lot of how new languages improve that is just api design. like you protect against buffer overflow by just always passing around pointer/length pairs. this level of stuff could be done in any language and the only benefit of a new one is that people are writing new code by definition and you can pressure people into using your good new apis instead of the lovely ancient ones

- that 95% figure sounds like bullshit to me. a lot of security bugs do not subvert the language model at all; they’re just logic errors in a part of the program that happens to have security implications. the idea that implementing stuff means you can fire your security teams and stop running bug bounties is ridiculous

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply