Beta
×

Welcome to the Slashdot Beta site -- learn more here. Use the link in the footer or click here to return to the Classic version of Slashdot.

Thank you!

Before you choose to head back to the Classic look of the site, we'd appreciate it if you share your thoughts on the Beta; your feedback is what drives our ongoing development.

Beta is different and we value you taking the time to try it out. Please take a look at the changes we've made in Beta and  learn more about it. Thanks for reading, and for making the site better!

Open-Source Python Code Shows Lowest Defect Density

Soulskill posted 1 year,16 days | from the errors-should-never-pass-silently dept.

Python 187

cold fjord sends news that a study by Coverity has found open-source Python code to contain a lower defect density than any other language. "The 2012 Scan Report found an average defect density of .69 for open source software projects that leverage the Coverity Scan service, as compared to the accepted industry standard defect density for good quality software of 1.0. Python's defect density of .005 significantly surpasses this standard, and introduces a new level of quality for open source software. To date, the Coverity Scan service has analyzed nearly 400,000 lines of Python code and identified 996 new defects — 860 of which have been fixed by the Python community."

cancel ×

187 comments

Sorry! There are no comments related to the filter you selected.

Python == LAME (-1, Troll)

For a Free Internet (1594621) | 1 year,16 days | (#44750959)

That's because nobody ever writes anything important in Python. It's a toy language for slow learning bourgeois fartsniffers.

Re:Python == LAME (-1, Flamebait)

Anonymous Coward | 1 year,16 days | (#44750993)

You were quickly modded down, but there is definitely an element of truth in your post.

Re:Python == LAME (-1, Flamebait)

Anonymous Coward | 1 year,16 days | (#44751111)

You were quickly modded down, but there is definitely an element of truth in your post.

No, I had quite a few drinks and I was joking. It happens after I've had anal sex with my mother.

See, when you have to implement an algorithm - and one that has to change over time - Python is the best when it comes to it. The data analysis libraries are only surpassed by R and when you have to pull data from the Internet, Python is THE language to use.

Sure, if I had something that required high performance, I'd write it in C - NOT C++ or Java - straight ANSI C. Nor would I write it any other language that requires a 'run-time environment'.

I want my executable to be loaded by the boot loader and run like it is - no runtime, no OOP overhead, or anything else.

Re:Python == LAME (-1)

Anonymous Coward | 1 year,16 days | (#44751177)

No, I had quite a few drinks and I was joking. It happens after I've had anal sex with my mother.

Completely understandable. All of us here at slashdot have a hearty laugh after having anal sex with your mother.

Re: Python == LAME (5, Informative)

Anonymous Coward | 1 year,16 days | (#44751031)

Most of Python isn't written in Python, smart ass. They're talking about the language interpreter itself, written in C/C++ etc.

WRONG! RTFA! (0)

For a Free Internet (1594621) | 1 year,16 days | (#44751107)

I quote: "Coverity scanned over ten thousand Python programs on the popular GitHub open-source software repository..."

Re:WRONG! RTFA! (4, Insightful)

Zero__Kelvin (151819) | 1 year,16 days | (#44751603)

"I quote: "Coverity scanned over ten thousand Python programs on the popular GitHub open-source software repository...""

Great. Now where the hell do you quote it from, since that sure as hell isn't in the linked to article anywhere.

"Coverity's scanning technology has analyzed more than 396,000 lines of code in the latest builds of Python 3.3.2. That analysis has led to 181 new defects being identified. For the year to date, Python developers have already fixed 278 defects. - See more at: http://www.eweek.com/developer/open-source-python-code-sets-new-standard-for-quality-study.html#sthash.wSdGotDE.dpuf [eweek.com] "

That makes it pretty clear that they are talking about the Python executable itself. Version 3.3.2 to be exact.

"One of the more interesting defects that Coverity identified in Python that developers have since fixed is a "double-free" defect. "'Double free' means that you allocate memory for a pointer, and then you free the memory twice," Samocha explained. "This can cause memory corruption, which can lead to unexpected behaviors or program crashes." - See more at: http://www.eweek.com/developer/open-source-python-code-sets-new-standard-for-quality-study.html#sthash.wSdGotDE.dpuf [eweek.com] "

... and that clearly shows that they are talking about the interpreter, written in C, which has pointers, malloc() and free(). Python has a memory manager with garbage collection and doesn't use pointers. The Python programmer doesn't allocate and free memory resources directly.

I especially love how you criticized a language earlier, when you clearly have literally no knowledge of said language.

Re:WRONG! RTFA! (0)

Anonymous Coward | 1 year,16 days | (#44751869)

"One of the more interesting defects that Coverity identified in Python that developers have since fixed is a "double-free" defect."

Shit! Haven't they ever heard about valgrind?

Re:WRONG! RTFA! (1)

Zero__Kelvin (151819) | 1 year,16 days | (#44752031)

They probably have. The Python interpreter is pretty complicated and valgrind isn't foolproof. Furthermore, if you don't have test cases that expose the problem, valgrind won't find them since it doesn't do static analysis of code, it hooks the calls to malloc() and free() and reference counts. Valgrind is an awesome tool, but if you run your program and valgrind doesn't complain that doesn't mean it is bug free, unless it is a very procedural / linear program and you can guarantee that every execution path has been taken and all the corner cases have been captured in your use cases / unit tests.

I'm going to 'toy with you' then... apk (-1)

Anonymous Coward | 1 year,16 days | (#44751947)

".sreffinstraf sioegruob gninrael wols rof egaugnal yot a s'tI .nohtyP ni tnatropmi gnihtyna setirw reve ydobon esuaceb s'tahT" - by For a Free Internet (1594621) ANOTHER "ne'er-do-well" /. OFF-TOPIC TROLL on Tuesday September 03, 2013 @05:21PM (#44750959)

"???"

Uhm... Could we get a translation of that off-topic "troll-speak/trolllanguage" of yours, please?

---

* HOWEVER: I tend to agree somewhat, since by comparison to say, C++ or Object Pascal/Delphi, it's just not there & can't DO as much: It's good for scripting & smaller projects for "quick & dirty" runs OR prototyping, imo @ least.

APK

P.S.=> "ReVeRsE-PsYcHoLoGy", for trolls - Courtesy of this code by "yours truly" in less than 1 second flat):

---

#TrollTalkComReversePsychologyKiller.py (Ver #2 by APK)

def reverse(s):
    try:
        trollstring = ""
        for apksays in s:
            trollstring = apksays + trollstring
    except:
        print("error/abend in reverse function")
    return trollstring

s = ""
print reverse(s)

try:
  s = "Insert whatever 'trollspeak/trolllanguage' gibberish occurs here..."
  s = reverse(s)
  print(s)
except Exception as e:
  print(e)

---

... apk

Python one-liner (1)

tepples (727027) | 1 year,16 days | (#44752411)

Simpler:

print(''.join(reversed('yuG stsoH .rM olleH')))

Python is readable (-1, Flamebait)

Anonymous Coward | 1 year,16 days | (#44750965)

Python is readable and readable code is easier to fix.

Also smarter guy have tendency to use Python/Haskell/Erlang

Re:Python is readable (5, Funny)

Anonymous Coward | 1 year,16 days | (#44751013)

Python is readable and readable code is easier to fix.

Also smarter guy have tendency to use Python/Haskell/Erlang

Oh yeah? Well, I'm working on a readable Perl script to refute that statement. How long do they accept comments in these threads?

Re:Python is readable (1)

X0563511 (793323) | 1 year,16 days | (#44751243)

I've seen multiple-kilobyte posts before. Slashdot truncates it on initial display with a 'read more' link appended to the end, that shows the full post.

Re:Python is readable (1)

Mitchell314 (1576581) | 1 year,16 days | (#44751385)

I think GP meant time, as in how long the comment sections stay open for posting. The answer is plenty long enough to finish a readable perl project, as long as TFAC doesn't have a life. Or waste time on petty little thinks like sleep. :P

Re:Python is readable (4, Funny)

Anonymous Coward | 1 year,16 days | (#44751267)

Python is readable and readable code is easier to fix.

Also smarter guy have tendency to use Python/Haskell/Erlang

Oh yeah? Well, I'm working on a readable Perl script to refute that statement. How long do they accept comments in these threads?

How is this possible? Perl is a write only language.

Perl IS readable (3, Funny)

Anonymous Coward | 1 year,16 days | (#44751273)

@*(&^)&^)^$

Perl programmers write their code in cartoon profanity!

Re:Perl IS readable (0)

Anonymous Coward | 1 year,16 days | (#44752337)

@*(&^)&^)^$

That doesn't look like valid Perl. You don't have balanced parentheses, and end on a scalar marker.

Re:Python is readable (1)

ebno-10db (1459097) | 1 year,16 days | (#44751841)

If you write a readable Perl script, then you've completely missed the point of the language. Ever hear of job security?

Re:Python is readable (5, Informative)

MetalliQaZ (539913) | 1 year,16 days | (#44751271)

The result in question tested the Python project's code, which is commonly known as CPython, which is the Python interpreter written in C.

Re:Python is readable (2)

ceoyoyo (59147) | 1 year,16 days | (#44751457)

It appears you're right. Neither the submitter nor the article writer understand the difference between "code written in Python" and "the CPython interpreter, which is written in C", which is what Coverity actually tested. So 90% of the comments are off topic. Mods - kudos to the parent.

Re:Python is readable (0)

cold fjord (826450) | 1 year,16 days | (#44751605)

You went past the point where you knew what you are talking about.

Re: Python is readable (-1)

Anonymous Coward | 1 year,16 days | (#44752167)

Hey, an idiot on slashdot!

You're supposed to post as AC when you say dumb stuff like that.

Re:Python is readable (0)

Anonymous Coward | 1 year,16 days | (#44752513)

Hey, an idiot on slashdot!

Re:Python is readable (3, Insightful)

vux984 (928602) | 1 year,16 days | (#44751461)

Python is readable and readable code is easier to fix.

True and true. But Python's use of semantic whitespace is also very brittle very easy to break, and a huge pain in the ass to fix compared to languages that use braces, or keywords to define 'blocks'.

But that's not even terribly relevant here, because this article is about the source code used for the python interpreter, which is C, not python.

Re:Python is readable (4, Insightful)

XcepticZP (1331217) | 1 year,16 days | (#44751555)

But Python's use of semantic whitespace is also very brittle very easy to break, and a huge pain in the ass to fix compared to languages that use braces, or keywords to define 'blocks'.

This is one thing I never quite get about python criticism. Sure, whitespace is significant, but I've never had it break easily or be "brittle" as you say. Then again, I don't go past 2 or 3 levels of nesting, class nesting included. And all my units of work are in separate methods/functions instead of being child blocks inside a giant function which I've regularly seen done. Perhaps the use of whitespace isn't the real issue many people have with python, but rather delineating blocks using whitespace exposes a bit of an inherent flaw in the way they structure their program's flow.

Either way, having a proper IDE when writing python code will go a long way to making you comfortable with using whitespace instead of braces. Initially it was weird and unsettling for me, because I didn't understand all the consequences that whitespace could have. But a little fluid and constant coding in a IDE will rid you of that quick enough.

Re:Python is readable (2)

AvitarX (172628) | 1 year,16 days | (#44751741)

I saw a trivial example break when posted to /. not that long ago, in the interview.

Re:Python is readable (1)

XcepticZP (1331217) | 1 year,16 days | (#44752063)

As I recall, the comments in that thread pointed out that no sane coder would be transferring code using such a medium as html that mangles white space.

Although, I have been bitten many times when copy-pasting python code between a text file and the command line. Though I've mostly gotten around that problem by working with files rather than trying to use the CLI to input arbitrary python code as every single console does it slightly differently.

Re:Python is readable (4, Insightful)

fahrbot-bot (874524) | 1 year,16 days | (#44752015)

Sure, whitespace is significant, but I've never had it break easily or be "brittle" as you say.

Not python, but one example of this type of thing would be in a Makefile where target commands are indented by a tab. Some newer versions of (g)make will allow spaces, but most require a tab. Cut and paste that in an X-Windows session (tabs are converted to spaces) and you're screwed. From Make Software: Makefiles [wikipedia.org]

Each command line must begin with a tab character to be recognized as a command. The tab is a whitespace character, but the space character does not have the same special meaning. This is problematic, since there may be no visual difference between a tab and a series of space characters. This aspect of the syntax of makefiles is often subject to criticism.

Re:Python is readable (4, Insightful)

vux984 (928602) | 1 year,16 days | (#44752443)

This is one thing I never quite get about python criticism. Sure, whitespace is significant, but I've never had it break easily or be "brittle" as you say.

Anytime you refactor stuff, or modify something even somewhat nested, especially in a 'dumb text editor', it's a pain in the ass.

Anytime you need to pass code snippets via email, forums, etc... well... you just don't because its a total waste of time. :)

Its also easy to barf all over code going into word processors, pdf files, and so forth. Its nice to be able to copy-paste some C out of a PDF file or an email, or off a forum, and then tell the ide to just reformat it.

erhaps the use of whitespace isn't the real issue many people have with python, but rather delineating blocks using whitespace exposes a bit of an inherent flaw in the way they structure their program's flow.

No. Because we use whitespace / indenting in our C / C++ etc projects too. We even have standards requiring it, and our IDEs / toolchains may even be set up to reformat it just-so before commits. We want all the benefits of well formatted code.

We just like the IDE to do all the work actually formatting it, and reformatting it as neccessary.

Either way, having a proper IDE

Is how you lose the argument. Everyone but python groupies agrees that any programming language worth considering MUST have its programs represented as plaintext files, with no proprietary / binary stuff that can only be accessed with specialized tools. Requiring an IDE is the sign of a bad language.

Python passes this test, but it can be pretty hideous to use with an arbitrary text editor. And really, even brainfuck wouldn't be too bad with the right IDE, right?

Re:Python is readable (1)

Zero__Kelvin (151819) | 1 year,16 days | (#44751615)

... which would matter if the Python interpreter was written in Python. It's not. It is written primarily in C.

Re:Python is readable (0)

Anonymous Coward | 1 year,16 days | (#44751673)

Haskell is written in Haskell by coders that only think in Haskell.

Can't be right (-1)

Anonymous Coward | 1 year,16 days | (#44750973)

It's written in Python. That's the biggest defect in the world.

Re:Can't be right (1)

crutchy (1949900) | 1 year,16 days | (#44751323)

it might have an advantage in forcing lazy programmers with no concept of 'code etiquette' to write semi-readable code as indentation is forced by syntax.

on the other hand, making indentation part of the language creates all sorts of other readability problems.

they probably started trudging through thousands of python files and got to the 20th and though "fuck this is giving me a headache... that's enough bugs already", and then published their number of bugs found out of the thousands of files they intended to check but couldn't bear to.

i like pascal as a language. i know it takes a fraction of a second longer to type "begin" instead of "{" or some other block delimiter, but it makes for very readable code, particularly with syntax highlighting on, and even if you're having to suffer the code of others. i also use php which feels a little C'ish, but its more symbolic than pascal but with similar whitespace freedom, which can make readability harder if you aren't a convention perfectionist (which i think programmers should strive to be, at least in their code).

Re:Can't be right (1)

skids (119237) | 1 year,16 days | (#44751473)

it might have an advantage in forcing lazy programmers with no concept of 'code etiquette' to write semi-readable code as indentation is forced by syntax.

Since the "density" is measured in defects per lines of code, I siggest that Python mandate an extra line return between all lines. Then they could half their defect density. Done.

Re:Can't be right (1)

Zero__Kelvin (151819) | 1 year,16 days | (#44751639)

That would not change the number of lines of code. An LOC is a logical unit not measured by the number of carraige returns or printable lines. For example, here is a single line of C code:
int


my_int

;

C initializers (1)

tepples (727027) | 1 year,16 days | (#44752433)

Whitespace normalization stops some but not all metric gaming. How many lines of code does each of these C examples have?

// Example 1
int egg = 0, sausage = 0, spam = 0;

// Example 2
int egg = 0;
int sausage = 0;
int spam = 0;

Re:C initializers (1)

Zero__Kelvin (151819) | 1 year,16 days | (#44752485)

I concur, and never said LOC metrics was a good metric, nor that it can't be gamed. I was merely pointing out that the GPs idea didn't hold water. OTOH, there is nothing that says a tool that counts atoms and calls both of those three lines cannot be devised / used. Of course, that won't make LOCs a great metric. Nothing can do that, as I think we both can agree. [is that a first? ;-) ]

Re:Can't be right (0)

Anonymous Coward | 1 year,16 days | (#44751533)

Lazy programmers are not someone I want to work with (if they can't be bothered when this kind of thing is built-in for most, if not all, worthwhile text editors/IDEs, how can you trust them to not be lazy when it comes to actual hard work?) If by some miracle they're lazy, but output good code, then there are tools to reformat code to a specific style.

Re:Can't be right (3, Informative)

XcepticZP (1331217) | 1 year,16 days | (#44751569)

it might have an advantage in forcing lazy programmers with no concept of 'code etiquette' to write semi-readable code as indentation is forced by syntax.

on the other hand, making indentation part of the language creates all sorts of other readability problems.

You'd be surprised at how much syntax in python actively ignores whitespace. As soon as you open up any brackets, it's a veritable free-for-all when it comes to whitespace and indentation. In such a scenario, a proper coding standard document is imperative for readable code.

Coverity fails to detect errors in python (4, Insightful)

Anonymous Coward | 1 year,16 days | (#44751007)

"Coverity fails to detect errors in python" would be my headline of choice here. Seem a much more reasonable explanation for the results.

Re:Coverity fails to detect errors in python (1)

Anonymous Coward | 1 year,16 days | (#44751095)

http://docs.python.org/devguide/coverity.html
Known limitations: Python’s C code are not yet understood by Coverity

Re:Coverity fails to detect errors in python (1)

TopherC (412335) | 1 year,16 days | (#44751229)

The actual doc says "Some aspects of Python’s C code are not yet understood by Coverity." That's much more vague admittedly, but not as shameful.

Re:Coverity fails to detect errors in python (2)

someone1234 (830754) | 1 year,16 days | (#44751349)

This causes false positives, so if they are really not bugs, then Python's code is even more awesome :D

Re:Coverity fails to detect errors in python (0)

Anonymous Coward | 1 year,16 days | (#44751379)

cold fjord sends news that...

I'm still trying to figure out how Coverity is related to the NSA....

Can some one please explain? (2)

OzPeter (195038) | 1 year,16 days | (#44751033)

I read TFS and both TFAs and all I can glean is that Coverity Scan service is some sort of report that measures defects in code, but never defines how such defect are determined. They articles also mention comparing open source code metrics, but the only project that is mentioned anywhere is Python.

So what is a Coverity Scan service and why should I care? After all I can make up all sorts of metrics about my own software.

Re:Can some one please explain? (-1)

Anonymous Coward | 1 year,16 days | (#44751051)

Find and fix defects in your C/C++ or Java open source project for free: https://scan.coverity.com/

Learn how BRL-CAD, an open source project with 840 KLOC, used Coverity Scan to fix 1,654 bugs in a 5 day bug fixing marathon: http://www.tenlinks.com/news/PR/brl_cad/080812_7.22.htm

Re:Can some one please explain? (1)

Sponge Bath (413667) | 1 year,16 days | (#44751071)

What is Coverity Scan service? It is a product they hope to sell you. Does advertising work? It just did!

Re:Can some one please explain? (2)

msauve (701917) | 1 year,16 days | (#44751161)

"Coverity's code-scanning system for open-source projects... has been in place since 2006, when the effort was first funded by the U.S. Department of Homeland Security (DHS)."

A defect is when the code uses encryption, and doesn't send the keys to the NSA, or uses smtplib, and doesn't bcc:archives@dea.gov.

Re:Can some one please explain? (3, Informative)

Krishnoid (984597) | 1 year,16 days | (#44751165)

Here's the python dev's own page [python.org] describing it and how to get to the results.

Re:Can some one please explain? (0)

Anonymous Coward | 1 year,16 days | (#44751331)

...how to get to the results.

"Access is restricted to Python core developers only."

Re:Can some one please explain? (1)

cold fjord (826450) | 1 year,16 days | (#44751645)

Here is the data sheet [coverity.com] (.pdf) that should help you understand.

Here is some addition detail on the common problems [coverity.com] (.pdf) it looks for.

Here is a background article: A Few Billion Lines of Code Later: Using Static Analysis to Find Bugs in the Real World [acm.org]

Re:Can some one please explain? (1)

TapeCutter (624760) | 1 year,16 days | (#44752113)

So what is a Coverity Scan service

It's the same idea as the 'lint' command, it picks up potential bugs.

These sort of tools can't help improve the quality of your code. Having said that, in my (20+) years of experience it's not common practice to use these things, I've worked on several large "mission critical" systems and the Y2K ordeal was the only time someone even asked if I used such a tool, let alone demanded it. At the end of the day (actually more like a month) the "Y2K lint" tool's only practical achievement was to tick a due-diligence box for insurance purposes.

Where is the study? (1, Informative)

achacha (139424) | 1 year,16 days | (#44751039)

I could not find a link to the actual study, instead the company links lead back to the article and the article leads back to the company home page. Is this more "faith-based computing"? I am interested in the comparisons to other languages and in what type of code was analyzed.

Re:Where is the study? (0)

Anonymous Coward | 1 year,16 days | (#44751167)

http://softwareintegrity.coverity.com/register-for-the-coverity-2012-scan-report.html

Register for the study? (1)

Anonymous Coward | 1 year,16 days | (#44751931)

So, it's definitely spam then?

Hmmm (5, Informative)

Anonymous Coward | 1 year,16 days | (#44751075)

TFA seems to be about the Python interpreter, also known as CPython (because it's implemented in C), rather than about code written in Python itself. So maybe it has nothing to do with the Python language, but everything to do with the fact that the Python authors are apparently awesome C programmers.

That's great, but most people interpret "Open Source Python Code" to mean code written in Python that is Open Source, not code written in C (to implement the Python interpreter) that is Open Source.

Re:Hmmm (0)

Anonymous Coward | 1 year,16 days | (#44751309)

I've seen the CPython code and it looks pretty awesome.
I think it may be because of the consistency of the design and C-API. For example the builtin Python Integer type is written in the same way as any (3rd party) python module which defines types.

Also all the code uses reference counting, instead of malloc and free where ever you want. Reference counting, even done by hand, seem to be much less error prone than malloc/free. I have noticed this with reference counting with Objective-C.

ok, and this means what? (2)

intermodal (534361) | 1 year,16 days | (#44751077)

Does it mean better coders, or better language? Seems like the results are ambiguous in their meaning.

Re:ok, and this means what? (2)

dfsmith (960400) | 1 year,16 days | (#44751257)

It means that the Python developers fixed the warnings.

This is w/r/t CPython, not random code in Python (5, Informative)

paulproteus (112149) | 1 year,16 days | (#44751085)

The Slashdot summary is confusing, as is the eweek.com headline. Reading the article, it is clear that it is about the code that powers the official Python interpreter, AKA CPython, AKA /usr/bin/python. When I clicked the link, I thought Coverity had surveyed the entire world of open source Python code and discovered that Python programmers as a whole publish higher quality code than people who e.g. program in Ruby. That's not what the article's about.

It'd be great if the headline in Slashdot were to be fixed to say, "Python interpreter has fewer code defects compared to other open source C programs, says Coverity."

Re:This is w/r/t CPython, not random code in Pytho (-1)

Anonymous Coward | 1 year,16 days | (#44751143)

But that wouldn't let people say "look, Open source produces better quality code than closed source"

Re:This is w/r/t CPython, not random code in Pytho (2)

lightBearer (2692183) | 1 year,16 days | (#44751263)

Yes it would, as the Python interpreter is open source: Python License & History [python.org]

Re:This is w/r/t CPython, not random code in Pytho (0)

Anonymous Coward | 1 year,16 days | (#44751587)

You can thank "cold fjoord [slashdot.org] " for that. Slashdot collectively seems to enjoy sucking his cock as I see his shit propaganda modded up constantly.

Math impairment (5, Informative)

fava (513118) | 1 year,16 days | (#44751113)

0.005 defects per thousand lines times 400,000 lines gives a total defect count of 2.

So where did the other 994 defects come from?

Re:Math impairment (1)

Anonymous Coward | 1 year,16 days | (#44751173)

Looks like snake oil to me.

Re:Math impairment (0)

Anonymous Coward | 1 year,16 days | (#44752001)

Whoosh...

Re:Math impairment (0)

sjames (1099) | 1 year,16 days | (#44751193)

Since they were fixed, they no longer count. Logic impairment.

Re:Math impairment (2)

aaaaaaargh! (1150173) | 1 year,16 days | (#44751261)

However, only 860 were fixed. Double logic impairment.

Re:Math impairment (0)

sjames (1099) | 1 year,16 days | (#44751353)

Just motivation impairment, I don't care to track down the rest of it after knocking it down by a factor of 8 point something.

Re:Math impairment (4, Funny)

jwkane (180726) | 1 year,16 days | (#44751797)

Maybe those two LOC are is really, really, really bad.

Re:Math impairment (1)

Tumbleweed (3706) | 1 year,16 days | (#44751361)

0.005 defects per thousand lines times 400,000 lines gives a total defect count of 2.

So where did the other 994 defects come from?

They were in comments.

Re:Math impairment (1)

EuclideanSilence (1968630) | 1 year,16 days | (#44751425)

I'm more interested in this software that detects bugs in code. Does it also solve the halting problem? Can it satisfy finite combinational logic in polynomial time?

Re:Math impairment (2)

ShanghaiBill (739463) | 1 year,16 days | (#44751833)

I'm more interested in this software that detects bugs in code. Does it also solve the halting problem? Can it satisfy finite combinational logic in polynomial time?

The don't claim to find all bugs. I have used Coverity, and they found quite a few bugs, and also found many instances of unclear code that wasn't really a bug but should be rewritten anyway. But they don't find most logic bugs, or flaws in your requirements, etc. You still have to use your brain for those. But you can use tools like Coverity and other dynamic and static analysis tools to flag the easy bugs so you can spend more time on the hard bugs.

Re:Math impairment (1)

EuclideanSilence (1968630) | 1 year,16 days | (#44752245)

Does it analyze source code or is it like a fuzz tester?

Re:Math impairment (4, Informative)

ShanghaiBill (739463) | 1 year,16 days | (#44752449)

Does it analyze source code or is it like a fuzz tester?

It is static analysis of source code. It doesn't actually run the code, it scans it for patterns that might be bugs. I like Gimpel Lint [wikipedia.org] better, but it isn't either-or, so you can use both and they will find different bugs. You still need to do dynamic testing with something like Valgrind [wikipedia.org] . Tools are cheap compared to people, so you want to give your developers the best testing tools you can, and put your code through the wringer. We use six different tools for C/C++, and no code is shipped out the door till it passes them all (plus unit, usability, and requirements testing).

Re:Math impairment (0)

Anonymous Coward | 1 year,16 days | (#44751467)

Apparently the Coverity Scan application has more than few defects of its own.

Excellent marketing! (5, Insightful)

caffeinemessiah (918089) | 1 year,16 days | (#44751131)

So a private, for-profit company named "Coverity" has released a report that shows that their "Coverity Scan" software finds the fewest vaguely-defined "defects" in a programming language whose community has added the "Coverity platform" product to their development process? I was about to say "excellent marketing" by writing a fluff piece for free Slashdot traffic, but it's really not even excellent marketing.

Coverity: Static analyzer (5, Informative)

dwheeler (321049) | 1 year,16 days | (#44751137)

Coverity sells software that does static analysis on source code and looks for patterns that suggest defects. E.G., a code sequence that allocates memory, followed later by something that de-allocates that memory, followed later by something that de-allocates the same memory again (a double-free).

The product is not open source software, but a number of open source software projects use it to scan their software to find defects: https://scan.coverity.com/ [coverity.com] It's a win-win, in the sense that Coverity gets reports from real users using it on real code, as well as press for their product. The open source software projects get reports on potential defects before users have to suffer with them.

Re:Coverity: Static analyzer (3, Interesting)

Anonymous Coward | 1 year,16 days | (#44751209)

We've ran Coverity on several very large projects where I work. For C++ it did a decent job of finding little and simple things that Visual Studio missed, like variables that were never initialized before use, subtle type violations Visual Studio missed, or accessing past the end of a statically allocated array. These aren't the sorts of bugs that we worry about. The evil bugs - like those created by programmers that don't know enough about multithreading but were assigned because some offshore contractor service is the only place we're allowed to staff from and nobody vets their skillsets - all slipped right by Coverity and had to be fixed by the few remaining senior programmers. ( Attrition will fix that problem soon, at least for the senior programmers moving anywhere less strategically suicidal. )

Re:Coverity: Static analyzer (2, Informative)

Anonymous Coward | 1 year,16 days | (#44751337)

you should try TSAN. See : https://code.google.com/p/thread-sanitizer/

Re:Coverity: Static analyzer (0)

Anonymous Coward | 1 year,16 days | (#44751369)

Thanks, hadn't ran across this before!

Past Coverity reviews (4, Informative)

greg1104 (461138) | 1 year,16 days | (#44751147)

Coverity's services have been useful to a number of open-source projects. But this article is carefully picking its terms to get a headline worthy result. Compare against the Coverity scan of PostgreSQL [postgresql.org] done in 2005 for example, and CPython's defect rate isn't very exciting at all. But that was "Coverity Prevent" and this is "Coverity Scan"...whatever that means.

Defect detector limitation (1)

Anonymous Coward | 1 year,16 days | (#44751157)

The defect detector depends on brackets. The 0.005 defects found is because no code is perfect.

Slashvertisement? (0)

Anonymous Coward | 1 year,16 days | (#44751163)

n/t

C code, not Python code (2)

paavo512 (2866903) | 1 year,16 days | (#44751203)

The title is misleading again as hell. It appears they talk about the C code included in the Python compiler/interpreter project, and it is to be compared against other open source software projects, not against other languages. All that it shows is the Python project developers are eager to fix problems what this particular verification software founds. If they have fixed all those bugs, then they will have exactly zero known defects. Good for them, but most probably there will remain unknown defects, and it is hard to measure their amount.

In short, a meaningless article and a misleading title. The correct headline would have been "Python core developers are fixing bugs with help of a tool".

Impossible. (0)

Anonymous Coward | 1 year,16 days | (#44751205)

If bugs are defects then Python has, and has had, heaps. Number one defect is mandatory indentation. If only they had used C-style braces! Unfortunately then it would almost look exactly the same as C. There is little in Python that a good library cannot also do for C/C++/C# or whatever.

How rude! (2)

sgt scrub (869860) | 1 year,16 days | (#44751225)

They counted my C++ features as bugs?

What does the measering mean? (1)

angel'o'sphere (80593) | 1 year,16 days | (#44751255)

Numbers like .69 or 1.0 or 0.005 mean nothing if you don't know to what it relates.

Usually defect counts are based on 1k LOC (one thousand lines of code, and no: a line of code is likely not what you consider a line of code).

I doubt that 1.0 is a accepted industry standard defect density [...] for good quality software of ...

1 defect per 1 kLOC is absurd high, luckily I never was in a project the last 20 years with such a high defect rate.

Re:What does the measering mean? (1)

K. S. Kyosuke (729550) | 1 year,16 days | (#44751561)

1 defect per kLOC is pretty good. The question is, however, *what* is exactly a defect? It is one thing to define a defect as an error that manifests itself when a piece of code is passed what ought to be a valid input, but we all know that no program will ever be handed any significant subset of all valid input during anyone's lifetime. Even that 1 defect per kLOC may never be triggered because even though the function is defective in terms of not handling all possible inputs from what one would consider the maximum reasonable input domain, the real usage could easily differ.

Doubtful (-1)

Anonymous Coward | 1 year,16 days | (#44751269)

I doubt they looked a Lua [lua.org] because I'm sure it's one of the lowest if not the lowest. Definitely lower than Python. It's probably the most stable piece of software I use regularly.

Hey metric retards (4, Interesting)

Sulik (1849922) | 1 year,16 days | (#44751311)

While it can be useful in pinpointing common code defects, interpreting coverity results as an absolute indicator of code quality is just retarded. 90% of coverity's defect's tend to be really false positives that would be obvious to even the average code monkey... Not sure that massaging a code base to please coverity and getting a 'high score' is really any kind of achievement and may be more an indicator that you have way too much time on your hands...

Bullshit (2)

gwstuff (2067112) | 1 year,16 days | (#44751345)

This is bullshit, but a great tactical conversion of non-informative data into marketable news by Coverity.

Coverity uses lexical pattern matching to find bugs based on "tricks" discovered by Dawson Engler and his colleagues in Stanford University in the early 2000s. The tricks (find "malloc" not coupled with "free", cli() not coupled with sti(), dereferences of uninitialized pointers etc.) were developed in the context of the C language used for Operating System code.

So they used tricks developed for one language and context, to another language in a different context, and found that they didn't find as many bugs in the latter as they did in the former. You would think that this suggests a failure - in that their techniques are not quite as effective on Python as they were on C. Instead, they have turned it around as a statement on the inherent high quality of Python code.

It's like saying that the fact that a good tennis player sucks at playing table tennis, it implies that table tennis is a harder game.

Re:Bullshit (2)

Lehk228 (705449) | 1 year,16 days | (#44751409)

article is about the c code that makes up the CPython interpreter, not about Python scripts.

Re:Bullshit (1)

gwstuff (2067112) | 1 year,16 days | (#44751927)

I apologize. I misunderstood the article, but looking at the other comments I wasn't the only one who misinterpreted "open source python code" to mean a side sampling of open source code written in Python. /me yanks foot out of mouth.

Doesn't surprise me (0)

Anonymous Coward | 1 year,16 days | (#44751421)

Doesn't surprise me. Obviously, Python is not suitable for everything. But, it is easy to read, easy to write code in, avoids those little issues of C and even Java where some OK-looking code is in fact a security risk. I think it's permitting virtually any programming model you want is helpful too (you want this part to use functional programming, and this part object oriented? Go ahead.) This sounds like a receipe for disaster but avoids the condition of the programmer having to force some particular problem to follow a particular programming method because that's what the language supports best... it supports all methods.

Re:Doesn't surprise me (1)

Desler (1608317) | 1 year,16 days | (#44752223)

Doesn't surprise me. Obviously, Python is not suitable for everything. But, it is easy to read, easy to write code in, avoids those little issues of C and even Java where some OK-looking code is in fact a security risk.

FYI: The article is about the CPython code which as you can probably guess is written in C. It is not about projects written in Python.

defect density (0)

Anonymous Coward | 1 year,16 days | (#44751513)

never heard of defect density before. i learned something new today.

..and thats why there are few job opportunities. (2)

ClassicASP (1791116) | 1 year,16 days | (#44752235)

I once thought about learning python. Then i combed craigslist across the US looking for job opportunities doing python programming. Relatively few out there by comparison to ASP.NET and Java. Sure its less buggy.....but whats to motivate anyone to learn something they can't easily find work in?
Load More Comments
Slashdot Login

Need an Account?

Forgot your password?

Submission Text Formatting Tips

We support a small subset of HTML, namely these tags:

  • b
  • i
  • p
  • br
  • a
  • ol
  • ul
  • li
  • dl
  • dt
  • dd
  • em
  • strong
  • tt
  • blockquote
  • div
  • quote
  • ecode

"ecode" can be used for code snippets, for example:

<ecode>    while(1) { do_something(); } </ecode>