5 ms·
You know what I would like? (Yeah, speaking of entitlement :) ) A "safe C". No classes, no functional programming (except function pointers, maybe anonymous f
by dispose13432 10y ago
You know what I would like? (Yeah, speaking of entitlement :) )
A "safe C". No classes, no functional programming (except function pointers, maybe anonymous functions), no exceptions, just plain C but
1. memory safe
2. optional array overflow detection (possibly unset by an operator in code, so [] is safe, but a^[] is unsafe. It's nice so if you _really_ need speed in a certain block and you know it's safe, you can turn it off).
Maybe something like Go but with "manual" (c++ safe pointer style) memory management.
Rust seems (to my untrained eye) too similar to C++ (it's quite a complicated/powerful language).
- zzzcpan 10y agoThere are safe C dialects already. The problem is they are not compiling into C, so you can't leverage the whole C ecosystem with them. Although I would suggest a different road - C code generation with meta languages, you'll get all the benefits of C with total control and all the high-levelness and safety you might need.
- nickpsecurity 10y agoI second that recommendation. It's what PreScheme, Ada, Chicken, and Nim did among others. All brought benefits in practice.
- icebraining 10y agoThere are a few attempts like Cyclone: https://en.wikipedia.org/wiki/Cyclone_(programming_language) https://en.wikipedia.org/wiki/Cyclone_(programming_language)
- jerf 10y agoYou really have pretty much spec'ed Go, except that when you want something manual you either use some []byte hacks or use the unsafe package to speak to some C code. Even when you want manual memory management it's rare that you need the entire program manually managed; usually there's some sort of hot data structure or code or something that you'd like to take over but that doesn't mean you want to fiddle with every last little character string manually. In particular, in the modern era, you're not going to find very many other languages that have anonymous functions but almost no functional programming capability like Go has. If you want to keep FP sealed away from your program... you know, for whatever reason, but to each their own... Go's got you about as well covered as you could hope for. Almost anything else that might come out is probably going to have FP constructs in it. (Especially after watching Go get raked over the coals for not having them.)
- akiselev 10y agoI don't even understand why you'd want to remove functional programming from a low level language like Rust. Its focus on zero cost abstractions and LLVM's optimizations mean that functional patterns like map or filter are most often inlined with your function at the call site, combining their overhead with the caller's stack and optimizing the code down to a single loop that is far less likely to have a cache miss or branch misprediction. This gives you complete control over performance and it's really easy to write your own iterators/operators to tweak the final result. Functional programming gets a bad rap for performance and clarity (of the generated assembly) because most of them have gigantic runtimes like the JVM or Haskell but the way it is implemented in Rust is quite a bit different.
- dispose13432 10y ago>I don't even understand why you'd want to remove functional programming from a low level language like Rust Because I want a simple to read language? It's not all about performance. C++ doesn't have bad performance and is safe, yet isn't used in Linux, nginx, or OpenBSD. Why? I've heard here how every team has their "subset" of the language that they use. So you're trying to unseat C from it's perch. Fine. I understand, it's too easy in C to have memory errors and pwn computers. But if you want to fix that by forcing people to switch to a different paradigm, it aint gonna happen. Out of the top 10 programming languages on GitHub, most (by far) are imperative. If someone would make a safe C, there can be hope in convincing Linus to slowly switch. Now? There's 0 chance of that happening.
- pjmlp 10y ago> C++ doesn't have bad performance and is safe, yet isn't used in Linux, nginx, or OpenBSD. >Why? Because those communities, logically due to the UNIX influence, are biased towards C. C++ is heavily used on Android and ChromeOS native subsystems, Mac OS X drivers, Windows, Genode. Symbian and BeOS were written in C++.
- dispose13432 10y ago
- nickpsecurity 10y agoI mentioned a few in this thread on top of Cyclone already referenced: https://news.ycombinator.com/item?id=13266736 https://news.ycombinator.com/item?id=13266736 Note that, while C developers ignored Cyclone, Rust built on its safety techniques. It's not that people aren't making the safe C's. It's that C developers at large don't care about them. So few write them. Then they die. More work in CompSci, industry, and FOSS is therefore going into static analysis or automatic transformations of C into safe code. EDIT: You might also like a version of Modula-2 with C-like syntax. It was a language for OS writing small like C but with modules & safe-by-default features. http://modula-2.info/m2r10/pmwiki.php/Spec/DesignPrinciples http://modula-2.info/m2r10/pmwiki.php/Spec/DesignPrinciples