The Y combinator allows the definition of anonymous recursive functions. These have names ("fac").
Personally, I have never found much of a reason to use the Y combinator. I typically use the method you used in the second example; I declare a named function within the scope of the anonymous one. I find it to be a readability win.
But I agree with you that Y combinators are not generally a good approach for working programmers because there are clearer ways of accomplishing the same thing. However I've heard that in some functional languages they can be very useful as a pattern to compile language constructs to.
Huh. Nokia is pretty much the #1 sugar daddy of open source in the mobile tech business. In the past year, they have:
* Bought Symbian and open-sourced the entire OS.
* Bought Trolltech, relicensed the Qt toolkit to LGPL, and developed new Python bindings from scratch.
* Poured investment into Maemo, including 3G phone support (check out the upcoming Nokia N900).
They're just testing the waters with this new Windows 7 notebook. (Did you notice that the screenshots are mostly showing Ovi Suite 2.0 which is Qt-based and will be available on Linux as well?)
The analyst quoted in the article thinks that it may just be an experiment for now. Maybe using Windows is the quickest way for them to get to market and test their product. Just because they chose Windows for this first launch doesn't mean they won't use open source for netbooks in the future.
I just can't wait for my browser to becomes my OS - it would be a game changing scenario - it won't matter what is pre-installed, you'll be able to switch your OS in a second ... it won't even matter what h/w you are using (PC on intel, MAC on intel, Linux on whatever) ....
i wonder how much a h/w platform or pre-installed s/w would matter in one's life when a browser is your new OS and almost all your apps are on the cloud !!!
Who wrote the browser? The window manager? The compiler, assembler, and linker? What about computer games? I don't see us doing Crysis in Javascript any time soon.
The web is great for some things, but some things aren't everything.
I bet most computer users have never used a bash shell. I still prefer the world with it to a hypothetical one without it. Same goes for high end computer games.
whatever i said is from common endusers perspective and not from YC news reader's(who are mostly techies) point of view - just like the way we switch our browser right now ... we will be able to do the same with the OS!! or even better, there will be multiple browser OS preinstalled, you pick what you want....
as far as h/w platform is concern it would be too early to make a call, we may think right now that intel will lead the market/platform as they now support both (PC & MAC) but i wont be surprised if there are new players... especially from taiwan and china!!!
And even if intel dominates the microprocessor market, I really wonder how would a common man will differentiate a MAC laptop with Lenovo's thinkpad because all they have installed is the same Browser-OS (chrome, safari etc.) on the same platform (intel), with the same specs(say 4GB RAM, 5 USB ports, 2HDMI, same display card.... etc.) and almost everything else is on the cloud .... i guess then it would be all about speed, power and exterior look/design of the laptop??!!!
Please, exactly, tell me what a browser-OS is. Are we talking about something like Chrome OS, which looks like it will be an OS whose primary (edit: or even sole?) purpose is to run a browser? Then it's basically just a crippled version of what we already have. Or would we actually be talking browser-as-an-OS-properly, where some hypothetical browser decides to take up the mantle of process management, drivers, etc?
I don't doubt that lots of interesting things will pop up on the web. But "browser-as-that-thing-I-spend-a-lot-of-time-in" is very, very different from any sane definition of "browser-as-an-OS".
If you watch his talk he doesn't claim he invented JSON; he goes out of his way to say he discovered it -- because it was already there. And he even says that he wasn't the first to discover it either -- as many other people figured it out around the same time.
The first thing he says is that he didn't invent JSON. He also tells who used it a year before as such. Around 8:30 he also explains why he did create a website - to create a "standard" out of it, etc..
It would be better if you watched the video before commenting this.
In this case it's more that ignorance is blindness. That syntax is a feature. The fact that Lisp code is expressed in Lisp data structures makes it easy to write programs that write programs.
Even not as a real lisp guy that's one of the things that I appreciate about lisp and the only time that I've done anything particularly powerful with it: the fact that it's basically a parse tree makes it really interesting for genetic programming.
It seems that the fact that Lisp is a parse tree is what makes it a limiting case. That is, if there's only one canonical structure for representing programs, and Lisp makes it explicit, then any other language that makes it explicit is going to be isomorphic to Lisp.
I'd like to know, though: is that true? Is an abstract syntax tree the only good way to represent programs as data? Has any other expressive way to do this been invented, or do programs always boil down to an AST after the syntax has been stripped away?
I say "expressive" because I can think of at least one other code-as-data representation: binary. But that isn't suitable for programming. If there is another representation that is suitable, but isn't isomorphic to a parse tree, then presumably one could derive from it an analog to Lisp that doesn't simply reduce to Lisp. Until then, though, I think the point that PG made semi-jokingly in the essay, that any language as powerful as Lisp will be a variant of Lisp, has to hold true.
Some day I'd like to research this question (or better, someone on HN could just tell me the answer). If other meaningful representations are possible, surely some must have been invented by now. And if they aren't, then the AST is a considerably more remarkable discovery than people realize.
I don't think that a parse tree is intrinsic -- it's just something that maps well to the languages that we actually use: of course you could translate everything to a turing machine's tape, but that wouldn't be particularly useful.
What would really interest me would be exploring that if human logic fundamentally reduces to a parse tree because of something to do with the language faculty of the mind, and the programming languages that we create tend towards that just because programming languages are built out of the same logical faculty.
Yeah, that's the point. Other representations are possible (binary), but only one has proven suitable for programming. This is presumably because of the way the human mind works. It would be remarkable if it were the only good representation for this. It would also be the reason why Lisp is the limiting case among programming languages, at least when it comes to metaprogramming. But I repeat myself :)
Sure, trees are powerful no matter how you delimit them. Most Lisp hackers would be fine with using {}, [], or <> if they had to. What Lisp hackers like is programming in lists, not parens per se.
I don't see what you're trying to claim. Initially you seemed to be saying that you preferred conventional sytax to sexprs. I pointed out that this meant you had to give up macros. You reply that you could use other characters to delimit sexprs. Sure, but so what?
You're assuming your conclusion: that the languages are equivalent in power and differ only in syntax. If that were true, then sure, one would simply make an arbitrary choice based on taste. But it isn't true. It's profoundly untrue.
The syntax in that first example you quote isn't arbitrary. It's essentially the only notation that exists for representing the structure of a program explicitly in language. Is that valuable? Uh, yeah. It's incredibly valuable. It's worth a lot more than syntax in many cases.
By contrast, the syntax in the second example is arbitrary: the delimiters and operators could just as easily be organized differently. Perhaps this particular organization makes certain programs clearer, but it loses the ability to represent programs in general.
If that doesn't make sense, think of the fairy tale of the goose that lays golden eggs. Everybody's obsessed with their particular golden egg. Lisp - precisely because of the difference visible in those two examples - is the goose.
There's nothing in this that PG didn't already express in his comment. But what you wrote deserves more than one protest :)
That Python code shouldn't work. It needs a 'return', assignments aren't expressions, and assigning to a nonlocal variable in the absence of a declaration just creates a local. (Might be nice if Python did look more like that, though!)
We have this convention for the benefit of humans. Indexing starting at 0 has the convenient property that when we modulus an arbitrary number by the size of a range, the result is a valid index into that range. This comes up when implementing things that map a larger set onto a smaller set, such as buffers or hash tables.
We could still achieve the same effect if we started indexing at 1, but it would require more code, and it would be less clear.
When we start indexing from 0, the only time we need to do a +/- 1 is when we need to index the last element. All other times (iterating, mapping) we don't need to.
Also, starting indices at 1 would change the idiomatic iteration to:
for (int i = 1; i <= SIZE; ++i)
I find that the <= and >= operators add more to my cognitive load than the strict relation operators < and > because there's an or in there. I don't find the alternative to that idiom any better:
for (int i = 1; i < SIZE + 1; ++i)
Your original argument was that we should make it easy for humans to understand, not computers. I think that starting indices from 0 is easier for humans to understand because it simplifies the code we must write and read.
But he was making the point that there are valid human reasons for zero-based indexing - e.g. keeping the lower bound within the natural numbers; having the upper bound be the number of elements in the preceding sequence, etc. The "way computers think" doesn't enter the discussion.
That's false. You'd be forced to sacrifice the exclusive upper bound, which would then force you to sacrifice the difference between the upper and lower bounds being the number of elts in the collection. Unless the lower bound was exclusive, in which case it could be an unnatural number.
No, the only way there's no lump in the carpet is his way.
What makes you think people who 0-index arrays and prefer half-open intervals count any differently? Is this argument directed at a four year old?
4+1=5 never enters into it. What a rubbish argument. I might as well complain that your [a,b] has (b-a+1) integers in it. (5-0)=5 so the half open interval has 5 things in it.
What's the measure of a real interval 1<=x<=5? 4. 0<=x<5? 5.
You're using an inclusive upper range here. Not that that's necessarily wrong, but it isn't standard for the reason Dijkstra mentioned (how many fingers do I have? 5 - 1 = 4. Oops.)
Congratulations; you have successfully introduced a whole new way to have off-by-one errors.
People are used, due to forty years or more of tradition in the great majority of major languages, to zero-based indexing. Tossing that away Because It's Inelegant won't do much good to anyone, especially when you take into consideration the fact that an awful lot of math is more convenient with 0-based indexing.
Having a chat frame in your web page is really easy if you use WebSockets and can run a simple chat engine on your server (some hosting services don't allow sockets at all)
Since WebSocket is not available everywhere yet, use a Flash interface (pure actionscript, no visuals) with the same methods: onopen, onsend, onreceive, onclose, to communicate with the server. So when WebSockets is available all you have to do is replace the flash object with the real stuff.
mychat = new WebSocket(chatserverurl);
mychat.send("Hello");
mychat.send("Can you hear me?");
mychat.send("Am I getting through to you");
Don't get confused, the chat client is pure html, not flash, and can be easily spiced up with some jquery effects.
We've used Strophe to implement a pure-javascript/html chat like this (with an XMPP server on the other end, and jetty handling proxying of non-blocking asynchronous comet long-polling requests to the XMPP server).
XMPP supports this natively via its HTTP binding specification, and there are free open source servers such as openfire that will work with Strophe out of the box.