r/programming • • Nov 11 '22

NSA urges orgs to use memory-safe programming languages - C/C++ on the bench, as NSA puts its trust in Rust, C#, Go, Java, Ruby and Swift

https://www.theregister.com/2022/11/11/nsa_urges_orgs_to_use/
4.2k Upvotes

799 comments sorted by

View all comments

Show parent comments

24

u/small_kimono Nov 11 '22

Probably because lots of the more performance oriented Python libraries are coded in C?

-8

u/[deleted] Nov 11 '22

You think that isn't true for Java? Go?

25

u/gigastack Nov 11 '22

Totally different though. Performant Python code has to use c/c++ libraries. That isn't the case for go and Java.

8

u/small_kimono Nov 11 '22

This. The more performance oriented JVMs are now written in Java. See Graal.

Most Go libraries I've seen are written in Go. Even the math functions are written in Go when they could/should have used libm. Why? ...Take a look at the precision of the math functions. When you ask for arctan with 64bits of precision, I'm not sure you expect ~40 bits of precision.

2

u/aes110 Nov 11 '22

I agree with your overall point, but fyi there are quite a few python libraries that use rust instead of c

1

u/[deleted] Nov 11 '22

Even JS has an escape hatch due to hot path JITting

43

u/QualitySoftwareGuy Nov 11 '22

Can’t speak for Go, but certainly not true for Java. Most Java libraries, including “performance-oriented” libraries, are pure Java behind the scenes.

-7

u/[deleted] Nov 11 '22

The JVM isn't written in C or C++?

14

u/vicegrip Nov 11 '22

So is the OS.

The difference is the number of implementations and re-writes. Compared to the amount of Java written every day, changes to the JVM itself are infinitesimal. So the problem is reduced to one C implementation rather than millions of software written in C.

12

u/small_kimono Nov 11 '22

Graal is a rewrite in Java and its way faster.

And I'm not sure the JVM is the security vector like your libraries might be.

5

u/QualitySoftwareGuy Nov 11 '22 edited Nov 11 '22

The comment I responded to of yours (and the one you responded to about Python libraries) were both talking about general-purpose libraries for use in applications — not virtual machines.

5

u/markehammons Nov 11 '22

There's actually work to make it mostly written in java. It's called project metropolis. GraalVM has been moving toward the ideal with it's JIT compiler being written in Java (and cool enough, subject to JIT compilation by itself into machine code)

1

u/HorsesFlyIntoBoxes Nov 11 '22

Yeah, I mean the garbage collectors of all those languages the nsa mentioned are probably written in C/C++. I don’t think that’s their point.

9

u/masklinn Nov 11 '22 edited Nov 11 '22

Certainly isn't for Go, you can barely call C from Go. That's why they rewrite everything.

To be more precise, it's very easy to do so in terms of "source code to update" but it fucks up with your build system, it's massively slow (to call a C function from Go compared to a Go function, even ignoring inlining), most of the tooling gets lost, it changes runtime behaviour, and it has a bunch of additional footguns around pointers.

So it's not done unless absolutely necessary, the go people would much rather port / rewrite the entire thing than use C bindings (I think sqlite3 is one of the rare common uses of a cgo library, and even then there's a pure go translation).

0

u/[deleted] Nov 11 '22

[deleted]

11

u/pslessard Nov 11 '22

I've heard of CS:GO, is that the same thing?

2

u/markehammons Nov 11 '22

I think so. It's in his post, but maybe he made a typo while typing go 🤷‍♂️

1

u/NoInkling Nov 12 '22

Same goes for Ruby though.