My teacher is teaching HORRIBLE THINGS

A place to discuss the implementation and style of computer programs.

Moderators: phlip, Moderators General, Prelates

mrkite
Posts: 336
Joined: Tue Sep 04, 2007 8:48 pm UTC

Re: My teacher is teaching HORRIBLE THINGS

Postby mrkite » Wed Mar 11, 2009 3:04 am UTC

The thing about 32bit transparency in PNGs isn't that they "break in ie6" it's just that ie6 doesn't composite the PNG on the page.

If you use an alpha channel in a PNG, IE6 will composite it on the BKGd color. So if you have something that fades to transparent, and the BKGd color in the PNG is set to, say, white, IE6 will fade to white.

This allows you to use PNGs with alpha channel and have them degrade relatively gracefully in IE6.

User avatar
OOPMan
Posts: 314
Joined: Mon Oct 15, 2007 10:20 am UTC
Location: Cape Town, South Africa

Re: My teacher is teaching HORRIBLE THINGS

Postby OOPMan » Wed Mar 11, 2009 7:00 am UTC

Xanthir wrote:I'm strict about closing my elements, because I know how much trouble the unclosed element handling causes when you're trying to add new elements to the language.

Plus, this way I don't have to remember which elements will self-close. It's all symmetric.


Another reason to be strict about closing elements is that unclosed elements tend to have unpredictable effects on the DOM which cause major crap when you're working on the DOM with JS.

Maybe you guys who don't close your XYZ elements know something I don't about this, but in my experience it's not so fun trying to debug an AJAX issue that is actually a DOM issue.
Image

Image

User avatar
Cosmologicon
Posts: 1806
Joined: Sat Nov 25, 2006 9:47 am UTC
Location: Cambridge MA USA
Contact:

Re: My teacher is teaching HORRIBLE THINGS

Postby Cosmologicon » Wed Mar 11, 2009 11:45 am UTC

OOPMan wrote:Maybe you guys who don't close your XYZ elements know something I don't about this, but in my experience it's not so fun trying to debug an AJAX issue that is actually a DOM issue.

What I know is that some elements have optional close tags and some don't. I wouldn't leave a div or a b unclosed. When they're optional, they won't cause any problems for the DOM to leave them off. I'm pretty sure that you've never encountered a DOM issue on a page with valid HTML.

User avatar
jordan
Posts: 106
Joined: Thu Mar 15, 2007 2:41 pm UTC
Location: Coventry

Re: My teacher is teaching HORRIBLE THINGS

Postby jordan » Fri Mar 13, 2009 10:19 pm UTC

My employers recently opened a mobiles and accessories shop in Lancaster; if you look at the source of the (ugly and hastily-designed) holding page, you'll see that I miss out quite a few optional tags. In my opinion, it remains pretty readable and easily comprehensible—at least to anyone who knows HTML well enough to realise that it's perfectly legitimate to omit these tags.

The basic thing to wrap your mind around is that in HTML, a tag != an element; tags only indicate the opening and closing of an element which may be implied anyway. Once you realise that, it makes perfect sense that, in unambiguous situations, you might wish to save a few bytes. The savings are not massive, but they're noticeable for e.g. large tables, and it's no more difficult to read or write.



Incidentally, just for those of you who shiver at the thought of missing tags, a minimal valid HTML 4.01 Strict document reads something like this:

Code: Select all

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"><title//<p>


