Live data from Hacker News

Not Lisp again (2009)

funcall.blogspot.com

141–150 of 276 posts

Re: Not Lisp again (2009)

#141
post #133
post #112

Earlier quoted context omitted.

SICP uses Scheme, which is not Lisp. It was taught at an introductory level because some concepts of computation can be taught nicely with Scheme, up to making a compiler for another language (perhaps a "real" language in the student's minds?), but it doesn't actually teach you Lisp, and I imagine leaves a bad taste in many students' mouth at the nonsense no-for-looping-no-mutation they had to suffer through which is…

> SICP uses Scheme, which is not Lisp. Wikipedia [0]: > Scheme is a functional programming language and one of the two main dialects of the programming language Lisp. [0]: https://en.wikipedia.org/wiki/Scheme_%28programming_language...

Keyword: dialect. But Erik Naggum, 2002 [0]:

> The "Lisp" Scheme is a dialect of is no longer the current meaning of "Lisp". It is somewhat like calling English a dialect of German because of ancient history that has since between invalidated by each of their separate evolution, Fahrvergnügen, Weltanschauung, Kindergarten, and Pennsylvania to the contrary notwithstanding. There is also a very limited value in talking about "Germanic languages" in terms of your actual ability to use any of the Germanic languags. You do not order the "vertebrate" in a restaurant, but generally choose between fish or bird or meat. In other words, there is a time when an abstraction and a commonality has completely ceased to be valuable.

[0] http://www.xach.com/naggum/articles/3224964049435643@naggum....

Re: Not Lisp again (2009)

#142

Earlier quoted context omitted.

To be fair, the one time I decided to do something biggish and kinda important in Lisp, I stopped at #3. Not exactly because "it does not have many libraries", but because "library for X, Y and Z are not there and I don't want to write them". Oddly, Haskell has a similar problem, but going through C code by the FFI does not feel like a problem. I don't think why it does in Lisp, it may be just a matter of better docu…

I'm working on FFI for TXR Lisp. Until this morning, it was in the stage of "collection of working API functions, written in C, exposed with Lisp bindings". I have almost everything I want working, including callbacks. There is a decently rich type system which supports pointers that annotate data passing directions for automatic malloc and free, and this works in both directions: out calls and callbacks (closures).…

That's a great look-and-feel :)

How does memory management work? Do you have self-destructing structures (AKA automatic pointers) on the Lisp side?

Re: Not Lisp again (2009)

#143

Earlier quoted context omitted.

Probably hadn't thought of passing a subroutine address to a routine in z80 machine language he was familiar with?

Passing function addresses as parameters is easy. It's more difficult to return a nested function that closes over the outer function's variables.

Not really in machine language or even BASIC (see below).

Re: Not Lisp again (2009)

#144

Earlier quoted context omitted.

It's been stated a number of times, but x.f(y, z) has just as many parens as (f x y z). And Haskell particularly comes with so many syntax quirks. There is a lot of cruft you need to learn to get to the underlying functional core of haskell. Lips you can get 100% of the cruft out within a few days / 1 week. And the rest is just understanding programming concepts. I don't use any LISP on a regular basis, but it still…

x + y * z has way fewer than (+ x (* y z)) though. I'm not arguing for one or the other, but e.g. infix operators do have upsides.

>infix operators do have upsides

What you are also glossing over are the precedence rules for operators. In this case it works in favor of your point and LISP indeed needs more parens.

However in other situations, you might need to re-parenthesize (language with flat precedence like APL) or consult your favorite chart[0] in order to figure out what is going on.

[0] http://en.cppreference.com/w/c/language/operator_precedence

Re: Not Lisp again (2009)

#145
> Slower than assembly? Maybe for table lookups, but who cares about something as mundane as that? I want to do magic. If I have to look up something in a table, maybe I'll use assembly code.

Best line.

Also, I wonder how Go compares? Can you do basically the exact same things?

Re: Not Lisp again (2009)

#146
post #73

Earlier quoted context omitted.

f(x + dx) does look more conventional than (f (+ x dx)), but (/ numerator denominator) looks more like the conventional fraction syntax than putting a / somewhere in the middle of a line.

I'll give you that but also, ask 100 random people what "3/4" means and what "(/ 3 4)" means.

Yes, I'm sure hardly any would say "three fourths" for (/ 3 4) and a lot of them would for 3/4. (A lot of them might also say "three or four".)

Incidentally Scheme syntax recognizes 3/4 as a rational number. It will do rational arithmetic without floating point problems.

Re: Not Lisp again (2009)

#147
post #138

The objections the author had way back in the day are no longer the objections programmers of mainstream languages have to Lisp today. Today the objections I hear are more along the lines of: 1 - All those parenthesis. (Still a top objection) 2 - Lisp doesn't look like or work like what I'm used to. 3 - Lisp doesn't have as many libraries as the most popular mainstream programming languages. 4 - There aren't nearly a…

> 1 - All those parenthesis. (Still a top objection) If you actually count parens fairly you will find that Lisp has no more than any other language, it's just that other languages use a mix of parens, square brackets and curly braces whereas Lisp only uses parens. Also, if you really don't like parens, you can get rid of a lot of them using macros. See e.g.: https://github.com/rongarret/ergolib and in particular the…

The part about lisp being primitive was rather silly. Many languages don't have anything close to what Lisp has in its macro system, not even other functional languages, even in those languages with temperating systems. Perhaps Perl 6 comes close (I haven't had the chance to use p6 macros yet) but to say that lisp is 'primitive' is rubbish, unless you're going to claim that case insensitivity is enough to declare a language primitive.

