|
|
This thread is locked; no one can reply to it.
|
1
2
|
| JavaScript: Enough BS |
|
BAF
Member #2,981
December 2002
|
Marcello - looks interesting... how does it compare with PHP (as far as core functionality goes)? |
|
Matthew Leverton
Supreme Loser
January 1999
|
It looks like it uses Java for library support. For core support, I would assume it is pretty much standard JS. There is no perfect language. In fact, when it comes to web coding, no language is enough. You need good coding practices and a framework that knows about the internet. PHP doesn't force the former and certainly doesn't provide the latter. That said, I enjoy working with PHP using my framework and see no reason to switch. I won't gain any measurable productivity using someone else's framework or a different language. But I won't touch another person's crap PHP code for any price (that anyone offers...) So the nice thing about some of the other web frameworks is that they force a somewhat intelligent design upon the ignorant coder, but I don't really think it's the language itself that provides the main benefits. |
|
Marcello
Member #1,860
January 2002
|
Kent: it is in firefox 1.5+ with the <canvas> thing. BAF: Depends how you look at it. It can load any java library, so technically its "core" functionality is quite broad. I haven't played enough with it to really say. I suppose it depends what functionality in PHP you use. All the standard stuff is there (get, post, cookies, sessions, email, image handling, ftp, file access, database access), and it uses OO rather than a c-style api. As far as I can tell all or most of the core API is actually written in JavaScript itself, to give you an idea how versatile it is. I haven't used it enough as of yet to give a full report, though. edit: I think JavaScript on the server-side makes a lot of sense if you're going to be heavily using JavaScript on the client side, you can share code and modules (form validation, server/client based template engine, anyone?). It's worth noting that Helma does provide a number of framework features for you off the bat, such as database abstraction (which I don't plan on using myself, since I'm using SQueaL as an alternative), template support, and a certain level of hiearchy control (which again I'm not using, thanks to SQueaL). Marcello |
|
kentl
Member #2,905
November 2002
|
Marcello: Cool! Something new to play with! |
|
CGamesPlay
Member #2,559
July 2002
|
What do you mean, Quote: a framework that knows about the internet
-- Ryan Patterson - <http://cgamesplay.com/> |
|
Matthew Leverton
Supreme Loser
January 1999
|
I mean the web in particular. What is the difference between PHP as a CLI and as an Apache module? Almost nothing. You basically just get a $_REQUEST array. PHP doesn't think outside the box at all. It's just about adding more and more 3rd party libraries and adding a few helpful functions now and then. PHP doesn't do anything to provide a framework for your web application. It's great for a web page, it is bad for a web site. To be good for a web site, it needs to provide ways to gracefully handle application tasks. The $_SESSION array is about the only thing it does provide. Now I know that all of this stuff can be done within PHP as layers of classes (because I do it), but considering PHP is supposed to be a "web language," I think it should officially support a standard framework. Also, PHP as a language is not very elegant if you want to add these things yourself. Some examples: using -> and $this is hideous and the absence of named parameters (by the caller) means you must pass things using an ugly array() syntax. In the case where a function has a huge number of possible parameters, all being optional, which do you prefer?
For the most part, I like the PHP language. It's not filled with magic and it's quite powerful. (A number is a number and not some stupid object just for the sake of purist OOP...) But it's missing many simple things that even JavaScript does nicely (like short-hand array/object syntax). I'm not alone with my thoughts... Zend recently announced the "PHP Collaboration Project." Hopefully it begins to seriously address some of these fundamental shortcomings to using PHP for building web applications. To quote from them, emphasis mine: Quote: Anyone building industrial-grade PHP applications knows there's more to a well-designed, robust, scalable, secure PHP application than the language itself. The open source Zend PHP Framework is a body of PHP code that provides developers with the essential structure and services for an industrial-grade PHP Web application. We also think that it's very important this framework embody the "extreme simplicity" mindset that PHP itself exemplifies. We want to deliver a framework that helps solve developer problems and speeds development; not one that's overly complex and heavyweight. With this framework, PHP developers will have a big "jump start" when developing Web applications, with the ability to focus more on unique functionality and less on the plumbing and infrastructure that all applications share. I don't know how it will turn out. Hopefully it will remain simple and get people away from writing the standard filthy PHP code. Obviously it won't address some of the shortcomings to the PHP syntax, but maybe it will help standardize the basic tasks. |
|
Marcello
Member #1,860
January 2002
|
For the record, a number isn't an object in JavaScript either. It's a value, and gets passed by value, not by reference, as objects are. I find the amount of syntax in a language is a good indicator of how good it is. More is not better. The fact that PHP has $ in front of every variable isn't a good thing, the fact that you can refer to variables in literal strings isn't a good thing. The fact that you have to use -> for class membership isn't a good thing. Hell, even c++ doesn't use -> unless it's a pointer (but shouldn't you be using references anyway?). The array thing is what really started to bug me though, take, for example:
And my original code in PHP:
They both actually generate the exact same thing, and never mind on the generating part, but once you've created them, it's a hell of a lot easier to do xml.children[0].attributes.name than $xml->output['children'][0]['attributes']['name'] I also ported my SQL Schema class from PHP to JavaScript and it was just kind of a 'wow, what have I been missing' thing. Marcello |
|
spellcaster
Member #1,493
September 2001
|
Quote: Javascript is BS, dude.
Well, if the negative comments would come from other people that our prooven geniuses, I'd probably tempted to explain to them the difference between the scripting language, the host application, the impact of the exposed interfaces and similar related topics. /me bows. -- |
|
Billybob
Member #3,136
January 2003
|
Quote: the fact that you can refer to variables in literal strings isn't a good thing.
I find it extremely helpful and it makes the code easier to write, and shorter. Certainly not a necessary feature though. Ya know, it's things like that that make a language "fun" to use, as opposed to a bore/pain to use. On the string concat thing, if you didn't have that, you'd hit that age old problem of trying to concat two values and ending up adding them instead. Of course what one finds nice is entirely a personal thing, which I guess raises the question; could a language contain all the things 90% of people need? Or are we forever split between PHP/JS, C++/Java? It's kind of hard to say considering that nobody ever improves these languages like they improve other opensource applications. Personally, I've been thinking about modding a new version of GCC, because I'm getting sick and tired of some things in C++. A static constructor or static class would be wonderful. Truth is, though, I'm scared of GCC! I have no idea how easy it would be to modify. And then of course nobody would be able to compile my code unless they had my version of GCC.
|
|
kentl
Member #2,905
November 2002
|
Quote: A static constructor or static class would be wonderful. Could you explain some more? I'm afraid I'm missing what would be wonderful about it. |
|
Matthew Leverton
Supreme Loser
January 1999
|
Quote: For the record, a number isn't an object in JavaScript either. It's a value, and gets passed by value, not by reference, as objects are. I wasn't referring to JavaScript. I don't mind working with it at all. The problem with JS is that most people use it when having to deal with browser incompatibilities, so they stay clear away. Quote: xml.children[0].attributes.name than $xml->output['children'][0]['attributes']['name'] Well, you are using PHP4's dated XML handler. There are two better alternatives with SimpleXML and DOM. The latter is very similar to JS's, as it's based on the W3C standards. |
|
Marcello
Member #1,860
January 2002
|
True. I haven't played with PHP5 much as of yet, but I don't recall SimpleXML making what I said terribly shorter. JavaScript 1.5 (I think that's the version) added E4X, a literal xml syntax which is kind of interesting, but I haven't messed with that either, as Helma is still using the previous version of Rhino (it's not yet compatible with the new one). Quote: String(value_x) + String(value_y) Can't say I've ever needed to do that, but you could just do "" + value_x + value_y In general I'll have a character in there, though, so it'll be more like value_x + "," + value_y. Marcello |
|
Matthew Leverton
Supreme Loser
January 1999
|
The other direction is more common. var x = document.getElementById('foo').value; // 42 var y = document.getElementById('bar').value; // 1 var z = x + y; // z should be 43! alert(z); // 421 :O
Of course you can avoid the problem with casting, but PHP has the edge here with the . operator. But, then it can no longer be used with objects. Someone wrote a patch to optionally change . to _ and -> to . but it was rejected. I'm actually tempted to see if a "zend extension" shared object could do just that, because I use classes extensively now... That along with the $this pointer are the two most fundamental annoyances with PHP. When PHP was less about classes, it wasn't a big deal. But it is annoying now. |
|
Marcello
Member #1,860
January 2002
|
True, but that's an inherent problem with loose type languages. Explicit casting helps, but also, in general you should be storing data in the correct format to begin with, if something is stored as a string no matter what, I think an explicit cast is fairgame (and you might want to go a step further and validate the cast is possible). Still, overall, I've been preferring JavaScript over PHP. I prefer Java over PHP, as well, though there are some things that are just easier in PHP (but also in JS), such as the Array and associative array types. Well, that doesn't really matter, and straying from the point. For anyone who is interested, I've got a working version of SQL Schema in JavaScript/Helma (reading xml file, analyzing, validating, and synchronizing with MySQL database), and am currently working on implementing Delight, hopefully I'll have some kind of functionality working soon enough. Marcello |
|
Thomas Fjellstrom
Member #476
June 2000
|
Perl: $x = $document->getElementById('foo')->value; // 42 $y = $document->getElementById('bar')->value; // 1 $z = $x + $y; // z should be 43! alert($z); // 43 :O No inherent problem there, except if course some people's dislike for excess "operators". -- |
|
Marcello
Member #1,860
January 2002
|
What about people's dislike for Perl? |
|
Fladimir da Gorf
Member #1,565
October 2001
|
If you love Java and want to get fancy, you could always use Echo. It's a Swing like GUI and the only GUI that I know of which runs mostly with JavaScripts, thus saving bandwidth. But it's mostly for web based applications, though. OpenLayer has reached a random SVN version number ;) | Online manual | Installation video!| MSVC projects now possible with cmake | Now alvailable as a Dev-C++ Devpack! (Thanks to Kotori) |
|
Thomas Fjellstrom
Member #476
June 2000
|
Quote: What about people's dislike for Perl? That is what I was alluding to -- |
|
Marcello
Member #1,860
January 2002
|
What scares me about Perl is I find it impossible to read or understand anyone else's code. That's a bad sign right there. It's not exactly an accessible language. Marcello |
|
Thomas Fjellstrom
Member #476
June 2000
|
Thats up to the coder. Its hardly the languages fault a given coder decides to write code thats hard for people to understand. Unless of course you have a major alergic reaction to excess $ymbol$. -- |
|
Marcello
Member #1,860
January 2002
|
Actually, I would argue that it is the language's fault. There's too much syntax and too many 'unique' ways of doing things. While that's very fine and well for art or poetry, it's not so useful with coding. The fact that 95% of Perl is impossible to read or understand tells me that the language is at fault. Marcello |
|
CGamesPlay
Member #2,559
July 2002
|
Are you sure it's the language and not the reviewer? -- Ryan Patterson - <http://cgamesplay.com/> |
|
|
1
2
|