News for hackers. Stuff that matters.
Re:Five languages in seven lines, or how not to do web devel... by jcl on Monday February 23, 2009 @06:28PM (#492397)
Truth be told, it's not too bad considering all it does. Each language is being used for its strengths.

Programming at that level requires HTML and Javascript. Python is integrated as part of Mako; calling them separate languages is valid but questionable. (Given that the author is maximizing the number of languages, I'm a little surprised jQuery wasn't included in the list.)

Re:Five languages in seven lines, or how not to do web devel... by jwilliams on Monday February 23, 2009 @06:47PM (#492421)
Yeah I don't see the beef either - what is the counterpoint "ideal" way of doing it?

One language? Because you'd have to select HTML by default... And I'm guessing that might not make for the best user experience.

Also surprised they didn't include (implied) CSS.

Re:Five languages in seven lines, or how not to do web devel... by jdminhbg on Monday February 23, 2009 @06:49PM (#492422)
I think you need to at least move the JS out and write it unobtrusively. Sticking 'onClicks' all over the place inside a templating language is a recipe for spaghetti.
Re:Five languages in seven lines, or how not to do web devel... by swombat on Tuesday February 24, 2009 @06:34AM (#492931)
Sure, but the point is, to put together any decent web page template, you'll need at least:

1) Your server-side language (e.g. Ruby)

2) Your templating language (e.g. ERB, which may be very similar to 1)

3) HTML

4) CSS

5) Javascript

5 languages is pretty much a minimum unless you're doing something trivial. I'll agree that the onclick should be extracted, but as has been pointed out in other places, this is a quick documentation example, so it is reasonable to use onclick there to keep it brief.

PS: Also, perhaps worth pointing out that HTML and CSS aren't actually programming languages... Should they count? probably not.

Re:Five languages in seven lines, or how not to do web devel... by scott_s on Tuesday February 24, 2009 @10:06AM (#493104)
They're still languages, so I think they should count, because it still takes a mental context switch when going from any language to another.
Re:Five languages in seven lines, or how not to do web devel... by axod on Tuesday February 24, 2009 @11:17AM (#493202)
The number of languages isn't the issue. The issue is putting them all together in the space of a few lines.

It's bad organization.

Re:Five languages in seven lines, or how not to do web devel... by jwilliams on Tuesday February 24, 2009 @09:21PM (#493951)
Actually just curious - but what is a means of separating them?
Re:Five languages in seven lines, or how not to do web devel... by cake on Tuesday February 24, 2009 @09:48AM (#493078)
I wouldn't call jQuery a language. jQuery is JavaScript.
Re:Five languages in seven lines, or how not to do web devel... by jcl on Tuesday February 24, 2009 @02:00PM (#493421)
jQuery is JavaScript in approximately the same way CLOS is Common Lisp. Sure, jQuery is implemented in and uses JavaScript, but idiomatic jQuery differs enough from idiomatic JavaScript that it might be considered another language.

...And, if that handwaving fails to convince you, jQuery's selector string format is at least as much a language as the pager formatting string that merits its own language in the article. :)

Re:Five languages in seven lines, or how not to do web devel... by axod on Tuesday February 24, 2009 @09:52AM (#493084)
library/frameworky thing. It's not javascript though. Try getting help with a jQuery question in #javascript...
Re:Five languages in seven lines, or how not to do web devel... by psadauskas on Monday February 23, 2009 @08:40PM (#492516)
So in Rails best-practices, you'd still have 3 "languages", they'd just be spread around in 3 files.

I'm a Haml fan, so I'd have a view template like:

  = paginate(@employees)

  %ul
    - @employees.each do |employee|
      %li
        = employee.first_name
        = employee.last_name
and then a helper to fill out the "paginate", or some plugin to handle it for me, and finally an unobtrusive js file.

So I get 3 languages. The only real WTF I see here is the "onClick", and for an example in some documentation about a framework, its forgivable. Could also be broken up into separate files, because the pagination part is a bit complex for a view. Again, though, its a documentation example, on the paginator helper, no less.

Re:Five languages in seven lines, or how not to do web devel... by s3graham on Monday February 23, 2009 @10:53PM (#492626)
I think "$('#my-page-area')" is #6 actually (doing a CSS-style selector probably via jQuery or something)

I'm not sure that it's "how not to do web development", but it's certainly "this is common: what's a better way?".

Re:Five languages in seven lines, or how not to do web devel... by datico on Wednesday February 25, 2009 @11:48AM (#494555)
The point as I see it, normally one thinks of programming in "a" language, not 5-7 at once! Just imagine trying to rewrite this paragraph in multiple foreign languages...let's see, nouns in Japanese, verbs in French, adjectives in Russian, and the remainder in Taglish? Illustrates just how demanding web development is. And consider, not only are there best practices to follow for each real language, the conclusion reveals there must be implicit best practices (or at least opinions) for mixing them as well.
Re:Five languages in seven lines, or how not to do web devel... by thomasfl on Tuesday February 24, 2009 @05:18AM (#492863)
Even when using serverside javascript, you still end up with at least 4 languages; javascript, html, css and occasional sql queries.

Rails is actually not that bad, letting you use ruby for everything from javascript and html templates to sql queries and configuration. The future is languages that can be tweaked to express anything like lisp, ruby, python, groovy and one day also javascript.

Re:Five languages in seven lines, or how not to do web devel... by gaika on Monday February 23, 2009 @07:15PM (#492441)
Bug in parsing: line 2 is mostly javascript, not mako.
Re:Five languages in seven lines, or how not to do web devel... by biohacker42 on Tuesday February 24, 2009 @11:24AM (#493213)
Python, JavaScript and HTML puts you at 3 and that's the least you need for web development.

Or are you supposed to do nothing but back end in Python, or just HTML front ends?

Re:Five languages in seven lines, or how not to do web devel... by mcav on Monday February 23, 2009 @11:27PM (#492657)
Nothing wrong with this example. Would you rather see XSLT? Really?
Re:Five languages in seven lines, or how not to do web devel... by jrockway on Tuesday February 24, 2009 @01:42AM (#492750)
There are other ways to build HTML without templating. Take a look at Template::Refine, for example:

http://search.cpan.org/~jrockway/Template-Refine-0.02/lib/Te...

http://search.cpan.org/~jrockway/Template-Refine-0.02/lib/Te...

(Those are two different examples, which is unclear due to news.yc's URL truncation.)

Re:Five languages in seven lines, or how not to do web devel... by axod on Tuesday February 24, 2009 @09:43AM (#493073)
What's even more worrying is people posting here defending it. It's plain ugly.

Call me old fashioned, but I'm pretty much a one language per file guy.

Re:Five languages in seven lines, or how not to do web devel... by herval on Wednesday February 25, 2009 @09:50AM (#494403)
I'm curious to know how do you do web development. Mind sharing?
Re:Five languages in seven lines, or how not to do web devel... by bhiggins on Monday February 23, 2009 @07:33PM (#492455)
yikes, missing two languages. everyone knows number of lines should equal number of languages.
Re:Five languages in seven lines, or how not to do web devel... by tlrobinson on Monday February 23, 2009 @10:25PM (#492602)
Technically the first 3 lines have all five languages.