From: David Masover on
On Saturday, July 17, 2010 11:43:52 am Tony Arcieri wrote:
> On Sat, Jul 17, 2010 at 12:46 AM, David Masover <ninja(a)slaphack.com> wrote:
> > Do you really know JavaScript well enough to hate it? It's possible
> > you're an
> > exception, but most people who hate JavaScript don't seem to know it
> > particularly well.
>
> That's a pretty pretentious question to ask. But I'll bite.

I was never asserting that it was impossible for someone to know JavaScript
well and to hate it for that. But I do want to make sure it's an actual,
legitimate concern -- often, I see people trying to avoid JavaScript because
they like Object-Oriented Programming, for example.

> Am I a JavaScript expert? But I know it fairly well. I could sit here and
> prattle off a couple dozen things I hate about JavaScript, like the
> practically broken coersion model, the inconsistent and likewise broken
> core types, including inexplicable and useless box objects for those types
> and mismatches between the literals and what core types they map to ([]
> instanceof Array is true but "" instanceof String is false???),

Those are all pretty weird, though I could mention similar oddities in Ruby,
like the use of === in case statements, the concept of single inheritance but
multiple mixins (but they behave like inheritance anyway), the ugliness of
trying to pass multiple blocks as arguments, hashes as keyword arguments...