The funny "<title//" bit exploits a little-used feature of SGML called NET-tags, which were a shorthand to save typing. (Beware: no browser I've tested implements them correctly.) Note also that both the start tags and the end tags for the html, head and body elements are optional in HTML 4.01—believe it or not, browsers don't seem to have a problem with this, and neither do I as you can see from my code.

In contrast, a minimal XHTML 1.0 Strict document would read:

Code: Select all

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><title></title></head><body><p></p></body></html>


Notice that I had to include explicit opening and closing tags for all elements, the system identifier and the XML namespace on the document root. This, in my opinion, is yet another point in favour of HTML: it might be easier to write a parser, but unless you seriously need the functionality of XML, it seems like pointless metadata.

User avatar
Xanthir
My HERO!!!
Posts: 5423
Joined: Tue Feb 20, 2007 12:49 am UTC
Location: The Googleplex
Contact:

Re: My teacher is teaching HORRIBLE THINGS

Postby Xanthir » Fri Mar 13, 2009 10:30 pm UTC

Ignoring the DOCTYPE, though (because DOCTYPEs are a failure, which is why HTML5 just uses "<!DOCTYPE html>"), on a normal page are you really going to go without a head/body/etc.? No. The differences are absolutely minimal in practice.

And, since I can, this is the minimal HTML5 document:
<!DOCTYPE html><title></title><p>
(defun fibs (n &optional (a 1) (b 1)) (take n (unfold '+ a b)))

User avatar
jordan
Posts: 106
Joined: Thu Mar 15, 2007 2:41 pm UTC
Location: Coventry

Re: My teacher is teaching HORRIBLE THINGS

Postby jordan » Fri Mar 13, 2009 11:32 pm UTC

Xanthir wrote:[…]DOCTYPEs are a failure, which is why HTML5 just uses "<!DOCTYPE html>"[.]


Agreed, the DOCTYPE is a pretty fail construct.

Xanthir wrote:[O]n a normal page are you really going to go without a head/body/etc.? No. The differences are absolutely minimal in practice.


Honestly, I already do. Of the three, my standard template contains only an opening html element on which the document language is set to British English. I see no use in explicitly tagging implicit elements in trivial contexts. In this particular instance, the only time that there might be an ambiguity is when adding a script element to the document head, which I almost never do in practise since Javascripts should normally be placed at the end of the document.

It's not something on which I hold strong views; a few bytes here or there doesn't really bother me. It just so happens that I have a moderate preference for excising superfluous code, so I tend to omit optional tags. :)


Edited to add: it's interesting to see the minimal HTML 5 document! I do hope it takes off soon!

User avatar
phlip
Restorer of Worlds
Posts: 7573
Joined: Sat Sep 23, 2006 3:56 am UTC
Location: Australia
Contact:

Re: My teacher is teaching HORRIBLE THINGS

Postby phlip » Sat Mar 14, 2009 1:31 am UTC

jordan wrote:(Beware: no browser I've tested implements them correctly.)

As mentioned, lynx does:

Code: Select all

phlip@boris:/tmp$ cat>tmp.html
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"><title//<p>This word is <b/bold/.
phlip@boris:/tmp$ lynx -preparsed -source tmp.html
<TITLE></TITLE><P>This word is <B>bold</B>.

</P>
But it still ignores the standard and does the defacto thing for <tag/>:

Code: Select all

phlip@boris:/tmp$ cat>tmp.html
a <br> b <br/ c <br/> d
phlip@boris:/tmp$ lynx -preparsed -source tmp.html
a <BR> b <BR> c <BR> d
(the strict standard thing would be "a <BR> b <BR> c <BR>> d")

Code: Select all

enum ಠ_ಠ {°□°╰=1, °Д°╰, ಠ益ಠ╰};
void ┻━┻︵​╰(ಠ_ಠ ⚠) {exit((int)⚠);}
[he/him/his]

mrkite
Posts: 336
Joined: Tue Sep 04, 2007 8:48 pm UTC

Re: My teacher is teaching HORRIBLE THINGS

Postby mrkite » Sat Mar 14, 2009 1:39 am UTC

jordan wrote:The funny "<title//" bit exploits a little-used feature of SGML called NET-tags, which were a shorthand to save typing. (Beware: no browser I've tested implements them correctly.)


w3c explicitly warns against using NET tags

http://www.w3.org/TR/html4/appendix/not ... mlfeatures

User avatar
jordan
Posts: 106
Joined: Thu Mar 15, 2007 2:41 pm UTC
Location: Coventry

Re: My teacher is teaching HORRIBLE THINGS

Postby jordan » Sat Mar 14, 2009 1:47 am UTC

Thanks Philip, I must have missed that post! For some reason it never even occurred to me to test SGML shorthand in lynx.

And indeed, Mr Kite. The only remotely justifiable application I've seen of the NET tag shorthand is, well, demonstrating how to write a minimal HTML document. :)

User avatar
phlip
Restorer of Worlds
Posts: 7573
Joined: Sat Sep 23, 2006 3:56 am UTC
Location: Australia
Contact:

Re: My teacher is teaching HORRIBLE THINGS

Postby phlip » Sat Mar 14, 2009 2:29 am UTC

mrkite wrote:w3c explicitly warns against using NET tags

http://www.w3.org/TR/html4/appendix/not ... mlfeatures

Hmm... of those four shorttag features, Lynx supports three:

Code: Select all

phlip@boris:/tmp$ cat>tmp.html
<p<b<i/bold and italic/ just bold</> normal
phlip@boris:/tmp$ lynx -preparsed -source tmp.html
<P><B><I>bold and italic</I> just bold</B> normal

</P>
I'm not sure what <>, the empty start tag, is supposed to do... lynx just spits it out as text.

It also handles <![INCLUDE[]]> and <![IGNORE[]]>, whatever the point of those are, and seems to skip over processing instructions properly.

Code: Select all

enum ಠ_ಠ {°□°╰=1, °Д°╰, ಠ益ಠ╰};
void ┻━┻︵​╰(ಠ_ಠ ⚠) {exit((int)⚠);}
[he/him/his]

User avatar
jordan
Posts: 106
Joined: Thu Mar 15, 2007 2:41 pm UTC
Location: Coventry

Re: My teacher is teaching HORRIBLE THINGS

Postby jordan » Sat Mar 14, 2009 2:15 pm UTC

The empty start tag basically repeats the last tag used:

Code: Select all

<p>First paragraph.
<>Second paragraph.


As for marked instructions, you should already be using them if you include inline Javascript, say, in an XHTML document—specifically with the CDATA keyword. Otherwise, any "&," "&&," "<" or ">" operations, for example, need to be encoded as entities or processing will fail—if you are serving the document with the correct MIME-type, that is. (This also applies to the parent selector if you use inline CSS.) The IGNORE and INCLUDE instructions aren't so useful most of the time; they simply direct the processor to, well, leave content out or include it. It's more useful if you're writing a fully-featured SGML document which should include different content in different contexts; you can use entities in the marked instructions, setting their values to IGNORE or INCLUDE in the internal subset at the beginning of the document depending upon the context, instead of applying a more complex algorithm that requires going through the whole document.

(Important note: I have never, ever seen anyone attempt this in an HTML document, at least not one intended for public consumption.)

User avatar
Dropzone
Posts: 405
Joined: Sun Dec 30, 2007 10:12 pm UTC
Location: North Lincs., UK

Re: My teacher is teaching HORRIBLE THINGS

Postby Dropzone » Sat Mar 14, 2009 3:00 pm UTC

jordan wrote:(This also applies to the parent selector if you use inline CSS.)

I don't think it does, at least if I'm reading the specifications correctly. ">" only needs to be escaped if it occurs in the string "]]>", and I don't think there's any way that could occur in valid CSS.

User avatar
jordan
Posts: 106
Joined: Thu Mar 15, 2007 2:41 pm UTC
Location: Coventry

Re: My teacher is teaching HORRIBLE THINGS

Postby jordan » Sat Mar 14, 2009 3:59 pm UTC

Dropzone wrote:
jordan wrote:(This also applies to the parent selector if you use inline CSS.)

I don't think it does, at least if I'm reading the specifications correctly. ">" only needs to be escaped if it occurs in the string "]]>", and I don't think there's any way that could occur in valid CSS.

Now, that is interesting. I always read that one must always escape ampersands and angle brackets. You're correct, however; one does not need to encode ">", and this validates:

Code: Select all

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-gb">
<head>
<title>Quick test</title>
</head>
<body>
<p>></p>
</body>
</html>


Thanks for that, I've learned something I didn't know about SGML. :)

As a complete side-note, it is just barely possible to get the string "]]>" into valid CSS, although (as with NET tags) the only probable application is to demonstrate some obscure point…

Spoiler:
Simply, use the parent selector combined with an attribute selector that finishes with an escaped "]":

Code: Select all

a[b\]]>c{}


Or, even more simply, slip it into a quoted value:

Code: Select all

a{content:"]]>"}
@import "]]>";


For import rules, you can even get rid of the quotes:

Code: Select all

@import url(]]>);

User avatar
Xanthir
My HERO!!!
Posts: 5423
Joined: Tue Feb 20, 2007 12:49 am UTC
Location: The Googleplex
Contact:

Re: My teacher is teaching HORRIBLE THINGS

Postby Xanthir » Sat Mar 14, 2009 5:15 pm UTC

jordan wrote: In this particular instance, the only time that there might be an ambiguity is when adding a script element to the document head, which I almost never do in practise since Javascripts should normally be placed at the end of the document.

Ah, that's probably a big difference between us, then. I use jQuery, which gives me a proper "wait till the document is loaded" ability, so I put all my scripts in the head where they belong. Putting them in the body is a hack because of bad support for such abilities in core javascript.

It's not something on which I hold strong views; a few bytes here or there doesn't really bother me. It just so happens that I have a moderate preference for excising superfluous code, so I tend to omit optional tags. :)

