Do Strongly Typed Languages Reduce Bugs? (acolyer.org)
"Static vs dynamic typing is always one of those topics that attracts passionately held positions," writes the Morning Paper -- reporting on an "encouraging" study that attempted to empirically evaluate the efficacy of statically-typed systems on mature, real-world code bases. The study was conducted by Christian Bird at Microsoft's "Research in Software Engineering" group with two researchers from University College London. Long-time Slashdot reader phantomfive writes:
This study looked at bugs found in open source Javascript code. Looking through the commit history, they enumerated the bugs that would have been caught if a more strongly typed language (like Typescript) had been used. They found that a strongly typed language would have reduced bugs by 15%.
Does this make you want to avoid Python?
Does this make you want to avoid Python?
>>> The study was conducted by Christian Bird at Microsoft's...
This came from Microsoft, so most likely the premise for the study was specifically designed to generate results that would strongly suggest that one of Microsoft's horrid, awful, crap, packages would be superior to some free open-source package. (It looks like Python and Javascript are being targeted by Microsoft, in order to try and supplant it with their Typescript crapola.)
As far as I'm concerned, the source of this study makes it "fake news" and junk-computer-science.
I suspect that there is something like a "law of conservation of bugs" or something in software - you take away one vector for bugs to originate and you just move them into another place.
Dynamic languages do have an easy way to introduce bugs - especially languages like javascript that simply create new variables if you have a typo.
But there is the old adage in statically typed compiled languages "Hey, my code compiles! Now I get to find out where all my bugs really are."
This also applies to other aspects of programming languages. Consider the arguments about manual vs automatic memory management. Managed code still has bugs, just not memory management bugs.
"There are a dozen opinions on a matter until you know the truth. Then there is only one." - CS Lewis (paraprhase)
Didn't we go through this thing with Ada? Strongly typed languages end up with fewer bugs because they are caught at compile time, if not before. On the other hand, if the language isn't strongly typed, it's easier to write little programs super fast. Someone had to do a study on it again?
Strong typing is nice when people learn coding for the first time. Then they need to learn to do it without. The metric "less bugs in some code" is meaningless, just as the metric "fell over less" is with driving a bike. When you cannot do without training wheels than there is either something seriously wrong with you or you stopped learning way to early. The same applies to strong typing.
In essence, people that need strong typing do not have what it takes to get everything else right. They should stay away from professional coding altogether.
Most ACs are not even worth the keystrokes to insult them. Be generically insulted by this and ignored otherwise.
Python and Javascript is to this decade the same as Basic was to the 80's.
If builders built buildings the way programmers wrote programs, then the first woodpecker would destroy civilization.
How does development time and/or effort differ between statically and dynamically typed languages?
Also, why does the title ask about strong typing while the body talks about static typing? Do the editors not know there's a difference? Or do they not care?
Python... smython...Still using FORTRAN 77 with the wonderful way of (not) declaring types of variables... or rather looking at the name of the variable to understand what kind of type it is...
Spoken like a true cretin. While JavaScript is admittedly a really bad programming language, Python is a very good one. But both are real in any sense that matters and a competent coder can do real work of any size in both of them. The actual problem is that many people writing code these days are not "real" coders, but incompetent wannabees that like to blame the tools used for their personal limitations.
Most ACs are not even worth the keystrokes to insult them. Be generically insulted by this and ignored otherwise.
A friend of mine likes to say: "If you want to do something robust, code it in Ada. If you want to do something quick, code it in Python".
I have found the harder I mash my keyboard the more the bugs infesting it die. I think eating baklava while coding might have something to do with that. . .I go through a lot of keyboards. . .
C statically typed but weakly typed.
Java is statically and strongly typed.
Smalltalk is dynamically typed and strongly typed.
A strongly typed language doesn't let the type of an object change - that's a different thing to static typing.
Strongly-typing a language doesn't come at no cost.
Maybe the bugs that do get created are harder to fix?
Maybe the strong typing reduces productivity?
"Just use language X and your bug count will go down" is a meaningless statement in a vacuum.
But I guess a loose type system is another good reason to avoid it.
This observation doesn't make me wish to ditch a programming language, but it does make me glad I do test-driven development.
Warning: This signature may offend some viewers.
While JavaScript is admittedly a really bad programming language, Python is a very good one.
You sound like one of those weenie user-space developers.
... real programming languages. They are for idiot kids who like to play dress-up and pretend to be real developers.
They are also great for rapid prototyping and cases where you only need something basic. They have issues, but I am wondering whether you are just rocking your high horse?
Jumpstart the tartan drive.
The more you catch at compile time, the less there is to bite you on the ass at runtime. Cheaper in terms of development effort too to fix bugs before customer reports them.
Current python programmer, and former C programmer here. Dynamic typing is great for a small to medium sized code bases but I would hate to work on anything really big and mature without static type checking. I have worked on large code bases with maybe 100 megabytes of code and C and Ada, a lot of it dating back 20 years or so. You can't safely refactor code that old, and you can't allow data of the wrong type to get in to it, so type checking at compile time is an important line of defense.
You can do that in python with run time checks of data types and thats what you would have to do at the entry point of your libraries, but it eats into your performance doing that. Python is too malleable for static type checking.
http://michaelsmith.id.au
Yes, and it also reduces the amount of code you write. Since it forces you to solve problems right away, it takes a lot longer to get to the point where the code is starting to work enough to provide you with an environment where progress starts to accelerate. Basically, you want to write code without it - but to have written code with it.
You mean you cannot code in user-space? That seems to be a pretty peculiar disability....
Most ACs are not even worth the keystrokes to insult them. Be generically insulted by this and ignored otherwise.
Easy enough to add strong typing in Python by adding a type check decorator to each function and method.
-- In the beginning was the WORD, and the WORD was UNSIGNED, and the main(){} was without form and void...
Python is very powerful when working alone. When working in teams, it becomes nightmare, because if one changes something, others are not automatically informed, and runtime errors (which may hide under conditionals) are introduced.
Also, javascript is shit and a typed language would be better, whether it is typescript or elm or whatever else.
Avantgarde Hebrew science fiction
Spoken like a true cretin. While JavaScript is admittedly a really bad programming language, Python is a very good one. But both are real in any sense that matters and a competent coder can do real work of any size in both of them. The actual problem is that many people writing code these days are not "real" coders, but incompetent wannabees that like to blame the tools used for their personal limitations.
JS has closures and introspection. Python is easy to write in, but not a good language. That's why there are so many tools to convert Python source to real languages like JS and C++.
GNOME SAYIN?
The title of this thread incorrectly conflates "strongly typed" with "statically typed".
They are two completely different things.
... the benefit of statically typed languages is not only less bugs: it's maintenance.
Ask any programmer who has to inherit some code with more than a few source files what kind of language he'd chose (say: Java vs Python).
As someone that has had to program in a number of languages I can say that strongly typed languages can catch a lot of trivial bugs quickly. One example is an if/then statement that allows non-Boolean arguments. If I mistype a comparison in an if/then statement then I should expect an error on compile. If I type an assignment "if (foo = bar)" instead of a comparison "if (foo == bar)" I expect this to get flagged, but some languages don't see this as a problem.
I prefer strongly typed languages as it can catch a lot of typographical errors and sloppy logic. It can also be frustrating at times since it can mean nesting type conversions to near absurdity. VHDL comes to mind in this. It can also be frustrating if trying to do something quickly and the compiler complains on what I would think is a pretty obvious implied type conversion.
It's interesting to see someone try to get an idea on how many errors strongly typed languages would catch. I'm not sure this makes an argument for one language over another. It might make an argument for testing, coding style, and such though.
I am armed because I am free. I am free because I am armed.
Have they also looked at bugs that typically plague statically typed languages but dynamically typed languages usually don't suffer?
For example, many statically typed languages do little or nothing to help you avoid integer overflows, which can result in severe crashes and vulnerabilities. Many dynamically typed languages, such as Python, gracefully switch to big integer types as needed.
Just imagine where Python could have been if it had static typing and delimited blocks which are the main problems opposed developers have with it. It would not have reduced the language in usability much at all, and it would still be highly suitable for scripting tasks.
I think it could then have been a real contender in the language space and would have been far more widely adopted. It could have been the default language for Android for example.
First off, do you mean strongly typed or statically typed? They are not the same thing.
Second, if you do not already know that statically typed languages reduce bugs greatly, either you do not have a degree in computer science or else you should give it back because you did not learn anything.
My entire career I've been practically screaming that static typing reduces bugs. The entire purpose of static typing is to force the programmer to think through types carefully and only allow code that will work. My profession experience has been that people who prefer dynamic typing do it because they do not want to think carefully about their code, they just want to throw something together quickly and run it to see how it breaks, then fix a bug and try again. The people I've worked with who actually care about writing bug-free code universally prefer static typing.
Universally.
I've been using Janson and Bookman lately. Futura for san-serif. What was the question, again?
In my experience, type errors are a lot more likely for scalars than for composite objects, i.e. I'm less likely to "add apples to oranges" than I am to add "count of apples" to "count of oranges". (Or horizontal pixels to vertical pixels, a real mistake I made once.)
I suppose it's possible to do typed scalars in C++, not sure about Java (without tool extensions). But making a scalar into a full 'class' is probably overkill (with runtime impacts).
The combination of typed scalars and named parameter associations that languages like Ada have can catch a lot of errors at compile-time (with good quality diagnostic messages). And this supports refactoring by making it easier to find the impacts when an interface changes (for instance, if you go from a single type 'pixel location' to separate types for 'horizontal pixel location' and 'vertical pixel location'), you just find and work off the type errors reported by the compiler. (Been there, done that.)
Of course, it's not Politically Correct to favorably mention Ada (so often a technology is panned by those without substantial experience using it.)
The answer is obvious that for identical code strong typing will reduce bugs. And yet does typing force people to write in ways that lead creating bugs?
More importantly why isn't there some gray scale on typing that I could slowly turn on as my program design matures? THis is what I would dearly love. Let me abuse polymorphism to add calling arguments during my exploratory phase but then don't make me switch to a different language when I want to tighten the screws.
What I'd like for example is an option in a dynamically typed language to be able to say that whatever duck I'm calling this argument with it's going to always be the same duck. If the first call used and int, then every other call had better use an int. Sure I could put in a lot of asserts but I'd rather just have this be a global debug setting.
I'd like to be able to optionally declare types in the function definition and have it enforce static typing.
Finally I'd combine these and have an option to have the code re-write the source to insert the static typing based on whatever the type of the calling args I'm using is.
Some drink at the fountain of knowledge. Others just gargle.
but not a good language
LoL... ok sure, whatever. Ok now go back to your play area, the adults are talking.
When coding in Python you ought to replace the compile time type checking with 100% code coverage... Even simple getter and setter methods have to be tested due to the risk of misspelling. In compiled, type checked these very simple errors are taken care of.
In C++ I usually go a lot further and make classes (not typedefs) for even simple types to make the code more readable and make the compilation fail if the wrong type is used. Could for instance be a class simply wrapping an int32_t to be used as an id another class for an id for something else. Never just an "int".
There's already plenty of reasons to avoid Python. This is just another one.
"Lots of Borland/Pascal programmers are saying we told you so though." - by Crashmarik ( 635988 ) on Saturday September 23, 2017 @05:33PM (#55251659)
See subject & far less buffer overflow possibles too (strings in pascal/delphi have length incorporated into 'em) unlike C/C++ deal with.
APK
P.S.=> Oddly though, I used Microsoft's C++ & VB alongside SQL for the bulk of my career the most (even over Delphi which I FAR preferred - especially when it kicked the crap out of both VB & MSVC++ (by 3-5x the performance of the latter even in math & strings no less which EVERY program does work in pretty much) in a competing trade rag "Visual Basic Programmer's Journal" Sept./Oct. 1997 issue "Inside the VB5 Compiler" where Delphi swept the floor w/ both in 4/6 tests total... apk
Really dumb question, but it got me to search for funny or insightful comments, since it's a target rich environment for both. Not surprised to be disappointed in the search, but it's early so I can pretend to be hopeful they'll appear later, eh? It's not like the editors (owners? secret masters?) of today's Slashdot would pick a story in hopes of starting a flame war.
A more meaningful question would be something along the lines of "Do the restrictions of strongly typed languages actually produce better programs?" or "Are the most productive programmers more or less productive when using strongly typed languages?" or "Does the prevalence of average and below programmers justify the use of restrictive and strongly typed languages?" Lots of others come to mind, though my own interest is more philosophic in the conflict between languages that try to drive programmers towards a best solution (which also tend to be strongly typed) versus languages that take a more neutral position towards ANY solution that works (thus fostering more open-ended creativity).
Hint of an answer? I think the quest for a best solution is good, but I doubt it exists in most cases. Are the best quests quixotic?
Freedom = (Meaningful - Coerced) Choice != (Speech | Beer^2), and sad sock puppets' bad mods avail them naught.
To even question this displays a massive lack of insight and understanding of programming, how programs work.
ALL programs need a "design", even if a simple "Hello world". When it becomes more complex, static typing help you catch silly bugs at compile-time (read: early).
To even question this, and it getting onto the frontpage of /., tells me the world is going to hell in a handbasket, and morons driving it there.
Depends on whether you are talking about finding more bugs at compile time or run time. I mean if you are measuring run-time bugs but your compiler catches all the stupid syntax, etc. bugs at compile time then you're going to have fewer bugs of that nature at run time. So it looks like you've got fewer bugs but that's not actually the case.
I find that dynamically typed languages require me to think less about what language I'm using and more about the problem I'm solving.
The problem with rapid prototyping is that too often the prototype ends up being shipped as the actual product.
http://dilbert.com/strip/1996-...
No, this red herring post does not make me want to suddenly reject Python.
Python is dynamically typed and strongly typed.
Strongly typed != manifestly typed and statically typed. This does appear, however, to be how this Slashdot post incorrectly uses the phrase "strongly typed".
Strongly typed == the availability of few to no implicit type conversions in a language.
Python is not 100% strongly typed, the chief exception being that you can use almost anything in a boolean context without getting an error. This typically tests for "nonemptiness", (AKA falsiness) EG a nonzero integer, or a nonempty list.
Java is also not 100% strongly typed, the chief exception I'm aware of being that you can add a number to a string without getting an error.
Please see http://stromberg.dnsalias.org/svn/Java-strong/trunk/JavaStrong.java for an example.
Python 2.x and Python 3.x can eliminate many runtime errors using tools like pylint, pychecker and/or pyflakes (I prefer pylint) - these look for variables that are set but not used, or used but not set, and can sometimes also use type inference to check for further errors before runtime.
Python 3.x (and to a lesser extent, 2.x) can also eliminate even more errors using what is called "gradual typing". This allows you to declare some of your variables' types and check them before runtime using a tool like mypy or pytype (I prefer mypy).
Also, unit tests can easily find many runtime errors before code hits production. Not unit testing your C++ and Java? You really should: "Compile and hope for the best" isn't terribly effective at yielding high quality code.
Haskell is worth thinking about here: It is statically, implicitly typed. You don't declare your variables' types - IOW it's not a manifestly typed language, even though it is a statically, strongly typed language.
HTH.
There's a story of this 1 MLOC AI war simulation program in Smalltalk that beat a crap out of its C++ competitor in DoD tests. Chances are that it's not for everyone, but most problems we're facing should not require anywhere near that. (One could even say that if they do, we've failed somewhere.) So most people should be fine.
Ezekiel 23:20
I know I make a lot more "easily caught" mistakes when writing ruby code than I did when I used to write Java. Referencing a variable before it enters scope, NPEs, etc. Passing wrong number (or types) of parameters to a method.
First of all, the issues with weakly typed language poorly designed overloading by developers used to strongly typed construction.
For example, a common error is writing something like this:
add_function (3, "1")
And the result is the string 31 instead of 4, because some idiot overloaded the + function so that while it adds numbers, it also concatenates strings.
This is a overloading problem, not a type problem, but some fools won't realize that. Yes, if the function had a requirement of only accepting numerical strings it would have caught the error, but that is not the problem cause. The problem was that you should never overload a numerical operation to do anything but return an error when it is fed something besides a number. That's asking for hidden bugs later on.
In addition, this study only went looking for errors caused by week typing, rather than also checking for the errors caused by strong typing.
Here is a simple thing - a week typing language can easily add an integer and a float. It comes out with a float. But a strong typed language should return an error as they are different numerical types. In a very strongly typed language, you can't add an integer and a float, you need to convert one from the other.
But this problem has occurred so often, people started overloading "strongly" typed language with auto conversion. In part because we have a loner history dealing with strongly typed languages - originally we didn't have the memory to deal with anything except strong typing. Now we do, but don't have the proper experience.
excitingthingstodo.blogspot.com
Yeah but is it safe? I should have mentioned that my example was a safety critical real time system with actual lives at stake. Additionally it had hundreds of functions which might only get used in emergencies, and which would cost > $100 M to validate properly.
http://michaelsmith.id.au
See subject: You COULD use "Option Explicit" (or "Option Strict") to help offset some of the problems dynamic typing introduces (still a runtime interpreted language though, even MSVC++ is via MSVCRT.DLL for its forms) - yes, Delphi CAN be too (but I never used it that way, only statically compiled true .exe work).
APK
P.S.=> That's in addition to my original post favoring Pascal/Delphi over both VB & MSVC++ here https://developers.slashdot.org/comments.pl?sid=11155081&cid=55251983/ ... apk
There has never been, and never will be, a language in which it is impossible to write bad programs.
But if the programmer in question really appreciates the right way to use static types, then they reduce errors dramatically. If you hear static types and think "great, now I have to type int and string and struct everywhere, what a nuisance" then static types are not for you. If on the other hand you have experienced writing in ML and having your programs come out bug-free almost every time then you might be a good fit.
Personally I find that proper use of static types in a suitable language (Java at minimum, but hopefully something better) almost completely eliminates the need for unit testing. You still need testing of course, but your bugs are all going to be around interacting with libraries and arbitrary input, where unit testing doesn't help anyway.
If you're lucky enough to be able to use Scala, you can write code almost as bug-free as you can in ML, with the added value of being able to actually do real-world work with it.
If it's actually critical, "ordinary" static types won't save you and you probably need formal methods. Technically there's no reason you can't apply them to any language.
Ezekiel 23:20
Python allows too much fiddling with the standard library for static analysis to be reliable. The the same reason why java style just in time compilers won't work with python and precise locking for threads is so difficult.
http://michaelsmith.id.au
After the initial introduction to computing via BASIC, I picked up Pascal (Turbo, of course) and fell in love with it. I prefer a language where you have to declare all your variables and won't let you assign one type to another type without type casting or properly converting. I also want it to be case insensitive because I've seen code where the idiot used "foo", "Foo", and "FOO" as different variables.
I haven't touched Pascal in years, but I miss it occasionally.
-- Will program for bandwidth
I prefer strongly, statically typed programming than programming in e.g. Python. Like even Java, which is in many ways a horrible language, is more understandable for me. You need to understand the importance of the first two and last two words in that sentence though.
Why is it better for me to catch stuff at compile time? Because I prefer it that way.
Why is it preferable for Pythonistae to do whatever they do? Because they prefer it that way.
I have a very intelligent and productive friend who loves Python and has no problem with the way it handles types. I find Python annoying and avoid it, partially for that reason. But what would it even mean for him to be "wrong", or for me to be "wrong", or for either of us to be "right"? Nothing, that's what.
Stop bitching at each other and having stupid arguments like the "other side" is trying to steal your toys or come in your ice-cream.
Oblig: "LambdaConf 2015 - Dynamic vs Static Having a Discussion without Sounding Like a Lunatic" https://www.youtube.com/watch?v=Uxl_X3zXVAM
Now shut the fuck up.
If you want to willingly shoot yourself in the foot, there's no process in the world to prevent you from doing that. There's no reason why "java style just in time compilers" couldn't work with Python - after all, they have Strongtalk/Self legacy. Except for, of course, nobody willing to fork the really serious money needed for that. But admittedly, striving for a good Python compiler does seem like a misplaced effort for other reasons. Good Lisps (such as Chez or SBCL) are much more desirable and more easily achievable, for example.
Ezekiel 23:20
The question isn't really "Does a strongly typed language reduce bugs?", because the obvious answer is: Yes, it does. If you went to the logical extreme and created a language that only had 3 commands, you could eliminate whole classes of bugs. The more strict the rules, the harder it is to do the wrong thing.
But the question is really: Would developers spend more time fighting against the type system in a strongly typed language or against type related bugs in a dynamic one?
The answer to that question seems much murkier, and I don't think a study looking at the types of bugs checked in on GitHub can answer it.
That's not a problem with the language. It's a process problem. When management doesn't understand Fredrick Brooks all bets are off.
Guns don't kill people; Physics kills people! - John Lithgow as Dick Solomon on Third Rock From The Sun
The study appears to answer the question "How many bugs slip through QA in statically versus dynamically typed languages". A better question to have tried to answer is "How much test/debug/fix time does it take to get non-trivial programs to production quality in statically versus dynamically languages".
Strong typing seems like a good idea until you download a large legacy program and it won't compile because the language has been redefined to enforce stronger typing. Then you look at the particular error, and find that the type name has been aliased, and the alias has been aliased, and so on ten deep. Repeat for dozens of variables, and 2 days later than nice program that was going to save you a couple of hours still won't compile.
How many types of casts does C++ have to get around the strong typing problem? Can you figure out what each one actually does, and which one to use in a particular instance? Why does it seem that none of them claim to do what I need done?
Contribute to civilization: ari.aynrand.org/donate
Significate whitespace makes me avoid Python.
Python invites these misunderstandings. It has the everything and the kitchen sink in it, making it look attractive from afar. But it falls flat on its face with its syntactically meaningful whitespace. That little aesthetic choice makes it much much much harder to write large codebases in it, and part of the hit you take when you do so is make design compromises that favor readability but end up impacting performance.
This aesthetics bleeding into performance isn't unique to Python. Java makes it impossible to split a class definition over multiple files the way you can in C++. That means you either have big giant files that are hard to navigate by yourself and tricky to edit by multiple developers, or you "refactor" and split your logic into different classes, each of which take up a few more bytes of memory and a few more cycles of CPU time to create and destroy when they're needed. Not the sort of thing that ever happens in small programs, but happens plenty of times in large codebases that deal with tens and hundreds of millions of records or data points.
Considering there are tens of thousands of people making shitloads of money every day coding some serious, useful applications in in Python, I'd say you're mistaken.
Just cruising through this digital world at 33 1/3 rpm...
I don't think it makes much sense to put this question in a language specific context.
Simple example being anyone can define an integer in a strongly typed language when a type specific enum would have been more appropriate. The compiler lets them get away with it just the same regardless of language choice.
Some dynamic languages allow programmers to require more constraints than the default operating mode.
Extent to which strong typing really matters comes down to discipline of the programmer/development enterprise more than it does language. My personal perspective is while I tend to leverage pedantic type constraints as much as possible it was never much of an issue.. limited mostly to unmasking unintentional typos.
The best mechanisms for reducing bug rates is liberal use of assertions and always designing new code in a manner where systematic verification remains tractable.
The article talks about static typing, not strong typing; the two are different concepts. Strong typing means that type errors are always caught, static typing means that if type errors are caught, they are caught at compile time. JavaScript is both weakly typed and dynamically typed; weak typing is probably a bigger problem than dynamic typing. In any case, whatever conclusions you derive about type systems from experimenting on particular languages really only apply to that language. TypeScript is nice for JavaScript; that doesn't mean that adding static typing to Python would be as useful.
In addition, there is a price to pay for static typing: software becomes more complex, people tend to implement their own "dynamic type light" libraries, etc. So, even when static typing reduces bugs, it's not clear that it results in a better product at a lower cost, which is what you ultimately care about.
What kind of bugs are prevented? What about the bugs introduced in strongly typed languages, like the diamond inheritance case?
Ph'nglui mglw'nafh Cthulhu R'lyeh wgah'nagl fhtagn
Well well well. Slashdot's highly valued commentator and moderator and submitter is posting at -1. Look at that.
"Does this make you want to avoid Python?"
No, not just this. If I ever loved it, this wouldn't matter. Since I never loved it, this still doesn't matter. If I have to use python, regardless of love or hate, this still doesn't matter. Overall, this just doesn't matter, at all.
I am putting myself to the fullest possible use, which is all I can think that any conscious entity can ever hope to do.
There you are you disgusting fat sexist tube of lard, Christopher Dale Reimer!
You can be sure I will be watching this fake account too. I know this is you because you told me you were working on your freepass 11 file server and you are so dumb that you can't even masquerade yourself properly.
Now, I told you I was out of meds last week and you didn't even care to contact me you lazy fucker.
How many time do I have to express the emergency of the situation??????
The python click script you wrote for my pheromone revenue stream web site suddenly stopped to work!!!!!!
You fucking incompetent python script writer!!!
When it works, I get 4000+ clicks a day on my pheromone revenue stream web site but only 5 or 6 without it!!!!
Now, it seems like you dont care and that you have abandoned me you heartless fucking pig!
Bonus:
Here is a story that creimer told me when convincing me what a hard life he had:
The tree was him and the tree knot was his butt hole!
So, his uncle packed his fat ass with lard and with his cock! Not that it makes much of a difference but anyway, there it is!
Signed:
The girl that used to love you and now hates you, burn in hell where you belong you sexist pig!
With PEP 484, you can annotate typed method signatures. And with PEP 526 you can annotate variable types too. If you're willing to go with straight up Python 3.6+ syntax, it's pretty nice looking. mypy can do pretty reasonable type-checking, which is supported in PyCharm and Atom via plugin now.
What's great is you can use it where you want extra checks (more complicated infrastructure code) and just stick with plain old duck typing where you don't (fast and loose scripts).
Hey Creimy-Dumpty,
Since you always talk about "enterprise-level" closets, "enterprise-level" offices, "enterprise-level" chairs, "enterprise-level" snacks, etc.:
Why don't you just use an "enterprise-level" language you silly? Applications written for java 1.0 in 1997 still run fine without a change on a 2017 java 8 installation.
"enterprise-level" chair:
http://www.keynamics.com/image...
Maybe "enterprise-level" goofs are unable to use "enterprise-level" languages!:
https://school.discoveryeducat...
Indeed, indeed, Creimy-Dumpty had a great fall.
As others mention, strongly-typed languages reduce or eliminate a class of errors related to type.
However having used both strong and weakly typed languages extensively, I would argue that in terms of time spent there is a near constant amount of time taken by either dealing with coding around a strongly typed system, vs. finding flaws in using a weakly typed system...
An argument for a weakly typed system would be, if all developers are very experienced they can potentially write pretty solid code and therefore save time.
An argument for strongly typed systems would be, if you are going to have some less experienced developers working with the code, that it will eliminate some potential bugs they might otherwise introduce... possibly also it could be the case that if you prefer to not write may (or any) unit tests, strongly typed systems to some extent take the place of that.
"There is more worth loving than we have strength to love." - Brian Jay Stanley
You fucking ignorant Chritopher Dale Reimer, shell script are not written in python you dumb fool!
1. Create script file, example.py
2. Set executable bit on example.py.
3. Execute example.py.
4. Result is...
The article shows javascript as buggy and untyped with 3 + "0" = "30" -- the classic stupid example.
Everyone likes to say that Perl is weekly typed, because "1.5" + 1 = 2.5.
Everyone is incorrect. Perl is very very very very strongly typed. Not the variables, the operators. Not the nouns, the verbs. Developer says "add these two variables", and perl adds them. Because the developer said so. If the developer said "concatenate these two variables" then perl will concatenate them. Every time.
That sounds strongly-typed to me. "3" + "1" = 4; 3 . 1 = "31". Every time.
I dare you to find out what perl does with 3 + "information". Go ahead. I dare you.
My point is this. Human beings don't care about type. An apple is an apple, and an orange is an orange, and I can eat them together, cook them into a sauce, bake a pie, cut them up, juice them, or put them into a basket. Whatever I tell you to do with them, you'll never respond with "but apples can't do that because they aren't oranges". Just bake the g.d. pie, because I told you to.
Now, if you can explain to me why any language would ever use the same symbol for "add" and "concatenate", then you're smarter than I am. For the life of me, I've spent 30 years trying to understand that one. What idiot makes one symbol do two things, and then builds the language to guess which one to do based on the values themselves, at the language-level no less? Idiotic.
> will give you a more stable product more quickly.
Weakly typed will more quickly produce less robust software, which is perfect for one-time use scripts, small programs written for well-known, well-defined inputs, etc.
As an example, suppose I have a log file of the format:
URL - bytes - epoch - username
If I want to produce some summary statistics from that particular log file, to use in my year-end presentation, a weakly typed language will let me whip up a simple script very quickly.
On the other hand, if I'm deploying production software to the web, where it will encounter unknown user input in different character sets thousands of times per day, I'd want to take a few more minutes of development time to have more robust software. That's when strong typing is good.
Sometimes "quick and dirty" is what you want, sometimes "careful and reliable" is what you want. Duct tape is famous for a reason, and high strength bolts are used for a reason. Each has their place.
From interviewing around in the Bay Area, I've seen at least two companies with app backends coded in Scala. When doing similar app backend work myself, I've chosen Python, but it didn't have to do with it not being a strongly typed language. It had more to do with the available third-party libraries and compatibility with cloud providers.
Big apple, new Yorik, undig it, something's unrotting in Edenmark.
Strongly typed or statically typed?
Not "good languages"
Sent as ripples into the electromagnetic field. No single photon has been harmed in the process.
One of my assignments at Apple was cleaning up a framework that had thirty or more coders over the previous ten years. The first time I ran it through the static analyzer, there were over six hundred issues identified. I tracked down and fixed all of them over the next couple of months in the process of cleaning up the code to build under LLVM and pass the App Store rules.
Most of the easier cases were things like parameters of the wrong type being passed to methods, which caused no problem at runtime and hadn't been spotted before for that reason. The more difficult ones were mistakes in memory handling, and in a lot of cases, I found myself saying "holy shit, GCC lets you do THAT?"
Comparing Obj-C to Swift, I would say that easily 90% or more of those bugs can't be written in Swift at all unless you resort to the UnsafeMutablePointer types, which put it right in your face that you're doing something dicey.
I was a huge fan of loose coupling for all the years I was an Obj-c developer, but today I spend almost no time in LLDB, since almost all of the mistakes I make writing Swift are caught at compile time.
-jcr
The only title of honor that a tyrant can grant is "Enemy of the State."
I didn't read past the first line of your post, which made it perfectly clear you lack the capability to enter into an intelligent discussion.
Guns don't kill people; Physics kills people! - John Lithgow as Dick Solomon on Third Rock From The Sun
I basically program exclusively in PLs with sloppy typing and no compiling and stuff. Python, PHP, JavaScript the works. The speed at which you get stuff done is notable, especially compared to classic "Type Nazi" languages. However, the trade-off is clear as can be: Write critical code beyond a certain scale in sloppy type PLs, and you're asking for trouble. Type Nazi languages force you to think before typing ... errrm ... hitting the keys ..., and that is a good and useful thing if the use case isn't a trivial scripting stuff that you can debug and modify on your Smartphone willst sitting on the bus.
Sloppy typed PLs have some stopgaps (code standards, frameworks, hacks, transpired dialects (such as JavaScripts TypeScript) but those are things intended to cover the gap and cater to specific needs.
Long story short: Nazi typing is more work to front but prevents lots of trouble downstream of large non-trivial projects, including a specific subset of bugs.
We suffer more in our imagination than in reality. - Seneca
python is strongly typed.
its not statically typed
A strongly typed language doesn't make it less likely that you'll write bugs, but it does make it more likely that your bugs will prevent the program from compiling or running, thus forcing you to fix them.
See subject: For finding length of a string (or char array as you put it I'd use 2 pointers vectoring thru an array vs. indices for it - more direct & better speed/less overhead (pointers & indirection etc.)) - so merely keeping one double the size of the other as you move them thru it will yield midpoint on the smaller one once the larger errs out/no longer advances, essentially giving you the length (probably the sourcecode of strlen functions I'd even wager).
APK
P.S.=> That's how I'd do it & yes, I have before (for an interview with Microsoft "way, Way, WAY BACK" in 2003 where oddly, THEY approached ME, not the USUAL "other way around")... apk
fuck python
I shudder to think what your other conversations are like because I suspect they consist entirely of you running your mouth and not your ears.
Explain why.
Answer is: yes. You take out so many problems handling unexpected type mismatches from the word go. Seems like we hear a lot of stories about PHP being broken because of an unhandled fucked up type.
Chewbacon
The Bible is like Wikipedia: written by a bunch of people and verifiable by questionable sources.
They don't involve complete fucking idiots, so you'll never know :-)
Why does it matter how hard I press the keys when programming?
Jsish (http://jsish.org) walks a fine line with an implementation of javascript wherein type-checking is provided only for function signatures. This can improve module usability, without impacting the bulk of an implementation. And although Jsish is primarily embedded, it also provides in-Browser support that pre-processes just the function signature, rather than the entire code body (ie. like typescript).
Disclaimer: I am a Jsish developer.
Yes.
Entire categories of errors are simply not present in strongly typed languages, which are present in weakly types languages. The example of PHP is the worst, as this may be a retardedly typed language, but the example still is applicable.
I've also noticed that there is a tendency is for weakly typed languages to be interpreted, while strongly typed languages are compiled. This is another language attribute that moves the bug detection from compile time to run time, and introduces an entire category of run time only bugs which compiled languages do not have.
All of these are reasons that weakly typed languages allow for more bugs, which are detected later. I am not saying that strongly typed compiled languages are better than weakly typed interpreted languages, but they are different.
A crappy programmer with a good type system is not better than a good programmer with a crappy type system. I'm pretty sure this is a paraphrasing of something Donald Knuth must have said...
I hope to never have to deal with your code. :(
You won't. Most of it has already lasted in production for over twenty years. Long-since proven to not need you.
That said, if you can't read the equal sign that's plain-as-day, then you really aren't skilled enough to understand the system as a whole, so you wouldn't be the best person for the job.
And, since you aren't willing to put your name to your comments, you wouldn't be a good fit for any team.
The argument at the beginning was for strongly typed languages. I do feel the lack of a strongly typed language is one of the shortfalls of Javascript. That stated Python is a strongly typed dynamically typed language. I think the original comment is confusing strong/weak vs. static/dynamic. They are fully orthogonal from each other. C++ is a statically typed language (ignoring the auto keyword) that is also fairly weakly typed. Ada is quite heavy handed in both static typing and strong typing. PHP is dynamically and weakly typed.
I've used JavaScript and Perl (and more recently Ruby) for about 17 years and I can't tell you how many times I've encountered runtime errors because of mismatched or unexpected types such as the elusive adding of a string to an integer, which is valid JS code, e.g. "12" + 3. But of course you would likely catch those bugs during development. If not, then you have unit testing. If such bugs are STILL not caught, you have SIT and UAT in most organizations. With the popularization of CI systems like Bamboo that can run unit tests automatically on checkin, it becomes even easier, not to mention peer reviews with tools like BitBucket and Github. If there are still these kinds of bugs after all of this, you (and your organization) are either too lazy or too incompetent and have no business writing software. The whole static vs dynamic argument suddenly becomes irrelevant if you have decent testing. In my experience I spend 3-4x more time and effort on unit tests than on the actual code it's testing, and the SLOC for test code could easily be 10x the target source, especially if you're aiming for 100% coverage. On the other hand, with a language like Java, I always FEEL like I have a better idea of what's going on in any given block of code, even if I've never seen it before. I personally like strong typing because it's comforting (to me) to have a full understanding of what methods or variables can and cannot contain, accept, or return. Languages like Ruby can feel highly ambiguous with absurdities like implied returns. In any case, either way it doesn't really do much to reduce bugs. In my opinion it's a non-argument.
Yes, that is one reason why I absolutely avoid using Python. Or any of the other fad languages. I am using Object Pascal for pretty much all of my project and a lot of possible bugs won't even allow the program to compile. There are even type checks in more "open" languages, like C11, but then I noticed that a lot of people just turn off all the warnings about possible bad conversions, just to get their code compiled instead of fixing the problem properly...
Given the choice of a large project between:
- project written in well defined modules, with some written poorly or in the "wrong" language
- project written as a single program, using the "best" language, object oriented, using "state of the art" design patterns, strongly typed, of course.
I would always choose the poorly written code in well defined modules.
The over-engineered object oriented (but not modular), is almost always throw away by nature. The layers of abstraction intended to account for future changes usually have the opposite affect.
I totally buy it because strongly typed is basically the developer writing some very basic âtestsâ(TM) in the code during development itself. Like âoeParam one is int16 and Param two is char* and oh, better expect a Boolean!â. The more such coverage you have the fewer bugs.
Is python having adoption problems that I'm not aware of? Last I checked, it was in the top 5 of most programming language popularity indexes.
If you take all the bug-prevention technologies, then add up all the "bugs not prevented" by this methodology, you'd surely account for all bugs at 3000% of totality, along the same lines that medical technologies have "prevented" more deaths than the total number of patients studied.
Furthermore, can you really count every memory management bug in C/C++ style languages as a "bug prevented" had automatic memory management been employed (ignoring that the translated applications would certainly not have met any original hard-performance criteria?)
What if one moved all software to the hardest of the hard languages (nominally Haskell)?
Well, we'd have a 99% reduction in bug production per unit of function, and a 99% reduction in total units of function delivered (far fewer employed programmers, working far more methodically)—for a whopping 99.99% reduction in total bughood.
Right. Sure.
Experience and training count for nothing, we'll enforce "correct programs" by compiler.
For amusement value, kiddies, go look up how OO, OOP, and esp. java were being talked about in the mid-nineties. Really, "java won't allow null pointer exceptions" I read over and over (tell that to me as I show you a 150 line tomcat dump with a null pointer exception).
It got so sold that on the cover of the Jan, 94 issue of the IEEE's Computer magazine,, OO was *literally* pictured as the silver bullet to solve the programming backlog.
I don't mean to be pedantic, but Python is inherently strongly typed.
It is difficult to be pedantic about strong typing because there is no clear definition of what it means. Wikipedia will tell you that Liskov gave a definition of "strongly typed" that is closer to our current usage of "statically typed".
Python has support for some basic types, but it does not support typing for lists, enumerations, structures or functions. You can test the class of an object, but you cannot tell if two objects have the same or related classes. And Python allows you change the members and methods of a class after it is declared, so knowing the class doesn't really help much anyway.
In my view Python lacks a sufficiently rich type system to be classed as "strongly typed", but YMMV.
[And before you decide, look at Scala to see a rich type system that supports both static and dynamic typing of all data types ]
Please, let's not use JavaScript as a representative of the pinnacle of dynamic languages. It's common primarily because most browsers support it, NOT because developers love it. QWERTY Syndrome. And sloppy library writers can ruin anything in any language.
Table-ized A.I.
Not at all because I don't use Python for its ability to reduce my bugs, I use it for the ability to produce a functional program in the least amount of time.
I have been an SE for 13 years and I cannot recall anyone ever saying a dynamic typed language is going to be less error prone than a static typed language. It's really not necessary to do a "study" to figure that out. I mean, the whole point of a static typed language is to remove that vector of failure. The whole point of a dynamic typed language is that it is inevitably faster and easier to program and can therefore be used to create shitty programs more cheaply. If you want to program the flight controls of an airplane, you don't use dynamically typed languages, period.
The real study that needs to be done is one that determines how often Python is used for applications it should not be used in. The vector of failure here isn't the typing of the language, its the quality of the human component that should, ideally, know better than to use one language for all purposes. Knowing how prevalent the use of Python is, for things it should not be used for, might help to focus efforts on education and training of those individuals who just aren't very good at their job.
For that environment, it's best to have as much static checking as you possibly can. Most programs aren't in that environment.
"When you have eliminated the unacceptable, whatever is left, however improbable, must be the truthiness" - Holmes
One can imagine this taken to the logical conclusion where the coder is jacked into the machine and is aided by an AI that not only can read his mind, but also has all the foresight and business knowledge necessary to produce the correct 'solution' which obviously is not only bug-free code, but also code that solves the business requirements (and hopefully nothing more) while retaining enough flexibility to hopefully handle most (90%?) possible future requests.
So yes, strongly type languages are I would argue better, specifically because you are eliminating the capability to produce a type of bug.
Actually, static analysis is pretty effective with python - see pylint.
Also, there's more than one JIT for Python - see Pypy and Numba, for examples.
Threading works fine on Jython and IronPython, but you're right that the threading in CPython is poor.
Yeah I integrate pylint with my editor so I get that information more or less as I type it, but python generally can't tell me that I am making the wrong assumption about a variable passed in to the local scope, whereas java can because arguments are always typed.
http://michaelsmith.id.au