Welcome, Guest. Please Login
 
  HomeHelpSearchLogin FAQ Radified Ghost.Classic Ghost.New Bootable CD Blog  
 
Pages: 1 2 3 4 
Send Topic Print
PHP and regular expressions (Read 62216 times)
Nigel Bree
Ex Member




Back to top
Re: PHP and regular expressions
Reply #15 - May 27th, 2008 at 1:06am
 
Well, crud. I mentioned linguistics and forgot to mentioned one of the funnest languages around - Inform. Seriously, just reading the manual written by Emily Short is a joy.

Those neato Lisp hackers at MIT delivered the goods in the 1970's creating a game built on Lisp's ability to wrangle natural language (parse Chomsky Grammars, or at least a passable collection of them). A game called Zork, which ran on everything from mainframes to the 120Kb floppy disk in an Apple ][ due to being compiled to run in an amazingly compact virtual machine (the Z-machine), which was the first of a truly astonishing series published by the company they formed, Infocom (their motto: Imagination Sold and Serviced Here).

And Graham Nelson has taken that amazing work, and it's sometimes spooky ability to work with the written word as well as print it, and performed the ultimate art of linguistic Jujitsu; turned the natural-language system created by those guys to understand the input to the games to the purpose of writing the games themselves.

Inform is written in a language targeting Z, and reads a description of a game world written as a novel to compile into a Z-machine (runnable with the exact same code that ran Zork in the 1970's). It's the ultimate expression of Donald Knuth's concept of Literate Programming.

Quote:
ZORK I: The Great Underground Empire
Copyright (c) 1981, 1982, 1983 Infocom, Inc. All rights reserved.
ZORK is a registered trademark of Infocom, Inc.
Revision 88 / Serial number 840726

West of House
You are standing in an open field west of a white house, with a boarded front
door.
There is a small mailbox here.

>open mailbox
Opening the small mailbox reveals a leaflet.

>read leaflet
(Taken)
"WELCOME TO ZORK!

ZORK is a game of adventure, danger, and low cunning. In it you will explore
some of the most amazing territory ever seen by mortals. No computer should be
without one!"

>


Inform sometimes has to strain a little to maintain the metaphor of writing a novel to express a program, but it's an amazing accomplishment nonetheless. If only I could use it instead of C++ at work Smiley
 
 
IP Logged
 

Rad
Radministrator
*****
Offline


Sufferin' succotash

Posts: 4090
Newport Beach, California


Back to top
Re: PHP and regular expressions
Reply #16 - Jun 15th, 2008 at 9:27pm
 
Just wanna say, Nigel, I'm still pluggin' away at learning PHP. Been distracted with legal things recently, but those should clear up in a month or so.

I'm digging it. One quote that stuck out called PHP » "The reigning king of web development."
 
WWW  
IP Logged
 
Nigel Bree
Ex Member




Back to top
Re: PHP and regular expressions
Reply #17 - Jun 15th, 2008 at 11:23pm
 
Heh. At some point in the near future I'll be writing a lot of PHP myself again; I need to port all my changes to DokuWiki (I did a HUGE amount of customization to it back on our internal site web when I moved us to that in 2003/2004) to the 2008 edition after reformulating the changes that I made which the base version hasn't caught up to as plugins against it.

[ And hopefully, this time I'll be able to contribute them back. Couldn't back in those days due to the hostile ex-PQ VP, but he's not ruining our lives any more. ]

Probably will have to be done after-hours though, like the first time around. Be nice to actually do some of this stuff on paid time for a change, but unless we hire more folks I'll never ever get a free hour in the office.

Incidentally, as for "king of web development" it's interesting to look at the stats for requests for languages to run with the Google App Engine (which is Python-based to start, largely because Google hired Guido van Rossum).

Note that Java, of all things, is the #1 requested thing; PHP second, with Ruby and Perl in the next two spots. The next language listed is the one I'd prefer it do over all the others, JavaScript (because it's a Lisp, so it's automatically more powerful than any non-Lisp, and unlike full Common Lisp or Smalltalk the fact it's the linchpin client-side for web development already makes it a win over them), but as you can see that's only the fifteenth issue overall.

Bear in mind that Java also might have picked up votes from people who really despise Java but who know they can at least use the JVM to run something better than Java itself, though (viz the 150-ish folks having also explicitly asked for the JVM separate from Java).
 
 
IP Logged
 
Rad
Radministrator
*****
Offline


Sufferin' succotash

Posts: 4090
Newport Beach, California


Back to top
Re: PHP and regular expressions
Reply #18 - Jun 15th, 2008 at 11:53pm
 
Quote:
At some point in the near future I'll be writing a lot of PHP myself again

Again? Didn't know you dabbled. I know you told me about Dokuwiki (I've visted the site several times.) But didn't know you actually worked with it.

I am not very familiar with the Google apps. I know Java is a popular language, but I don't find many Java apps on the web.

I read some things about JavaScript, as it pertain to web design, and because it is implemented in the browser, it's know to cause an awkward "flickering" is some instances .. after the web page loads .. but before the JS runs.

But you know way more about this stuff than me.

I've also been watching TortoiseSVN, which should be releasing v1.50 any day/week now. That seems like it would be a good launch pad.

http://tortoisesvn.net/
 
WWW  
IP Logged
 
Nigel Bree
Ex Member




Back to top
Re: PHP and regular expressions
Reply #19 - Jun 16th, 2008 at 2:07am
 
Rad wrote on Jun 15th, 2008 at 11:53pm:
But didn't know you actually worked with it.

One can cover a bit of ground when one is interested in something from a young age and is able to pursue that interest with monomaniacal intensity for several decades. I recently compared notes with a musician (singer/songwriter) also in his 40's, who I first got to know when he was performing while I was a student over 20 years ago; he got his first guitar when he was about 12, a similar age to when I chose computing/mathematics. And neither of us has (or likely will) ever stop trying to get better at what we have chosen as our life's direction.

The comparison is helped by the fact that just as all (Western, anyway) music is played on the same scale, computing has the single mathematical basis I talked about earlier.

Really there are only two major kinds of computer languages, and in the imperative group in particular which accounts for all the languages most working programmers can deal with, almost all of them are really similar in all but their surface aspects. They all are basically derivatives of the classics from the 50's and 60's - FORTRAN and Algol - to some degree, with perhaps a dash of string-processing mixed in for the more scripty ones (the notable progenitors of that sub-species being Ralph Griswold's SNOBOL and later Icon), and where they differ beyond this is merely to cut their cloth a little differently to tailor it for some application area.

Learn FORTRAN, something low-level like FORTH, something string-oriented, and something object-oriented, and you've basically covered almost everything any language in the imperative world can really throw at you - and then it's just a matter of ticking off the applied use of them in different problem domains; databases, concurrency, networking, user interfaces, and so forth. In the application areas some language may bring a certain ease (or be cumbersome) based on some specific built-in facility or other, but none of them really solve problems in a way that involves a truly major difference in how you think.

Now functional languages - particularly lazy-functional languages like, say Haskell, named another of the logicians working in the early 20th century on formal logic along with Church and Kleene (there is an important technique in the lambda calculus called "Currying" also named in his honor) - are another kettle of fish entirely, but then if you've gone through one of the related branches of mathematics (denotational semantics, category theory, or the like) then you've done the hard part for the bulk most of the entrants in this sub-group as well, although they do differ more from each other than the imperative group.

Even so, in this sub-field if you cover say Common Lisp, Prolog and Haskell, then you've seen a good chunk of what's on offer from this group and then you're just mastering the applied problem domains (albeit with a different spin; functional languages used functionally treat time in a fundamentally different way to imperative languages, and the most gnarly problem domains in the imperative world are those which involve wrangling time in some way).
 
 
IP Logged
 
Nigel Bree
Ex Member




Back to top
Re: PHP and regular expressions
Reply #20 - Jun 16th, 2008 at 2:09am
 
Rad wrote on Jun 15th, 2008 at 11:53pm:
it's know to cause an awkward "flickering" is some instances .. after the web page loads .. but before the JS runs.

That's not so much to do with Javascript-the-language, so much as it's a consequence of the Document Object Model and the poor integration between HTML and script generally when scripting was first retrofitted into HTML and browsers. This flickering is a consequence of the way that classic old-school Javascript is written to manipulate the base HTML document, how the browser responds to that, and the way that the page-load and rendering processes don't work together well.

In particular, you get this when the script is used to write raw HTML into sections of a page (via, say, document.write () which was one of the first things people did with Javascript to make pages change dynamically). Because browsers render ahead as they grab the document - which was essential in the mid-90's when 28k8 modems were still considered fancy - script that then retroactively changes parts of the page the browser had already made visible naturally means the browser has to undo its guesswork, with these ugly consequences.

Different browsers handle this different ways (early browsers flicker much more, IE7 and FF3 much less because they are very smart about repainting), but the essence of the tradeoff is that if the page is being changed too much then you have to stop the rendering-ahead of things that aren't static to stop this completely - it depends on the page itself and how you approach legacy browsers as to how you go about that, is all. Sometimes just a display:none style is all it takes, for instance, so that the container into which scripted content is put doesn't get visible ahead of time.

GMail, for instance, deals with all this by going through server-side user agent sniffing to determine whether to give rich or dumb content back (and they even have graded levels of dumb content) and in the richest case then basically goes through a landing page that loads all the important script before making anything else visible.
 
 
IP Logged
 

Nigel Bree
Ex Member




Back to top
Re: PHP and regular expressions
Reply #21 - Jun 17th, 2008 at 1:12am
 
By the way, one of the many good books which my great friend for many years Andrew Paxie - who works in the office across the hall from me - steered me to long with many others over the years is one by Simon Peyton-Jones called The Implementation of Functional Programming Languages.

Prentice-Hall who published so many of the Great Works of computer science (I've certainly got a heap of their white-and-red paperbacks in my stacks) have let the work go out of print but to balance this have let the copyright revert to the author - kudos to them - and although the TeX originals of the manuscript have been lost you can view a high-quality scan of the work online at the link above.

This is deep stuff indeed - although the elements are simple, being able to really see the meaning of the opening 25 pages and the amazing thing that is the Y combinator is an important milestone - and despite the research community having long moved on past this treatise you may note that things like ZF-expressions (list comprehensions based on the theory of set comprehensions) which this book treats as quite a simple thing are the very same as that is being marketed now with so much fanfare as LINQ in C#, over 25 years after their introduction in practical programming languages.
 
 
IP Logged
 
Rad
Radministrator
*****
Offline


Sufferin' succotash

Posts: 4090
Newport Beach, California


Back to top
Re: PHP and regular expressions
Reply #22 - Jun 17th, 2008 at 3:50pm
 
Knowing what you know, I take seriously all your suggestions .. tho I sometimes feel you over-estimate my intelligence. Smiley

Here are the 1st two sentences from your ref:

http://research.microsoft.com/~simonpj/Papers/slpj-book-1987/PAGES/001.HTM

Quote:
This book is about implementing functional programming languages using lazy graph reduction, and it divides into three parts.

The first part describes how to translate a high level functional language into an intermediate language, called the lamda calculus, including detailed coverage of pattern-matching and type-checking".

Q1: Are there (do they exist) such animals as NON-functional prgm'ing languages?
Q2: Why would anybody want to translate a high level language into a lower-level (intermediate) language? Higher is usually better than lower, no?
Q3: "THE lamda calculus"?? .. and not just (regular, ol') "lamda calculus"?
Q4: What patterns?

Maybe if I could sit next to you, and pick your brain .. I could proceed, but reading seems to present more questions than answers .. at least at this stage of my prgm'ing venture.

In learning PHP, I've come across references to 'C' .. and a book that keeps coming up in the "K&R" book:

http://www.amazon.com/C-Programming-Language-2nd-Ed/dp/0131103709/

Have you heard of this?

Seems that many languages evolve from C, no?
 
WWW  
IP Logged
 
Rad
Radministrator
*****
Offline


Sufferin' succotash

Posts: 4090
Newport Beach, California


Back to top
Re: PHP and regular expressions
Reply #23 - Jun 17th, 2008 at 4:10pm
 
on a less esoteric note .. are the terms 'functions' and 'statements' interchangable?

if not, how do they differ?

my book seems to use them interchangably, yet I doubt they are.
 
WWW  
IP Logged
 
Rad.Test
Technoluster
***
Offline


Rad's non-Admin test-profile
in Firefox

Posts: 108


Back to top
Re: PHP and regular expressions
Reply #24 - Jun 17th, 2008 at 6:20pm
 
Today I read about the importance of good documentation and was pointed to phpDocumentor:

http://www.phpdoc.org/

.. where I tried to glean insight on how to use. Eventually I made my way to a manual that is over 1,300 pages itself:

http://manual.phpdoc.org/

http://manual.phpdoc.org/PDFdefaultConverter/documentation.pdf

I mean, this is even bigger than my PHP/MySQL book, and it's a fatty (>1K pages).
 
 
IP Logged
 
Rad
Radministrator
*****
Offline


Sufferin' succotash

Posts: 4090
Newport Beach, California


Back to top
Re: PHP and regular expressions
Reply #25 - Jun 17th, 2008 at 8:54pm
 
Here's something I'm having trouble understanding .. an example from the book:

Code:
printf("%d bottles of tonic water cost $%f", 100, 43.20); 


Isn't it easier to simply write html/text » 100 bottles of tonic water cost $43.20 ??

I'm sure I'll see the light as I continue .. but right now, I fail the see the utility of outputting php strings to screen/browser. Seems easier to do it in html.
 
WWW  
IP Logged
 

Nigel Bree
Ex Member




Back to top
Re: PHP and regular expressions
Reply #26 - Jun 17th, 2008 at 9:53pm
 
First, a quick diversion to the ever-reliable Stevey, and his Portrait of a Noob. Along with an enormous number of user comments. Good read, as always.

Rad.Test wrote on Jun 17th, 2008 at 6:20pm:
Today I read about the importance of good documentation

Cool. It is important.

The only problem, unfortunately, being nailing down a useful notion of what "good" means, and more importantly to whom it applies.

Now, skill matters - but in relation to commentary in code or other forms of documentation, what really matters so much isn't the skill of the person writing the code, but the person who the commentary is one day going to be read by.

Who is that person? What is he (or she, naturally) looking at this code for anyway?

[ And for that second one, many of the answers lead to an inevitable follow-up: where the hell will I be then? ]

Of all the things you can describe in the code - who, what, when, where, why, and how - what are the ones that matter most to the purposes of that notional future reader?

The skill question comes in because the most contentious aspect of the commentary is how much of it is redundant duplication of things that are easily understandable from the code itself, and how much of it is describing all the things that aren't there in the code.

The other thing is that code is, in many settings, not the only artifact around. The identity of the person who wrote things? That's in the source-control system, right?. When they wrote it? Ditto? And there's why information going into the changelist summary in the source-control system too, yeah?

What if you've got a bug-tracking system in which there are summaries of future intent and plans made. What about a Wiki and forums? Indeed, it's likely that we have all of them, and they all link easily together thanks to the magic of the web.

What then, is the particular importance of the stuff that we write that goes into the code itself, and isn't kept for us elsewhere?

Those questions aren't actually all that easy to answer in the abstract, and often they aren't easy to answer in the particular either. And they especially aren't easy when you consider that writing genuinely readable and informative prose is actually quite a demanding skill in itself, and one that isn't necessarily correlated with those more mathematical skills involved in the wrangling of the code itself.

Everyone wants more documentation. Of course, it takes time (and therefore money, in a business context) to write, and it then also becomes an artifact that has to be maintained just like the code itself so it doesn't become out of date when the code changes.

[ And how rapidly does the code change? If really rapidly, maintaining the docs to match it adds to the same drag effect of sheer size that bedevils development. If really infrequently, then no-one is looking at the comments, so what did we put all that effort into writing them for? ]

Given all that, what do you do?

Me, I in practice I end up write a lot of commentary (relatively little in PHP or other kinds of script, lots and lots for C++). And I write huge honking change descriptions for the change-control system. And I use wikis and issue-trackers and such. And none of that text really describes things that can be determined by something who knows the language reading the code itself ether.

And who is the notional future reader am I writing it for? A future Me, pretty much, who I can therefore rely on to be perfectly capable of reading the code itself, and thus doesn't need a reference manual but does tend to forget all kinds of other stuff. And since I've maintained most of the code I've written for many, many years, I've slowly learned what it is that I do tend to forget and need to re-learn.

In fact, that's a really important source of comments. Maintaining things. When I come to revisit something later on, if there's anything that *isn't* obvious to me later on, when I go to the effort of re-discovering it *that's* something I always put into the code to save myself time if it happens again (as it often does, because the parts of systems that need maintenance at all tend to need it on an ongoing basis).
 
 
IP Logged
 
Nigel Bree
Ex Member




Back to top
Re: PHP and regular expressions
Reply #27 - Jun 17th, 2008 at 9:56pm
 
Rad wrote on Jun 17th, 2008 at 8:54pm:
Isn't it easier to simply write html/text » 100 bottles of tonic water cost $43.20 ??

Yup. Sure would be.

The example makes more sense if the source of the number of bottles was an entry form, though. And if the price came from a database. And you're writing the PHP for the shopping cart for your store... and so you replace those literal numbers with variables that contain the data you got from those other sources.
 
 
IP Logged
 
Nigel Bree
Ex Member




Back to top
Re: PHP and regular expressions
Reply #28 - Jun 17th, 2008 at 10:03pm
 
Hey, good questions. I linked to that book not as a serious suggestion that you learn Haskell or anything, but more for mathematical interest, by the way.

Rad wrote on Jun 17th, 2008 at 3:50pm:
Q1: Are there (do they exist) such animals as NON-functional prgm'ing languages?


Yup. Heaps. They vastly outnumber the functional kind, in fact, which are comparatively a small niche.

The common kind are called imperative, because rather than trying to describe things in terms of mathematical equations, you're treating the computer like a mindless robot slave, telling it step by step what to do and in precisely what order.

1. Pick up the trash can.
2. Move to the door.
3. Open the door.
4. Go through the door and out to the curb.
5. Put down the trash can.
6. Go back to the door.
7. Go through the door.
8. Close the door.

That's ultimately what most programming tends to be like, although we're ordering our mindless robot slaves to move strings of text from place to place instead.
 
 
IP Logged
 
Rad
Radministrator
*****
Offline


Sufferin' succotash

Posts: 4090
Newport Beach, California


Back to top
Re: PHP and regular expressions
Reply #29 - Jun 17th, 2008 at 10:26pm
 
Quote:
The example makes more sense if the source of the number of bottles was an entry form, though. And if the price came from a database. And you're writing the PHP for the shopping cart for your store... and so you replace those literal numbers with variables that contain the data you got from those other sources.

Okay, I can see that. That's clearly better.
 
WWW  
IP Logged
 
Pages: 1 2 3 4 
Send Topic Print