Live data from Hacker News

The unreasonable effectiveness of declarative programming

bollu.github.io

111–120 of 128 posts

Re: The unreasonable effectiveness of declarative programming

#111
post #64

Declarative is great, and I wish more people created clean declarative API with regular languages instead of writting yet another DSL. But remember that the problem with a declarative syntax, is that it needs a runtime, which typically the end user doesn't touch. And if the runtime doesn't take into consideration one use case, the user is stuck. Don't forget to provide an escape hatch.

Declarative code doesn’t need a runtime if you have a compiler

You're conflating runtime with interpreter. Interpreter translates non-native code to native code, a runtime is what gives you garbage collection, the vm(ex: JVM), std libraries, etc.

Re: The unreasonable effectiveness of declarative programming

#112

Earlier quoted context omitted.

First off, this part: >anim_interpolate(ease_cubic, "cr", /val=/10, /time=/3) is still declarative. In any your example is incomplete and proves nothing because the end result should be a function that takes t and returns cy and cr . Not sure what your code is supposed to be really. Secondly, the author explained at length what the advantages of their approach are (purity, composition, time travel debugging, ...). I'…

You confuse declarative and functional. Declarative is when the sequence of execution is not related to the order of operators in the program text, but is derived at run time. The animation, where sequence of events is known exactly, is the poorest example for declarative programming.

> You confuse declarative and functional.

No I'm not. Also functional programming is declarative programming (but not the other way around). If your code is supposed to be functional, it is also declarative.

I was trying to freely guess what your incomplete example was supposed to do. Maybe I was wrong, but then you didn't provide much to work with.

> The animation, where sequence of events is known exactly, is the poorest example for declarative programming.

This wasn't a competition to come up with textbook examples of declarative programming.

Re: The unreasonable effectiveness of declarative programming

#113

Earlier quoted context omitted.

You can use a normal language to well design a declarative library. That's the point.

You're just throwing terms around here. Something like Django or Rails, is no longer just a "declarative library" it's a framework. You're using their patterns, and you're limited to their escape hatches.

Never talked about frameworks.

Declarative is just a paradigm, you can use any language to design a declarative API.

Nox, pydantic and sqla are examples of it.

Re: The unreasonable effectiveness of declarative programming

#114

Earlier quoted context omitted.

You're just throwing terms around here. Something like Django or Rails, is no longer just a "declarative library" it's a framework. You're using their patterns, and you're limited to their escape hatches.

Never talked about frameworks. Declarative is just a paradigm, you can use any language to design a declarative API. Nox, pydantic and sqla are examples of it.

I'm not familiar enough with any of those tools to evaluate what you're saying. :shrug:

Re: The unreasonable effectiveness of declarative programming

#115
I'm curious about how one is supposed to reason about the time and space complexity of declarative programs. I don't work in a realm where CPU and memory costs can be assumed to be infinite (or even cheap). How do declarative programming paradigms typically offer guarantees or bounds on computation cost?

I'm assuming that any declarative language powerful enough for general use is expressive enough to represent an NP-complete problem; i.e. : Find a set of booleans X1..XN that satisfy Y logical statements (or prove that there is none possible). Therefore absent opening up the "black-box" of the language, the time and space complexity could be unbounded.

With an imperative language, of course, since the programmer is probably specifying the exact order of operations and data structures being used, reasoning about and bounding the cost is usually straightforward.

Re: The unreasonable effectiveness of declarative programming

#116
post #50

Earlier quoted context omitted.

I've got to ask, for stuff like "Murder, She Wrote", did you license anything? If so was that hard and what was the process like?

For MSW, CSI:NY, Sherlock, and others, we were working with a company in LA called Legacy Interactive. Technically, these are "their" games, we did exclusively all the programming and scripting. They got the licenses for the TV properties, commissioned the art, and wrote the storylines. So unfortunately I can't comment on the licensing process, as I wasn't involved :(

Still really cool =)...

Re: The unreasonable effectiveness of declarative programming

#117

Earlier quoted context omitted.

I would. Because at the pure end imperative->declarative spectrum, you lose turing completeness. It is certainly less imperative than the equivalent C, that's for sure.

That's not true at all. The following is a declarative program: Yield an interpretation of a set of boolean variables that satisfies the following conditions: - A AND B - (NOT C) or A or B - A AND (NOT C) ...etc

[deleted]

Re: The unreasonable effectiveness of declarative programming

#118

In Haskell, one can make more general combinators in the following way: type Anim a = (Duration -> a, Maybe Duration) -- Linear interpolation linear :: Anim Duration linear = (id, Nothing) -- Sequencing seq :: Anim a -> Anim b -> Anim (Either a b) seq (f, Nothing) g = (\t -> Left $ f t, Nothing) seq (f, Just df) (g, dg) = (\t -> if t Anim b -> Anim (a, b) par (f, df) (g, dg) = (\t -> (f t, g t), max df dg) -- Constan…

I am literally too dumb to know what you typed... and then all of the following comments. It is like you are speaking in Martian or something. Haskell is effectively impenetrable to me.

I thought so too, but Haskell was an object of adoration and envy for me long enough for me to become hooked.

If Martians visited Earth, surely you'd want to learn their language. :)

Re: The unreasonable effectiveness of declarative programming

#119

Earlier quoted context omitted.

OMG, seriously? You made my day Try the two Sherlock games if you can get them somewhere - these have a special place in my heart :)

Do you know where to get your games still? My wife would like them... The reason you are not just putting them on archive.org is because of the contracts you had I guess? Edit: read your other comment and saw the licensing stuff... Shame about games (and such) that you just cannot keep them for sale forever... But just let them die.

Looks like Big Fish Games still sells them: https://www.bigfishgames.com/games/2452/the-lost-cases-of-sh...

Never thought of putting our first-party games on archive.org, sounds like a great idea, I'll look into it :)

Re: The unreasonable effectiveness of declarative programming

#120
You should look at Actions in the Python implementation of Cocos2d. It uses operator overloading to allow '+' for sequential actions and '|' for parallel actions. These are composable and reversible for quickly creating complex animations.

http://python.cocos2d.org/doc/programming_guide/actions.html

Example:

        bounce = Jump(150, 0, 4, 2)
        scale = ScaleBy(2, duration=1.5)
        rot = RotateBy(360, 0.80)
        scale_and_rot = scale | rot
        bounce_in = bounce | scale_and_rot
        bounce_out = Reverse(bounce_in)

        logo.do(bounce_in + bounce_out)
Post reply on HN