News for hackers. Stuff that matters.
Re:The Safe C Library (2009) by LambdaComplex on Wednesday April 12, 2017 @08:26PM (#14102987)
C is not a safe language. This sort of thing seems (to me, at least) like a jury-rigged workaround rather than an actual solution.

If you actually care about memory safety—which you should, as the CVE list shows—then why not use an actual memory-safe language?

Re:The Safe C Library (2009) by cvwright on Wednesday April 12, 2017 @09:49PM (#14103445)
I don't disagree.

> If you actually care about memory safety ... then why not use an actual memory-safe language?

Many teams are stuck with established codebases that they can't afford to re-write entirely from scratch.

I think the proposal in the article is an interesting point on a continuum of mitigations for C, spanning from the really weak and/or hacky (but cheap/easy) all the way up to safe systems languages like Rust and Ivory. Other points on this continuum include Cyclone [1], SAFECode [2], and the fat pointer approach in Cello [3].

[1] http://cyclone.thelanguage.org/

[2] http://safecode.cs.illinois.edu/index.html

[3] http://libcello.org/learn/a-fat-pointer-library

Re:The Safe C Library (2009) by duneroadrunner on Wednesday April 12, 2017 @11:48PM (#14104015)
And don't forget the llvm (and gcc) sanitizers[1] and SaferCPlusPlus[2] (essentially a memory safe subset of C++), which are more modern and have arguably better overall combinations of performance/safety/compatibility/practicality.

Automatic translation (assistance) from native C to SaferCPlusPlus is being worked on. And if you'll permit me to gripe a little here - you might think it's a reasonable undertaking, until you start contemplating code like this:

  int **var1 = (int **)malloc(20);
  var1[2] = (int *)malloc(10);
  int *var2 = var1[2] + 4;
  var2--;
  free(var2 - 3);
  free(var1);
:)

[1] https://github.com/google/sanitizers

[2] shameless plug: https://github.com/duneroadrunner/SaferCPlusPlus

Re:The Safe C Library (2009) by sametmax on Thursday April 13, 2017 @01:45AM (#14104429)
> Many teams are stuck with established codebases that they can't afford to re-write entirely from scratch.

You don't have to. Most alternative can call compiled C libraries. Rust can.

Re:The Safe C Library (2009) by AstralStorm on Thursday April 13, 2017 @07:01AM (#14105778)
Converting a monolithic chunk of code into modules then rewriting it in another language takes a lot of effort with not too much to show for it.
Re:The Safe C Library (2009) by sametmax on Thursday April 13, 2017 @03:22PM (#14110137)
Rust can be compiled to be called from C too.
Re:The Safe C Library (2009) by zik on Wednesday April 12, 2017 @08:42PM (#14103089)
I once wrote a C interpreter for scripting (picoc) which had memory safety. To my surprise I received a lot of complaints from people who wanted the more conventional memory unsafe semantics. I changed it to being memory unsafe and I've never had any requests to change it back.

Perhaps there's a place in this world for both approaches?

Re:The Safe C Library (2009) by mamcx on Wednesday April 12, 2017 @10:20PM (#14103615)
Or more probable you userbase was full of C developers, that can't imagine to be possible to code outside the C-mindset.

Take in account how many can't even consider the possibility that a full OS can (and have be made before) safer, have GC, is NOT C, is NOT EVEN ALIKE C, etc.

C, C++, Unix are the biggest roadblock in the progres of computing. Or more exactly, the users, that prefer patch-along and commit million of dollars in wasted effort than in build (or rediscover) better ways.

This is alike climate change resistance. Why go solar, if carbon is better and well understood? Instead, push ahead and waste money fixing symptoms instead of causes.

And "causes" is a word that here mean, C, C++, Unix, etc...

Re:The Safe C Library (2009) by pmilot on Wednesday April 12, 2017 @11:17PM (#14103866)
That's an unfair judgement toward the C development community as a whole.

There are legitimate use cases for C. If you're writing low-level, bare-metal programs then there is no other portable programming language that offers better semantics. C programmers often laud that language because they can easily reason what the output of the compiler will be. That is an extremely important and rare property for a portable programming language.

But hey, don't listen to me, listen to an actual experienced C programmer: https://youtu.be/MShbP3OpASA?t=20m45s

Re:The Safe C Library (2009) by adrianN on Thursday April 13, 2017 @03:55AM (#14105003)
The key-word is "portable". C is running on momentum in the embedded world because for many chips you only have a crappy "kinda C, but not standard C" compiler the vendor provides. Ada for example is a nicer language than C, suitable for embedded work, but not as popular and hence less supported. So is Pascal, and some more modern languages that get mentioned often enough on HN that some readers find it disagreeable.
Re:The Safe C Library (2009) by naasking on Thursday April 13, 2017 @01:09AM (#14104303)
> C programmers often laud that language because they can easily reason what the output of the compiler will be.

They certainly do, and in doing so, conveniently forget all the instances of their compilers surprisingly deleting invalid code as optimization because it inadvertently depended upon undefined behaviour.

Re:The Safe C Library (2009) by mamcx on Thursday April 13, 2017 @03:12PM (#14110041)
> There are legitimate use cases for C* * Or C-like langs...

Of course something must be use to fill the niche C have. But is clear that exist a huge resistance to fill it with something better, to the point that anything is almost dismissed and the only "valid" answer is continue with C (or C++, or Unix, or Old-School Terminals).

Probably you have see

https://www.destroyallsoftware.com/talks/a-whole-new-world

Is not hard to imagine that better/improved tools must have arise in all this decades. In contrast, we (as community) are stuck in more or less the same things and maybe even devolving in some areas.

Re:The Safe C Library (2009) by sametmax on Thursday April 13, 2017 @01:44AM (#14104428)
Would rust fit the bill though ? It's not as mature, and don't support as many platforms yet, but it is considered now as a serious safer alternative, with as much bare metal capabilities.
Re:The Safe C Library (2009) by geocar on Thursday April 13, 2017 @03:37AM (#14104915)
No.

Because it's not as mature, and doesn't support as many platforms. Those things are very important to me, and there is no steel thread for them.

I imagine that in twenty years, it could be worth talking about rust as an alternative, but rust is only two years "stable", and it's unclear what the language, the tooling and the libraries are going to look like in that time.

Meanwhile, I have software I wrote 20 years ago in C that still runs, correctly, and on the Internet, generating income, and a big part of the reason why is that C was already more than twenty years old at that point.

Re:The Safe C Library (2009) by mamcx on Thursday April 13, 2017 @03:20PM (#14110122)
> I imagine that in twenty years...

But WHY in 20? With this thinking NEVER WILL BE IMPROVED THE SITUATION!

And I don't mean you, I mean the whole industry.

Obviously stability and compatibility is important, but is not this almost like the COBOL problem? Nobody try to move out from COBOL because "maybe in the far future a solution will emerge" and the the future get here, and we are decades LATE?

And RUST is not the only viable alternative. Ada, Pascal, Oberon, Modula (to name the family of languages I know more, but is likely some lisp and others exist too) where already there (decades ago) without break too much from the C mindset (and go crazy with monads and stuff like that).

So, because look like without {} a system language have not chance in hell, take oberon and put the C syntax? And them we are not waiting 20 years in the future for it.

But this will fail, for the same reasons that renuevable energy will fail against carbon:

The community will not accept the costs in the short-term, not matter how much things could improve later...

P.D: And what if a "rust-alike" lang but trans-piling to C, like with Nim?

Or even better:

C2 (C with improvements and eliminating as much baggage as possible) trans-piling to C. Eventually this will allow to bootstrap and still keep a way to old code bases...

Re:The Safe C Library (2009) by marktangotango on Wednesday April 12, 2017 @09:02PM (#14103194)
That's really interesting. Is there any documentation around for memor safe version? I'd like to study your implementation!
Re:The Safe C Library (2009) by Nokinside on Thursday April 13, 2017 @08:17AM (#14106129)
For new Language to become safe you need to write state of-the-art linters, static source code analyzers, dynamic code analyzers, code coverage analysis tools, testing tools for the language.

C has all these. Only C/C++ and Ada have these.

People who say "C is not a safe language" may not be aware, but most of the worlds safety critical code is written in C or ancient C++. Most aerospace, military and medical applications are written either in C/C++ or Ada. Ada would be much safer than C, but it has been abandoned for C/C++ because language of choice is not that important.

If the culture and tooling to write safe code is not there, changing language is not going to help. It's currently easier to write safe code in C than it's to write safe code in your favorite 'memory safe' language like Rust.

https://en.wikipedia.org/wiki/MISRA_C

Re:The Safe C Library (2009) by danieltillett on Thursday April 13, 2017 @08:38AM (#14106261)
This is so true. It seems like most of the arguments against C are made in isolation of the ecosystem that has been built around C. At this point we should be helping new programmer learn how to work with C with all the safely equipment we now have.
Re:The Safe C Library (2009) by pjmlp on Thursday April 13, 2017 @09:20AM (#14106576)
Because only around 1% of all C developers care to use such band aids.
Re:The Safe C Library (2009) by Nokinside on Thursday April 13, 2017 @09:37AM (#14106718)
They are not band aids.

Analysis tools for C exceed anything you can have in Rust or Go compiler in scope and features.

Re:The Safe C Library (2009) by pjmlp on Saturday April 15, 2017 @08:23AM (#14120449)
Something that is optional doesn't exceed what are standard safety features in programming languages since Algol and its derived languages exist.

Having external tools to track out of bonds errors, use after free, double free, free bad pointers, implicit conversions and UB, errors that don't happen in another languages is band aid.

Other languages just don't need them thanks to being designed with safety first.

Re:The Safe C Library (2009) by danieltillett on Saturday April 15, 2017 @06:58PM (#14123310)
I write in C (mostly) and very few of my bugs are the typical errors C is famous for - 99.9% are logic bugs that can occur in any language. I have lots of great tools to catch the C type bugs - I wish I had a tool to catch my logic bugs. Tests can only find the bugs where the code doesn't do what I expect, not where what I expect is wrong.
Re:The Safe C Library (2009) by pjmlp on Sunday April 16, 2017 @01:39AM (#14124524)
Which tells me that you work alone without other devs of various skillsets messing around your beautiful C code.
Re:The Safe C Library (2009) by danieltillett on Sunday April 16, 2017 @03:24AM (#14124791)
Well I wouldn't call my C code beautiful, but no I don't work alone. I do only work with devs better than me :)
Re:The Safe C Library (2009) by Nokinside on Wednesday April 19, 2017 @11:53AM (#14148625)
>Other languages just don't need them thanks to being d esigned with safety first.

Other languages are not used for writing safety critical code. Language features are not even close being enough for that.

Re:The Safe C Library (2009) by pjmlp on Thursday April 20, 2017 @11:16AM (#14157422)
Ada and SPARK are such languages, better improve your knowledge.
Re:The Safe C Library (2009) by Nokinside on Friday April 21, 2017 @01:16PM (#14167411)
I specially mentioned Ada with C/C++ in my first post that started the tread.

No need to defensively boast if you realize that you are wrong.

Re:The Safe C Library (2009) by pjmlp on Friday April 21, 2017 @07:01PM (#14170123)
I don't need to be defensive in any way.

The band-aids called MISRA-C, Frama-C, High Integrity C++ and DOD certifications are a mechanism to force Ada safe like semantics in C and C++, while paying lower salaries, instead of hiring Ada devs.

F-35 proves how good they work out in large scale projects.

Re:The Safe C Library (2009) by danieltillett on Thursday April 13, 2017 @07:11PM (#14111558)
Exactly. The real problem is many C developers are unaware of these tools. Rather than just saying use programming language x, we should be helping people use C with the right tools.
Re:The Safe C Library (2009) by pjmlp on Saturday April 15, 2017 @08:25AM (#14120456)
Not at all.

These tools exist since 1979, it hasn't changed anything.

C doesn't deserve a place on any security conscious developer toolbox.

Re:The Safe C Library (2009) by Safety1stClyde on Wednesday April 12, 2017 @08:38PM (#14103062)
> This sort of thing seems (to me, at least) like a jury-rigged workaround rather than an actual solution.

Really? I had a look at the code and I would agree with the basic idea of eliminating errno and always using the return value.

> If you actually care about memory safety—which you should, as the CVE list shows—then why not use an actual memory-safe language?

Following the logic here, you seem to be implying that no-one except the irresponsible should use C.

Re:The Safe C Library (2009) by LambdaComplex on Wednesday April 12, 2017 @09:03PM (#14103203)
> Following the logic here, you seem to be implying that no-one except the irresponsible should use C.

There are some platforms (such as embedded systems) where C really is the only choice. But if you do have a choice? Then I don't think using C is a good idea.

I'm not sure if "irresponsible" is the right word, though. I think developers underestimate the risks of C's unsafety and/or overestimate their ability to properly deal with it. Hanlon's razor[0] applies.

0. https://en.wikipedia.org/wiki/Hanlon%27s_razor

Re:The Safe C Library (2009) by Safety1stClyde on Thursday April 13, 2017 @04:11AM (#14105085)
Given a problem, C may or may not be the correct tool to solve it. Decrying C as so dangerous that it can never be safely used under any circumstances, as you and others on this discussion seem to be doing, is absolutely ridiculous, like trying to ban chefs from ever using sharp knives because they might cut themselves.

Much of the software that we all currently rely on is in C, for example all of the common operating systems are in C, and the reliability of these operating systems shows very clearly that C is nowhere near as inherently dangerous as you claim it to be.

Re:The Safe C Library (2009) by nickpsecurity on Thursday April 13, 2017 @12:09AM (#14104103)
"There are some platforms (such as embedded systems) where C really is the only choice. "

That's never true. You can always use a higher-level, safer language that can compile to C. The result is C code but you never write it & avoid its pitfalls. Ivory language in Haskell, Ada-to-C, and Modula-2-to-C come to mind. Alternatively, you can use something even more primitive in a C subset or native assembly that it compiles to. OcaPIC or JavaCard come to mind. Astrobe Oberon is another for safe, low-level coding but not sure how its compiler works.

Re:The Safe C Library (2009) by adrianN on Thursday April 13, 2017 @04:04AM (#14105049)
Adding an extra compilation step doesn't make debugging easier. The embedded C compilers also aren't known for their stability and standards compliance, so you'd likely have to massage your generated C to avoid bugs in the C compiler.
Re:The Safe C Library (2009) by nickpsecurity on Thursday April 13, 2017 @11:42AM (#14107946)
Those are good points worth considering for a given tool.
Re:The Safe C Library (2009) by sametmax on Thursday April 13, 2017 @01:43AM (#14104424)
No you can write rust now.
Re:The Safe C Library (2009) by jsymolon on Thursday April 13, 2017 @11:20AM (#14107713)
Per the Reenix OS implementation:

"This boot-loader, unfortunately, did not support loading any kernel images larger than 4 megabytes. This turned into a problem very quickly as it turns out that rustc is far less adept than gcc at creating succinct output. In fact, I was hitting this problem so early I was barely able to make a “Hello World” before having to stop working on rust code. Fixing this problem required rewriting most of the early boot code, all of which was x86 assembly ..."

Re:The Safe C Library (2009) by adrianN on Thursday April 13, 2017 @04:05AM (#14105052)
Not for all targets.
Re:The Safe C Library (2009) by geofft on Wednesday April 12, 2017 @08:43PM (#14103101)
> Following the logic here, you seem to be implying that no-one except the irresponsible should use C.

This seems highly likely, yes.

C was a good language at the time. It's still probably a very good teaching language for systems programming. But it's a bad language for anyone who wants to write software that needs to be used responsibly. It predates the entire idea that some people on the network might be hostile. It predates the knowledge that buffer overflows might be used for malice. It predates about 40 years of programming language research and security research, some of which has even shown results.

C also predates computers of modern speed; it was written at a time when interpreted languages were mostly unthinkable for serious software. There's no reason that, say, the manpage rendering tools (the most recent thing I had half a mind of exposing to the network) would be written in C today, but it was presumably the best tool for the job at the time.

It is no criticism of C to say that it has served us well but it is a bad choice for new software for clear and objective reasons.

Re:The Safe C Library (2009) by pjmlp on Thursday April 13, 2017 @12:25AM (#14104155)
ESPOL and a full OS written in it, Burroughs B5500 nowadays sold as Unisys MCP, predates C by about 10 years, having been released in 1961.

There were already powerful computers than the PDP-11, with more saner languages.

Re:The Safe C Library (2009) by Safety1stClyde on Wednesday April 12, 2017 @10:36PM (#14103686)
> There's no reason that, say, the manpage rendering tools (the most recent thing I had half a mind of exposing to the network) would be written in C today

Someone called Kristaps Dzonsons wrote a manual page renderer and a cgi/fastcgi library in C quite recently.

Re:The Safe C Library (2009) by durandal1 on Wednesday April 12, 2017 @08:44PM (#14103106)
In how many "safe" languages can you write a complete shipping application without calling into libraries and/or kernels written in C?
Re:The Safe C Library (2009) by thesuperbigfrog on Wednesday April 12, 2017 @11:10PM (#14103839)
It depends on what platform you are targeting, but as far as safe languages go, it is hard to beat Ada: https://en.wikipedia.org/wiki/Ada_(programming_language)

Although Rust shows a lot of promise, Ada has a proven track record of use in safety critical applications such as avionics and railways.

Re:The Safe C Library (2009) by nickpsecurity on Wednesday April 12, 2017 @09:00PM (#14103186)
Is C being in at some point even relevant? There's plenty of safer languages thst can fo that. There's also containers, OS's, and embedded runtimes for some. The first, business mainframe was even programmed in an early one. It's even still on market although less desirable today. And C itself has automated toolimg available like SAFEcode that can make it safer with one team doing that for FreeBSD.

So you can make the C safe or get rid of it. However much work you want to put in.

Re:The Safe C Library (2009) by pcwalton on Wednesday April 12, 2017 @11:15PM (#14103857)
You can make the same argument for assembler.
Re:The Safe C Library (2009) by geofft on Wednesday April 12, 2017 @08:52PM (#14103144)
Today? Zero, probably.

Five years from now? Probably a number of them. You've been able to write in Go with no standard library for years. There's a project to avoid it in Rust. There are lots of active kernel development projects. Do you want your software to continue to be written in C with a kernel and standard library in safe languages?

And why does it matter to you to avoid improving your code until it's possible to run on an all-safe stack? It is as if it is 1990, and you are asking, why should I license my code as free software? How much can I run on a free C library and a free kernel?

Re:The Safe C Library (2009) by steveklabnik on Wednesday April 12, 2017 @09:03PM (#14103200)
You don't need a project to do it with Rust, you just need a !#[no_std] marker.
Re:The Safe C Library (2009) by steveklabnik on Wednesday April 12, 2017 @09:02PM (#14103195)
You can do so with Rust, and there's a number of them, from toy POCs to much more serious projects.
Re:The Safe C Library (2009) by pjmlp on Thursday April 13, 2017 @12:27AM (#14104162)
Lots of them, like any Modula descendent.

C only became relevant outside UNIX around the late 90's.

Re:The Safe C Library (2009) by khedoros1 on Thursday April 13, 2017 @01:18AM (#14104334)
That doesn't sound right. A ton of DOS software in the late 80s and early 90s was written in C.
Re:The Safe C Library (2009) by pjmlp on Thursday April 13, 2017 @09:07AM (#14106462)
Not at all.

MS-DOS was written in Assembly, just like any application where performance mattered.

CRUD applications were mostly written in an xBase dialect, with Clipper being the prominent one.

Turbo Pascal, Turbo C, Turbo C++, Turbo Basic, Quick Basic, Quick C, Quick Pascal.... All of them had plenty of users.

I own MS-DOS system programming books, with examples in Assembly, Pascal, Basic and C for both Microsoft and Borland variants.

Re:The Safe C Library (2009) by otterley on Thursday April 13, 2017 @03:13AM (#14104801)
Are you thinking of Pascal, maybe? I thought that was the language of choice for DOS application development (and 8086 assembly, of course).
Re:The Safe C Library (2009) by khedoros1 on Thursday April 13, 2017 @12:56PM (#14108730)
I'm thinking of games, really. The ones I'm most familiar with had certain performance-critical parts written in assembly, with the bulk of the connective code written in C. I suppose it depends on the definition of "written in C".
Re:The Safe C Library (2009) by pjmlp on Saturday April 15, 2017 @08:25AM (#14120457)
So not C at all, that was a common practice in Basic and Pascal as well.

Those languages were the "Unity" of the 80 and 90's.

Real games were 100% Assembly.

This only started to change with the adoption of Watcom C, as it could generate relatively good code and use a DOS 32 bit Extender.

Re:The Safe C Library (2009) by AstralStorm on Thursday April 13, 2017 @07:04AM (#14105793)
That and advanced variants of BASIC such as GWBasic and QBasic.

There is a good reason why Visual Basic is still alive.

Re:The Safe C Library (2009) by snakeanus on Thursday April 13, 2017 @01:23AM (#14104353)
> C is not a safe language

More like "most C implementations do not offer memory safety by default". This is unrelated to the language per se, it's like for example calling Scheme unsafe because an implementation could have set-cdr! on '() write on random memory. It can be applied to any language.

Re:The Safe C Library (2009) by boomlinde on Thursday April 13, 2017 @03:16AM (#14104816)
Is it C if it's incompatible with any standardized or widely accepted notion of it?
Re:The Safe C Library (2009) by catnaroek on Thursday April 13, 2017 @12:09AM (#14104101)
(0) Memory safety alone doesn't fix the downsides of lacking a formally defined semantics. You can turn most undefined behavior into trapped errors for the cheap price of a constant overhead factor, but that won't make writing correct programs any little bit easier. Your programs will just fail in more manageable ways.

(1) Once you have a formally defined semantics, undefined behavior is no big deal, because you have the tools to prove its absence in whatever program you're writing.

Re:The Safe C Library (2009) by cyphar on Wednesday April 12, 2017 @08:30PM (#14103009)
Because every platform generally has a C compiler (which is usually GCC, not LLVM/clang).
Re:The Safe C Library (2009) by c8g on Wednesday April 12, 2017 @11:21PM (#14103883)
even my tp link router has gcc!
Re:The Safe C Library (2009) by movedx on Wednesday April 12, 2017 @09:06PM (#14103223)
> C is not a safe language.

It what ways is it unsafe? Thinking about the examples you'll cite, can the programmer introduce checks and safety nets to overcome them? For example, you'll no doubt mention buffer overflows, but can these be protected against?

Re:The Safe C Library (2009) by geofft on Wednesday April 12, 2017 @09:44PM (#14103422)
Yes, it is possible to build checks and safety nets to overcome them. But it isn't easy.

The simplest example here is the one the Safe C Library is about: it's very hard in C to talk about memory buffers that know their own capacity. C wants you to think about pointers, often with implicit lengths (memcpy takes a single size parameter, strcpy takes none, tmpname takes none, etc.). You can write a library where you pass lengths alongside every pointer. But you've got to keep track of two variables for what should conceptually be a single variable.

Now, one approach is to make a struct buffer {char *ptr; size_t len;}. But then you run into C's problem that it has no encapsulation or operator overloading. You can't index into a buffer; you can call a function that checks the length, or you can just do the tempting thing of ->ptr[i], which you'll get wrong at some point. The compiler won't help you notice that you got it wrong.

And even if you do that, the C standard library is full of the unsafe approach to pointers. If you scrupulously avoid all functions that use unsafe pointers, you've also got to avoid the C standard library as well as almost all third-party libraries. This is not what most people think of when they think of using C.

C++ (and especially C++11 with good discipline) is a very good step forward in the direction of making C more safe, in no small part because C++ has its own standard library and the entire ecosystem tends to use that standard library. Due to the desire to be backwards-compatible with C, C++ retains a lot of unsafety, but it makes safer paradigms possible. If you're not bound to backwards-compatibility, though, there's probably no reason to voluntarily take the burden of dealing with the things that are unsafe in C.

Re:The Safe C Library (2009) by cvwright on Wednesday April 12, 2017 @09:57PM (#14103492)
> Now, one approach is to make a struct buffer {char ptr; size_t len;}.

A "fat" pointer. That's essentially what the Cello project does [1]. The author has pulled together some crazy hacks to make this approach accessible in C. Including, apparently his own version of many standard library routines. Crazy, but very interesting. Discussed on HN yesterday/today: https://news.ycombinator.com/item?id=14091630

[1] http://libcello.org/learn/a-fat-pointer-library

Re:The Safe C Library (2009) by Jweb_Guru on Wednesday April 12, 2017 @09:18PM (#14103296)
With multiple threads, detecting UB is undecidable (as seen in https://www.ideals.illinois.edu/bitstream/handle/2142/30780/...). If you ignore the weirdest UB and are willing to eat a lot of performance at runtime there is probably a conservative version that works though (there is for sure in the single-threaded case, e.g. see http://robbertkrebbers.nl/research/thesis.pdf).
Re:The Safe C Library (2009) by GoToRO on Thursday April 13, 2017 @02:20AM (#14104577)
Because they use a library to manage memory is one reason. Also they use linters which means that the C that they write is totally different from the C you see in tutorials. Of course it depends on the company/project.
Re:The Safe C Library (2009) by snickerbockers on Wednesday April 12, 2017 @08:30PM (#14103011)
There are no unsafe languages, only unsafe coders.
Re:The Safe C Library (2009) by Jweb_Guru on Wednesday April 12, 2017 @08:40PM (#14103070)
I'm going to go ahead and say that if (1) deciding whether code is valid for your language is undecidable, (2) no industrial compiler makes any effort to conservatively accept only valid programs, and (3) unsoundness cannot even be detected at runtime (this is true of C in the multithreaded case) and may result in completely arbitrary behavior, your language is unsafe.
Re:The Safe C Library (2009) by metajack on Wednesday April 12, 2017 @08:38PM (#14103064)
There are only unsafe coders.
Re:The Safe C Library (2009) by Someone on Wednesday April 12, 2017 @08:36PM (#14103050)
There are no unsafe cars, either, only unsafe drivers.

However, there also are plenty of cars that safe drivers will refuse to drive. You don't need crumple zones, safety belts, etc. in a car you will never drive.

Re:The Safe C Library (2009) by naasking on Thursday April 13, 2017 @01:12AM (#14104309)
> There are no unsafe languages, only unsafe coders.

There are no unsafe nuclear launch buttons, only unsafe nuclear launch button pushers.

Hmm, maybe some buttons should be harder to push...

Re:The Safe C Library (2009) by geofft on Wednesday April 12, 2017 @08:44PM (#14103107)
I enjoy using computers because they make fewer mistakes than humans.

I would like to apply the same principle to the language I program computers in. Make it the computer's job to minimize mistakes - it might not be perfect, but it's definitely better than I am!

Re:The Safe C Library (2009) by lacampbell on Wednesday April 12, 2017 @09:14PM (#14103269)
I agree with this sentiment. What I disagree with is the sentiment (which I'm not saying you expressed) of a silver bullet for it. IE if only our test coverage was complete, or our type system was sophisticated enough.
Re:The Safe C Library (2009) by LambdaComplex on Wednesday April 12, 2017 @09:55PM (#14103479)
You're right, there's no silver bullet. But it seems like some people have the mindset of "Since everything is bad and (to some extent), there's no point in trying to improve."
Re:The Safe C Library (2009) by mamcx on Wednesday April 12, 2017 @10:15PM (#14103592)
>There are no unsafe languages, only unsafe coders.

And who develop the languages? Coders.

Ergo, exist unsafe languages.