From owner-freebsd-chat@FreeBSD.ORG Mon Apr 26 02:43:22 2004 Return-Path: Delivered-To: freebsd-chat@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id CFBE116A4CE for ; Mon, 26 Apr 2004 02:43:22 -0700 (PDT) Received: from harrier.mail.pas.earthlink.net (harrier.mail.pas.earthlink.net [207.217.120.12]) by mx1.FreeBSD.org (Postfix) with ESMTP id B9A1043D67 for ; Mon, 26 Apr 2004 02:43:22 -0700 (PDT) (envelope-from rsidd@online.fr) Received: from user-0cdfelv.cable.mindspring.com ([24.215.186.191] helo=bluerondo) by harrier.mail.pas.earthlink.net with smtp (Exim 3.33 #1) id 1BI2e2-0000IY-00 for chat@freebsd.org; Mon, 26 Apr 2004 02:43:22 -0700 Received: (qmail 7619 invoked by uid 1002); 26 Apr 2004 09:43:35 -0000 Date: Mon, 26 Apr 2004 05:43:35 -0400 From: Rahul Siddharthan To: Chris Pressey Message-ID: <20040426094335.GA7578@online.fr> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20040425215837.3f4708fe.cpressey@catseye.mine.nu> X-Operating-System: DragonFly 1.0-CURRENT i386 User-Agent: Mutt/1.5.6i cc: chat@freebsd.org Subject: Re: Beginning C++ in FreeBSD X-BeenThere: freebsd-chat@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Non technical items related to the community List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 26 Apr 2004 09:43:22 -0000 Chris Pressey wrote: > > A single Greek word for which there isn't an equivalent word in > > English-- and I mean exact equivalent, including all the possible > > meanings and nuances that this word can express in the Greek language > > -- should be enough as an example, right? > > Unfortunately, no, it's not enough. > > A single Greek word for which there isn't an equivalent English word, > phrase, sentence, paragraph, essay, book, or library would be enough > though. Which has very little relevance to programming languages. Anything that can be done in one Turing-complete language can be done in another Turing-complete language. The trade-off is in development time ("expressiveness") and running time. For a long time I've thought that the tradeoff is between ugly, laborious and fast (C and, in the scientific community, Fortran - ugh) and elegant, expressive and slow (Python etc). But now I'm beginning to play with functional languages like lisp and ML. Some implementations of these (cmucl, ocaml) are quite competitive with C in speed (ocaml can even be faster in some circumstances), while being orders of magnitude simpler and more elegant, and allowing far fewer foot-shooting possibilities. No more hideous hacks to write a function that can deal with data of any type. No more memory leaks, no more segfaults, no more buffer overflows. And if written in purely functional style, no "side-effect" bugs. For example, these languages recognise a particular form of recursion ("tail recursion") that can be optimised into a regular iteration, so you get the efficiency of a goto with the programming elegance of recursion. And you can do things in them in a few lines that seem unthinkable in C: eg, in ocaml, you can define a discrete derivative of an unspecified function (a "function of a function") with let dx = 1e-10;; let deriv f = (fun x -> (f (x +. dx) -. f x) /. dx);; or, for better accuracy, let deriv f = (fun x -> (f(x +. (dx/.2.0)) -. f(x -. (dx/.2.0))) /. dx);; Then you can get a pretty good approximation of, say, sin' (=cos): let sin' = deriv sin ;; sin' 0.7854 ;; - : float = 0.707105485275860701 cos 0.7854 ;; - : float = 0.707105482511236283 As for Lisp, its macros seem to have no equivalent in any other language I can think of. And a lisp program can basically rewrite itself (or generate its own functions and execute them), which would be a hideous hack at best in any other language. So now I'm wondering: why aren't these languages more popular? Back in the 1970s the hardware didn't allow for efficient compilers, so I can understand that C looked attractive, but that's no longer true. And these languages are hardly newcomers: ML is nearly as old as C, while Lisp dates to the 1950s. Rahul