From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: a07f3367d7,ac4955b8006bd13c X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,UTF8 Received: by 10.68.196.232 with SMTP id ip8mr13471861pbc.6.1338897993358; Tue, 05 Jun 2012 05:06:33 -0700 (PDT) Path: l9ni6202pbj.0!nntp.google.com!news1.google.com!goblin2!goblin1!goblin.stu.neva.ru!eternal-september.org!feeder.eternal-september.org!mx04.eternal-september.org!.POSTED!not-for-mail From: Brian Drummond Newsgroups: comp.lang.ada Subject: Re: Q: type ... is new String Date: Tue, 5 Jun 2012 12:05:10 +0000 (UTC) Organization: A noiseless patient Spider Message-ID: References: <82defba0-2d39-4418-b678-ebbefeb105d7@x21g2000vbc.googlegroups.com> Mime-Version: 1.0 Injection-Date: Tue, 5 Jun 2012 12:05:10 +0000 (UTC) Injection-Info: mx04.eternal-september.org; posting-host="3/9i4eU3tV30IAhXHAPg/g"; logging-data="12143"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/wkCPuVBvgCjqhtvZtrJVnaIQISS8+U/A=" User-Agent: Pan/0.135 (Tomorrow I'll Wake Up and Scald Myself with Tea; GIT 30dc37b master) Cancel-Lock: sha1:kDMT4du8VZ/6H0+UjPe4eHd168k= Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Date: 2012-06-05T12:05:10+00:00 List-Id: On Mon, 04 Jun 2012 06:36:31 -0700, Maciej Sobczak wrote: > On 4 Cze, 13:39, Brian Drummond wrote: > >> Now it seems to me that he would be better off saying "type >> UnsafeString is new String;" >> and bypassing the rest of that (rather long) article entirely. > > Except that it would not work in the language that he used for > presentation (which is VBScript, I guess). "pseudocode" he called it, having started the article using C. And in pseudocode, anything the author wants will work... >> Or am I missing something in that article? > > Yes, this: > > "Let’s pretend that you’re building some kind of a web-based application > [...]" > > The author describes a problem in a well-defined domain (web-based apps > written in some dynamically-typed language similar in nature to > VBScript) and presents a possible solution. Given the constraints, the > solution he proposed is probably the best he could do. Joel Spolsky did indeed define it as a web-based application, though the nature of the language is not discussed. Since there are some tools like AWS for building Web apps using Ada, I believe the _stated_ constraints don't prohibit strong typing. (I can't rule out unstated constraints along the lines you suggest) Dynamic typing and scripting do not necessarily imply weak typing, though they are usually used that way. There is even an Ada-based scripting language as one counterexample. > Like it or not, for many people switching to Ada is not a viable > solution. While I have to agree with that, I suspect that for many more, it might be viable, but is automatically dismissed without consideration; this article being just one example. The article works AGAINST reliable software by dismissing not just Ada, but strong typing in general. The fact that it does so by omission rather than by discussion and disagreement helps foster ignorance; at least if it said "the Ada approach is stupid because ... (see ref #) " at least it would raise awareness and let the reader think, read further, and agree or disagree as she saw fit. Or the article could add "a strongly typed language would allow a better solution using ... but this is all you get in C (VBScript, whatever), so ..." I do not know whether the author is to blame, or if he is genuinely unaware of the power of a good type system. My point in this post is simply that if people are unaware of a good thing, then there will be no demand for it. > Having said that, I agree that most of the security problems that plague > the web-development ecosystem could be solved with a proper type system > and static type-safety. Or at least some type safety. Even in a well designed dynamic language, type safety is possible. In the context of the example, let all the input methods return UnsafeString (i.e. the base String class has no input methods), the encode methods return String, then you simply (explicitly) make the write methods reject UnsafeString. It is of course possible that not all dynamic languages are well-designed. - Brian