News for hackers. Stuff that matters.
Re:Just what does “code as data” mean anyway? (2014) by quadcore on Friday February 16, 2018 @10:36AM (#16393020)
I agree, OO is ultimately good enough. Problem is, coding using OOP is like printing ideas on paper: you dont wanna do that because it's hard to discard ideas that's been printed on paper. You wanna use post-its instead because post-its are easy to discard. Refactoring is hard using OO and refactoring is the key difference between waterfall and good software development. Refactoring is easier, even fun, using functional programming because the medium is more malleable.
Re:Just what does “code as data” mean anyway? (2014) by Retric on Friday February 16, 2018 @11:02AM (#16393247)
Refactoring lisp gets harder the more complex the program gets. Approachs that are clever and reasonable for a 1000 line program can become hell in a 100,000 line program.

Effectively programming languages get less powerful the longer the program becomes. Breaking up programs into more powerful little pieces is never a clean separation and you need to make real trade offs between more separation and more power.

Re:Just what does “code as data” mean anyway? (2014) by DannyB2 on Friday February 16, 2018 @11:17AM (#16393367)
> Refactoring lisp gets harder the more complex the program gets.

I have found that to be true in dynamically or duck typed languages.

I have found it to be not true in strongly typed languages with good tooling. Example: refactoring large java program in, say, Eclipse.

> Breaking up programs into more powerful little pieces is never a clean separation

I would tend to disagree, to some extent.

In Lisp(s), there are lots of small, sometimes obviously correct functions that do powerful operations on abstract data structures. Part of the reason for this is that unlike OOP (and I write Java daily) which has lots of data structures, Lisp has very few. In OOP you model your domain with new classes. In Lisp you model your domain with combinations of a few basic structures. (In Clojure...) List, Set, Array, Map.

Maybe you have layers of separation. With one layer being between primitives that manipulate your domain objects, and another layer being the logic that decides how and when to do the manipulations. I want to solve a puzzle. The puzzle board has various states, pieces, and operations that transform a board into a new board state. Then the logic layer is an algorithm or algorithms written using the layer of primitive manipulations. That logic layer may, in fact, use canned algorithms, because the data structures are common primitives. Say, sort, search, A* search, depth first, breadth first, reduce, map fn over a sequence, etc.

You can end up with a large program. But it can be a lot easier to reason about than, say, a large Java program. It seems to take more deliberate effort to keep a large java program easy to reason about.

Re:Just what does “code as data” mean anyway? (2014) by Retric on Friday February 16, 2018 @01:18PM (#16394441)
> layers of separation

Layers are exactly the kind of power trade-off I am talking about. If code X can't(1) impact code Y, you have less freedom in code X because it can't do some things, but can more easily reason about code Y.

(1) either as an actual limit or a self imposed one.

Granted, in theory you may be able to find perfect points of separation such that you don't lose power by doing so.

Re:Just what does “code as data” mean anyway? (2014) by flavio81 on Friday February 16, 2018 @11:31AM (#16393483)
>Refactoring lisp gets harder the more complex the program gets. Approachs that are clever and reasonable for a 1000 line program can become hell in a 100,000 line program.

Can you substantiate this claim? One of the reasons Lisp was used in the past was because it was particularly suited to complex, big projects... Like autopilot for spaceship, wind tunnel simulation, CAD/CAM systems, etc.

Lisp (as 'Common Lisp', the traditional dialect) has this concept of "packages" and "systems".

You can divide your code in "packages", each package contains separate namespaces for classes, function names, variable names, symbol names, keyword names and others. Thus each package doesn't collide with another package and names don't collide at all.

Many packages are combined into a "system" (by defining, for example, the required order for compilation, etc).

Thus you cleanly separate your code in packages and systems. The 100,000 line program becomes a combination of many shorter programs.

Of course this is nothing new, this is just standard practice for keeping big programs manageable.

>Breaking up programs into more powerful little pieces is never a clean separation

Care to explain? Well, i'll continue with my post. And we'll assume that what you say is true, so i'll list other advantages to keep complex systems at check.

Now, here is a big plus for complex systems: In such a Lisp, the system is hot-patchable. You can redefine functions while your program is running. Without stopping the program. We're talking about doing this even on a production environment, if necessary.

You can also redefine classes while your program is running. Without stopping the program.

Another big plus is the condition-restart system, which very few languages implement. Lisp has not only the notion of "catching exceptions", but also after catching the exception, provide alternate ways of recovering of this exception, including being able to resume operation at the point where the problem was found.

This is another big plus for building reliable systems -- and complex systems benefit from being composed of reliable parts.

I could go on with other big pluses as well. For example, multi-paradigm. Some parts are more readable (and thus easier to understand, maintenable) if written in the functional style. Others map better to the OOP style. Others would map better to the imperative/procedural style. Other would better be expressed as logic programming (think Prolog.)

Lisp allows you to use all these paradigms. So the code stays clear. I say this is very good for complex systems.

Re:Just what does “code as data” mean anyway? (2014) by Retric on Friday February 16, 2018 @01:11PM (#16394369)
> Care to explain?

Some of this comes down to what you consider a 'large' program. Suppose you want to build an MMO in lisp, now you need to consider things running on both a client, and server, as well as rendering, path-finding etc. Choosing reasonable primitives becomes difficult as you get pulled in several directions. Should I be running the same code on client an server or should I have multiple different models communicate etc etc.

My point is you start dealing with trade offs and no approach is universally better. Even with a clean API between different pieces of code you still get conceptual dependency's.

Re:Just what does “code as data” mean anyway? (2014) by kamaal on Friday February 16, 2018 @01:39PM (#16394659)
This looks more like software design problem and not a Lisp problem.

Building anything complex requires, apart from tools, getting organized in a lot of other things as well.

Re:Just what does “code as data” mean anyway? (2014) by Retric on Friday February 16, 2018 @03:20PM (#16395731)
That's part of it.

The is an old saying they enterprise software ends up mapping the organization that built it. If you have N teams you tend to break a large project into at least N parts.

Sharing code between teams works, but it's harder to share complex lisp macros vs functions. Which is really closer to my point, the larger the project the more tools get set aside too being to ~complex/risky to safely use.

Re:Just what does “code as data” mean anyway? (2014) by flavio81 on Friday February 16, 2018 @10:54AM (#16393181)
>I agree, OO is ultimately good enough.

And Common Lisp has arguably the most flexible and powerful OOP system around, CLOS.

Why don't write OOP in Lisp? It is done successfully by lispers around the world.

Re:Just what does “code as data” mean anyway? (2014) by kamaal on Friday February 16, 2018 @11:37AM (#16393527)
>>Why don't write OOP in Lisp?

Because most people understand OO as some kind of namespace scheme. Basically to bunch together functionality under a name(class).

When people talk of OO, most of them, are actually talking about modularizing code.

Re:Just what does “code as data” mean anyway? (2014) by goatlover on Friday February 16, 2018 @02:36PM (#16395285)
That's modules or packages. OO includes inheritance, polymorphism and treating objects as black boxes (little computers in Alan Kay's mental model) with messages they respond to, or APIs for working with that kind of object.

It's a lot more than simply being a namespace. It's also that idea that an object has state and behavior, with appropriate semantics for dealing with both (depending on the language).

Objects (with classes or prototypes) act as a new kind of data type bundled with functionality for handling that data, which is more than just putting a bunch of functions and variables into a namespace. So you can treat your class/prototype as a built-in complex data type. You're extending the type system in an encapsulated manner.

It's not called Namespace Oriented Programming

Re:Just what does “code as data” mean anyway? (2014) by skybrian on Friday February 16, 2018 @11:11AM (#16393323)
You'll have to substantiate that, because refactoring Java is pretty easy if you have a good IDE. In many other languages, you're lucky if you can reliably rename a function without having to manually check for false positives, let alone something complicated like change signature or extract superclass.

Also, in any statically typed language, you can fall back on changing the function and using compile errors to tell you all the calls that need to be updated.

Re:Just what does “code as data” mean anyway? (2014) by quadcore on Friday February 16, 2018 @11:47AM (#16393617)
refactoring Java is pretty easy if you have a good IDE

rename a function

Refactoring in software development is not the same as refactoring in IDEs. Refactoring in software development is changing existing code. Specially the architectural parts.

Re:Just what does “code as data” mean anyway? (2014) by skybrian on Friday February 16, 2018 @03:16PM (#16395692)
Could you explain what you mean? As far as I know it's the same process. Changing the architecture often involves a large number of small, safe code changes, many of which can be handled by IDE's and other software tools.