Live data from Hacker News

I want to fix programming

jonbho.net

71–80 of 163 posts

Re: I want to fix programming

#71
post #55

So, over the years I've played with many things that claim to be "declarative", and here's why I now shy away from them like the plague. There's no such thing as "declarative". No matter what you type into the computer, at some point it's going to turn into instructions that do the thing you want done. Trying to create a declarative language is a way of making it extraordinarily opaque as to what the machine is actua…

What if you created a declarative language which allows you to override the algorithms in a functional/imperative? You could create a public algorithm repo that auto-pulls into your local machine on setup. Could search for algorithms by declarations. That would be a lot of reuse.

Re: I want to fix programming

#72
post #55

So, over the years I've played with many things that claim to be "declarative", and here's why I now shy away from them like the plague. There's no such thing as "declarative". No matter what you type into the computer, at some point it's going to turn into instructions that do the thing you want done. Trying to create a declarative language is a way of making it extraordinarily opaque as to what the machine is actua…

I think to have a truly declarative language that doesn't just dissolve into obscure commands at some point requires the language to have a true understanding of human language. Which to currently do well even just for answering questions requires Watson levels of computing power.

Re: I want to fix programming

#73
You already said you will be looking and SQL closer, so let me give a few pointers here.

Consider that in SQL you specif how to store data, including indexes, and then what you wan to get, but not how to get it. In other words you specify data structures and the engine picks a set of algorithms and builds an execution plan. The next logical step would be for the user to specify the schema, while the database engine is not only choosing algorithms but also reshapes your data into data structures that would allow optimal algorithm selection later on. At first it would only build new indexes, but then it could also start employing partitioning and ultimately move to normalization/denormalization.

Secondly, be on the looklout for when a problem reminds you of a SQL query. For example, a mail application looks like a query where you specify which fields from which emails you want to see and in what order, and on top of that query result you're specifying a style sheet, CSS on steroids, to make it render pretty. Style sheet is also declarative, not imperative! I am presently working on a framework that follows this model to facilitate iPhone app development, and it's looking pretty good already.

Re: I want to fix programming

#74
So imagine you define some amazing PSL (Problem/Solution Language). It let's you "Code" by defining the problem and solution, ie:

    Define SORT: Given SET(x), Find SET(y) Where [For i in y] y[i]>y[i-1].
So now you're feeling all giddy because this amazing language is so awesome--you didn't have to specify how to do something step by step. You just declared what you wanted, and it gave it to you. Fantastic.

But then, now that you have defined this "SORT" routine, you still need to use it. You end up with the following code:

    Prompt SET.
    SORT SET.
    Display SET.
Shit! You're defining steps again.

You ultimately can never achieve your goal, because you will always need to define some steps. All programs of significance are a composition of tasks which need to be identified, and executed.

Re: I want to fix programming

#75
post #53

I once read a programming book on Elliptic Curve Cryptography, which was invented by Dr. Neal Koblitz. So the book said - whatever is in the next 200 pages is considered trivial by mathematicians working in number theory. If you write it in the form of equations, this entire book will occupy less than half a page. It is basically a lemma and a few theorems. But this book is 200 pages long. Why ? Because it tells you…

See Nile/Gezira: http://www.vpri.org/pdf/tr2009016_steps09.pdf

Also, the STEPS project in general (read the progress reports): http://www.vpri.org/html/writings.php

They talk about "active" or "runnable" maths. The programming languages they create aim to basically mirror mathematical expressions. This in turn makes the programming stack much smaller and easier to comprehend.

Re: I want to fix programming

#76
Bullshit. Sorry, but there's nothing essentially "broken" about programming. You don't like it, but it's a model that works.

Until you create a true AI, this is the way things are. It's not broken, it's apples and oranges. Instead of fixing programming, fix your way of looking at it.

Re: I want to fix programming

#77
post #53

I once read a programming book on Elliptic Curve Cryptography, which was invented by Dr. Neal Koblitz. So the book said - whatever is in the next 200 pages is considered trivial by mathematicians working in number theory. If you write it in the form of equations, this entire book will occupy less than half a page. It is basically a lemma and a few theorems. But this book is 200 pages long. Why ? Because it tells you…

That function definition is a monstrosity because it is poorly factored. Assuming pre-existing fromBase and toBase functions, here is a definition that in my opinion is easily readable and matches your verbal description:

    halton b n = fromBase b (reverse digits) / b^(length digits)
        where digits = toBase b n
Just to show there's nothing up my sleeve, here are the fromBase and toBase definitions:

    toBase b 0 = []
    toBase b n = (n `mod` b) : toBase b (n `div` b)

    fromBase b []     = 0
    fromBase b (n:ns) = n + b * fromBase b ns
They too read like how a mathematician would define them. (I abstained from use of foldr/unfoldr to make this clear.)

Edit: On second thought, it's easy to implement it as a direct recursion. I'll demonstrate it in C so I'm not accused of language chauvinism:

    double halton(int b, int n)
    {
	return (n == 0) ? 0.0 : (n % b + halton(b, n / b)) / b;
    }
Here the digit reversal is implicit in the recursion (the oldest programmer trick in the book).

This C code is self-contained and compiles to a tiny handful of machine code instructions, so it's hard to see how your statement that "this simple 1-line equation in math becomes hundreds of thousands of loops in practice" holds much water.

Re: I want to fix programming

#78

The problems the OP wants to solve are formally undecidable and reducible to the halting problem. 1. Given a formal specification, find a program that meets the specification. 2. The apparently simpler problem of checking whether a given program meets a specification. Both are undecidable. That said, there is an extensive literature on practical approaches to this problem. They generally suffer from intractability. h…

I agree with the sentiment that the problem the OP brings up is difficult, but bringing up the halting problem here seems pretty pedantic.

If you restrict yourself to a turing incomplete language, checking a specification no longer reduces to the halting problem. In fact, there are many systems that do exactly this, and most of these systems are perfectly capable of sorting a list and proving that the list is sorted.

However, I think the real point is that there are at least dozens of smart people who are working on this exact problem all day, every day. The OP shows neither a deep understanding of why previous attempts at this have failed or really, any knowledge at all about the state of the field of programming language research.

Re: I want to fix programming

#79
post #39

My vision of the future for programming is a room with 3d virtual reality goggles. Monitors are nowhere to be found, lines of code in files are presented to you on virtual monitors around you in a 760 degree panoramic view, above, below, and THROUGH. Our brains are evolved for a 3d world, not the lines-of-code on printed page world. Commands like "instantiate new object", "add items to object", "do an sql query", "ru…

that's actually not that far from what programming with well-designed libraries and abstractions is like now. at least, I know I have a more-or-less 3d visualization of my program in my head as I'm working on it... but that could be just me.

Re: I want to fix programming

#80

So imagine you define some amazing PSL (Problem/Solution Language). It let's you "Code" by defining the problem and solution, ie: Define SORT: Given SET(x), Find SET(y) Where [For i in y] y[i]>y[i-1]. So now you're feeling all giddy because this amazing language is so awesome--you didn't have to specify how to do something step by step. You just declared what you wanted, and it gave it to you. Fantastic. But then, no…

There's a bug in your definition of SORT.

The OP complains that it's easy to write imperative and functional programs that contain bugs; I don't think that declarative programs are fundamentally better.

Post reply on HN