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=-0.9 required=5.0 tests=BAYES_00,FORGED_GMAIL_RCVD, FREEMAIL_FROM autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 5b1e799cdb,3ef3e78eacf6f938 X-Google-Attributes: gid5b1e799cdb,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII Path: g2news2.google.com!postnews.google.com!v15g2000prn.googlegroups.com!not-for-mail From: fft1976 Newsgroups: comp.lang.scheme,comp.lang.ada,comp.lang.functional,comp.lang.c++,comp.programming Subject: Re: Alternatives to C: ObjectPascal, Eiffel, Ada or Modula-3? Date: Tue, 28 Jul 2009 19:52:16 -0700 (PDT) Organization: http://groups.google.com Message-ID: <76d51f01-725b-4146-82f6-cd89bfcb90eb@v15g2000prn.googlegroups.com> References: <2009a75f-63e7-485e-9d9f-955e456578ed@v37g2000prg.googlegroups.com> NNTP-Posting-Host: 71.136.236.45 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: posting.google.com 1248835937 18451 127.0.0.1 (29 Jul 2009 02:52:17 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Wed, 29 Jul 2009 02:52:17 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: v15g2000prn.googlegroups.com; posting-host=71.136.236.45; posting-account=XD7nMAkAAAAUcvFxxCbDAfgYkTA2oJDz User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.10) Gecko/2009042513 Ubuntu/8.04 (hardy) Firefox/3.0.10,gzip(gfe),gzip(gfe) Xref: g2news2.google.com comp.lang.scheme:6139 comp.lang.ada:7388 comp.lang.functional:2502 comp.lang.c++:48447 comp.programming:12087 Date: 2009-07-28T19:52:16-07:00 List-Id: On Jul 28, 5:40=A0pm, Oxide Scrubber wrote: Clojure is kind of cool, but many corrections are in order: > fft1976 wrote: > > Java: 1.5x slower than C as a rule of thumb. > > I think it can achieve parity. I disagree. I don't think the JIT can do much about the memory layout of the data structures. Compare a vector of complex numbers or of 3D vectors (NOT of pointers to them) in C/C++ and Java. Run some tests. I did and I looked at others'. For me, 1.5x is a good trade-off for safety though. > With Java, in most cases you can slap "implements Cloneable" on a > class and make the clone method public, Java's "clone" does a shallow copy only (check the docs). C++ default copy constructors call copy constructors on the members. > or slap "implements > Serializable" on a class to make its instances marshallable. Does this handle cycles and memory sharing among data structures? > (This doesn't, however, > interoperate with generic Java objects or Java serialization, and I'm > not sure it works with data structures with circularities. It won't work > with data structures with infinite sequences in them, but if you > represent such sequences symbolically it can.) But you'll need Java's data structures and mutations on Java's arrays to compete with it in speed of numerical code, so this argument goes out the window. > Clojure has strong support for parallelism and threading. Clojure's support for multithreading is good only as long as your code is pure-functional. Let's see you add 1.0 to all diagonal elements of a 1000x1000 matrix. > You need to work a bit to get the most speed out of Clojure too, but you > can then get C-like performance out of it in tight loops. In theory, imperative and Java array using Clojure can be made as fast as Java (which is slower than C), but in practice, experts seem to agree that Clojure is 5-10 times slower than Java: http://groups.google.com/group/clojure/msg/92b33476c0507478 Aside: do you remember to add -O3 when you are compiling C/C++? I use "-server" when running the JVM.