News for hackers. Stuff that matters.
Re:Checked C by Animats on Tuesday June 14, 2016 @02:35AM (#11900178)
This seems to be a successor to CCured from 2005, a project partially funded by Microsoft. [1]

The general idea is straightforward: "The unchecked C pointer type * is kept and three new checked pointer types are added: one for pointers that are never used in pointer arithmetic and do not need bounds checking (ptr), one for array pointer types that are involved in pointer arithmetic and need bounds checking (array ptr), and one for pointer types that carry their bounds with them dynamically (span)." So this is really a new language derived from C, to which programs can be converted.

This is basically a good idea, but it's only useful if pushed hard by somebody like Microsoft. People won't convert without heavy pressure.

[1] https://www.cs.virginia.edu/~weimer/p/p477-necula.pdf

Re:Checked C by vintermann on Tuesday June 14, 2016 @02:52AM (#11900244)
I thought so too, but looking at their paper, they have an impressive survey of prior approaches, and they explain their differences from CCured quite well. CCured used fat pointers, and apparently modified the data pointed to by WILD pointers (something I didn't know).

This seems interesting to me. I liked the way CCured did inference to document how you used and abused your pointers, but what it did with that information was maybe not ideal.

Re:Checked C by haberman on Tuesday June 14, 2016 @03:27AM (#11900363)
A link to the paper you are mentioning would be helpful.
Re:Checked C by jsingleton on Tuesday June 14, 2016 @03:34AM (#11900378)
Re:Checked C by cleeus on Tuesday June 14, 2016 @03:29AM (#11900366)
If that's all, it's nothing that cannot be done in-language with smart pointer/iterator types in C++.
Re:Checked C by Jtsummers on Tuesday June 14, 2016 @07:13AM (#11901180)
but I don't want to move my embedded C projects to C++. If I can use a language extension to get some extra confidence in my programs without changing the language im using then that's a compelling proposition.
Re:Checked C by scott_s on Tuesday June 14, 2016 @09:52AM (#11902004)
The difference between a language extension, and a new language, is one of degree, not kind. Personally, since the semantics of this "extension" go to the core of what one does in C, I consider Checked C a new language.
Re:Checked C by Jtsummers on Tuesday June 14, 2016 @10:48AM (#11902320)
I agree, in principle. But reading over this document, the changes can be made in an incremental fashion. And with far less impact than switching to using C++ just for these (assuming equivalents exist) features.
Re:Checked C by gpderetta on Tuesday June 14, 2016 @11:00AM (#11902402)
switching to c++ can also be done in an incremental fashion.
Re:Checked C by Jtsummers on Tuesday June 14, 2016 @12:26PM (#11903122)
Yes, but not quite as trivially as:

  Enable extension
  Add `checked` to array declarations. (for the simplest
  case they've implemented).
Converting to C++ also means making sure you have `extern "C"` in your function declarations to get around C++'s name mangling when calling C libraries. Among other, potential, source level changes. Or, similarly, making sure your C (now C++) library can be called correctly by C projects that depended on it.

I'm not sold on this project as we haven't seen any results of course, but the approach is simpler than switching to C++.

Re:Checked C by nitrogen on Tuesday June 14, 2016 @03:41PM (#11904726)
There are also some nice C99 syntax features like compound literals that may not be supported by your C++ compiler.
Re:Checked C by choosername on Tuesday June 14, 2016 @11:52AM (#11902821)
since many C programs will have simple array types like that, this addition is mostly syntactic.
Re:Checked C by adxlarbi on Tuesday June 14, 2016 @07:49AM (#11901342)
but here in the case of Microsoft Checked C , you still need to modify your actual source code to get safer one.
Re:Checked C by fao_ on Tuesday June 14, 2016 @08:28AM (#11901542)
But you're moving to a safer subset, not a safer superset, so it still shouldn't require significant alterations.
Re:Checked C by mixedCase on Tuesday June 14, 2016 @11:12AM (#11902485)
Uhhh moving from set to subset is what requires alterations, set to superset does not, by definition.

The problem here is compiler support and performance.

Re:Checked C by fao_ on Tuesday June 14, 2016 @04:40PM (#11905159)
C++ is an altered and extended form of C, thus I would say it is more accurate to call it a superset, rather than a subset. I'm not using precise definitions here.

And of course, but those will come in time. The point of it is that C++ isn't any safer (And actually, I would say is more risky in some aspects, because of the differences between (For example) the UB in C and C++), while Checked C is guaranteed to be safer, to a certain degree.

Re:Checked C by cleeus on Friday June 17, 2016 @04:11AM (#11921234)
OK, I have to admit that Checked C is probably strictly safer while C++ is ... a mixed thing (both safer and more complicated).
Re:Checked C by ptspts on Tuesday June 14, 2016 @03:06PM (#11904469)
Indeed, checkedc also introduces these 3 new pointer types (ptr, array-ptr and span). It also introduces invariants on variables, arguments and return values:

Quoting from the paper (https://github.com/Microsoft/checkedc/releases/download/v0.5...):

Reasoning about the correctness of programs with declared bounds sometimes requires reasoning about simple aspects of program behavior. To support this, lightweight invariants are added to Checked C. A lightweight invariant declares a relation between a variable and a simple expression using a relational operator. An example would be the statement x < y + 5. Lightweight invariants can be declared at variable declarations, at assignment statements, for parameters, and for return values. Checked C is extended with rules for checking these lightweight invariants. Just as type checking rules are defined by the programming language, so are rules for checking lightweight invariants. The checking of the correctness of programmer-declared bounds is integrated with the checking of invariants.

Re:Checked C by dragandj on Tuesday June 14, 2016 @03:09AM (#11900304)
Being pushed by Microsoft could be exactly the reason not to convert, for many people. Especially when there is no shortage of alternatives that are backed by a bit more benevolent entities (Rust, and many other less known variants).
Re:Checked C by johncolanduoni on Tuesday June 14, 2016 @07:42AM (#11901307)
I don't think this project is an instance where this is an important aspect, but in general I do agree that some caution is warranted when using an open source project backed by a corporation (Microsoft or anyone else) in your code. As someone who was recently burned by what happened to RoboVM[1], I am now always careful to check for any CLAs that are required to contribute to open source projects before I decide to use them in anything important.

The fact than you can fork is nice, but if the project is too reliant on the paid staff and doesn't have enough community surrounding it to survive getting dropped by its benefactor, you better hope you have the resources to maintain it yourself. This can happen even with no ill-intention involved, but the whole RoboVM debacle has convinced me that Embrace, Extend, Extinguish is not quite dead at Microsoft.

[1]: https://news.ycombinator.com/item?id=11503808

Re:Checked C by pjmlp on Tuesday June 14, 2016 @09:44AM (#11901962)
How many startups have been killed by other corporations, including Google, FB and friends?

The RoboVM situation, while unfortunate is a lesson for people not to rely on proprietary tooling for portable projects.

While I mostly code on JVM and .NET languages during the day, I use C++ for my hobby projects on mobile OSes.

The reason being that C++ is an open standard and officially supported in all SDKs, no need for third party layers like RoboVM.

A few similar lessons with my time spent on programming languages that weren't first party on platform SDKs, made me always choose first party languages, if I have decision power in the selection process.

Re:Checked C by johncolanduoni on Tuesday June 14, 2016 @07:23PM (#11906162)
> How many startups have been killed by other corporations, including Google, FB and friends?

Yeah, that's why I said "Microsoft or anyone else". The only other time I mentioned Microsoft was in reference to RoboVM, which doesn't have much to do with Google or Facebook.

> The RoboVM situation, while unfortunate is a lesson for people not to rely on proprietary tooling for portable projects.

I agree, but the fact that RoboVM started off open source with a GPL licensed compiler was one of the main reasons I chose it. It's my own fault I didn't look to see how contributions were structured, or notice that very little code came from outside RoboVM, sure. That's why I'm advising caution in similar situations.

Re:Checked C by cwyers on Tuesday June 14, 2016 @10:27AM (#11902193)
Where did Microsoft employ embrace or extend before extinguishing RoboVM? They bough Xamarin for Xamarin, and ended up with a RoboVM they didn't want. There was no RoboVM strategy there.
Re:Checked C by coldtea on Tuesday June 14, 2016 @03:44AM (#11900420)
To put things in perspective, consider than from web browsers and languages, to their respective ill-fated mobile OS efforts, nothing Mozilla created has ever gotten more adoption than something MS created.
Re:Checked C by dragandj on Tuesday June 14, 2016 @03:46AM (#11900433)
Only if we don't count Netscape and JavaScript. They put it in the browser, for better or for worse.
Re:Checked C by coldtea on Tuesday June 14, 2016 @08:52AM (#11901656)
Why would we count Netscape and Javascript?

We're talking about Mozilla.

Netscape was a different company -- and besides we're discussing under the context of MS vs benevolent/FOSS entities.

Re:Checked C by freeduck on Tuesday June 14, 2016 @04:09AM (#11900528)
According to w3counter ff and ie are neck to neck.

https://www.w3counter.com/globalstats.php

Last month ff was ahead

Re:Checked C by majewsky on Tuesday June 14, 2016 @05:09AM (#11900729)
It depends on the country. In Germany Firefox is actually the most popular browser according to usage statistics (even ahead of Chrome).

Source: http://de.statista.com/statistik/daten/studie/13007/umfrage/... (German statistics office. Paywalled sadly, but you can see the first paragraph that describes Firefox market share at 52%.)

Re:Checked C by nhaehnle on Tuesday June 14, 2016 @10:47AM (#11902315)
Just FYI, Statista is a private company. You may be thinking of http://destatis.de/, which is the homepage of the German federal office for statistics.
Re:Checked C by dragandj on Tuesday June 14, 2016 @03:44AM (#11900421)
In reply to myself: The times are changing indeed. It seams that HN-ers started liking Microsoft. Whenever I post some concern, even if only mild, there is first a few upvotes, and then a bunch of downvotes.

Microsoft became the darling of the community, OR, in addition to embracing open source, they embraced voting ring tactics. These are two explanations I have, maybe there is another. Maybe my criticism really was obnoxious...

Re:Checked C by ocdtrekkie on Tuesday June 14, 2016 @03:48AM (#11900440)
Maybe it's just because yes, we all remember the 90s. But today is not necessarily the 90s. It was a lot more recent that Google was a relatively benevolent company, and we've all seen how that's changed.

And the thing about open source projects, is just that. They're open source. If the wider community takes hold of them, there's not much Microsoft can do. Because then you just see a fork.

You don't have to be a fan of Microsoft to simply appreciate the contribution to open software, as it is.

Re:Checked C by marssaxman on Tuesday June 14, 2016 @04:34AM (#11900625)
Forced updates for Windows 10 burned all the credibility Microsoft was slowly regaining. Whatever might be going on in there, they still have enough of the old strongarm bullying monopolist in their collective corporate character that their good works really cannot be trusted over the long term.
Re:Checked C by ocdtrekkie on Tuesday June 14, 2016 @09:35AM (#11901910)
My Android has forced updates. I have to put my phone in airplane mode before each reboot and kill the process to prevent it. Chrome has forced updates. A lot of things have forced updates these days, and nobody bats an eye about it. Microsoft does it, everyone loses their minds.

And 'forced' is a stretch anyways, how to block it is well documented, and was months in advance. And you can revert, something Google and others will not let you do.

Re:Checked C by marssaxman on Tuesday June 14, 2016 @01:46PM (#11903819)
I sure bat an eye about it. I won't use Chrome.

I also deleted all the Google apps I could find on my Android phone, and I avoid storing any of my personal data on it, because Google seems to believe it's their machine, not mine. I'd use some other mobile OS if I had any choice in the matter.

Re:Checked C by sametmax on Tuesday June 14, 2016 @10:38AM (#11902271)
- Security update != version update.

- Paid OS != Free OS.

- OS update != software update.

Re:Checked C by ocdtrekkie on Tuesday June 14, 2016 @10:57AM (#11902380)
I have an Android 4.4 phone, Verizon/Google is trying to force my phone to install Android 5.1, a full version update to a version widely regarded as a lemon.

I paid for my phone. I paid for my Windows license. I paid a lot more for my phone, which Android is trying to forcibly update without my consent to a version which will cripple my phone's functionality substantially.

Re:Checked C by sametmax on Wednesday June 15, 2016 @04:18AM (#11907861)
Then you have the same problem and you should complain as much.
Re:Checked C by trelltron on Tuesday June 14, 2016 @06:01AM (#11900895)
What about forced updates makes them bullies? Or are you just generally angry?
Re:Checked C by marssaxman on Tuesday June 14, 2016 @01:45PM (#11903805)
I'm angry about the idea that forced updates might become a normal practice, because that could lead to a situation where it's difficult to find much software I am willing to use.

"Power to the people" has always been the whole point of personal computing, as far as I'm concerned. Give people control over their data, their processes, their lives; that's why we're doing this, isn't it?

That's why I'm doing it, at least.

Re:Checked C by Santosh83 on Tuesday June 14, 2016 @02:42PM (#11904265)
Power to the user is one aspect of personal computing. But with the rise of mobile and now IoT, the user has also become (increasingly) a 'consumer', and thus the software and hardware are getting more and more locked down. Hardware and software manufacturers will sleep easier at night when their products cannot (or can only limitedly) be modified.

I think the writing is on the wall. Computing devices will split into two diverging branches: one tailored for limited configuration and aimed at media consumption and use by non-tech users, the other providing (hopefully) full freedom to modify, aimed at IT co. and interested hobbyists. It will be quite some achievement if mechanisms to increase vendor control aren't increasingly integrated even into the devices in the second segment, as things like Intel ME/UEFI Secure Boot show.

Re:Checked C by EugeneOZ on Tuesday June 14, 2016 @03:58AM (#11900486)
pff.. they are "open source" just because they want to attract developers, because without developers writing apps for their platform, Microsoft will die (as any other platform). They are still just money-makers and nothing else, there is no any idea except money behind their movements to Open Source world, otherwise they wouldn't take revenues from Android.
Re:Checked C by eropple on Tuesday June 14, 2016 @04:05AM (#11900509)
Everything you say may (probably is) true.

Now why does anything in your post matter?

Re:Checked C by tremon on Tuesday June 14, 2016 @05:27AM (#11900781)
Because ocdtrekkie was using Microsoft's open source strategy to imply that Microsoft is no longer pursuing the same goals as before. EugeneOZ explained that Microsoft's strategy does not preclude their earlier goals.
Re:Checked C by EugeneOZ on Tuesday June 14, 2016 @04:37AM (#11900633)
Because it's important to distinct intention to contribute to open-source world and intention to use this world to make money.
Re:Checked C by devnonymous on Tuesday June 14, 2016 @05:10AM (#11900733)
It's sad to see that despite open source (or free/libre..etc) software being around for so long, people still don't get it that money and freedom are not mutually exclusive. I would argue that contributing to open source for business reasons is perhaps even more beneficial for the software and community than just doing it for a hobby or some philosophy because companies pay people to even work on stuff that is not exciting / interesting.
Re:Checked C by EugeneOZ on Tuesday June 14, 2016 @05:34AM (#11900806)
sad to see that people still thinks "it's sad to see" that somebody can have different opinion.
Re:Checked C by devnonymous on Tuesday June 14, 2016 @06:48AM (#11901067)
Huh? I acknowledge that you have a different opinion and I'm saddened by that opinion.

I respect your right to have a different opinion. I don't have to respect the opinion itself. Hope you can see the difference.

Re:Checked C by majewsky on Tuesday June 14, 2016 @05:10AM (#11900735)
As if these were orthogonal. My employer encourages me to contribute to open-source precisely because the open-source tools are the best for the job and thus allow us to make more money.
Re:Checked C by EugeneOZ on Tuesday June 14, 2016 @05:37AM (#11900819)
It's absolutely different case. Microsoft don't care if tools they use will be open-source or free - no. They only care if they can attract developers by playing role of "openSource company". It's not your case.
Re:Checked C by dewiz on Tuesday June 14, 2016 @04:08AM (#11900522)
last time I checked Microsoft was a company (not a platform) and like any other it has to make money to survive. Your saying is applicable to every other company releasing open source code
Re:Checked C by EugeneOZ on Tuesday June 14, 2016 @04:38AM (#11900638)
Approaches of Mozilla and Microsoft are quite different.
Re:Checked C by devnonymous on Tuesday June 14, 2016 @05:19AM (#11900763)
Yes they are... And believe it or not people / companies can change. And changing to a more open culture even if the reasons for doing this is because they will cease being competitive if they don't is still a good thing. Open source these days not only makes sense technically and ethically but also economically... And that's a good thing.
Re:Checked C by EugeneOZ on Tuesday June 14, 2016 @07:47AM (#11901333)
And I absolutely agree with it. Even happy about that. Companies should make money, developers should make money - it's all the right things. I love money too :)

The only thing I'm talking about is honesty - MS is trying to show they love open-source just because they are so awesome and hackers, but in reality it's just profitable mask and they are glad to wear it.

Re:Checked C by jknoepfler on Tuesday June 14, 2016 @01:08PM (#11903454)
I submit that Microsoft is staffed and led, in part, by talented software developers, many of whom are invested themselves in open source philosophy. When ideas make it into the light of day that reflect this internal culture, I think it is a cause for happiness. Let's use care when claiming to understand the actual decision making process in any complex organization, particularly one formed from many intelligent, autonomous agents. Certainly skepticism is healthy in general, but in this case it doesn't seem to serve a positive purpose.
Re:Checked C by EugeneOZ on Tuesday June 14, 2016 @03:43PM (#11904743)
I appreciate your efforts to register this account just to write this reply. But as it's just common words (each huge software company have developers who are involved to open-source projects), nothing has changed in my opinion - I'm still sure they wave "open-source" flag just to not loose developers for their platform and any their new standard or new language is a tool for vendor-lock (platform-lock) as it was before for years.
Re:Checked C by SixSigma on Tuesday June 14, 2016 @04:23AM (#11900588)
Did you think they would suddenly start waving "information wants to be free" flags?
Re:Checked C by EugeneOZ on Tuesday June 14, 2016 @04:39AM (#11900643)
Did I give any reason to think so?
Re:Checked C by SixSigma on Tuesday June 14, 2016 @10:54AM (#11902359)
You are dismissive of "attracting developers" as motive. That has always been a marketing ploy of the open source camp as an alternative to a fully open philosophy i.e. information wants to be free.
Re:Checked C by toomanythings2 on Tuesday June 14, 2016 @07:47AM (#11901335)
Microsoft was still under US Federal oversight as of 2010. Two years ago, Ballmer was still CEO. It takes a long time to turn a big ship.
Re:Checked C by dragandj on Tuesday June 14, 2016 @03:55AM (#11900469)
The only catch in that perspective is that the language specification is open source, while Microsoft's compiler implementation is not.

So, yes, we can edit those TeX documents they put on GitHub to our heart's delight.

Re:Checked C by vardump on Tuesday June 14, 2016 @04:16AM (#11900556)
https://github.com/Microsoft/checkedc-clang

https://github.com/Microsoft/checkedc-llvm

Doesn't that look like an open source implementation? Or did I misunderstand something?

However:

> The compiler is not far enough along for programmers to "kick the tires" on Checked C. We do not have a installable version clang available yet. If you are really interested, you can build your own copy of the compiler:

Re:Checked C by _pmf_ on Tuesday June 14, 2016 @03:55AM (#11900473)
> It seams that HN-ers started liking Microsoft.

Or maybe we stopped categorically demonizing some technology because of its provenience and started evaluating it based on criteria like usefulness and applicability.

You know, like if we actually take the "engineer" part of "software engineer" seriously instead of using it for everyone who once wrote a PHP page for his uncle.

Re:Checked C by EugeneOZ on Tuesday June 14, 2016 @03:59AM (#11900489)
it's funny how you are demonizing PHP in your comment
Re:Checked C by jo909 on Tuesday June 14, 2016 @04:42AM (#11900654)
He is "demonizing" some "typical PHP programmer". It's not the languages fault that it is allegedly often used by novices to start their first website project, and that by no fault of their own those novices do not have any appreciable CS education and thus build their programs like I build a sandcastle: keep trying random things until it does not fall over anymore.

The argument is exactly to make this difference. There is the technical and somewhat objective aspect of the language and its implementation, and there are the people who created the language, who use the language etc. A bad language can have a great community, and vise versa.

Re:Checked C by jjnoakes on Tuesday June 14, 2016 @10:19AM (#11902149)
Right, but not because of who made it, but because of its merits. Which is how things should be demonized.
Re:Checked C by coldtea on Tuesday June 14, 2016 @03:45AM (#11900425)
>Maybe my criticism really was obnoxious...

Well, the "maybe in addition to embracing open source, they embraced voting ring tactics" part sure is.