Domain: hamptoncatlin.com
Stories and comments across the archive that link to hamptoncatlin.com.
Comments · 10
-
Re:I am afraid, there is lack of direction for Rub
On a side note, I will use PHP on my servers before touching Ruby since I see no advantages for using it over PHP.
If you see no advantages to using it over PHP, you obviously haven't looked very hard.
Off the top of my head: Ruby has better syntax, a better object model, runs faster (really), better standard libraries -- Rails aside, Ruby tends not to pollute the global namespace with bullshit like mysql_escape_magic_quotes_no_really_I_mean_it_this_time...
PHP's advantage? Lots of unimaginative programmers like you know it, and it's slightly better at mixing code and data, since it's really just a Turing-complete template language. But I like haml anyway, and regardless, the template is one tiny part of your app -- the actual application logic should be buried in the model somewhere.
So for the majority of the program, PHP has no advantage. For the tiny minority where it would, in a well-designed app, haml makes it look so ugly it's not even funny.
-
Re:CouchDB
Having lambdas and eval is not enough to be a Lisp dialect
No, but it's enough to be quite a bit ahead of many other languages. For that matter...
Lisp is about S-exprs and code-as-data
Granted, it's not as clean, but most Javascript implementations include a toSource method on the function object. Is that enough to build what you want?
S-expressions.
Somehow, I like the JSON syntax better. But it's also a reasonable representation of a data structure, such that I would think it would be easy to store sexps that way.
side-effect free, lenient evaluation, no guaranteed evaluation order - all very important to enable advanced query optimizaters.
In other words: Performance. Got it.
You realize that CouchDB scales to an arbitrary number of nodes, right? And while the queries don't yet, they easily could, and will in the future?
Yes, when I know an app is going to be on a single machine only, I'll probably use something like sqlite for the raw speed and ease of deployment. But I'd much rather have something horizontally scalable than vertically scalable -- and as a nice side effect, I get a decent imperative language that's close to what I already know how to use. And if I really have a problem with JS, I can use whatever language I want.
I could, for instance, serialize sexps to JSON, and write an engine that deserializes them and passes them to LISP view functions.
Contrast this to SQL -- maybe faster on a single machine, but how do you make it really scale? How do you know what to index, when? How do you scale your queries to thousands of nodes?
There's a certain class of application for which SQL makes perfect sense. There's also a class of application for which SQL is a constant pain in the ass, and CouchDB makes perfect sense.
having first-class functions doesn't change that. Yes, you can go halfway there by using lambdas and such, but JS lambda notation is really way too verbose for that sort of thing
So write some sort of macro engine. In fact, someone is doing that -- check out jabl, from the author of haml.
Yes, it's ugly that you have to do that -- but then, I find LISP syntax ugly; unnecessarily verbose, and homogeneous enough that it's hard to tell, at a glance, what's going on.
I don't think Couch is ready -- the two features I really want to see are a nice Ruby interface for views, and support for stacking views. That said, I doubt I'll be using SQL for much even a year from now.
-
Re:Er...
I've got Web Developer, which tells me whether or not I'm in Quirks Mode -- that helps, somewhat.
Mostly, I don't worry about it. It's not particularly easy to make Haml output invalid code, unless you're trying to do so on purpose.
-
Re:Sometimes the correct answer is the simplest
-
Re:Is this really news?PHP doesn't have any weird syntax like Perl regular expressions---you can do Perl regex, but it is neatly encapsultated into proper strings the way it should be. Regex is never really going to be readable without a separate course learning that. By the time you know regex syntax, a little extra syntax in your language isn't that bad. There's no having to manually re-indent dozens of lines of code because you needed to add another nesting level and whitespace is part of the language, etc. And there's no need to do so in any modern programming environment, either. Most text editors these days have ways to re-indent code, uncomment/comment keyboard shortcuts, etc. It's just a really clean, lightweight OO language that's exceptionally easy to learn Easy to learn if you already know HTML, I suppose. But where's my actual, interactive PHP shell that I can play with while I'm learning the language?
OO? Only recently.
Clean? Not even close, not when you've used a real OO language. and happens to integrate very well with HTML. So does everything else, now. I'd argue Ruby is actually better at this than PHP. Don't get me wrong, PHP has plenty of weak points when it comes to performance My language of choice right now is Ruby, so I don't really care about that. availability of modules to do various obscure things Considering the amount of crap built-in to the language, I doubt that's a huge stumbling block, either. I like CPAN, but it does help when the language itself is clean enough that I'll happily write a library of my own. But most that I'd need to do with a C library has bindings everywhere I really want to do it. mainly because it isn't a kitchen sink like Perl I think Perl has too many built-in functions, available everywhere, completely un-namespaced, compared to Ruby.
But you know what? Perl has a little over two hundred functions in the main namespace. PHP has a little over three thousand, according to this page.
So, it may not have the kitchen sink in the syntax, but it has the kitchen sink, the bathtub, the plumbing, and the neighbor's shower in the core library.
Finally, I call BS on this: Almost any code written in C (or C++ without templates/exceptions/other icky stuff) can be trivially ported to PHP by replacing the type names with "var" and adding dollar signs in the right places. (I'm exaggerating slightly, but not much.) Is there a language, other than Python, that this isn't true of, for very simple, "Hello World" or "My first HMAC implementation" examples? Sure, the rules would be different, but dropping all the type declarations (swapping for "var") and adding dollar signs is significant.
Oh, and does PHP support structs? What about function pointers? I doubt it's "almost any code". It's easy when you understand both C and PHP, but again, I assert that's true for many languages, particularly popular web scripting languages. -
Re:Literate programming...Yeah, that's the one thing I hate about Ruby now -- seeing the end of a file that looks like this:
# for some reason, Slashdot won't indent the first line...
Especially when the whole culture around things like Ruby on Rails is "Convention over Configuration" (thus, your code should always be indented properly anyway) and "Don't Repeat Yourself" (tons of 'end' statements isn't particularly DRY).
end
end
end
end
end
end
I will say one thing, though: After haml, I never want to write any raw HTML, or any XML, by hand again. Ever. -
Re:And Microsoft was the biggest offender.
Trying to strip out HTML you don't want users to use without mangling the output is very very hard.
Not really. Add a checkbox to enable HTML. If it's not enabled, escape those less than symbols for them -- and detect URLs, and other things.
Preview, blah blah, whatever.
Do the preview in Javascript. Not Ajax, just straight Javascript, client-side, as they type. Gracefully degrade to a preview button.
Unless you're running an intelligent auto-correcting validator like Tidy, or you're parsing the document into a valid object model and then deleting nodes that way (both quite CPU expensive options, compared to running some regular expressions against a string
Regular expressions can be both CPU intensive and wrong. Just look at a real email validator, which I would paste here, but the lameness filter won't let me.
Tell me that isn't error prone, or at least CPU-intensive. (And remember, you're dealing with individual comments, most of them short -- and it's a massively parallizable problem.)
The second reason is convenience features -- instead of making the user write
evanbd said:
, you can just have them write [quote=evanbd]It's a web site. You use HTML.[/quote], and the parser will convert that intelligently into valid HTML.It's a web site. You use HTML.
Or you could just make the blockquote by itself, and rely on the fact that a properly threaded view will show who you were replying to, anyway.
There's also many better choices for convenience, and most BBCode is going to be generated by the wanna-be-WYSIWYG buttons on the forum.
If you decide down the line that you want to change the code that's outputted for whatever reason, all you need to do is change the application logic and clear out the caches.
Or apply CSS.
And to be fair to the poster, before this new comment system, Slashdot used to say below the post box what HTML could be used.
Oh, they got rid of that? I didn't realize... I'm deliberately still using the old comment system.
-
...What?
Let's compare. In HTML:
<a href="http://example.com/rick_astley">get rick rolled</a>
And in BBCode:
[url=http://example.com/rick_astley]get rick rolled[/url]
It saves you a grand total of three characters. It is arguably more intuitive, at the expense of meaning that someone coming from BBCode won't necessarily understand HTML -- and HTML is actually a web standard. And the fact that every forum seems to use its own markup makes it even worse.
You know what I think? I think BBCode was invented because at some point, someone found it easier to create a parser of something entirely different (and escape out anything HTML-ish) than to simply enforce a subset of HTML. The fact that the second link from Google (after Wikipedia) on a search for bbcode takes me to phpbb is kind of a dead giveaway that it was some lazy PHP coding.
Besides, there are even simpler syntaxes out there, if ease of use or ease of typing was the goal. There's WYSIWYG editors for HTML, there's Markdown, Haml, and more. If I wanted to save people from the horrible complexity of HTML, bbcode would be about dead last on my list.
-
Haml information
They briefly mentioned Haml... which has made a big impact in the Rails and Cake PHP development communities. Yes.... I made it and I'm pimping it here.
- Main/Ruby Haml: http://haml.hamptoncatlin.com/
- Cake PHP Haml: http://bakery.cakephp.org/articles/view/haml-markup-haiku
Enjoy, bitchez!
(plug, plug, plug) -
Re:Which platform?
On ruby is good, thanks. And actually, I type fast enough that it's not that I don't want to type 'end' -- it's that I think it makes the code look cluttered.
Oh, and I don't really like ERB much, either -- hooked on Haml.