News for hackers. Stuff that matters.
Re:Memory Safe Languages in Android 13 by goodpoint on Thursday December 01, 2022 @02:14PM (#33821161)
There's been many, for example Ada/SPARK, D, Nim, Java, Kotlin, Swift.
Re:Memory Safe Languages in Android 13 by kllrnohj on Thursday December 01, 2022 @03:35PM (#33822337)
I can't speak to the others, but Java & Kotlin do not at all have C++-like performance, especially not in anything beyond a toy level benchmark.

And even in those toy level benchmarks (like https://benchmarksgame-team.pages.debian.net/benchmarksgame/... ), there's a clear divide between C/C++/Rust & everything else.

Re:Memory Safe Languages in Android 13 by goodpoint on Thursday December 01, 2022 @03:39PM (#33822390)
The claim that performance are comparable only on "toy benchmarks" is false.
Re:Memory Safe Languages in Android 13 by pkolaczk on Friday December 02, 2022 @02:17AM (#33827806)
Toy benchmarks give JVM an edge because JVM optimizes code locally. Small amount of code in a benchmark means a majority of it can be inlined and then the JVM can actually remove a lot of Java-specific overhead like heap allocations, at least theoretically (I've seen it utterly fail in some cases even on toy benchmarks, though). However in bigger programs JVM has no way to optimize the inherent overheads stemming from the design of the Java language.

Rust and C++ don't have those overheads from the start, and then on top of that their compilers can do whole program optimization because they have plenty of time and resources to do so.

Re:Memory Safe Languages in Android 13 by kllrnohj on Friday December 02, 2022 @01:30PM (#33834630)
Toy benchmarks are also a lot easier to write in "C-like" Java instead of "normal" Java. That is, avoiding boxing, interfaces, etc..
Re:Memory Safe Languages in Android 13 by nneonneo on Thursday December 01, 2022 @03:44PM (#33822461)
- Ada: good example, has substantial uses in certain areas. However, certain things are quite difficult, e.g. compile-time checked pointers (a la Rust's borrow-checked references).

- D, Nim: neither provide strong memory safety guarantees. D has a safe subset, but it's not default (see https://news.ycombinator.com/item?id=12391720). Nim allows you to turn checks off at runtime. Both Nim and D generally use a GC.

- Java/Kotlin are not low-level: requires GC, and not often used for low-level systems programming. Great languages, but different niche.

Re:Memory Safe Languages in Android 13 by thesuperbigfrog on Thursday December 01, 2022 @04:11PM (#33822821)
>> Ada: good example, but not usually used for low-level systems programming. Has substantial uses in certain areas.

Ada is primarily used for low-level systems programming and embedded systems:

https://learn.adacore.com/courses/intro-to-ada/chapters/intr...

Substantial portions of the Ada standard deal with systems programming and low-level representation on hardware:

http://www.ada-auth.org/standards/22rm/html/RM-C.html

http://www.ada-auth.org/standards/22rm/html/RM-13-1.html

Re:Memory Safe Languages in Android 13 by nneonneo on Thursday December 01, 2022 @04:36PM (#33823172)
Thanks for the correction. I will update my comment accordingly.
Re:Memory Safe Languages in Android 13 by goodpoint on Thursday December 01, 2022 @07:24PM (#33825109)
> Ada: good example, but not usually used for low-level systems programming

Ada is used for low-level programming plenty.

> Nim allows you to turn checks off at runtime.

That's not relevant.

> Both Nim and D generally use a GC.

No, Nim now uses deterministic reference counting ARC and provides safety similar to Rust.

Re:Memory Safe Languages in Android 13 by micronian2 on Monday December 05, 2022 @04:18AM (#33863251)
The fact that you originally didn’t know that Ada is heavily used in embedded clearly shows you don’t know it. Even though you edited your reply, any reader should seriously doubt your claim that “certain things are quite difficult” in Ada. Do you know that in Ada, you don’t have to use pointers or heap memory nearly as much as other languages such as C and C++? You can even write programs that don’t even use any. That avoids a whole class of issues.

One of the extra advantages with Ada is that you can decide to utilize the SPARK variant and do formal proofs on software components that are more critical. I invite you and and others to watch the presentation by Altrans where they talk about 30+ years of SPARK usage to help develop ultra low defect software: https://youtu.be/VKPmBWTxW6M