Ned Batchelder, a Python developer who created coverage.py and Cog, writes about Python, Unicode, and software practice.
HN commenters link Cog for generating C++ code from Python, and his talk on Python names and values; one describes him as creator of coverage.py.
Their server is down. Here's the content:
-- by Rohit Sethi on February 13, 2013
-- http://blog.sdelements.com/author/rohit/
The latest Rails security flaw [1] is example of a common anti-pattern. Ned Batchelder wrote an awesome post [2] explaining how a similar issue may also exist in Python’s YAML parser [3]. Looking at these vulnerabilities, I am reminded of similar flaws in other frameworks and libraries.
The issue in each case is an abuse of extensibility. At first glance the idea is clever: allow for run-time execution of new code or binding of server-side variables without changing your compiled code, thereby greatly enhancing extensibility. For example, provide extensions to your Python YAML parser that allow you to create arbitrary objects and execute Python code; provide extensions to XML Template parsing that allows for arbitrary command execution [4]; or dynamically assign user-supplied parameters to server-side variables [5] (aka mass assignment) based on the parameter name. This kind of vulnerability is by design in contrast to many other by accident vulnerabilities. We called the mass assignment anti-pattern out [6] several years ago when doing a security analysis of the Core Java EE Patterns for OWASP.
I have a strong feeling we’ll see more vulnerabilities of this type, particularly with the rising popularity of standards like SAML that are built upon several layers of libraries implementing and extending complex specifications. These kind of issues can…
Makes sense, I think you can get some answers in HN (worth asking again, maybe direct the question to "parents of children in the autistic spectrum"?), but there are better places to ask. It's great that you're taking steps to give your son the best environment you can, please take these as attempts to help you achieve that.
You say you don't know about what I asked and if asked directly they'll justify as necessary focusing on the affected children. That doesn't help you much, maybe there's something already published you can find yourself and read to help figuring things out? What do Dane psychologists/neurologists say in articles they write? Are the comparisons of the different systems in Europe? You have to go a bit deeper to figure out what is best, reading about about autism is part of the package IMO. Some people[0][1] find that writing about it also helps.
Also, you're (going to be?) THE expert on your son and his needs, no doubt about that. So if you study a lot right now it'll help to make your case (and/or mind, if you haven't decided what's best yet) and get the assistance he needs sooner. You can be the best people at fighting for what your son needs, it's a necessary skill to have in the long run. Asking and caring about the best way shows you've already started on this journey.
Being somewhat of an outsider does complicate some things, but it also offers you perspective and that may be more important for you and your son in the long run. So don't blame…
This is a quibble, but there are cases when the physics of the computer cannot be disregarded and must be considered. Two of my favourite examples are cosmic rays flipping bits [1] and printers jamming. [2]
Regardless, I agree with his overall thesis: the machine is just a hunk of atoms with no meaning of its own. It is us who place a meaning on the machinations of the computer. Computer people have come to accept the abstractions of computer science as tangible and consider the abstractions of mathematics intangible. I think both abstractions are comparable. Both end up being interpreted and executed by humans and by computers, and it is merely the overwhelming prevalence of CS abstractions being executed by computers and mathematical abstractions being executed by humans that
is causing this divide between the two tribes.
There is much that computer scientists can learn from remembering that the machine is just a represantion of abstractions, just like mathematicians can benefit from remembering that occasionally the physics of the machine are relevant.
----
[1] An entirealy reasonable explanation at times,
http://lwn.net/Articles/219983/
[2] http://nedbatchelder.com/blog/200811/print_this_file_your_printer_will_jam.html
The difference is that with exceptions sloppy code is the default.
As you write code in a language with explicit errors, the language makes you acknowledge that the code you call can error out. This makes you stop and think what to do about the error. You can choose to ignore it, but that's a conscious decision that the language forces you to make.
With exceptions, there's no such feedback mechanism from the language/compiler. In order to write robust code you yourself must have the discipline to add exception handlers around the appropriate calls.
In short, defaults matter. It's simply easier to write correct, robust code when you don't have to go out of your way to do it.
See https://devblogs.microsoft.com/oldnewthing/20050114-00/?p=36693:
> It’s really hard to write good exception-based code since you have to check every single line of code (indeed, every sub-expression) and think about what exceptions it might raise and how your code will react to it.
... which leads us straight to favorite exceptions-caused bug: https://nedbatchelder.com//blog/202001/bug_915_solved.html:
> Inside tempfile.NamedTemporaryFile, the error handling misses the possibility that _TemporaryFileWrapper will fail.
This is what I do, these days. Whenever I would previously have reached for X-macros or some other macro hack, I tend to use Cog [1] now instead.
It's quite a clever design; you write Python to generate your C++ code and put it inside a comment. Then when you run the Cog tool on your source file, it writes the generated code directly into your C++ file right after your comment (and before a matching "end" comment).
This is great because you don't need Cog itself to build your project, and your IDE still understands your C++ code. I've also got used to being able to see the results of my code generation, and going back to normal macros feels a bit like fiddling around in the dark now.
[1] https://nedbatchelder.com/code/cog/
Mitsuhiko has written extensively about Py3 unicode problems, e.g. http://lucumr.pocoo.org/2014/5/12/everything-about-unicode/
I think a lot of it boils down to, sometimes you really really don't want to care about unicode. Linux filenames are one thorny issue - Linux thinks of them as strings of bytes, and a tool is broken if it can't also deal with them that way. Py3 makes it very difficult to do that correctly. There are also issues with stdin/out being opened as unicode vs byte streams.
For web development, the "unicode sandwich" (http://nedbatchelder.com/text/unipain.html) works great in my experience. However, I can see his point that for some kinds of tasks, Py3 is unambiguously a downgrade.