Re: Not Lisp again (2009)

#148

Earlier quoted context omitted.

How? Functions are first class in lisp.

Functional programming is but one of the many paradigms that you can use in Lisp, along with imperative, object-oriented, relational, etc. When you say a language is a functional language, you are saying that it is the paradigm supported, which is not the case here.

Lisp has lots of mutable types and lots of ways to smuggle them into and out of a procedure. I'd say pure functions are tolerated but not supported.

Still hard to beat for creating domain-specific languages, though, and a carefully designed DSL can rule out nondeterminism and side effects.

Re: Not Lisp again (2009)

#149

a lot of people handwave the parenthesis and prefix notation as something you get used to, but it really is the thing that I think most people can't get a handle on. There's a reason why DSPs and languages that look like a real languages are sought after - it makes conversion between business logic/requirements to code easier. It makes maintenance easier - it's easy to make sure you made the right changes when the ch…

I would restate that as people not pushing through past their initial uncomfortable feelings and preferences. Similarly, of all the people who have ever tried Prolog only a small fraction got past the "this is weird" stage. Or Forth.

This unwillingness to learn something more than slightly different is limiting, and usually expresses itself in other ways as well. That does NOT mean that such people aren't good developers. You do run risks asking them to work outside their comfort zone, though.

Re: Not Lisp again (2009)

#150

Earlier quoted context omitted.

Well, in 1992 (IIRC), I did a numerical integration in C. For a "first class function", it just took a function pointer. That approach would have been available in C in 1983...

He is right, you could do something roughly equivalent in 1983-era C, albeit a fair amount clunkier due to the lack of partial application or (any kind of) type-checking: #define DX (double)0.0001 double f_prime(f, x) register double (*f)(); double x; { return ((*f)(x + DX) - (*f)(x)) / DX; } #define DERIV(F, X) f_prime((F), (double)(X)) double cube(x) double x; { return x * x * x; } #define DERIV_CUBE(X) DERIV(cube,…

And in >=C89:

  #include 

  double deriv(double (*f)(double), double x)
  {
          static const double dx = 1e-8;
          return (f(x + dx) - f(x)) / dx;
  }

  static double cube(double x)
  {
          return x * x * x;
  }

  double deriv_cube(double x)
  {
          return deriv(cube, x);
  }

  int main(void)
  {
          printf("%f\n%f\n%f\n", deriv_cube(2), deriv_cube(3), deriv_cube(4));
          return 0;
  }
Post reply on HN