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: 103376,21960280f1d61e84 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Newsgroups: comp.lang.ada Subject: Re: How come Ada isn't more popular? References: <1169531612.200010.153120@38g2000cwa.googlegroups.com> <1mahvxskejxe1$.tx7bjdqyo2oj$.dlg@40tude.net> From: Markus E Leypold Organization: N/A Date: Sun, 28 Jan 2007 16:06:48 +0100 Message-ID: <2tfy9vgph3.fsf@hod.lan.m-e-leypold.de> User-Agent: Some cool user agent (SCUG) Cancel-Lock: sha1:pYxpMSf0B35IU+m7UiApPKHNTHg= MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii NNTP-Posting-Host: 88.72.211.238 X-Trace: news.arcor-ip.de 1169996523 88.72.211.238 (28 Jan 2007 16:02:03 +0200) X-Complaints-To: abuse@arcor-ip.de Path: g2news2.google.com!news4.google.com!news3.google.com!homer!news.glorb.com!news-spur1.glorb.com!news.glorb.com!feed.xsnews.nl!border-1.ams.xsnews.nl!newsfeed.kamp.net!newsfeed.kamp.net!news.unit0.net!newsfeed.arcor-ip.de!news.arcor-ip.de!not-for-mail Xref: g2news2.google.com comp.lang.ada:8662 Date: 2007-01-28T16:06:48+01:00 List-Id: "Dmitry A. Kazakov" writes: > On Sun, 28 Jan 2007 00:24:27 +0100, Markus E Leypold wrote: > >> Charles D Hixson writes: > >>> It's easier to do simple things in Fortran, C, Pascal, Modula II, PL/I >>> or even Snobol. Oh, yes, and BASIC, too. (The other current >> >> It's easier to do simple things with languages that have lists in >> them. E.g. Lisp or Scheme (or Python for today programmers). No, I >> disagree: It's not even easy to do simple things in C: Every time I'm >> astounded by the contortions I've to go through for anything involving >> strings of varying length (OK, I can work in large statically >> allocated buffer, but this simply stinks, since it imposes arbitrary >> limits). And very soon the wish comes up not to have to write out >> specialized list processing code every time for 'list of ints', 'list >> of floats', 'list of strings', 'list of lists of strings', 'list of >> trees' etc -- and than you start to suffer and it never ends. There is >> no way to write generics in C, to fake them or even graft them onto >> the language as an afterthought and use a precompiler or a >> preprocessor (I'm perhaps exaggerating here, but the pain is there >> nonetheless. I've written those things (a generics "expander" for C >> :-) and I think/hope I know about what I'm talking here). > > Generics is a wrong answer and always was. As well as built-in lists you > are praising is, because what about trees of strings, trees of lists etc. > You cannot build every and each type of containers in. You missed my point. :-). A language with a Hinldey-Milner type system has a 'tree of something' type where something can be anything in every given instance of usage. So you get 'tree of foo' from it and 'tree of bar' when you use it like this, but there are no generics instantiated. There are trade offs, of course (like that you probably can't design such a language without GC and without loosing a certain degree of control of the representation of types), but since C D Hixson and me have been talking about usefuleness in a general sense, that doesn't count here. A useful language needs to have lists, you must be able to write recursive functions on lists and preferably in a functional way and you should not need explicit instantiation declaration for every instance (like 'of float', 'of int', 'of ...'). Languages of the Algol-FORTRAN-C-Pascal-Ada group are all far from that ideal. Since a lot of programming these days is general list manipulation, everyday jobs become painful. Has anybody here aver wondered about the popularity of "scripting", like with Perl, PHP, Python and so on? As I see it, the presence of lists and hashtables/dictionaries in those languages together with the absence of memory management is a factor in this popularity. Which I hope, if not proves, at least makes my point plausible. :-). > > Right answers should be a more powerful type system than Ada presently has. Yes. > In my view there are three great innovations Ada made, which weren't > explored at full: > > 1. Constrained subtypes (discriminants) > 2. Implementation inheritance without values (type N is new T;) > 3. Typed classes (T /= T'Class) Here 2 things are missing: - parameterized types (see Java generics and the ML type system, the first is just borrowing from the latter). - Separation of implementation and type or to put it differently inheritance and subtyping compatibility. See the ocaml type system. I admit the contracts are weaker for allowing to instante a generic with a package with the "right type signature" as parameter instead of requiring an instance of another specific generic. But what is absolutely annoying, is, that the compatibility of objects is determined by inheritance instead by the type signature. This makes things like the factory pattern necessary and it really doesn't work in general case. (And yes, Java and C++ share this defect). I suggest that anyone trying to improve on the type system of languages of the Algol family first should aquire a knowledge of the Hindley-Milner type system, then read the part about objects and classes in the OCAML manual (this is an extension of Hindley-Milner) http://caml.inria.fr/pub/docs/manual-ocaml/manual005.html and finally reads the tutorial on Java generics (introduced in 1.5): http://java.sun.com/j2se/1.5/pdf/generics-tutorial.pdf To me those three together were an eye opener. The Java generics tutorial in I my eyes documents 2 things: (a) what has been really sorely missing from Java for 10 years and (b) that you can complement a type safe pascalish type system usefully with subtyping and parameterized types. > P.S. All strings have fixed length. It is just so that you might not know > the length at some point... (:-)) Ah, well, thats splitting hairs. We are talking about 2 different lengths (of strings in C) here: The one is the allocated storage, the other the distance from the start to the first occurrence of the '\0' delimiter. Since strlen() returns the latter ... The problem I've been talking above, is of course to manage growing strings that might outgrow the allocated storage. Regards -- Markus