And that's not even getting to my personal pet peeves, like many C methods
calling other C methods directly (so I can't override them -- for example,
Kernel#autoload calls the C implementation of Kernel#require directly, not the
actual Kernel#require that might be there), the fact that I can't bind a
method to an object that isn't related to it (so much for duck typing)...

Every language has its warts.

But I love Ruby, mostly because of how little these things actually matter to
most of what I actually want to do. I can't say I've ever been bitten by
JavaScript's coercion model or by its odd comparisons, though it is especially
perverse that in Javascript, you can have this:

[] != []

Explosion principle for the lose.

Still, it's fair to hate a language for reasons like that. It's not fair to
hate a language because of outright wrong assumptions -- again, most (no all)
people I talk to who hate JavaScript hate it for the wrong reasons.

> the need
> for a JQuery jock strap to even make the language tolerable by masking
> away all the bizarre gymnastics you'd otherwise have to do to get basic
> functionality out of the language, etc etc.

In other words, Ruby has a better standard library. So what? I could just as
easily claim that Ruby needs a "Rack jock strap" before it's a useful Web
development language.

It also seems especially bizarre to mention jQuery here, when jQuery does
nothing to make the language itself more or less tolerable -- it wraps itself
around the DOM, though it comes with a few easily-duplicated utility
functions. Are you complaining about JavaScript, or the DOM?

> But like... this is ruby-talk,

While that's true, I do try to offer general solutions, whether or not they
involve Ruby. I also try -- and I've been accused more than once of being rude
and pretentious for doing so -- but I try to find out what the actual problem
is that someone's trying to solve and provide a solution to that problem,
rather than to the specific question they asked.

> and the guy wants to use Ruby instead of
> JavaScript. I think you'll be extremely hard pressed to find anyone with
> moderate level expertise in both languages who would disagree that Ruby is
> a significantly better language than JavaScript.

It depends what your goals are -- and you have to set some sort of goal before
you can define a language to be "better" than another.

I like Ruby. I'm certainly not going to start using v8 on the server side
anytime soon. I'll run JRuby on Appengine to avoid writing Java or Python --
but I won't run JRuby applets on the client to avoid writing Javascript.

From: steve ross on
Hello--

On Jul 17, 2010, at 5:21 PM, Jeff Pritchard wrote:

> Just to clarify…I was hoping there might be a universal replacement, not
> a special case for some specific mobile platform.
>
> Today I can make a web 2.0 rails app with gobs of yucky un-testable
> javascript/jquery/prototype/ajax that will run anywhere/everywhere. It
> will run on any desktop machine; any apple device; android; WP7; etc.
>
> The problem with that approach is that a modern web 2.0 app has very
> little rails. The rails part of it is quick and easy but amounts to
> little more than a web service or the app's "back end". There are good
> ways to do TDD for that part. Good tools, good plugins, lots of creamy
> goodness all around.
>
> Most of the development time though, is in getting a polished web 2.0
> ajaxy UI stuck on the front of that. For this part (which, as I said,
> is the long slow part) there is no universal ruby solution; there is no
> good way to do TDD. jQuery and prototype are better than cranking all
> your own javascript libraries, but they are not a GUI framework that
> leads to a clean and standardized app (like rails does).
>
> Sorry for whining. Just amazes me that so many years have gone by with
> GOBS of stuff happening on the server side and NOTHING happening on the
> client side to make web app development smooth and easy like server side
> is.
>
> thanks,
> jp
>
>
> Jeff Pritchard wrote:
>> I've seen jRuby and IronRuby, and really want to use them since i really
>> really hate javascript and since so much of a modern web app winds up on
>> the client side…but none of the client-side ruby solutions I've found
>> will work on mobile devices.
>>
>> Are there any? (even something that is much less complete or
>> performant?)
>>
>> thanks,
>> jp

There are numerous js test frameworks. One that is similar to Test::Unit is jsTest. You can read about it here.

http://thinkpond.org/articles/2008/jstest-intro.shtml

If you are more of an rSpec kind of person, then look into jsSpec or ScrewUnit:

http://jania.pe.kr/aw/moin.cgi/JSSpec

http://github.com/nkallen/screw-unit

Rubyists are likely to use TDD or BDD, but it is more how they think about development than about available tools. There are tools available for testing other languages.

Hope this helps.

Steve
From: Jeff Pritchard on
Thanks Steve. I will check these out.

jp

Steve Ross wrote:
> Hello--
...
>>> thanks,
>>> jp
>
> There are numerous js test frameworks. One that is similar to Test::Unit
> is jsTest. You can read about it here.
>
> http://thinkpond.org/articles/2008/jstest-intro.shtml
>
> If you are more of an rSpec kind of person, then look into jsSpec or
> ScrewUnit:
>
> http://jania.pe.kr/aw/moin.cgi/JSSpec
>
> http://github.com/nkallen/screw-unit
>
> Rubyists are likely to use TDD or BDD, but it is more how they think
> about development than about available tools. There are tools available
> for testing other languages.
>
> Hope this helps.
>
> Steve
--
Posted via http://www.ruby-forum.com/.

From: Tony Arcieri on
[Note: parts of this message were removed to make it a legal post.]

On Mon, Jul 19, 2010 at 11:55 PM, David Masover <ninja(a)slaphack.com> wrote:

> I'll concede that they may be difficult, and I'm sure I'm underestimating
> the
> instanceof problem above. I just don't agree that verifying the type of
> something is essential functionality. It seems like I'm reaching for
> Activesupport to give me 5.minutes.ago far more often than I'm reaching for
> jQuery to tell me whether something's an array or not.
>
> What else is broken by default? I'll give you a skin-deep ugliness, sure.
>

You know, we can beat around the bush all day about this. I think I'll just
end on this note:

http://jmesnil.net/weblog/wp-content/uploads/2009/09/RzRcw.jpg

<http://jmesnil.net/weblog/wp-content/uploads/2009/09/RzRcw.jpg>:)

--
Tony Arcieri
Medioh! A Kudelski Brand

From: David Masover on
On Wednesday, July 21, 2010 12:22:58 pm Tony Arcieri wrote:
> On Mon, Jul 19, 2010 at 11:55 PM, David Masover <ninja(a)slaphack.com> wrote:
> > I'll concede that they may be difficult, and I'm sure I'm underestimating
> > the
> > instanceof problem above. I just don't agree that verifying the type of
> > something is essential functionality. It seems like I'm reaching for
> > Activesupport to give me 5.minutes.ago far more often than I'm reaching
> > for jQuery to tell me whether something's an array or not.
> >
> > What else is broken by default? I'll give you a skin-deep ugliness, sure.
>
> You know, we can beat around the bush all day about this. I think I'll
> just end on this note:
>
> http://jmesnil.net/weblog/wp-content/uploads/2009/09/RzRcw.jpg

You could likely draw a similar comparison with many other languages. From the
preface of "The Good Parts":

"This is not a book for beginners... This is not a book about Ajax or web
programming... This is not a book for dummies. This book is small, but it is
dense. There is a lot of material packed into it."

From the preface of "The Definitive Guide":

"Chapter 1 provides an introduction to JavaScript... Chapters 2 through 6
cover some bland but necessary reading; these chapters cover the basic
information you need to understand when learning a new programming
language....

"The next six chapters... document parts of the language that will not be
familiar to you even if you already know C or Java....

"Part II explains JavaScript in web browsers.... Part III and IV contain
reference material covering core JavaScript and client-side JavaScript,
respectively. These parts document relevant objects, methods, and properties
alphabetically."



If nothing else, it's the difference between a best-practices Ruby book for
experienced developers, and a comprehensive introduction to Ruby and Rails for
non-programmers. It's the difference between saying "Don't use mass
assignment" and a screencast walking you through all the details of what mass-
assignment is, how it could be exploited, how to fix it, and what happens when
people try to exploit it again.



I can respect wanting to end what could be a very long and offtopic flamewar,
so I hope that was a tongue-in-cheek thing, and not an attempt to present
actual evidence. I just couldn't let that go unchallenged.