28 ms·
Getting Past C
- falcolas 10y agoHow much concern would non-standard architecture support matter for ntp? Given how many architectures Linux supports, I would think that C would still be the best choice, until these other languages gain support for those missing architectures. Or perhaps it's a good opportunity for a language which offers transpilation with ANSI C as the target?
- squiguy7 10y agoRust has impressive support for different architectures. I ran `rustc --print target-list` and it returned 63.
- falcolas 10y agoThat includes one line per architecture / platform (i.e. OS) combination. I only count about 14 architectures, though my rustc is old (GCC has 23 major, 24 minor, and 30 legacy as a point of comparison). Last I checked, some of the popular IOT architectures (atmega, etc) were not included without some 3rd party plugins.
- IshKebab 10y agoATmega is not really a popular architecture any more. It only stuck around because of Arduino, and even that is moving towards ARM. Nobody is going to be running NTPsec on it in any case!
- falcolas 10y agoWhat arduino-class (that is, low power microcontrollers) devices are moving towards ARM? Seems like a very different use case from portable computers (like the Raspberry Pi) - the power consumption differences are pretty major. > Nobody is going to be running NTPsec on it Never say never. :) There are wifi, ethernet, and clock shields for Arduino, all of which are running microcontrollers, and many applications which would benefit from using NTP.
- dragontamer 10y ago> Never say never. :) There are wifi, ethernet, and clock shields for Arduino, all of which are running microcontrollers, and many applications which would benefit from using NTP. FYI: Microcontrollers really ought to just be interpreting the WWVB radio signal (aka: the 60,000 Hz Atomic Clock radio signal throughout the entire continental USA). Alternatively, Microcontrollers easily connect up to GPS modules for an alternative radio signal / alternative time source. If anything, Microcontrollers are a great interface to the 60kHz Atomic Clock signal and are therefore would probably be the best NTP-server. In any case, the "real" best architecture is probably a microcontroller doing Radio Logic / digital signal processing for WWVB, and that is connected through a simple connection (ex: I2C that says the last announced time from the WWVB signal) helping a "bigger" Raspberry Pi. And the Raspberry Pi can handle the ethernet / server stuff
- leoedin 10y agoMicrocontrollers aren't moving towards application level processors like the Raspberry Pi uses, they're moving towards low power ARM cores like the Cortex M0/M3/M4. It's not clear to me why you'd choose an AVR for a new product unless you really, really needed a specific feature. Current generation ARM Cortex M0 devices are available at a similar cost and with significant performance gains, with the benefit that if you realise you need a more powerful core you can scale up to hundreds of MHz with effectively the same code base.
- falcolas 10y agoI'd love to read more about this microcontroller migration towards ARM - any hints on where to look?
- dragontamer 10y agoI dunno if its a 'major' migration, but NXP is basically doubling down on ARM-only architectures. Microchip / Atmel (same company now btw) are doing an "everything and anything" strategy. PIC, ATTiny, ATMega, UC3, AND ARM chips are available from them. It seems like the smaller 8-bit microcontrollers use less power and have better features for embedded engineers (ie: ADC converters, PWM, Real-time clocks, deeper sleep modes). While ARM has the general benefit of being much faster from a computational perspective. But if you want to read the voltage from a simple thermo-resistor and then output it on an I2C bus... I'm thinking a classic 8-bit AVR is going to be superior over any ARM. -------- I'm still seeing 8051 stuff pop up everywhere, and that thing was supposedly dead years ago.
- topspin 10y ago>> though my rustc is old I just counted on nightly and got 20 distinct architectures, including all the le variants; every distinct architecture value, iow.
- jeffmcjunkin 10y agoFWIW, with latest rustc: $ rustc --print target-list | cut -d- -f1 | sort | uniq | wc -l 20
- jerf 10y agoIn addition to squiguy7's point, I'd add that A: it may not be clear if this is your only contact with ntpsec.org [1], but this is actually a fork of the classic ntp, so they may be more willing to abandon some older architectures to produce a more secure product going forward than the core NTP project would and B: the older versions will still be around even so. Also, it has been suggested by some experiences that older architectures often end up getting supported past when they really should be stopped out of sheer inertia, though I'm not having luck digging up the articles that prompt me to say this. Are there that many systems out there running ntp that can't run Go and/or Rust, and if there are, are there enough to be worth bending the project around? If the people running those things care, perhaps they should fork the project and maintain it themselves. Which is less harsh than it may sound, because they can still pull from upstream, and they probably just need to tread water rather than stay up with the latest & greatest. (I should emphasize that the operative question is are there enough to be worth bending the project around, rather than whether there are any. Because there certainly are non-zero numbers of systems running ntpd that can't run Rust or Go. But who's going to pay to maintain them? Especially if classic ntp is still available?) [1]: https://www.ntpsec.org/ https://www.ntpsec.org/
- falcolas 10y agoWell, it's not just older architectures which are not currently supported, it's architectures used in IOT devices, mainframes, and other non-commodity hardware. Specific to LLVM based languages, if it's not a priority to Apple (or the other big LLVM players), it infrequently gets done. Specific to IOT devices, I would personally love to see secure everyting. NTP, TLS, SSH, etc.
- TheAceOfHearts 10y agoIf it's a business requirement, they should hire engineers and contribute. Expecting free support seems unreasonable. There's a high cost for supporting and maintaining features, so somebody ends up having to pay for it.
- falcolas 10y ago
- aaron-lebo 10y agoOutside of the language war bubble it's really great to see a post like this. Practical concerns, reasonable advantages/disadvantages of each language, a real project dealing with real timelines. Thanks!
- eduren 10y agoI'm excited to see where this goes because it could go a long way towards providing concrete data for the large "work to replace old infrastucture C code with (Rust||Go||Modern C++)" discussion that has been taking place. More data points will help to inform discussion, or at the very least add structure to the flame wars.
- jstimpfle 10y agoWas going to say the same. In the past ESR has come across as a patently arrogant gun maniac, but the first part of this post is great for all the reasons you mentioned. (What irritated me though was the switch to first-person narrative at the end).
- lacampbell 10y ago> One of the medium-term possibilities we’re seriously considering for NTPsec is moving the entire codebase out of C into a language with no buffer overruns For a small one time fee of 1000 USD I can copy paste you 50-100 lines of C that provides an implementation of an array without buffer oveflows. Cheaper than switching to rust or you know, learning C properly.
- noselasd 10y agoCan you pass this buffer to e.g. read() and it will still guarantee no buffer overflow even if the programmer mis-calculate the size argument to read() ?
- falcolas 10y agoYou can with fixed sized buffers; the size passed to read() would be constant. I'd argue that for programs such as NTP, avoiding dynamic allocations on heap is not such a terrible goal.
- lacampbell 10y agoNo. It then follows that reading things safely is therefore a completely insurmountable problem in C. There is no possible way for me thin wrapper around read that works on bounds checked arrays, and not use "read" cavalierly in my code without thinking. Right?
- Animats 10y agoThe track record of two decades of CERT advisories for buffer overflows suggests that doesn't work in practice.
- lacampbell 10y agoJust because people fail to do something doesn't mean it's not both possible and easy.
- jstewartmobile 10y agoA 62 KLOC secure NTP server seems like an ideal project for this kind of experiment. I imagine it would be self-contained enough to actually use Rust or Golang instead of just treating them like FFI scripters.
- tptacek 10y agoThis is literally the only thing I can think of that "NTPsec" can do that would result in the project having any relevance. I understand why some very specific sites are chained to the ntpd codebase, but the vast, overwhelming majority of the ntpd deployed base not only isn't tied to ntpd, but also doesn't need 99% of what ntpd does. Trying to "secure" that codebase always seemed to me like a very silly windmill to tilt at.
- pklausler 10y agoHonestly, why not do it once and for all in a strongly typed pure functional language, validate it, and then tweak the GC parameters to get the performance? Use the safest and most powerful language that you can, if you can.
- jstimpfle 10y agoSome people don't believe in tweaking GC's. I've heard horror stories from people who tried it on the JVM. (And I have made terrible experiences with JVM's GC, but never tried tuning). Some people don't believe that extremist functional languages are needed (depending on the domain). Validation. Oh, well. I think you propose Haskell, and it might disqualify for an NTP daemon, for example in terms of debuggability (stack traces?).
- nathyong 10y agoA more relevant point that would disqualify Haskell is the fact that its runtime (or rather, the GHC's runtime) is nowhere near predictable enough for the realtime guarantees that time synchronisation software would require. A Haskell DSL that outputs some safer low-level code would be a more likely choice (for example http://hackage.haskell.org/package/atom http://hackage.haskell.org/package/atom), but Rust is both more popular and has more commercial support.
- jstimpfle 10y agoWhen opting for a DSL that compiles to low-level the "Haskell" part is less important. I've heard the idea of DSLs over and over again, but who actually does that? I know of course of sed, awk, regex, etc but what part of NTPsec is narrow enough in scope and large enough in volume to justify creating a DSL? (just asking -- I'm not familiar with NTPsec).
- nickpsecurity 10y agoCompanies that like consistently getting results. Example: http://ivorylang.org/ivory-introduction.html http://ivorylang.org/ivory-introduction.html
- dreta 10y agoCan anybody make a strong case to me as to why are buffer overflows considered an issue in C when it takes like 10 minutes to write and test an array implementation that prevents that from ever happening? I do agree that C has issues (though in my opinion neighter Rust nor Go address almost any of them) i just don't understand why are buffer overflows such a huge problem in C when the same thing is going to come up when trying to work with memory in Rust.
- ArkyBeagle 10y agoC is the new "goto". Y'all please, please note that dreta said "... an array implementation that prevents that from ever happening..."
- pjmlp 10y agoC is the PHP and JavaScript of the 70's.
- ArkyBeagle 10y ago:) I don't know anything about either.
- ArkyBeagle 10y agoFinal word on the subject - what we have is people who are trying to make Open Software Reputation Points by finding a problem and fixing it, rather than waiting to find a real problem and fixing that. When the figure of "ten minutes" was used - that's really what it should be as a mean or median figure, with some long-tail outliers for knotty cases. While I am (somewhat) sympathetic, I don't miss what it is - it's make-work. There's not some body of material on language, O/S and software design available today that wasn't available 40 years ago. People new better back then, and didn't do better. But the endless, circular, Utopian arguments just don't cut it. It ain't the crate, it's the pilot. I am sorry that oh so many are put upon to actually - gasp - test their code but that's what this is. The economics of a Rust or Go or whatever make perfect sense - in the long run. Just recall what Keynes said about the long run.
- asdaksdhksajd 10y agowhy does it take 62KLOC of C to distribute time? thats more code than the whole plan9 kernel.
- asdaksdhksajd 10y agodoom was 52KLOC of C.
- chungy 10y agoLess than that even: all 37641 (100.00%) in 135 files c 37311 (99.12%) in 66 files asm 232 (0.62%) in 1 files makefile 98 (0.26%) in 2 files
- signa11 10y ago> why does it take 62KLOC of C to distribute time? as a starting point look here: http://www.ntp.org/ntpfaq/ http://www.ntp.org/ntpfaq/. you can go from there to the rfc's (5905 - ntpv4) to get a more indepth look.
- dhsjxhx 10y agoRather than looking for a new language, why not ban programs from writing to executable memory?
- twic 10y agoBecause that isn't enough: https://en.wikipedia.org/wiki/Return-oriented_programming https://en.wikipedia.org/wiki/Return-oriented_programming
- bvinc 10y agoI'm not an expert in this field, but it's my understanding that this is often the case for C programs executing nowadays. The AMD64 architecture even has the NX bit. There are some other ways that this can be enabled too. But surprisingly, this doesn't solve all code execution security problems from buffer overflows. Sometimes exploiters can find non-executable memory to change that allows them to change the program behavior to do what they want, such as changing the command string that gets passed to a normal execve call later in the program. But even if you solve the security issues, buffer overflows are still a huge headache. A one byte buffer overflow can cause your program to crash an hour later, with almost no hope of figuring out why it happened. A developer can easily spend weeks tracking down a single buffer overflow crash.
- dhsjxhx 10y ago>A one byte buffer overflow can cause your program to crash an hour later, with almost no hope of figuring out why it happened. I don't know about rust, but you can have an ArrayOutOfBoundsException in Java, and equivalent in Go and other safe languages
- nullc 10y ago> Sometimes exploiters can find non-executable memory to change that allows them to change the program behavior to do what they want, such as changing the command string that gets passed to a normal execve call later in the program. Changing function pointers or the return value on the stack are the normal things to do. In particular if you corrupt the stack you can simply return into system() with whatever arguments you want.
- w8rbt 10y agoI would start by getting the code to compile with g++, then begin migrating the dangerous C constructs to safe C++ constructs. IMO, that would be a safe, reasonable thing to do.
- pjmlp 10y agoHow would you prevent other developers to write C style code?
- blub 10y agoProject leadership, coding standards, automated analysis and code reviews. But realistically speaking it might be easier to change tools for a significant number of teams, because the software development community is in general poor at leadership and process. A rewrite seems more approachable for the average (not necessarily average skills-wise) dev compared to a change in attitude, self-reflection and incremental improvement at a department or company level. Then the rust compiler will pummel everyone into submission. This can be a succesful strategy. :)
- pjmlp 10y agoWhich I seldom see in enterprise projects, specially in companies whose business is unrelated to software development and IT is nothing else than a cost center. Anything that is optional gets pushed aside.
- zzzcpan 10y agoAfter reading this post the idea of a C-to-C translator that injects bound checking, etc. comes to mind. Such translator could be used by OS distributions to provide safety in the least intrusive way and possibly completely automatically for many C codebases they have in their repositories. Translating into Go or Rust, on the other hand, cannot scale beyond some individual projects, that decide to undertake such efforts. Mainstream C compilers could implement safety features too, but realistically it cannot happen, as it's not something most people care about. So, C-to-C translator might be a best bet with the most impact.
- the_duke 10y agoIt's a shame, really, but if you could write a decent C to safe Rust transpiler, than Rust probably would not exist. Lifetime inference etc is a hard problem, and if it could be done right now, compilers would just have static checks for all that. There is a C to UNSAFE Rust transpiler, though: https://github.com/jameysharp/corrode https://github.com/jameysharp/corrode.
- jawnv6 10y agoSimilar work has been done, over a decade ago at that. http://people.csail.mit.edu/rinard/paper/osdi04.ps http://people.csail.mit.edu/rinard/paper/osdi04.ps Realistically, the situation where you have source access with known errors you're somehow barred from fixing seems vanishingly rare.
- nickpsecurity 10y agoCompSci keeps making them, even open-sourcing some, but little uptake or improvements from the FOSS crowd. Here's two of the top ones: http://sva.cs.illinois.edu/ http://sva.cs.illinois.edu/ https://github.com/jtcriswell/safecode-llvm37 https://github.com/jtcriswell/safecode-llvm37 https://www.cs.rutgers.edu/~santosh.nagarakatte/softbound/ https://www.cs.rutgers.edu/~santosh.nagarakatte/softbound/
- duneroadrunner 10y agoAs we've discussed, one issue is the big performance cost of these solutions. Anyone interested in working on an automatic C to SaferCPlusPlus[1] translator? It should address the performance issue[2]. And should be much more straightforward than these C to Rust/Go translators. [1] shameless plug: https://github.com/duneroadrunner/SaferCPlusPlus https://github.com/duneroadrunner/SaferCPlusPlus [2] https://github.com/duneroadrunner/SaferCPlusPlus-BenchmarksGame https://github.com/duneroadrunner/SaferCPlusPlus-BenchmarksG...
- elchief 10y agowhat's wrong with OpenNTPD exactly?
- NelsonMinar 10y agoThere's a summary of some of its limitations here: https://en.wikipedia.org/wiki/OpenNTPD#Criticism https://en.wikipedia.org/wiki/OpenNTPD#Criticism One of them (lack of leap second support) is fresh on our minds since we just had a leap second. Some thoughts from the OpenNTPD folks are at http://undeadly.org/cgi?action=article&sid=20150628132834 http://undeadly.org/cgi?action=article&sid=20150628132834 Chrony is another alternate NTP implementation, here's their comparison vs ntpd and openntpd. https://chrony.tuxfamily.org/comparison.html https://chrony.tuxfamily.org/comparison.html
- elchief 10y agoIt sounds like the leap-second thing isn't that big of an issue though...
- NelsonMinar 10y agoThe leap second thing is a big issue for a server. OpenNTPD serves the wrong time on the day of the leap second. They don't propagate the leap second flag properly either. It's not correct and doesn't belong in a public server pool IMHO. This issue isn't just theoretical: it was responsible for a lot of the bad time being served by the NTP Pool last week. You're right that the article I linked argues the leap second isn't a big problem to client machines. I guess I sort of believe it, if you don't care if your client is a second off from true time once every couple of years.
- giancarlostoro 10y agoI wish more mention of D would happen. It is compatible with C and C++ libraries and features GC without sacrificing the good things of C and C++. I always loved the idea of Rust and Go but they are nowhere near C or C++ where it matters to me. D fits the bill, otherwise I just use Python. I like being able to design software in my own way as opposed to being told how to do it.
- thesmallestcat 10y agoI thought D still required a GC? Not that that's the end of the world, but with such strict requirements I'm surprised it would satisfy you.
- p0nce 10y ago> I thought D still required a GC? Not strictly required. You can certainly disable it at the cost of more work (and understanding). Or live with it and reduce its impact as needed.
- scriptkiddy 10y agoLast time I took a look at D I was awed by how terrible it's documentation is.
- cakes 10y agoI very much enjoy using D and want it to succeed but this statement along with finding "everyday uses" for things (e.g. using zeromq) are huge drawbacks to buying into it. I'll still advocate but it's not easy sometimes
- giancarlostoro 10y agoI think three things attribute to a programming languages success or failure: tooling, documentation and standard library. Look at Go, great out of the box library, same with Python, but the tooling for Go isn't the greatest (debugger? a real IDE? etc) then you look at C#: tooling (Visual Studio, VS Code, debugger), documentation, and even out of the box the .NET Framework is a decent "standard library" with plenty included. If only D had at the very least a well dedicated IDE. I hope more people notice D so that the community around it builds solutions, it has a lot of great potential yet to be tapped, and plenty of groundwork has already been done with D.
- awinter-py 10y ago> One such cleanup: we’ve made a strong start on banishing unions and type punning from the code. These are not going to translate into any language with the correctness properties we want. Really? This sounds like idiomatic rust to me (heavy with enums).
- Ericson2314 10y agoC unions have no discriminant. But yeah it's a pity—I'd try to hack up discriminated unions then. Or convert to Rust unions and then enums and remove unsafety.
- awinter-py 10y agoC union declarations should correspond pretty closely to rust enum declarations. It's a surprisingly important feature. Every large codebase I've worked on has clunky workarounds for storing heterogeneous types in collections. Haven't seen a silver bullet; dynamic languages are great at this until you have to scale (either in lines of code, number of types or dataset size) and then they become unmanageable. Static languages force you to type a lot and build in-memory ETL-style transformations but scale better. Using SQL is another solution, but that separates you from the language's type-checker and can be another source of error. Type safety at the serialization boundary was the promise of CORBA and protobuf but we need better tools. I hope we see more focus on ser/des types in the next generation of industry languages.
- steveklabnik 10y agoClose, but not quite: unless the type is NonZero, you need space for the tag. c-style unions are in nightly behind a flag; they're not stable yet.
- deleted 10y ago[deleted]
- Manishearth 10y ago
- rafinha 10y agoI didn't understand why rust and go are natural alternatives to C. Wouldn't C++ be a more natural option? (Despite the fact that both go and rust are developed by third party companies)
- jimbokun 10y ago"out of C into a language with no buffer overruns, and in general much stronger security and correctness guarantees." Doesn't sound like C++.
- shermanyo 10y agoReally? It sounds like a good fit to me, maybe I'm missing something?
- rafinha 10y agoI still don't get it. Can't it be done in c++ via appropriate data structures? I mean, it's not like Go is magic, at the end I suppose Go would be doing just that. As far as I know the main reason people opt for Go over C++ are the compiling times...
- steveklabnik 10y agoYou can write safe C++, if you're careful, and everyone you work with is careful, all the time. Judicious use of features can make your code more safe, but they can never make it actually safe. Rust and Go, in various different ways (and to various degrees), make it actually safe.
- jstewartmobile 10y agoI did a lot of C++ years ago, so maybe things have changed since then, but I think Rust and Go addressed a lot of the design flubs of C++. My experiences getting things to compile across gcc and visual c++, dealing with strings (especially Microsoft's WCHAR), reliable integer sizes (pre stdint.h), and debugging templates were not things I would wish on anyone. Re-doing some of my side projects in Go and Rust was a lot more enjoyable. I could focus on what I was doing instead of trying to work around deficiencies in the language and its libraries.
- ericfrederich 10y agoI like go, I'd love to write libraries in it but as far as I can tell you can't really create a C compatible shared library from it. That it still the common denominator if you want to call into it from other languages. I'd love to write Python programs with performance critical stuff in Go
- LukeShu 10y agoas far as I can tell you can't really create a C compatible shared library from [Go]. Sure you can! (as of Go 1.5, iirc) Change your build command to use the c-shared build mode: go build -buildmode=c-shared Then, to change the linkage of the functions you want to export, use the magical comment "//export" directive: //export MyFunction func MyFunction(arg1, arg2 int, arg3 string) int64 { ...
- steveklabnik 10y agoThis still doesn't get over the inherent overhead in calling between the two languages though, right? (And you're bringing that whole runtime with you. Which might be okay! As always, it depends.)
- deleted 10y ago[deleted]
- nurettin 10y agoWhy does 90% of this huge comments section revolve around Rust? Haven't we had enough of the same already? Yes, we know it provides memory safety guarantees. Yes we know you hate everything written in C with great passion. This has been made apparent and banged on our heads for the past several dog-years. Did anyone bother to look at the sheer amount of refactoring the author & team did? Did anyone realize how difficult this is and what they might learn from this tarrasquesque ordeal they went through? Oh no, apparently it is C and logic mandates that Rust supercedes it so why.the.hell.bother.
- deleted 10y ago[deleted]
- eridius 10y agoThe huge discussion about Rust is because that's literally what this post is about. It's titled "Getting Past C" and most of the post is about considering Go or Rust as the future language for the project. And, not surprisingly, a lot of people think Rust is a great choice for this (and I agree).
- nurettin 10y agoThe title is Rust-bait so let's all chant rust! Rust! RUST! Oh but there are only three tentative mentions of Rust in it and this entire comment section is corroded. Just compare the two pages in a browser with ctrl-f rust
- kbenson 10y agoI'm not sure where you're under the impression that the number of times something is explicitly mentioned corresponds directly to the number if times it's being discussed, which is what is implied by your suggestions to search for occurrences of the name. The whole article is about future plans for NTPsec, and the work going into making it so it can be converted to a new language later. The article is about the relative merits of different languages for this task, and Rust is one of the languages. Of course Rust is going to be talked about in the comments. The only odd thing here is that Go isn't talked about more in the comments, not that Rust is talked about a lot.
- anthk 10y ago>Under Linux, some SECCOMP initialization and capability dances having to do with dropping root and closing off privilege-escalation attacks as soon as possible after startup. Thanks, Eric. Now, FFS, learn how the Cathedral model WORKS, get OpenBSD, learn pledge(2) and stop spreading old FUD against C.
- e3b0c 10y agoRust has some very desirable properties to me. Writing Rust programs from scratch is not as scary as I've heard of from the internet either. The documentation is excellent, the compiler diagnostic messages are very helpful and the notorious borrow checker didn't stand in my way that much. And I love Cargo and Cargo.io. I have some projects where Rust is the saner choice than Go or other GC based languages. That said, there are actually drawbacks of Rust compared with Go, IMHO. When facing a moderately large project written by others, the ergonomics for diving into the project is not as smooth as Go. There is no good full-source code indexer like cscope/GNU Global/Guru for symbol navigation across multiple dependent projects. Full text searching with grep/ack does not fill the gap well either since many symbols, with their different scopes/paths, are allowed to have the same identifier without explicitly specifying the full path. That makes troubleshooting/tracing a large, unfamiliar codebase quite daunting compared with Go.
- steveklabnik 10y agoRLS will hopefully full that gap.
- rattray 10y agoRLS?
- anuragsoni 10y agoit stands for Rust Language Server Github project: https://github.com/jonathandturner/rls https://github.com/jonathandturner/rls Announcement: https://internals.rust-lang.org/t/introducing-rust-language-server-source-release/4209 https://internals.rust-lang.org/t/introducing-rust-language-...
- deleted 10y ago[deleted]
- wocram 10y agoI haven't had too many issues with Intellij-rust or racer failing to jump between symbols. There are also many other tools that provide indexing, eg. ide [plugins], kythe, and the rust language server.
- acjohnson55 10y agoIt's not yet ready for primetime, but Scala Native (http://scala-native.readthedocs.io/en/latest/ http://scala-native.readthedocs.io/en/latest/) might just make a splash in the systems space. I don't think it has anything like ownership yet, but I wouldn't be surprised if it eventually develops that capability. I think you can get it to run without GC, too, but using C Stdlib memory management. Although, that largely defeats the memory-safety. Just throwing it out there as something to keep an eye on!
- arunmu 10y agoI do not contest on the opinion that Rust is a good language, but it slightly hurts me when people club C and C++ together. One can easily write correct by construction code using modern C++. Use of meta-programs allows you to create typesafe constructs. It provides you with zero cost abstractions to specify ownership of resources and ..... <I can go on> One has to just strive to not use the C baggage that comes with it.
- Manishearth 10y agoC++ is much better, but still not safe. Null still exists. Moves are runtime moves, so you can still attempt to access the value at compile time. Iterator invalidation is still an issue. Of course, C++ might be "safe enough" for your use cases.
- arunmu 10y ago> Moves are runtime moves, so you can still attempt to access the value at compile time. What do you mean by that ? Are you saying the standard decided to make it non-destructive moves ? Then yes, it is a possible scenario for error but also a performance advantage in some cases.
- Manishearth 10y ago> What do you mean by that ? Are you saying the standard decided to make it non-destructive moves ? You can still access a value after it has been moved out. use-after-move is allowed by the compiler. It places (stdlib) types in an unspecified but valid state (I've seen C++ code reusing these types and assuming that the state after move is something in particular -- it's not). Most optimizations you can do by reusing a moved value could be done automatically by the compiler (by using the same stack space since it statically knows that it's been moved out). Linear types are a pretty well known pattern and could have been used as a part of the design of moves. This would have the additional benefit of removing explicit move constructors from 99% of all types out there. This has not been done (and can't be now). Edit: The pretty rare optimization potential of runtime moves is pretty much negated by the fact that common things like reallocing a vector can't be made into a memcpy for most types, just because they have nontrivial move ctors which wouldn't exist in the compile-time move scenario.
- z3t4 10y agoWhy do they have to use a low level language ? Why not use NodeJS ? One argument would be time management, but even with C you can not be sure that no interrupts happens in between ...
- jaco8 10y agoLooking at the current new and coming languages I would take a hard look at NIM. It may be is not there yet but it looks highly appealing, is as fast as the often mentioned Rust and compiles significantly faster. http://nim-lang.org/ http://nim-lang.org/
- nimmer 10y agoNim compile times are faster and often the execution time is faster, too. Also it's very expressive, almost like Python.
- amadvance 10y agoRust is surely fine, and an improvement over C, but its main advantage is that all the rust code is written now, when everyone takes more care about security. It doesn't have to deal with 40 years of bad legacy code written by sloppy developers. You can obtain similar quality in a C modern code-base, using tools like static and dynamic analyzers. In fact, today the hardest issues came from multi-threading. I won't even dare to write multi-threading apps without helgrind/TSAN. And Rust doesn't help in this regard. From: https://doc.rust-lang.org/nomicon/races.html https://doc.rust-lang.org/nomicon/races.html 'So it's perfectly "fine" for a Safe Rust program to get deadlocked or do something incredibly stupid with incorrect synchronization.'
- blub 10y agoSome people take more care about writing safe & secure code today. Most only care just enough to switch to Java or Python in order not to care any more. The big question for me is what will happen when those same developers writing insecure C and C++ code start writing rust? Will they find ways to subvert the safety checks? Will they even want to subject themselves to them in the first place?
- _yosefk 10y agoI find it rather daring to use raw POSIX threads or similar, hoping that automated debugging tools operating at this abstraction level, such as Helgrind or TSAN, will pinpoint your bugs. The problem is that the state space of a thread-based program synchronizing with mutexes is too large to explore at a reasonable time. More about this: http://yosefk.com/blog/checkedthreads-bug-free-shared-memory-parallelism.html http://yosefk.com/blog/checkedthreads-bug-free-shared-memory... and http://yosefk.com/blog/making-data-races-manifest-themselves.html http://yosefk.com/blog/making-data-races-manifest-themselves... Which higher-level abstraction to use is a question and depends on the problem at hand; for throughput computing in C, Cilk is perhaps the best today (I guess you could call my own project checkedthreads a bit of a Cilk knock-off.) AFAIK, Rust developers are more interested in higher-level abstractions than Go developers (Go's built-in goroutines being on par with threads in terms of ability of automated debugging tools to flag bugs; perhaps there's work in Go on higher-level abstractions but the vibe I felt, perhaps mistakenly, is that these are non-problems, which I disagree with: http://yosefk.com/blog/parallelism-and-concurrency-need-different-tools.html http://yosefk.com/blog/parallelism-and-concurrency-need-diff...)
- tannhaeuser 10y agoMy experience is that using C for main(argc,argv)-style programs is rarely a problem. Trouble comes when using long running single-address space containers for service-like abstractions with pthreads etc.; in that kind of environment, malloc() and co. don't cut it because even if you get memory allocation right, unless using pooled memory allocators, memory fragmentation is becoming a serious (ie. unsurmountable) problem. It's been said over and over since at least the Java times that creating OS processes for individual service invocations is bad for performance, but I've never seen proof for this statement in the form of a benchmark. Even the OpenBSD developers (who know a thing or two wrt. security of memory allocation schemes) diss process-per-service-invocation architectures in their httpd implementation (eg. calling their CGI bridge "slowcgi" and favouring fcgi over it). Isn't that inconsequential? I mean if there's a performance problem with CGI-like process-per-service invocations, why not target these problems at the OS level (or via pooling of network connections or whatever the bottleneck is)?
- eggy 10y agoI didn't see Ada or ATS mentioned upon a quick read here. I don't program in either beyond exploratory play, but they seem to fit the need here no?
- kcudrevelc 10y ago> Under Linux, some SECCOMP initialization and capability dances having to do with dropping root and closing off privilege-escalation attacks as soon as possible after startup. I was under the impression that these specific things were actually quite hard to do in Go. I believe that both setuid/setgid and seccomp_load change the current OS thread (only), and since Go multiplexes across multiple threads and gives programmers very little control over which ones are used for what goroutines, I'm not sure how you would, for example, apply a seccomp context across all threads in a Go program. setuid/setgid are currently unsupported for this reason, with the best method being "start a subprocess and pass it file descriptors" (https://github.com/golang/go/issues/1435 https://github.com/golang/go/issues/1435). I'd be interested to hear if others have found ways to actually do this reliably for all OS threads underlying a running Go process.
- deleted 10y ago[deleted]
- plietar 10y agoI did this once, by writing a small C program which sets up the seccomp context before exec'ing the Go binary. Unfortunately Go's runtime makes a huge number of system calls in the background, and the whitelist kept growing. Switched to Rust and there was only had one hidden system call left, getrandom used to initialize the hashmap