Yeah, like I said before, I prefer not having to memorize which elements can have their endtags omitted, so I just put them all in. Plus, as noted, I've seen firsthand the difficulties that supporting end-tag omission causes when trying to extend the language while maintaining backwards compatibility.

Edited to add: it's interesting to see the minimal HTML 5 document! I do hope it takes off soon!

Many features of HTML5 are already usable, and many more will be available in the next versions of the browsers. FF3.1, frex, adds explicit support for the new <article>, <section>, etc. elements. I think Safari 3 already handles them; Safari 4 certainly will. IE7 and higher can handle them with a javascript shim. I'm not sure about Opera. <video> and <audio> will come into proper support over the next 2-3 years as well, I think. LocalStorage is already available in several browsers, which is awesome.
(defun fibs (n &optional (a 1) (b 1)) (take n (unfold '+ a b)))

mountaingoat
Posts: 80
Joined: Wed Aug 01, 2007 6:01 am UTC

Re: My teacher is teaching HORRIBLE THINGS

Postby mountaingoat » Sat Mar 14, 2009 10:41 pm UTC

In my web design class, we used Dreamweaver exclusively, and only dealt with the WYSIWYG portion of it. We never talked about tags of any sort.

Usually, I'd be upset about something like that, but honestly I wasn't expecting much at all.
Anyway, it was a class my senior year right before an end of the day study hall, so needless to say, I skipped a lot. My teacher was cool with it though.

User avatar
headprogrammingczar
Posts: 3072
Joined: Mon Oct 22, 2007 5:28 pm UTC
Location: Beaming you up

Re: My teacher is teaching HORRIBLE THINGS

Postby headprogrammingczar » Sat Mar 14, 2009 11:57 pm UTC

I can only imagine the abuse that would come from making an <audio> tag easy to use.
<quintopia> You're not crazy. you're the goddamn headprogrammingspock!
<Weeks> You're the goddamn headprogrammingspock!
<Cheese> I love you

User avatar
ninjacore
Posts: 213
Joined: Fri Jan 23, 2009 8:05 pm UTC
Location: Washington, USA
Contact:

Re: My teacher is teaching HORRIBLE THINGS

Postby ninjacore » Sun Mar 15, 2009 12:30 am UTC

the web design teacher i had in high school wasn't really great but he started me off right. One of the first things he directed us to do was go to htmlgoodies.com and start there with notepad.
Since I learn better on my own anyway it was a good thing he did that. I've seen people struggle with wysiwyg because they didn't know what was going on behind the scenes and couldn't figure out why things didn't work.
__________________

Wars are inherently exercises in unleashing and restraining chaos. The clash of opposing sides unleashes primal passions, which can only be controlled through enormous effort.

User avatar
SirHoundalot
Posts: 69
Joined: Sat Mar 29, 2008 1:56 pm UTC

Re: My teacher is teaching HORRIBLE THINGS

Postby SirHoundalot » Sun Mar 15, 2009 1:28 am UTC

Xanthir wrote:
jordan wrote: In this particular instance, the only time that there might be an ambiguity is when adding a script element to the document head, which I almost never do in practise since Javascripts should normally be placed at the end of the document.

Ah, that's probably a big difference between us, then. I use jQuery, which gives me a proper "wait till the document is loaded" ability, so I put all my scripts in the head where they belong. Putting them in the body is a hack because of bad support for such abilities in core javascript.


It's perfectly valid to put script in the body of the document. In fact, Yahoo's performance team specifically recommend it
Image

User avatar
Xanthir
My HERO!!!
Posts: 5423
Joined: Tue Feb 20, 2007 12:49 am UTC
Location: The Googleplex
Contact:

Re: My teacher is teaching HORRIBLE THINGS

Postby Xanthir » Sun Mar 15, 2009 2:19 am UTC

headprogrammingczar wrote:I can only imagine the abuse that would come from making an <audio> tag easy to use.

It's not like @bgsound. It's just a built-in browser-agnostic audio player, like <video> is a video player. Nothing more than you'd see on any audio streaming site, just without depending on a plugin like Flash, and consistent across a particular browser. And easy as *hell* to use. <audio src="myaudiofile.ogg">Maybe fallback content?</audio>
(defun fibs (n &optional (a 1) (b 1)) (take n (unfold '+ a b)))

vatar
Posts: 118
Joined: Wed Dec 31, 2008 4:58 pm UTC

Re: My teacher is teaching HORRIBLE THINGS

Postby vatar » Sun Mar 15, 2009 5:26 am UTC

SirHoundalot wrote:It's perfectly valid to put script in the body of the document. In fact, Yahoo's performance team specifically recommend it

I usually don't take performance tips from people who use PHP. :)

User avatar
jordan
Posts: 106
Joined: Thu Mar 15, 2007 2:41 pm UTC
Location: Coventry

Re: My teacher is teaching HORRIBLE THINGS

Postby jordan » Sun Mar 15, 2009 12:09 pm UTC

Sir Houndalot correctly identified why I put my scripts at the bottom—not to have JS run as soon as the DOM is loaded, but so that they don't block parallel downloads.

Incidentally, Xanthir, I'm just moving over to jQuery. I admit, for a while I looked down a little on framework programmers; why use tens of kilobytes for a job you can do in four? Then I realised that my own collection of utilities was fast becoming just as heavyweight as a small framework, and besides, there was a good chance people would already have the minified, gzipped copy of jQuery hosted by Google in their browser cache anyway. (As Neilsen puts it, people spend most of their time on other websites.) So I've caved, and I can't tell you just how simply fabulous it feels; I'm spending so much more time just doing stuff, instead of thinking about how to do it.

User avatar
Xanthir
My HERO!!!
Posts: 5423
Joined: Tue Feb 20, 2007 12:49 am UTC
Location: The Googleplex
Contact:

Re: My teacher is teaching HORRIBLE THINGS

Postby Xanthir » Sun Mar 15, 2009 1:43 pm UTC

That was *precisely* my evolution, jordan. I started out looking at it with disdain, then accumulated far too many utilities, then switched, and now can't imagine ever going back.
(defun fibs (n &optional (a 1) (b 1)) (take n (unfold '+ a b)))

User avatar
SirHoundalot
Posts: 69
Joined: Sat Mar 29, 2008 1:56 pm UTC

Re: My teacher is teaching HORRIBLE THINGS

Postby SirHoundalot » Sun Mar 15, 2009 2:42 pm UTC

Same here - jQuery has actually made client-side scripting fun!
Image

User avatar
TheAmazingRando
Posts: 2308
Joined: Thu Jan 03, 2008 9:58 am UTC
Location: San Diego, CA

Re: My teacher is teaching HORRIBLE THINGS

Postby TheAmazingRando » Sun Mar 15, 2009 9:55 pm UTC

afarnen wrote:EDIT: BTW since when is writing simple Java programs considered to be a course in "Computer Science"?
Despite the hatred some people seem to have for it, Java is a real programming language that real programmers use to develop real software. AP Computer Science is (I believe) meant to replace an introductory programming course. At many colleges and universities, this would be taught in Java (though it seems like many are moving towards Python). These classes are about teaching fundamental programming concepts. Loops, conditionals, function calls, and basic object-oriented concepts like creating objects, class vs object methods, and inheritance. "Writing simple java programs" covers all of these things.

The purpose of a class like this is to get you used to the mindset and general techniques of programming. In my experience, a lot of classes teach outdated HTML, not to give their students relevant information and good design practices, but to get them used to the idea of writing code, of the difference between what you write and what you get. Even if they were teaching perfect HTML, that isn't really enough to make a website, unless you want static content and a table or frame-based layout. It isn't about the language, it's about the ideas. They wouldn't be making any "real" websites without more education anyway, and it isn't like it would take more than a single course to set them straight, so it's not like they're being hopelessly corrupted. With this in mind, who cares if they learn how to make text scroll across the screen, or aren't coding to W3C standard?


Now, if you want a terrible teacher: My friend's C professor told the student that longs are always 64 bit. Then, in the first assignment (the "hello world" equivalent), he had them calculate a number that wouldn't fit inside a signed int, without teaching them about overflow. Then, he had them print it out in a printf, without telling them that unsigned ints had a separate format code.

User avatar
phlip
Restorer of Worlds
Posts: 7573
Joined: Sat Sep 23, 2006 3:56 am UTC
Location: Australia
Contact:

Re: My teacher is teaching HORRIBLE THINGS

Postby phlip » Sun Mar 15, 2009 11:00 pm UTC

Computer Science != Programming, though. Teaching Java as an introductory programming course, fine... it's not the best option, but it does the job. But as a CS course?

Sure, knowing how to program is useful for CS (and knowing CS is useful for programming). Knowing maths is important to physics, too... but they don't call a course on calculus an "intro to physics course" just 'cause you're doing a physics degree...

Code: Select all

enum ಠ_ಠ {°□°╰=1, °Д°╰, ಠ益ಠ╰};
void ┻━┻︵​╰(ಠ_ಠ ⚠) {exit((int)⚠);}
[he/him/his]

User avatar
TheAmazingRando
Posts: 2308
Joined: Thu Jan 03, 2008 9:58 am UTC
Location: San Diego, CA

Re: My teacher is teaching HORRIBLE THINGS

Postby TheAmazingRando » Sun Mar 15, 2009 11:42 pm UTC

The first required class (the prerequisite to all others) in my Computer Science degree was an intro to programming class, as has been the case with people I've spoken with at different universities. If the purpose of the AP class (well, technically, the AP test) is to take the place of an introductory college course, it seems reasonable that for AP Computer Science they would choose the course most programs start with.

User avatar
awec
Posts: 48
Joined: Fri Dec 12, 2008 1:48 am UTC

Re: My teacher is teaching HORRIBLE THINGS

Postby awec » Mon Mar 16, 2009 1:49 am UTC

Closing tags and indenting code makes code a hundred times easier to read.

User avatar
Why Two Kay
Posts: 266
Joined: Sun Mar 23, 2008 6:25 pm UTC
Location: Plano, TX
Contact:

Re: My teacher is teaching HORRIBLE THINGS

Postby Why Two Kay » Mon Mar 16, 2009 5:34 pm UTC

phlip wrote:Computer Science != Programming, though. Teaching Java as an introductory programming course, fine... it's not the best option, but it does the job. But as a CS course?

Sure, knowing how to program is useful for CS (and knowing CS is useful for programming). Knowing maths is important to physics, too... but they don't call a course on calculus an "intro to physics course" just 'cause you're doing a physics degree...


Technically AP Computer Science I (A) is a programming class. AP Computer Science II (AB) is closer to computer science because it is essentially a class in data structures. We spend the entire year working on writing our own queues, stacks, binary search trees, heaps, etc. We discuss big 'O', memory requirements, etc. All programming is assumed to already have been learned in APCSI. The AB test is being phased out after this year though, so then AP CS will be just programming.
tl;dr - I said nothing important.

User avatar
OOPMan
Posts: 314
Joined: Mon Oct 15, 2007 10:20 am UTC
Location: Cape Town, South Africa

Re: My teacher is teaching HORRIBLE THINGS

Postby OOPMan » Wed Mar 18, 2009 6:55 am UTC

vatar wrote:
SirHoundalot wrote:It's perfectly valid to put script in the body of the document. In fact, Yahoo's performance team specifically recommend it

I usually don't take performance tips from people who use PHP. :)


Meaning?
Image

Image

User avatar
headprogrammingczar
Posts: 3072
Joined: Mon Oct 22, 2007 5:28 pm UTC
Location: Beaming you up

Re: My teacher is teaching HORRIBLE THINGS

Postby headprogrammingczar » Wed Mar 18, 2009 12:50 pm UTC

Meaning PHP is about as optimized as Bubble Sort.
<quintopia> You're not crazy. you're the goddamn headprogrammingspock!
<Weeks> You're the goddamn headprogrammingspock!
<Cheese> I love you

User avatar
Emu*
Posts: 689
Joined: Mon Apr 28, 2008 9:47 am UTC
Location: Cardiff, UK
Contact:

Re: My teacher is teaching HORRIBLE THINGS

Postby Emu* » Wed Mar 18, 2009 8:13 pm UTC

Aah the sweet smell of ignorance.
Cosmologicon wrote:Emu* implemented a naive east-first strategy and ran it for an hour, producing results that rivaled many sophisticated strategies, visiting 614 cells. For this, Emu* is awarded Best Deterministic Algorithm!

User avatar
OOPMan
Posts: 314
Joined: Mon Oct 15, 2007 10:20 am UTC
Location: Cape Town, South Africa

Re: My teacher is teaching HORRIBLE THINGS

Postby OOPMan » Thu Mar 19, 2009 6:55 am UTC

headprogrammingczar wrote:Meaning PHP is about as optimized as Bubble Sort.


Obviously someone has never done any serious PHP development.

Do some research on thinks like:
  • XDebug
  • XCache
  • APC
  • Memcached
  • Quercus

and then get back to me. Last time I checked, PHP in the correct environment is a hell of a lot faster than
any of the alternatives (Although I *think* Python comes a near second or is neck-and-neck).
Image

Image

sje46
Posts: 4730
Joined: Wed May 14, 2008 4:41 am UTC
Location: New Hampshire

Re: My teacher is teaching HORRIBLE THINGS

Postby sje46 » Wed Mar 25, 2009 9:50 pm UTC

My web design teacher is teaching us to do this:

Code: Select all

<style>
.
.
.
</style>

Instead of this

Code: Select all

<style type="text/css">
etc

Is this a bad habit? Should I do it the longer way?
General_Norris: Taking pride in your nation is taking pride in the division of humanity.
Pirate.Bondage: Let's get married. Right now.

DivideByZero
Posts: 56
Joined: Sun Oct 19, 2008 4:04 pm UTC

Re: My teacher is teaching HORRIBLE THINGS

Postby DivideByZero » Wed Mar 25, 2009 9:59 pm UTC

My teacher has taught me to use brackets like this:

Code: Select all

function()
{
...
}


There's obviously nothing wrong but every online source (including the java website per se) uses a different notation:

Code: Select all

function(){
...
}


Its just really annoying when I have to convert from the latter one to the former just so I can see it the way I originally learned it.

User avatar
Emu*
Posts: 689
Joined: Mon Apr 28, 2008 9:47 am UTC
Location: Cardiff, UK
Contact:

Re: My teacher is teaching HORRIBLE THINGS

Postby Emu* » Thu Mar 26, 2009 1:15 am UTC

sje46 wrote:My web design teacher is teaching us to do this:

Code: Select all

<style>
.
.
.
</style>

Instead of this

Code: Select all

<style type="text/css">
etc

Is this a bad habit? Should I do it the longer way?


Doesn't matter in most browsers, but it's probably not valid, and may become a problem if some other styling language becomes common. (XSL:FO?)
Cosmologicon wrote:Emu* implemented a naive east-first strategy and ran it for an hour, producing results that rivaled many sophisticated strategies, visiting 614 cells. For this, Emu* is awarded Best Deterministic Algorithm!

User avatar
Why Two Kay
Posts: 266
Joined: Sun Mar 23, 2008 6:25 pm UTC
Location: Plano, TX
Contact:

Re: My teacher is teaching HORRIBLE THINGS

Postby Why Two Kay » Thu Mar 26, 2009 1:42 am UTC

DivideByZero wrote:My teacher has taught me to use brackets like this:

Code: Select all

function()
{
...
}


There's obviously nothing wrong but every online source (including the java website per se) uses a different notation:

Code: Select all

function(){
...
}


Its just really annoying when I have to convert from the latter one to the former just so I can see it the way I originally learned it.


This is actually highly debated by many different people. There is probably a thread in religious wars about it.

(I prefer the former, I like my braces on their own lines because of the way my editor highlights and draws dotted lines straight down from one to the other. It helps, it really does.)
tl;dr - I said nothing important.

User avatar
phlip
Restorer of Worlds
Posts: 7573
Joined: Sat Sep 23, 2006 3:56 am UTC
Location: Australia
Contact:

Re: My teacher is teaching HORRIBLE THINGS

Postby phlip » Thu Mar 26, 2009 2:14 am UTC

Why Two Kay wrote:This is actually highly debated by many different people. There is probably a thread in religious wars about it.

There is. It will not be continued here.

As for the style/@type, perhaps a better analogy is the same attribute on the script tag... 99% of scripts out there are JavaScript, but that's not the only scripting language that exists... it's just the only one that's common among different browsers. IE, for instance, will accept several languages... JavaScript, JScript (it's like JavaScript, except different!) and VBScript (yes, it's as bad as it sounds). The old way to say which one was in a specific script tag was with <script language="Javascript">... but the standardised way to do it now is <sytle type="text/javascript">. The same applies to any tag where you're inlining non-HTML data (currently just script and style), you should put in the MIME type of the inline content.

Code: Select all

enum ಠ_ಠ {°□°╰=1, °Д°╰, ಠ益ಠ╰};
void ┻━┻︵​╰(ಠ_ಠ ⚠) {exit((int)⚠);}
[he/him/his]

User avatar
hotaru
Posts: 1045
Joined: Fri Apr 13, 2007 6:54 pm UTC

Re: My teacher is teaching HORRIBLE THINGS

Postby hotaru » Thu Mar 26, 2009 2:31 am UTC

phlip wrote:As for the style/@type, perhaps a better analogy is the same attribute on the script tag... 99% of scripts out there are JavaScript, but that's not the only scripting language that exists... it's just the only one that's common among different browsers. IE, for instance, will accept several languages... JavaScript, JScript (it's like JavaScript, except different!) and VBScript (yes, it's as bad as it sounds). The old way to say which one was in a specific script tag was with <script language="Javascript">... but the standardised way to do it now is <sytle type="text/javascript">. The same applies to any tag where you're inlining non-HTML data (currently just script and style), you should put in the MIME type of the inline content.

the html spec does say that the type for style elements defaults to text/css if you don't specify it, though...

Code: Select all

factorial product enumFromTo 1
isPrime n 
factorial (1) `mod== 1

User avatar
Xanthir
My HERO!!!
Posts: 5423
Joined: Tue Feb 20, 2007 12:49 am UTC
Location: The Googleplex
Contact:

Re: My teacher is teaching HORRIBLE THINGS

Postby Xanthir » Thu Mar 26, 2009 12:03 pm UTC

sje46 wrote:My web design teacher is teaching us to do this:

Code: Select all

<style>
.
.
.
</style>

Instead of this

Code: Select all

<style type="text/css">
etc

Is this a bad habit? Should I do it the longer way?

There is nothing wrong with omitting the type attribute in <style>, as CSS is the assumed default. This is explicitly stated in HTML5.

Similarly, it's fine to just do <script></script> and leave out the type attribute there, as javascript is also the assumed default. Again, this is explicit in HTML5.

I just wish that when I *do* add the @type attribute, I could do it correctly as application/javascript without IE barfing at me.
(defun fibs (n &optional (a 1) (b 1)) (take n (unfold '+ a b)))


Return to “Coding”

Who is online

Users browsing this forum: No registered users and 5 guests