Hacker News new | past | comments | ask | show | jobs | submit login

I am writing PHP in Common Lisp, and my codebase is litered with the following:

  (defun make-record (&rest args) ; insert &allow-other-keys ;-)
    (let ((*db-auto-sync* t))
          (object (make-instance 'record args)))
       (when object
         (update-records-from-instance object))))
Both the LET binding of db-auto-sync and the update-records call do the EXACT same thing. However, due to weirdness I don't grok quite yet, the calls to the db driver get in only half the time, even with query caching disabled.

That's for record insertion.

For record update, I have something far more sinster. Every accessor has an :after method with explicit SQL inside. Allow me to explain this: Imagine if you had to write a function that does something as a side-effect everytime an assignment is made! E.g. I have a macro that generates explicit slot serializer for ever accessor; I managed this by wrapping defclass twice and now I program in a weird, session-oriented php-like dialect that's just too fucking brittle.

We will go over it after our first demo :-P

[Edit:

I wrote the following database agnostic routines and I deal with the db strictly through them.

LIST-OBJECTS type

LIST-OBJECTS-WHERE type slot value

FIND-OBJECT type slot value

FIND-OBJECT-WHERE type slot value

UPDATE-OBJECT-WHERE type slot value new-value

DELETE-OBJECT-WHERE type slot value

type is both a Lisp class and SQL table name. Slot and value are used in WHERE clauses, e.g. (select [*] type :where [= slot value])

]




UPDATE!

I hope no one was misled by the above false alarm; It seems like I have perfected a problem-solving technique known as "debugging through public embarassment". I just seem to catch agonizing problems the moment I write about them online or tell someone about them.

CLSQL:UPDATE-RECORDS-FROM-INSTANCE should NOT be fucked with; I am not sure how it's supposed to operate, but under MySQL, it will update all the records in a table and set them to the same slot-values as the instance. I.e. all identical records!

The feature I needed is cleanly implemented using WITH-TRANSACTIONS. Again, embarassed and sorry for the confusion.


I've always wanted to do sort of the opposite... That is to say, I've always wanted to compile Scheme to PHP. I make the claim that PHP is the web's assembly language. Or, at least it's portable assembly language.


Yeah, "apt-get install php" is much easier to type than "apt-get install sbcl perl ghc python ruby ..."... (The other langauges also all run faster, use less memory, and have more features.)

(And no, you should not compile your app into your frontend webserver. Use FastCGI or a reverse proxy!)


Javascript is the web's assembly language. PHP is the web's BASIC, down to its distribution method. BASIC was typed down from magazines and tutorials, PHP is google, cut and pasted.


You need varnish!




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: