Readit News logoReadit News
tialaramex commented on I write games in C (yes, C) (2016)   jonathanwhiting.com/writi... · Posted by u/valyala
jonahx · a day ago
Maybe (and I like C, for the record), but it doesn't follow necessarily. It's possible most of those devs were attracted by "working on linux," and are putting up with the pain of collaborative C. I know there's a movement pushing for more Rust.
tialaramex · 13 hours ago
I think the popularity of Rust for Linux is also in part a reflection of internal discontent with poorly documented and sometimes straight up poorly understood kernel internal APIs.

When a developer asks Can I Fizzle this Doodad? C is comfortable with the answer being "It'll definitely compile but whether it would work is complicated - ask the expert on Fizzling and the Doodad expert, and hope they give the same answer" but Rust wants the answer to be "Yes" or "No" or at the very least, "Here is some actual text explaining when that's fine"

Sometimes it really is hard work to figure this out but for a project as big as Linux even in those cases it's often worth doing that hard work, because you unlock something valuable for every non-expert contributor and Linux has a lot of those.

tialaramex commented on I write games in C (yes, C) (2016)   jonathanwhiting.com/writi... · Posted by u/valyala
teo_zero · a day ago
You can surely create a std::string-like type in C, call it "newstring", and write functions that accept and return newstrings, and re-implement the whole standard library to work with newstrings, from printf() onwards. But you'll never have the comfort of newstring literals. The nice syntax with quotes is tied to zero-terminated strings. Of course you can litter your code with preprocessor macros, but it's inelegant and brittle.
tialaramex · 14 hours ago
Because C wants to run on bare metal, an allocating type like C++ std::string (or Rust's String) isn't affordable for what you mean here.

I think you want the string slice reference type, what C++ called std::string_view and Rust calls &str. This type is just two facts about some text, where it is in memory and how long it is (or equivalently where it ends, storing the length is often in practice slightly faster in real machines so if you're making a new one do that)

In C++ this is maybe non-obvious because it took until 2020 for C++ to get this type - WG21 are crazy, but this is the type you actually want as a fundamental, not an allocating type like std::string.

Alternatively, if you're not yet ready to accept that all text should use UTF-8 encoding, -- and maybe C isn't ready for that yet - you don't want this type you just want byte slice references, Rust's &[u8] or C++ std::span<char>

tialaramex commented on Where did all the starships go?   datawrapper.de/blog/scien... · Posted by u/speckx
chasil · a day ago
Life cannot leave, no.

A radiation hardened, self healing computer could.

tialaramex · 18 hours ago
I think you should assume that the radiation hardened, self healing computer would consider itself alive.

But importantly that's not us leaving. Some distant future descendent of humans could have engineered itself to leave, but it's not us and we shouldn't fixate on that distant and unknowable future.

tialaramex commented on I write games in C (yes, C) (2016)   jonathanwhiting.com/writi... · Posted by u/valyala
ninkendo · a day ago
C's string handling is so abominably terrible that sometimes all people really need is "C with std::string".

Oh, and smart pointers too.

And hash maps.

Vectors too while we're at it.

I think that's it.

tialaramex · 18 hours ago
The C++ std::string is both very complicated mechanically and underspecified, which is why Raymond Chen's article about std::string has to explain three different types (one for each of the three popular C++ stdlib implementations) and still got some details wrong resulting in a cycle of corrections.

So that wouldn't really fit C very well and I'd suggest that Rust's String, which is essentially just Vec<u8> plus a promise that this is a UTF-8 encoded string, is closer.

tialaramex commented on I write games in C (yes, C) (2016)   jonathanwhiting.com/writi... · Posted by u/valyala
pjmlp · a day ago
Except that C++ provides the tools to do just like C, Rust, or whatever one feels like doing for dispatching, even if it requires a few pages of template metaprogramming mixed with compile time executions, or writing exactly the same C code on the common subset across both languages.

Now with reflection even more tools will be available.

Which is why despite all its warts and security flaws, many inherited from C source code compatibility, many domains will keep using it, because they will complain about their missing 1% that no one else uses.

tialaramex · 20 hours ago
Because these are General Purpose languages you can do the same things, but the contrast here is what's provided in the box and how it is used idiomatically, because in practice that's what gets used, and that's what I explained above.

You can write C++ style OOP hierarchy code in Rust but that's not idiomatic, and you can write Rust style explicit dynamic dispatch in C++ but again it isn't idiomatic.

tialaramex commented on I write games in C (yes, C) (2016)   jonathanwhiting.com/writi... · Posted by u/valyala
Panzerschrek · a day ago
> by welding a vtable onto every type

It's not true. Virtual methods table is present only for classes with at least one virtual method. Learn C++ properly before doing such claims.

tialaramex · 20 hours ago
The context you snipped is about dynamic dispatch, that is what you - as someone who has "learned C++ properly" apparently call "classes with at least one virtual method" and indeed the earlier comment calls "virtual interfaces".
tialaramex commented on I write games in C (yes, C) (2016)   jonathanwhiting.com/writi... · Posted by u/valyala
torlok · a day ago
I write mostly like I would in C, but use C++ features as needed. It ends up looking similar to Rust if you squint. All these "I write games in C" people complain about C++ features, and then end up reimplementing virtual interfaces manually with struct headers or massive switch statements, just to feel better about themselves. Writing games in C is not harder, you just have to implement modern language features by hand.

Complaining about a language having features you don't want is silly. C++ doesn't take longer to compile if you don't abuse templates.

tialaramex · a day ago
> then end up reimplementing virtual interfaces manually

C++ dynamic dispatch (your "virtual interfaces") is achieved by welding a vtable onto every type and providing a pointer to that vtable for instances of the type. If in 90% of your code you deal with specific types like Goose or Swan or Duck or Seagull, and only 10% needs to work with the broad Bird category well, too bad, every Goose, Swan, Duck and Seagull carries around that vtable pointer even if it goes nowhere near that 10% of the system. This way your Bird code "just works" in C++.

That's not the only way to crack this nut. Idiomatic Rust approach uses vtables only in the Bird code, elsewhere they don't exist, and thus don't take up space in a Duck or whatever that's always a Duck, but in exchange now you're spending more time thinking, because by default there aren't any vtables and so dynamic dispatch isn't possible at all.

So while that C programmer has to implement features by hand, they are at least able to specifically implement the feature they wanted, not whatever was easiest for Bjarne Stroustrup last century.

tialaramex commented on Where did all the starships go?   datawrapper.de/blog/scien... · Posted by u/speckx
wat10000 · a day ago
The part where superintelligent computers keep humans around as pets in a powerful and happy civilization is plausible. The part where there’s hyperdrive and energy grids and fields and effectors, less so.
tialaramex · a day ago
IIRC Banks insisted in interviews that the culture's citizens aren't pets. The exact relationship is, like the FTL travel and indeed teleportation, very vague and only sketched in where needed to advance the plot.

We have no experience with the extremely asymmetrical relationships which would result. Lem tries to imagine this in Golem XIV - what happens when humans who are used to thinking of themselves as smart are talking with a categorically more intelligent machine - and it doesn't work very well even though it's only a sketch.

"Tatja Grimm's World" has a neat trick where Vinge is able to sidestep this because [[SPOILER]] although Tatja is much smarter than everybody else from her world, that's not because she's smarter than we are, almost everyone born on her planet is an idiot for reasons the story justifies.

tialaramex commented on Where did all the starships go?   datawrapper.de/blog/scien... · Posted by u/speckx
nine_k · a day ago
Interstellar space contains neutral hydrogen atoms. Hitting a spaceship, they would produce electromagnetic radiation. When the collision speed goes past about 0.25c, the radiation becomes hard gamma rays which are dangerous to living things, and cannot be efficiently shielded against.

At this speed, the time dilation is slightly above 3%, so you're still not going to reach even Alpha Centauri in one human lifetime, or maybe you barely can.

tialaramex · a day ago
Right, we are never leaving. We should get comfortable here, and take better care of the only habitable planet, rather than doing insane things and justifying that as "Don't worry, we'll make Mars habitable" and other silliness.
tialaramex commented on British drivers over 70 to face eye tests every three years   bbc.com/news/articles/c20... · Posted by u/bookofjoe
chmod775 · 2 days ago
> I just dropped by daughter off at a friend's house. 4 minutes by car

In most urban areas that equates to about 20 minutes on foot. Why bother to even get into a car/bus for that?

Edit: I checked your weather. Definitely wouldn't want to wait at a bus stop.

tialaramex · 2 days ago
Car drivers are always like this, everywhere. Even when I was a little kid, last century, it's a village school, every pupil lives in the same mile or so radius and yet loads of them get picked up in a car.

I now live in a big city but when I walk to the office it's just before school starts, so I see that yeah at first I'm passing kids happily walking with parents but just outside the school it's a jam of idiots who "just quickly" are here to drop the child from a car. The contrast in a few weeks when school is closed will be dramatic, that street is dead, but I bet every one of those parents thinks of it as a "busy road, they ought to do something about that" while not remembering that it's busy because of them.

u/tialaramex

KarmaCake day30835October 22, 2016View Original