News for hackers. Stuff that matters.
Re:NeoCities by kyledrake on Friday June 21, 2013 @02:20PM (#5919954)
Here, I'll do one better: If anyone is concerned about the nature/security of the site, here is the source code to NeoCities, ready for anyone to do a full security audit: https://github.com/kyledrake/neocities-web

Pull requests welcome!

Re:NeoCities by slg on Friday June 21, 2013 @03:13PM (#5920297)
Good to see. This is the way to respond to these type of mistakes, be completely transparent. Now if only the NSA subscribed to the same plan...

And since it wasn't directed toward me, I guess we all can forget my little rant regarding the "trashing" comment.

Re:NeoCities by weland on Saturday June 22, 2013 @08:15AM (#5923337)
I can't believe what I just witnessed. Something expressing a valid concern in a somewhat uncivilized manner, the developer answering in a nice way, the original poster apologizing and the developer linking to the source code to quench other similar concerns. WHAT HAS THE INTERNET COME TO?

Cheers to you, fine folks!

Re:NeoCities by egeozcan on Friday June 21, 2013 @03:22PM (#5920353)
Hey, I'll try to hunt this down for you but just to give you a heads up, the server gives me a 500 internal server error when I use characters like "ğ" or "ü".
Re:NeoCities by mattl on Friday June 21, 2013 @03:13PM (#5920296)
Can you put up a license for it?
Re:NeoCities by pak on Saturday June 22, 2013 @12:26AM (#5922583)
You are the man for doing this. If only others, including myself, were so brave for every web project that they attempt.
Re:NeoCities by catshirt on Friday June 21, 2013 @04:45PM (#5920881)
great response. the bug's existence alone made me question the project intent and viability. even though i probably won't read your code, just making the source available mitigated my biggest concerns.
Re:NeoCities by jancborchardt on Saturday June 22, 2013 @05:00AM (#5923025)
Do you have a logo already? I would really like to add NeoCities to http://libreprojects.net
Re:NeoCities by csense on Friday June 21, 2013 @03:49PM (#5920541)
Why did you choose Ruby as the language?
Re:NeoCities by thomasfl on Friday June 21, 2013 @04:39PM (#5920844)
I think it's a pure joy to read the ruby source. Allthough ruby is not fast, it's got some of the simplest most elegant frameworks out there. Sinatra is not much more than a router config file with some logic. Sequel is the simplest database orm and migration tool around. And slim makes very readable templates. All frameworks perfect for the first minimum viable product. If this site takes off, I would perhaps pay someone to rewrite some bottlenecks of it in java.
Re:NeoCities by csense on Friday June 21, 2013 @07:44PM (#5921778)
> it's a pure joy to read the ruby source

If you like it so much, here's a copy-paste from the project for your edification [1]:

  def new_tags=(tags_string)
    tags_string.gsub! /[^a-zA-Z0-9, ]/, ''
    tags = tags_string.split ','
    tags.collect! {|c| (c.match(/^\w+\s\w+/) || c.match(/^\w+/)).to_s }
    @new_tag_strings = tags
  end
I don't mean to pick on this project in particular. In fact, this project as a whole is quite possibly the cleanest Ruby code I've ever seen.

That being said, Ruby's syntax makes me want to gouge my eyes out. There's equal signs, unquoted regular expressions, exclamation points, absolute value bars, and at signs all over the above code. You can't even sort-of follow what this code is doing without searching through the manual every third character. Ruby syntax is worse than C++ and almost as bad as Perl.

Someone tried to explain Ruby syntax to me last week [2], and I'm not sure if I understood it more, or less, as a result, because my conclusion was that Ruby's syntax is so bad, the language shouldn't even be able to exist! I.e., there are a large number of syntactical ambiguities, so writing a parser for it should be completely impossible!

[1] https://github.com/kyledrake/neocities-web/blob/933c3549264e...

[2] https://news.ycombinator.com/item?id=5872899

Re:NeoCities by dragonwriter on Friday June 21, 2013 @08:00PM (#5921861)
> equal signs

I fail to see how using equal signs for assignment (or for defining assignment methods) is a problem with syntax, rather than an enhancement to clarity.

> unquoted regular expressions

What's wrong with that? Regexes are a different type than strings. Why should they look like strings?

> exclamation points

...again, so, what?

> absolute value bars

vertical bars used to set off block argument lists aren't absolute value bars. (Neither are vertical bars used for logical-or.)

> at signs

Again, so?

> You can't even sort-of follow what this code is doing without searching through the manual every third character.

Yes, I can, and not just "sort-of follow" it.

> Ruby syntax is worse than C++ and almost as bad as Perl.

There's no accounting for taste, I suppose.

> there are a large number of syntactical ambiguities, so writing a parser for it should be completely impossible

As Ruby does exist, and is parsed, this is clearly not the case. That said, ruby's syntax is not optimized for machine parsing, its designed to be ruby-developer-friendly rather than ruby-parser-developer-friendly.

If you want something optimized for the developer of the language's parser, look to Lisp.

Re:NeoCities by fghfg on Friday June 21, 2013 @09:52PM (#5922206)

    // Parse tags string.
    // Example:
    // "tag1, tag2" => {"tag1", "tag2"}
    // "tag1, very long tag" => {"tag1", "very long"}
    string[] NewTags(string tags_string)
    {
        //Allow only letters, numbers and spaces in tag.
        tags_string = new string(tags_string.Where(c => char.IsLetter(c)
            || char.IsNumber(c) || c == ' ' || c == ',').ToArray());

        //Separate multiple tags with commas.
        string[] tags = tags_string.Split(',').Select(s => s.Trim()).ToArray();

        //Two word per tag maximum (extra words in a tag will be removed).
        for (int i = 0; i < tags.Length; i++)
        {
            List<string> validWords = new List<string>();
            string[] wordsInTag = tags[i].Split(' ');
            if (wordsInTag.Length > 2)
            {
                tags[i] = wordsInTag[0] + " " + wordsInTag[1];
            }
        }
        return tags;
    }
Re:NeoCities by whimsy on Saturday June 22, 2013 @12:56PM (#5924274)
> there are a large number of syntactical ambiguities, so writing a parser for it should be completely impossible

Keep in mind that while your protest does sound intuitive - e.g. that Ruby can be syntactically ambiguous, ergo it is unparseable, it turns out that that doesn't stop us from writing a parser. We can parse most things even if we can't parse the "general case." When we DO encounter something unparseable, the compiler can a) guess or b) fail, hopefully with a message that will help us investigate and rectify the failure.

You point out that Perl's syntax may be worse than Ruby's, and I assume that implies that it is more syntactically ambiguous, ergo, writing a parser should also be impossible for Perl. It turns out that Perl is provably unparseable in the general case - in fact, it's been done rather rigorously: http://www.jeffreykegler.com/Home/perl-and-undecidability

Regardless of Perl's general unparseability, we have compilers for Perl and even large projects manage to compile to what appear to be functional executables. The same is true for Ruby.

I wrote this comment mostly a reminder that while something may appear to be insoluble, we may be able to solve for sufficient cases that we don't care about the rest, particularly if we have an oracle to fix the number of cases that we can't solve. (In this case, the oracle is the developer.)

Re:NeoCities by pak on Saturday June 22, 2013 @12:12AM (#5922554)
Ruby's syntax is beautiful once you've realized two things:

1. How blocks work, and how their minimalist syntax is beautiful. You see absolute value bars but believe me, getting used to that barebones function syntax is a gift. (No other programming language that I know of has an absolute value operator with vertical bars so it is not as hard as you think.)

2. Every time you see a dot, do NOT think attribute access. Think message sending a la Smalltalk.

Suddenly then, things like the tags.collect! line become pretty for encapsulating a callback on one line unlike the ugly function() {} crud of JavaScript, and things like defining a newtags= method become sensible, because everything including traditional attribute getting and setting reduces to message passing.

Re:NeoCities by whimsy on Saturday June 22, 2013 @01:01PM (#5924300)
> Every time you see a dot, do NOT think attribute access. Think message sending a la Smalltalk.

Huh. You just rekindled my interest in learning Ruby. Learning Smalltalk was pretty mind-expanding.

Re:NeoCities by vinceguidry on Friday June 21, 2013 @08:20PM (#5921937)
What's difficult about that function? It's terse, but very understandable.

Oh, the inability to parse Ruby shouldn't be held against it. It has (at the least) a context-sensitive grammar. So do lots of languages, including HTML and perl.

Not being able to parse it doesn't really mean what you think it means. It just means that in order to figure out what it does programmatically, you have to evaluate it. Its unparseability makes certain things impossible, like writing a perfect syntax highlighter. Also makes building certain tools you'd normally see in an IDE difficult.

Re:NeoCities by Jeremysr on Saturday June 22, 2013 @12:02AM (#5922533)
I don't know if this works for everyone, (and I hate to appeal to magic), but I'm pretty sure it was http://mislav.uniqpath.com/poignant-guide/book/chapter-3.htm... that gave me a visceral understanding of Ruby's syntax. For example, the slashes surrounding the Regexp are like pins that you stick the Regexp onto the paper with, and it lights up if the pattern matches. The at signs stand for "ATtribute". Exclamation/question marks have meanings analogous to their natural language counterparts. And the vertical bars form a little chute that the block variables slide down into the block through. It's really fun.
Re:NeoCities by eksith on Friday June 21, 2013 @11:35PM (#5922473)
This is on the same league with arguing against Esperanto in favor of Interlingua. You'll never get anywhere with people with the "so what?" or "no it's just you" mindset as in their capacity, they're not capable of (or unwilling?) to entertain perspectives beyond their own.

That said, I do really enjoy reading this code. It's indeed very, very clean!

Re:NeoCities by kyledrake on Friday June 21, 2013 @06:27PM (#5921407)
It's what I know. And very productive in general. Nginx and the kernel (sendfile) does all the heavy lifting of serving the static files.
Re:NeoCities by fragsworth on Friday June 21, 2013 @07:22PM (#5921680)
I don't think it's a smart idea to publish the source code to your site (especially while on the front page of Hacker News) until you've spent a significant amount of money on auditing the security internally to the point that others are comfortable with a public release.

Now it looks like something happened, and you've got no site, and thousands of people trying to access it!

Re:NeoCities by contingencies on Friday June 21, 2013 @09:45PM (#5922181)
Disagree! Publishing is laudable. Paying customers might tip the scales otherwise, but apparently that's not yet an issue.