Forgot your password?
typodupeerror
GNOME GUI Programming Software IT Linux Technology

Building Linux Applications With JavaScript 288

Posted by kdawson
from the keeping-it-local dept.
crankymonkey writes "The GNOME desktop environment could soon gain support for building and extending applications with JavaScript thanks to an experimental new project called Seed. Ars Technica has written a detailed tutorial about Seed with several code examples. The article demonstrates how to make a GTK+ application for Linux with JavaScript and explains how Seed could influence the future of GNOME development. In some ways, it's an evolution of the strategy that was pioneered long ago by GNU with embedded Scheme. Ars Technica concludes: 'The availability of a desktop-wide embeddable scripting language for application extension and plugin writing will enable users to add lots of rich new functionality to the environment. As this technology matures and it becomes more tightly integrated with other language frameworks such as Vala, it could change the way that GNOME programmers approach application development. JavaScript could be used as high-level glue for user interface manipulation and rapid prototyping while Vala or C are used for performance-sensitive tasks.'"
This discussion has been archived. No new comments can be posted.

Building Linux Applications With JavaScript

Comments Filter:
  • by gravos (912628) on Monday January 19, 2009 @08:10PM (#26522737) Homepage
    Javascript is just one more language, but it's a VERY popular language and a hell of a lot more people know it and use it then C# or GNU-C or anything else. Gnome is about providing a programming environment for normal people to use and if Javascript allows that then they will use it. However...

    Gnome's base libraries are C and probably are always going to be programmed in C. This is because C is very universal.. it's relatively easy to port to other platforms and it's able to be included in most other langauges as modules.
  • Re:PyBank (Score:3, Informative)

    by segphault (724325) on Monday January 19, 2009 @08:11PM (#26522743)
    You need to read more carefully. There is a whole section about GObject introspection on the first page of the Ars tutorial. It even mentions PyBank.
  • says who? (Score:1, Informative)

    by Anonymous Coward on Monday January 19, 2009 @08:16PM (#26522809)

    Javascript is easy and useful. Perl and python have nothing to do with the functionality of javascript. Neither do .net or Java. What exactly are you talking about?

  • by monkeythug (875071) on Monday January 19, 2009 @08:34PM (#26523015) Homepage
    More to the point - this sounds very similar to QTScript which has been available for more than 18 months (since QT 4.3)
  • by erroneus (253617) on Monday January 19, 2009 @08:36PM (#26523051) Homepage

    What part of "Active Desktop" was a good idea? Why are we attempting to recreate that?

    At the very least, I hope steps and measures are taken to ensure that there is NO code that can be hidden and that a complete console allowing the viewing and editing of all Javascript code complete with the ability for users to DISABLE it.

    I can see where some things would be nice... and in fact, nicer because it was written in a scripting language rather than a compiled or interpreted binary. But there are some things I would rather not see "uncontrolled."

  • Re:God no! (Score:2, Informative)

    by Anonymous Coward on Monday January 19, 2009 @08:46PM (#26523145)

    Javascript lacks a clear way of enforcing interfaces. Any part of the program can extend or modify the prototype of any other object on the fly and wreak havoc by invalidating reasonable assumptions which other programmers had about that object. Javascript also lacks multithreading support (no way to synchronize in the language itself). Closures are nice if you know how to use them, but otherwise they are a serious memory leakage hazard. Last but not least there's the problem that Javascript is the VisualBasic of the web: Everybody and their mother pretends to know how to code with it. When real data is involved, it's definitely going to get ugly.

  • by FishWithAHammer (957772) on Monday January 19, 2009 @08:51PM (#26523213)

    There's nothing stopping you from writing a JavaScript compiler. Hell, there's an ECMAScript 4.0 [wikipedia.org] JavaScript implementation for .NET.

  • by mpyne (1222984) on Monday January 19, 2009 @09:06PM (#26523359)

    And even before QtScript there was KJSEmbed [xmelegance.org], which has mailing list archives [kde.org] dating back to 2003.

    Of course TFA itself pointed out QtScript and how it is used by Amarok...

  • Re:says who? (Score:1, Informative)

    by Anonymous Coward on Monday January 19, 2009 @09:15PM (#26523479)

    Having objects does not make a language Object Oriented.

    JavaScript has objects too, in fact everything in the language is an object. It's still not an OO language, though, as it doesn't (naturally) support all of the 'pillars.'

    My statement still stands, Perl is a 'multi-paradigm' language that had objects hastily tacked on. (Perl 5, IIRC)

    So, no, not an OOP language by design.

  • by caseih (160668) on Monday January 19, 2009 @09:46PM (#26523723)

    Umm, because it's precisely the *right* language for the job. C++ restricts your binding options to other languages pretty dramatically, especially if you use parts of C++'s object model such as multiple inheritance. In short, no C++ is the wrong too for the job, Qt's use of it notwithstanding. Although it's true that Qt does have bindings for many languages, the simple fact is that these bindings, such as PyQT, are against the *C* wrapper on the C++ api. So an entire extra layer in the way. Gnome and GTK's gobject-based object model is just about one-to-one with most models of object-oriented languages. Hence you can use just about any language under the sun to develop Gnome apps. All without losing any features of the API.

    If you do want to program in C with GTK, you can and it's very easy, actually. Memory leaks are minimized because of the coolness in glib. However, if you're not a C programmer then you shouldn't be programming GTK/Gnome apps in C at all. Use something more powerful like Python. In fact I can't think of any reason (except embedding on small systems, or core libraries and programs) where it's appropriate to write a Gnome app in C. There are tons of awesome bindings available. Use them. Write in C++ (which is a much nicer API at times than Qt's moc-ified native apis) if you want.

    So yes. Gnome is able to target the languages that normal developers want to use. Whether that's C#/.Net, Python, C++, Ruby, or C.

    If Gnome wasn't written in C, what language would you suggest? How would you provide extensive, 100% coverage of the API in any arbitrary language? Writing GTK itself in C# seems pretty silly. Same for Python, Ruby, etc, unless you want to restrict the entire toolkit to just one language.

  • Re:PyBank (Score:3, Informative)

    by morgan_greywolf (835522) on Monday January 19, 2009 @09:56PM (#26523833) Homepage Journal

    Right. But Python already has introspection without GObject. I think that was part of the original poster's point. And GObject and GTK have had very stable and mature Python bindings for years.

    So the question remains: What does JavaScript bring to the table that Python or Perl or Lua or Scheme or Ruby do not?

    IMHO, nothing other than the fact there are probably a lot more JavaScript programmers than all of those other languages combined. Of course, in general, they tend to be lower quality programmers.

    If you ask me, this whole thing reaks of another language *cough*VBScript*cough* that has been the root cause of multiple security vulnerabilities on another operating system platform. Mostly, in fact, due to the high percentage of low-quality programmers said platform brings to the table.

  • by SanityInAnarchy (655584) <ninja@slaphack.com> on Monday January 19, 2009 @10:00PM (#26523869) Journal

    What part of "Active Desktop" was a good idea? Why are we attempting to recreate that?

    Seems more like Active Desktop was a bad implementation of a good idea. (For other examples, see UAC -- I use sudo, and I like it fine, but I can't stand UAC, which is the same idea.)

    But this isn't even the same idea -- it is not about setting your desktop background to some website. It is about writing new applications in a different language.

    At the very least, I hope steps and measures are taken to ensure that there is NO code that can be hidden and that a complete console allowing the viewing and editing of all Javascript code complete with the ability for users to DISABLE it.

    ...why? Do you expect the same thing from C or Python?

    Because, as I understand it, that's all that's happening here -- you can develop a desktop application in JavaScript, just as you can in C, Python, Ruby, or whatever else.

  • Re:Didn't RTFA.... (Score:3, Informative)

    by shutdown -p now (807394) on Monday January 19, 2009 @11:49PM (#26524767) Journal

    Actually, yes, JS is much more convoluted than it has to be, partly because it pretends to be so many things at once. Non-local local scope is a good example. For a Java-looking language, you'd expect code blocks to introduce scope, but they don't. For example:

    var x = 123;
     
    function foo()
    {
      document.write(x);
     
      if (true)
      {
        var x = 456;
      }
     
      document.write(x);
    }
     
    foo();

    This will not give any errors on the second var, but it won't print "123123" as expected, either. This is because the var declaration makes the variable local in the scope of entire function (despite the declaration itself being in a block), and the declaration applies to all references to that variable within the function, even those preceding the declaration.

    If that's not a gotcha, I don't know what is. It's worse than VB6 scoping rules.

    And no, it's not the only messy thing in JS.

    If you really want to see what a clean, non-convoluted language with JS-like philosophy should look like, see Lua. It's no surprise that the latter is heavily used for scripting in many places where there's a lot of it (e.g. games).

  • by Rei (128717) on Tuesday January 20, 2009 @02:06AM (#26525621) Homepage

    There's a pervasive myth that C++ is just objects on top of C. Or that because you can use objects, that means that you *have* to use them everywhere.

    C++ is useful for tons of things. Someone who doesn't know how to use templates will create a nightmare's worth of code in a situation that calls for them. People who don't use object data structures in areas that aren't performance critical (and oftentimes even where they are, since there are a lot of optimizations in the std libraries that a lot of people miss out on when reinventing the wheel) often create a memory management nightmare and leaky code. People who don't use const correctness slow down their code and are at more risk for bugs. And on and on down the line.

    You misunderstand the concept of cache hits. Whether you get a cache hit or miss isn't dependent on how much memory your *program* loads up; it's based on what's being executed at a given point in time. If you have a core loop iterating through some data structure, if you're not calling any big libraries, then they're not affecting cache hits for your core loop; the cache is going to be dominated by that data structure. Quite the opposite, C++ actually often has a *greater* chance of cache hits because data stays local to an object, and when a block of data is read from memory to the cache, you're more likely to get variables that you need cached.

    Again C != C++.

    C is a subset of C++. If C can do it, so can C++. Anyways, why did this become a C vs. C++ thread?

  • by Anonymous Coward on Tuesday January 20, 2009 @03:54AM (#26526113)

    I'd really like a more complex, personalized moderation system where I could mark off people I've discovered as being closed to new ideas so I could know right away to give their posts less weight.

    It exists today. Just add them to your foes list and then assign a negative modifier to foes.

  • by hdon (1104251) on Tuesday January 20, 2009 @03:11PM (#26533421)

    But javascript is an awfully convoluted language. Why does it become easy when you put a language like that into the equation?

    To put it bluntly: "Because a lot of people already know it." ... The problem with attracting developers is that so many of them these days have went on to develop web applications with awful scripting languages like Javascript...

    You know what I don't think this is accurate at all. Javascript is actually a very elegant language [mozilla.org], what is convoluted is the "web" platform.

  • by Kidbro (80868) on Tuesday January 20, 2009 @06:33PM (#26537807)

    No. Inconsistently mixing tabs and spaces is a syntax error. The program simply won't run, and it will inform you as to why (much like how your C compiler will propably let you know when you've used a lower case l [wikipedia.org] rather than an upper case I [wikipedia.org], even though they look the same in your font).

System checkpoint complete.

Working...