Reply
Old 12-26-2007, 11:34 PM Why ;?
Extreme Talker

Posts: 205
This doesnt really relate to anything Im just curious.

Why does php still use ';'? It seems slightly archaic. Is it really necessary? Does it work faster having that at the end of each line as opposed to the server having to figure out when the line is up? Or is it more to keep in line with C and the ways people are use to programming.

Again, not complaining, just curious.
Truly is offline
Reply With Quote
View Public Profile
 
When You Register, These Ads Go Away!
     
Old 12-27-2007, 03:15 AM Re: Why ;?
Extreme Talker

Posts: 232
Location: United States
I think it's just one of those things where the language started with using line-ending semi-colons since it was originally inspired by C and Perl. At this point it would be too dramatic of a change to remove.
frost is offline
Reply With Quote
View Public Profile
 
Old 12-27-2007, 03:19 AM Re: Why ;?
Ultra Talker

Posts: 308
I think it is required if you want to allow a single statement to span multiple lines, otherwise we would have ambiguous cases just like javascript.
__________________
tiny url
dman_2007 is offline
Reply With Quote
View Public Profile Visit dman_2007's homepage!
 
Old 12-27-2007, 07:52 AM Re: Why ;?
tripy's Avatar
Fetchez la vache!

Posts: 1,924
Name: Thierry
Location: In the void
I don't see why it bothers you?

PHP as this syntax, others too.
Python doesn't, and use indentation to separate blocks, rather than { and }
plsql require the ; at the end, and to declare every variables, their types and their capacity before you use them, like c.

Different languages, different constraints.
Personally, I like the way PHP put constraints. Enough to not have something too messy, but not too much to still being easy.

In my memory, perl and visual basic are the most messy codes to read.
__________________
Listen to the ducky: "This is awesome!!!"

tripy is offline
Reply With Quote
View Public Profile
 
Old 12-27-2007, 08:14 AM Re: Why ;?
rogem002's Avatar
Webmaster Talker

Posts: 567
Name: Mike
Location: United Kingdom
Quote:
Originally Posted by frost View Post
I think it's just one of those things where the language started with using line-ending semi-colons since it was originally inspired by C and Perl. At this point it would be too dramatic of a change to remove.
I think frost has it about right. Personally I think I would get confused if it was done by lines.
__________________
Website Services
PHP Code:
if(Added_Talkupation($post) == TRUE){iHug($you);} 
rogem002 is offline
Reply With Quote
View Public Profile Visit rogem002's homepage!
 
Old 12-27-2007, 09:14 AM Re: Why ;?
dansgalaxy's Avatar
Eat, Sleep, Code

Latest Blog Post:
XDnet Starts Selling Domains!
Posts: 5,993
Name: Dan
Location: Swindon
i agree, PHP is my only real programming languagae,i have a little experience of VB and it does look confusing sometimes

it all comes down to coding styles, and how the authorer prefers to read and write code,

i absolutly HATE it when people use indentations.

and for if/else statments and things hate it when i see:

