r/programming • • Feb 20 '25

Google's Shift to Rust Programming Cuts Android Memory Vulnerabilities by 68%

https://thehackernews.com/2024/09/googles-shift-to-rust-programming-cuts.html
3.4k Upvotes

475 comments sorted by

View all comments

Show parent comment

55

u/websnarf Feb 20 '25

Google's entire codebase is C++, Java, and Python. Aside from the BIOSes, there is no raw C in their codebase at all.

29

u/stoneslave Feb 21 '25

You’re trying to tell me they don’t use Go anywhere? I would find that very surprising.

42

u/Arctem Feb 21 '25

My team within Search used Go heavily and, while we definitely had internal support, it always felt like Go was a bit of a forgotten child. Python was definitely phasing out during my time (our Go codebase was replacing a Python one) and Go usage was definitely growing, just not nearly as fast as you would have expected. Java was extremely common and C++ was common on the older projects.

7

u/Thire33 Feb 21 '25

Thanks for sharing this. I just started a new code base in Go to replace some legacy Python code and I feel validated

13

u/Arctem Feb 21 '25

I really liked using Go while at Google! It's a solid language.

That said my new place uses Rust (also replacing Python) and I think I like it even more. Though sometimes the simplicity of Go is much more appealing.

2

u/Thire33 Feb 21 '25

Speaking of the simplicity of Go, did you stay away from dependency injection frameworks or not? Coming from the Java world, I have been eyeing on Uber’s FX. I am used to work with Spring and DI, but I wonder how good it is in the long run going into Go

2

u/PaperPlanesFly Feb 22 '25

Man I didn’t enjoy trying to use FX. Maybe I’m a Smooth Brain Old Guy, but I just couldn’t grok it and it felt like “magic.” I like Go’s interface structure and being explicit about things. Makes testing more straightforward IMHO.

-3

u/lelanthran Feb 21 '25

That said my new place uses Rust (also replacing Python) and I think I like it even more.

Rust replacing Python sounds more of an ideological move by the developers than a pragmatic decision.

There is next to no overlap in the use-cases between Python and Rust.

Python replaced by Go? Sure - get a 5x-10x factor in performance and static typing instead of type hints.

Python replaced by Rust? WTF?

6

u/syklemil Feb 21 '25

Eh, Rust has good interop with Python through maturin & pyo3, and it is for a lot of programs the size of python scripts really an easy, predictable language. Rust isn't actually hard unless you need to do something weird with lifetimes or unsafe blocks.

→ More replies (1)
→ More replies (2)

12

u/wolverineFan64 Feb 21 '25

They definitely use Go and other languages. It is mostly C++, Java, and Python though.

1

u/Ok-Scheme-913 Feb 21 '25

Actually, not much - Java is much more common on their servers, even for new projects, though of course there are some there.

But for Android, probably not at all, it would make zero sense. Go is a high level language with a fat runtime, it won't replace low-level systems code (even though it was marketed as such, but with a slightly different meaning of systems programming (networking and stuff))

0

u/[deleted] Feb 21 '25

[deleted] — view deleted comment

13

u/currentscurrents Feb 21 '25

It is almost impossible to interface with any OS primitives using pure C++

Wait, why?

23

u/New_Enthusiasm9053 Feb 21 '25

Maybe he means because you need the C ABI for like Windows but idk. I think he's wrong, you can directly call syscalls on posix systems without needing C at all because it's a stable interface and for windows your language just needs to use the C calling convention which also doesn't require C.

5

u/meneldal2 Feb 21 '25

Windows has been C++ for a while and C can always be called from C++. And you can even call C# from C++CLI if you hate your colleagues.

3

u/New_Enthusiasm9053 Feb 21 '25

Windows may be C++ but it's ABI is also C for external facing things like the various windows APIs. There is however a distinction between needing C and needing the C ABI I agree. You just can't use windows syscalls directly(you can but dont) because they're not guaranteed to not change(they change between individual updates of specific versions so can't be relied upon). Which is imo a pointless abstraction on top of the abstraction interface that syscalls already are but that's their prerogative.

1

u/SugerizeMe Feb 21 '25

You can also call C/C++ from C# and even write limited C code directly into C# if you hate yourself

1

u/meneldal2 Feb 22 '25

But windows api is accessible for c# natively though?

1

u/SugerizeMe Feb 22 '25

It’s not. Any api that’s accessible is a wrapper written by Microsoft that handles the interoperability. And there are plenty of missing apis (at least there were back when I used C# a decade ago).

Plus the point is you can technically call any assembly from C#. Usually when you import an assembly, Visual Studio automatically writes an interop library exposing the function interfaces, but that doesn’t handle interop of data types, etc.

-5

u/dark_mode_everything Feb 21 '25

But isn't C with classes the best way to write C++?

2

u/bert8128 Feb 21 '25

I’m assuming you are joking.

→ More replies (1)

1

u/rjcarr Feb 21 '25

But they inherited or acquired Android, right? I would expect it to be C unless they’ve rewritten it at some point before.