Arc Forumnew | comments | leaders | submit | gnaritas's commentslogin
3 points by gnaritas 5892 days ago | link | parent | on: Arc's web server in Lua

My two cents on strings/symbols, there are semantic reasons they should always be separate. It's not about string mutation, ignore the implementation, it isn't relevant.

Two symbols 'foo can always be considered to mean the same thing, two strings "foo" can't, they may be only the same by coincidence. This matters if automated refactoring tools become available because you can safely rename all occurrences of a symbol, the same cannot be said of strings.

Mixing strings and symbols is a bad idea, they are different things and should remain that way.

-----

1 point by sacado 5892 days ago | link

Well, we could at least have a very lightweight bridge between both worlds, by allowing (and automatically converting) symbols into string where strings are needed and vice versa.

Code crashing because, for instance, you tried to concatenate a string and a symbol is rather annoying, but these bugs keep happening and the developer's intention is rather obvious there.

-----

4 points by gnaritas 5891 days ago | link

Oh I don't disagree, I'm actually a Smalltalker and I'm accustomed to Symbol being a subclass of String and a String being a list of Characters. I actually have refactoring tools so I just wanted to point out that they are different for more than just implementation reasons and there's a logical reason to have symbols beyond mere optimization.

I just hang out here because I like to see how a new Lisp is born and how you guys think, even though I don't actually use Arc.

-----

2 points by gnaritas 5913 days ago | link | parent | on: Show and Tell: elliottslaughter.net

Yes, and that's the right approach. See http://articles.slicehost.com/2008/4/25/ubuntu-hardy-setup-p... and scroll down to iptables to see how to setup a firewall on Linux.

-----

1 point by eds 5907 days ago | link

Thanks! That was a really useful article, and not only for setting up firewalls.

-----

2 points by gnaritas 5959 days ago | link | parent | on: Objects in Arc

Wouldn't that be...

    function Person(first, last, age) {
        this.first = first;
        this.last = last;
        this.age = age;
        this.full = function() {
            return this.first + " " + this.last;
        };
        this.until = function(year) {
            return year - this.age;
        };
    }
There's really no reason return an anonymous literal object from the Person constructor unless I'm overlooking something, it has been a year or two since I played with JS much.

-----

1 point by EliAndrewC 5958 days ago | link

You are correct; it's also been awhile since I played with Javascript, but I just checked "A Reintroduction to Javascript" then it listed both my way and your way as examples, describing your way as being cleaner: http://developer.mozilla.org/en/docs/A_re-introduction_to_Ja...

-----

2 points by tung 5954 days ago | link

I'd do it like this:

    function Person(first, last, age) {
        this.first = first;
        this.last = last;
        this.age = age;
    }
    
    Person.prototype.full = function () {
        return this.first + " " + this.last;
    };
    
    Person.prototype.until = function (year) {
        return year - this.age;
    };
You shouldn't really put functions inside the constructor function unless you really need the closure.

-----

1 point by gnaritas 5949 days ago | link

Which is handy if you want private instance variables. But you're right, prototype should be the first choice, like I said, it's been a while.

-----

5 points by gnaritas 6028 days ago | link | parent | on: Smalltalk vs LISP

Everything is python is not an object. Python uses procedural control structures like if/else/while/for implemented as special keywords. Smalltalk implements those control structures with objects, the Boolean subclasses True and False which have methods ifTrue:ifFalse: and the class BlockContext which implements methods such as whileTrue: and whileFalse:.

Having objects is entirely different from using objects as the basic building block of every abstraction in the language. Objects in Smalltalk are what S-expressions are to Lisp. Python and Ruby just have objects, but those languages aren't built from objects.

-----

4 points by gnaritas 6053 days ago | link | parent | on: possitives and negatives of a language

Not a former PHP'er, but I can tell why most of us hate it. It's an ugly bastard of a language created by accumulated hacks and inconsistencies. People love Python and Ruby because they're exactly the opposite, they embody coherent styles that let you build upon what you know in a logical fashion. No language is perfect, but they at least attempt to be consistent. PHP is full of dragons hiding everywhere that just jump out bite you when make the mistake of assuming something should work a certain way. The only style PHP embodies is "whatever works", which is a shitty design philosophy.

