49 points · by initself · 17y ago · 30 comments
p.s. I've written this here before, but can't track down the link.
I suspect that js is not yet the world's most popular language but by this link's argument, it may become one of the world's most popular languages.
However, as ajax evolves, js may become more of a "virtual machine" into which the initial UI source code is compiled rather than being the raw language in which the UI specified.
(Actually, I recommend sitting down and writing Javascript without a library, just so you have an idea of what works and what doesn't across browser. It was somewhat surprising for me to be sure.)
You are aware that programmers have been doing this in essence since Assembly Language was invented right? Programming directly in binary is just too much for our human minds to take.
That said, you are much more correct than you realize. Even programming a "simple" or "direct" translation, like compiling from C to object code is rife with pitfalls...
In general, as long as the compiler is bug free, you should be fine. Its just that never running into a compiler bug is much less likely when you're using very new code. Code is often buggy after all ;)
I see from another comment that you've used GWT. This may be why our experience differs. Java and Javascript are so far apart (ironic given their names) that to generate one from the other is inevitably going to be complex. We use Parenscript, and the semantics of Lisp and JS are much closer. As a result, I've been consistently surprised by how suitable JS has proven as a target language and how simple the whole approach is.
We've even extended Parenscript into a pretty expressive subset of Common Lisp compiling efficiently to Javascript. We never set out to do this - it just spontaneously evolved - and it's a small subset, nowhere near all of CL. But it covers enough that we can write large portions of our app to run both on the server and in the client, which turns out to be valuable sometimes.
That being said, we pay close attention to the generated Javascript, so I agree with your suspicion of X-to-JS compilers in that sense. What we do is a semi-abstraction.
But no matter what, you brush up against the fact that when the languages are just plain different, you have to be careful. And if you know Javascript is different from Language X, and can debug the difference, why are you writing Language X and not Javascript?
Honestly, most of what Lisp does that makes it unique (first class functions that aren't ugly, macros), are either availabe (first class functions), or something that the compiler can take care of for you, so it seems that Lisp is actually a scarily-good-fit for language to compile to JS. (Assuming no encountered bugs that is ;))
I'm not sure if javascript will become a big target language. The only framework that I know of that compiles into javascript is GWT and I don't think that it is receiving widespread use.
Parenscript is another language that compiles to JavaScript, and although it's very simple, I think most web apps written in CL use it. So it might not be popular overall, but it is popular among its target market.
Now if only I could have a cxml-stp style DOM in Javascript...
Parenscript's simplicity is by design and is one of the best things about it. It makes it easy to read and debug the generated JS, and allows for efficiency while still adding a ton of abstractive power.
Now if only I could have a cxml-stp style DOM in Javascript
I don't know what that is. I googled it, and still don't know what it is. Could you give a brief description and an example or two of why you like it?
already the desktop UI approach (think Java AWT/Swing) is gaining traction, eg GWT.
nonetheless, if using js directly, the js itself isn't so important: * use a good js library with helpful abstractions for DOM traversal, manipulation, etc * use good js frameworks, eg for compiling data plus templates into html * use ajax to get html
I've managed to have bugs that show up in the browser that I have had an amazingly difficult time tracking down. You get a pile of javascript from your pile of java, and it can be hard to tell where the bug is at all.
Complexity is dangerous, and GWT is fantastically complicated. I haven't run into a GWT compilation bug, but I'm sure there exists such a thing, and the day I run into it I will simply sit down and cry because I have no other recourse.
(But when it works, I guess its kind of a nice way to build UIs, if you like Java-style UI APIs... I've never met such a person, but I'm sure they exist ;))
I would disagree about it being elegant. It's a fine language, but it has no unifying concept. It's procedural, it has anonymous functions, it has simple OO built-in. This isn't really elegance because you can't go anywhere uncharted with this. The simplicity is there because there isn't much built-in. Code is not data. There is no module system. There is no generalized flow control. (I am not sure why language designers like manually implementing function calls / return, exceptions, loop/break/continue, etc. when continuations generalize all of this.)
Anyway, JavaScript is useful, but it is a limited subset of nearly every other language. This may be good, but where features are missing, everyone has their own incompatible "fix" for that. That may or may not be elegance; I'm not sure.
You're right.
What self respecting Startup would bother with such an obviously deficient language? It's just not up to the job. Just keep using your Turing complete C/C++, Java (or insert your own favourite Turing complete language) and everything will be alright.