PHP Code:
if(Condition
{ echo 
'TEXZT' }
else { echo 
'text' 
i find it so messy and annouying!

i much prefer it when its spread out a little:
PHP Code:
if(condition)
{
echo 
"text";
}
else 
{
echo 
"vfd";

and the ; are helpful for finding when functions and "actions" etc end.

anyway i like em i just wish php could easily be used to make desktop apps!

Dan
__________________
Personal UK Webhosting
Get 25% of ANY shared package for life ~ Promo: webmaster-talk (only for members!)
dansgalaxy is offline
Reply With Quote
View Public Profile Visit dansgalaxy's homepage!
 
Old 12-27-2007, 09:45 AM Re: Why ;?
joder's Avatar
Flipotron

Posts: 6,446
Name: James
Location: In the ocean.
I like the semicolon as a statement terminator.

I will disagree with Dan, I can't stand it when people don't indent their code. With indentation, it is so much easier to find where blocks and sections begin and end.
joder is offline
Reply With Quote
View Public Profile
 
Old 12-27-2007, 10:57 AM Re: Why ;?
dansgalaxy's Avatar
Eat, Sleep, Code

Latest Blog Post:
XDnet Starts Selling Domains!
Posts: 5,993
Name: Dan
Location: Swindon
it depends, it just annouying me when i see it when you have like


CODE
CODE
Code

when its huge and you have to scrol veritcally i have nothing gainst small or reaosnable indentations in code, its just when its uge and messy i hate it
__________________
Personal UK Webhosting
Get 25% of ANY shared package for life ~ Promo: webmaster-talk (only for members!)
dansgalaxy is offline
Reply With Quote
View Public Profile Visit dansgalaxy's homepage!
 
Old 12-27-2007, 11:04 AM Re: Why ;?
Skilled Talker

Posts: 73
Name: Mattias Nordahl
Location: Sweden
I also disagree with Dan. This
PHP Code:
if(condition) {
    if(
condition) {
        if(
condition) {
            
some code here...
        } else {
            
something else
        }
    }
} else {
    if(
condition) {
        
some code here...
    }

is much easier to read than this
PHP Code:
if(condition)
{
if(
condition)
{
if(
condition)
{
some code here...
}
else
{
something else
}
}
}
else
{
if(
condition)
{
some code here...
}

And semi colons are great!
lizciz is offline
Reply With Quote
View Public Profile
 
Old 12-27-2007, 11:10 AM Re: Why ;?
joder's Avatar
Flipotron

Posts: 6,446
Name: James
Location: In the ocean.
Quote:
Originally Posted by dansgalaxy View Post
it depends, it just annouying me when i see it when you have like


CODE
CODE
Code

when its huge and you have to scrol veritcally i have nothing gainst small or reaosnable indentations in code, its just when its uge and messy i hate it
I use 4 spaces of indentation. I can't stand to look at code with at least 8 and one section ends up starting on the right side of the screen. Too much indentation is unreadable and can be just as bad as none.
joder is offline
Reply With Quote
View Public Profile
 
Old 12-27-2007, 11:43 AM Re: Why ;?
dansgalaxy's Avatar
Eat, Sleep, Code

Latest Blog Post:
XDnet Starts Selling Domains!
Posts: 5,993
Name: Dan
Location: Swindon
^ Thats what i ment...

btw i didnt mean the code thing to be like that the middle one was suposed to have a ton of spaces

@lizciz
i sort of agree but i think i would still prefer it all right align but with line breaks between each statment,

its just my pref i find your first example messy.

Also i tend to add comments to tell myslef (and others) what the curly brackets are closing if i have a few.

so i would have // END for IF CONDITION jsut makes it easier to line up and when i have too many or not enought closing brackets to track down the offending one!


WOOT GO COMMENTS!! scripts dont have enough of them!

Dan
__________________
Personal UK Webhosting
Get 25% of ANY shared package for life ~ Promo: webmaster-talk (only for members!)

Last edited by dansgalaxy : 12-27-2007 at 11:45 AM.
dansgalaxy is offline
Reply With Quote
View Public Profile Visit dansgalaxy's homepage!
 
Old 12-27-2007, 01:23 PM Re: Why ;?
tripy's Avatar
Fetchez la vache!

Posts: 1,924
Name: Thierry
Location: In the void
Quote:
Also i tend to add comments to tell myslef (and others) what the curly brackets are closing if i have a few.
I agree for that.
Especially when you have several if or case stuffed inside loops, in that case, both the indentation and the end-curl brace comments are useful.

And as for the indentation part, I keep it on 2 spaces (real spaces, not tabs).
I found that 4 are usually too much. You end up needing a 22" wide screen to display everything without line breaks...
__________________
Listen to the ducky: "This is awesome!!!"

tripy is offline
Reply With Quote
View Public Profile
 
Old 12-27-2007, 01:34 PM Re: Why ;?
dansgalaxy's Avatar
Eat, Sleep, Code

Latest Blog Post:
XDnet Starts Selling Domains!
Posts: 5,993
Name: Dan
Location: Swindon
^ DITTO!

Lol
__________________
Personal UK Webhosting
Get 25% of ANY shared package for life ~ Promo: webmaster-talk (only for members!)
dansgalaxy is offline
Reply With Quote
View Public Profile Visit dansgalaxy's homepage!
 
Old 12-28-2007, 02:49 AM Re: Why ;?
Skilled Talker

Posts: 73
Name: Mattias Nordahl
Location: Sweden
Thru some programming courses etc. in school (not php actually, but I figured it should be the same) I've learned that lines should be 70-80 letters wide, for a good readability. So you don't really need a big screen, just keep the lines short. Make use of the semi colon :P

I also agree about commenting your own code, where itis nessesarry. That is, where it can make understanding the code easier.
And I use 4 spaces for indention btw.
lizciz is offline
Reply With Quote
View Public Profile
 
Old 12-28-2007, 03:26 PM Re: Why ;?
rogem002's Avatar
Webmaster Talker

Posts: 567
Name: Mike
Location: United Kingdom
Commenting is useful as it reminds you of what your doing (Useful if you code while drunk/tried/high like me) the next day. I'm more of a functions based person mind (like if something is used more than once, make it a function).

I never really care about line length, Dreamweaver automatically makes the code fit my screen (and tells me where the line ends).

Laying out code nicely is really useful (*Rogem tells you coding nightmare storys*). Though if I'm selling the code to someone I do not trust I may make the code nasty to read, with no comments...But not generally.
__________________
Website Services
PHP Code:
if(Added_Talkupation($post) == TRUE){iHug($you);} 
rogem002 is offline
Reply With Quote
View Public Profile Visit rogem002's homepage!
 
Old 12-28-2007, 03:59 PM Re: Why ;?
joder's Avatar
Flipotron

Posts: 6,446
Name: James
Location: In the ocean.
Quote:
Originally Posted by rogem002 View Post
Laying out code nicely is really useful (*Rogem tells you coding nightmare storys*). Though if I'm selling the code to someone I do not trust I may make the code nasty to read, with no comments...But not generally.
Hehe. Here is my name in perl
Code:
''=~('(?{'.('-[@@^]'^'])).*}').'"'.('*]-__}'^'`<@:,_').',$/})')
I love unreadable code
joder is offline
Reply With Quote
View Public Profile
 
Old 12-28-2007, 04:35 PM Re: Why ;?
tripy's Avatar