-----

2 points by agentbleu 6053 days ago | link

Thanks for the candid words, I only have the experience of actionscript2 javascript, and php, so it is hard for me to know if the grass is really greener or if there isnt just the normal battles as seen with all new technologies.

From what you say mind I haven't had this experience, I have found it easy to grasp and lots of examples to get me on my way with nothing left out, always finding that solution to a given problem.

Maybe I should frame the question like this, what would make me enthusiastic to migrate to a RoR or pythan etc. is that they are quicker to develop with, or have lots of prebuilt functions / classes saved you much work. etc. Can you give advantages such as these?

thanks agian

-----

4 points by absz 6052 days ago | link

I don't have too much experience with web apps, but I've done a little PHP (and I've used Ruby for non-web stuff). PHP has an amazing amount of resources out there, and it's ubiquitous, which are two large plusses. But its capabilities are rather elementary, and while this can be fine, it often isn't. For instance, PHP doesn't have real closures, and it doesn't have first-class functions. (When C's functions are more first-class than yours, you know you have a problem.) You have to pass their names around in strings. Ruby, on the other hand, is a nicer language to work in--it has the things I mentioned, and even more. And when the language isn't fighting with you, you don't necessarily need as many resources; nevertheless, Ruby has them.

Javascript, though, I feel is a better language. Real first-class functions and closures, innumerable examples and tutorials (though not always good ones), and more. Its problem is that every browser understands it slightly differently.

So between PHP and other things, I feel that the difference is within the language itself, not in the modules and prebuilt things (as all of the mentioned languages have these). But working in PHP felt confining when I was using it, and that's something I took away. (It reminded me of Java in that regard—the same feeling of being confined, as though I couldn't do what I wanted to.)

-----

4 points by gnaritas 6099 days ago | link | parent | on: Templating language or MVC-style arc?

The seperation of logic and presentation doesn't belong between code and HTML, it belongs between HTML and CSS. HTML is best controlled and generated programatically. Arc does it right, Rails does it wrong.

-----

4 points by KirinDave 6099 days ago | link

I'm not sure what your professional experience making websites is, but mine has shown me time and time again that making good looking sites is an iterative process full of workarounds for real-world considerations.

The method you're suggesting would make it excruciating to converge on a good design with any real designer. Look at the markup any good looking and well-implemented web page (especially one with dynamic content), and you'll see a huge amount of extra tag work to accommodate the real world of cross-and-backwards-compatibility between browsers, CSS limitations, browser quirks, and other concerns that people making professional sites require.

If every one of these changes and workarounds required changes to the code, which would require my time instead of the designer's time?

The Rails way is just copying a method that nearly every web toolkit uses, and they use it for a reason. Arc's way may be cleaner, but without a templating language it will be at a disadvantage.

-----

3 points by vrk 6099 days ago | link

I agree with both points of view!

- If you get the layout, including both how it should look and how things should work, from an external source, or if there is substantial external input, use templates. It will save time and headache.

- If you are just about the only one responsible for the layout but support skins (for lack of a better word; the CSS part), use the HTML tag functions and macros embedded in Arc.

Since Arc is at this point targeted for exploratory programming, the former is an unlikely case.

What I would like to see, though, is a templating engine akin to HTML::Template [1] in Perl 5. It has the minimum of control structures and extra syntax on top of standard HTML, just enough to make it possible to use the template for dynamic content. All templating frameworks suffer from the same fault, though: they define a new but severely restricted embedded language that's mixed in an unpleasant way with the HTML source. The language embedded in Arc is a much cleaner way to do things.

[1] http://search.cpan.org/~samtregar/HTML-Template-2.9/Template...

-----

2 points by tel 6098 days ago | link

Bingo.

Complex designed websites are pretty much impossible using Arc's current library. Well, unless you're a programmer/designer with a high pain threshold.

When Arc is no longer classified by whatever greek letter comes before alpha, it might be worth investing into a nice way to separate out some MVC/MTV/VH1/&c.

-----