Embedding other programs in an Electron app - javascript

I have recently begun working with JavaScript and have learned of the Electron framework. I am very interested in this framework (and the whole web technologies for desktop use concept). My programming capabilities could be best described as hobbyist. I have written a few small games and apps for my own use, and have a number of shell scripts to help me automate some of my workflow in Linux. My question is, is it possible to use an Electron app that is powered by a language other than JavaScript? For example, I have a bunch of Python scripts (and recently, some Haskell and F# ones too) to help me with my statistics, calculus, and accounting courses in school. I don't mind running a bunch of different scripts to do what I want but lately I've gotten the idea of potentially making some of them available for general distribution. But my scripts are, as I mentioned, written in several different languages, most of them functional languages and none of them in JavaScript. Is it possible to wrap these scripts into something like an Electron app? If not, does JavaScript have any features similar to a functional language? How would one go about creating a JavaScript library or framework to fullfil this need?
I am aware of platforms like SageMath and GNU Octave, but the whole point is to create something of my own.
I would appreciate any thoughts or suggestions. Thank you.

The short answer is there's no direct/easy way to do what you want.
But you have some options.
There's a Electron compiler, but it works only with Javascript based languages like TypeScript and CoffeeScript.
You can, of course, develop a local web application and communicate with your Electron UI using HTTP requests, here is an example using Python.
You can also use sockets for interprocess communication: https://www.npmjs.com/package/electron-ipc-socket
And you also has the option to just start a child process directly from your Electron Application.
Hope it helps and don't make you more confuse :)

Related

JavaScript basics/instructional

I have just begun giving JavaScript a try on a programmer friend's suggestion (though I have used it to some extent before with websites using jQuery without fully understanding the intricacies of the language itself) and was wondering how certain features work.
Question:
What other uses of JavaScript are there aside from websites (by itself and/or with jQuery framework)? Is there a difference between making a site interactive and an actual "web app"? I've heard the term and don't know the difference.
To add to my main question:
I've read and done some tutorials on prototyping and am not sure on its actual application (since what little I've dabbled in, by making a website more interactive, I've never seen them used). Can someone link a website with extensive deep/heavy JavaScript use so I can check it out?
Gist:
In essence, what I'm trying to understand is where heavy use of JavaScript comes into play because so far, all JavaScript I've experienced is superficial.
Appreciate in advance any advice/help in this matter!
What other uses of Javascript are there aside from websites (by itself and/or with jQuery framework)?
Check out node.js. It runs JavaScript programs not intended for web use. Node offers a bunch of imports for things like file system IO, socket IO and a bunch of others. I personally use it for a WebSocket server because I don't like my alternatives.
Further, JavaScript has native support in many operating systems, including all Windows versions after and including XP (not sure about before). Windows Script Host runs .js files as JScript and these can be used to achieve things like those node can. It's a convenient way to do things batch can't.

Creating a Web2.0 application with Maven(or other build tools)

Background:
I've been building web apps and web sites for many years, but each time I tend to start from scratch as each project has different requirements. However, this has me building my workflow from scratch as well. At this point, I'm about ready to settle on something a little more standard.
But what exactly is that standard? Being a JAVA developer by nature, I'm drawn to tools like Maven. And I've seen some work in the community for better Javascript support in Maven (javascript-maven-tools, javascript-maven-plugin, and others). But is this the best way to do it? I tried for a while to find a good WEB2.0 client/ajax-app maven-archetype to no avail.
I'm going to want to use tools in my workflow including JSLint [[http://www.jslint.com]], JSUnit [[http://jsunit.net/]] for testing, Documentation with things such as JSDoc Toolkit [[http://code.google.com/p/jsdoc-toolkit/]]. Compression and Framework inclusion would be nice too.
So, at this point, I'm even stumped at the the basic ways to start my app. What should a directory structure look like? For a pure client/frontend app (so no controllers, etc), do i just have a single webapp directory?
I guess I'm at that point where I'm questioning "my religion" with webapps. And after talking to everyone I know, I figured it was time for me to open it up to a hive-mind far smarter than my own.
Note. This is a question I also wrote
about in general on my site at
[[http://blog.jbjonesjr.com/?p=283]]
, but no one every cares about it
there.
Thanks for the help, I look forward to your thoughts.
I've started a couple of plugins (this and this) on Codehaus that facilitate the use of Maven for building JavaScript applications following Maven's goal oriented approach. I want to do more of this including the provision of a Surefire-compatible unit testing plugin and a minification plugin that leverages assembles. Take a look at what I've done so far and feel free to help out!
I'm also considering providing a JavaScript DSL for Maven using Polyglot Maven. A colleague kindly pointed out that JavaScript programmers will probably want to express their poms using JavaScript, not XML. In addition they probably won't want the learning curve of Maven. A JavaScript DSL could facilitate that.

Progressive enhancement / Graceful degradation and web applications

I am building a web application that uses a lot of Javascript. Now I am wondering does it make sense to make the application work without Javascript? I can understand for normal websites that you want to make sure everybody can use it but can you say the same of complex web applications?
I checked out some big web apps and it seems some do it and some don't. For example GMail has a basic version that works without Javascript.
If you look at Google Docs it doesn't work at all without Javascript. Creating an app like GDocs without Javascript is most likely not possible.
Is that a good standard to go by: if it's impossible to fall back to a non-Javascript working applicaiton you don't do it?
It really depends on what is your project about and who is your target audience.
For projects that are rather sites/pages than applications, there should be an option to browse through with JS disabled, but it's okay if only in read-only mode. This very site (SO) is an example of that approach.
For projects that are rather applications and involve very complex UI composition and dependencies, there is probably no other alternative. For instance, ASP.NET projects won't work without JavaScript but nobody would usually complain given the powerful abstraction it brings to play.

Starting out with rails. Suggestions for SDKs plug-ins etc?

I have 6 years of C# programming experience and I'm looking to broaden my horizons. I'm going to build a simple web app to demonstrate knowledge of Ruby on Rails so I can get my foot in a place that might want a Rails programmer. It's the hot new thing, so I want to be marketable.
Anyway, I have been playing around with solr and tomcat and I want to use solr as a search engine for a products database. This means that I will be using some java (tomcat and solr) and for the web app I will be using MSSQL because I'm using Windows. A friend suggested that I look into jRuby because if I'm going to be working with tomcat, it makes sense to put it all on one webserver. I want to use Eclipse as my editor. I hear that rails programmers typically use prototype as their java selector tool but I really like jQuery (or even mootools). I have also heard that jRails is something that ties jQuery to my ruby application.
Given that I use tomcat in conjunction with jRuby using Eclipse as the IDE, what would you suggest I use for handling javascript/ajax and what are some useful plug-ins, software, or tips you have for me that can help me get started on the right foot with ruby on rails?
I would stick with jQuery for your JS/ajax. My perception is that the RJS/Prototype is falling out of favor to jQuery but that could be just me. Where jRails would fit in is if you want to use RJS to generate JavaScript from Ruby code. My personal preference is to keep all of my JavaScript in application.js and keep it unobtrusive.
Some plugins I like are Authlogic, Nifty Generators, Paperclip, ssl_requirement, subdomain-fu, and QueryTrace.
A couple good resources for starting out are Rails Guides and Railscasts. I think it's a good idea to learn the language itself before learning the framework, but I'm sure it's possible to develop a simple Rails application with minimal Ruby knowledge.
As for your application stack, I would recommend reconsidering deploying a Rails app to Windows. Even developing a Rails app on Windows will likely be painful. If you can, I'd get a VM (or old machine) running with Ubuntu and use MySQL. If you're looking for a full text search on Rails you could use Thinking Sphinx - here's a Railscast if you're interested. I'd also give a gentle nudge into trying a Text Editor instead a full blown IDE - I like TextMate on OS X and gedit on Linux.
I also had a Microsoft background when I decided to learn Rails. There was a lot for me to take in - Not having the framework pretend the web is stateful (asp.net), learning a new language, learning a new framework, getting stronger css/html/javascript skills, new OSes (OS X and Linux for me), learning new databases. Overall I'm very happy I did. I'm a better developer for it.
If you want to be marketable, I'd start with learning the lowest common denominator, the default Rails stack, to get broad appeal. Then maybe consider acquiring some more niche skills to raise your value to a subset of potential clients/employers.
That pretty much means targeting MRI 1.8.6/7, Rails 2.3.4 (consider learning at least HAML and rspec in addition to erb and test/unit) and MySQL in an Apache *nix world.
I wouldn't recommend learning much about deploying to a Windows stack - the target for servers is overwhelmingly Linux or perhaps some other *nix flavour. For development web server purposes, Mongrel works fine on Windows.
Build on Windows by all means - I do, without too much pain - but be aware that the visible part of the Ruby/Rails community (the people who mostly develop the libraries and frameworks and most of those who write about it online) are predominantly OSX or Linux users, so there's often a delay in the trickle-down to Windows users, especially where OS interaction is called for or where there are compiled elements to libraries. Also, I'm reliably informed that Rails startup is much slower on Windows. I don't want to confirm it personally - I might get upset.
MSSQL works fine with Rails, but I'd be cautious about using any platform-specific features for reasons mentioned above: you're unlikely to find a site that will be happy to deploy to a mixed Win-*nix environment. The MSSQL ActiveRecord code may also not be quite as hardened as MySQL or SQLite - the one bug I ever found in any version of any Rails-related code was in there. That said, if you don't use any MS-specific features you'll find porting easy. But then if you don't use any extra stuff, why not skip it completely? There are enough differences (the query "optimizer" in MySQL for one takes some getting used to) that you're probably better off learning the platform you're most likely to be targeting.
As for Eclipse, it's obviously a mature development environment but I'm not sure how good the Rails plugins are (and as a hostage to Lotus Notes I'm allergic to using Eclipse any more than absolutely necessary). If you can't live without an IDE (and I'd recommend that you try - you'll learn more) then there are several SO questions that cover the alternatives.
Using Solr in your project doesn't require that you have a Java stack for running the actual Rails app. There are quite a few Ruby libraries out there that would help you easily interface with the Solr backend. A few to look at:
solr-ruby – This is the official client library included with the Solr distribution. It's lower-level than some of the other alternatives, but gives you some good flexibility in accomplishing what you need to.
rsolr – Another lower-level library that looks like a replacement to solr-ruby. At first glance it appears to be more frequently updated.
sunspot – I have not used this, but it looks like it's currently the most popular Solr => Ruby object mapping library. The acts_as_solr library was once an option, but I think that it has since fallen out of favor.
I agree with the other posters that you would want to target a C Ruby / *NIX environment, but if using Tomcat/JRuby helps you learn this faster, go for it.

GWT or DOJO or something else?

I come from the Microsoft world (and I come in peace). I want to rapidly prototype a web app and if it works out, take it live - and I don't want to use ASP.Net.
I am not sure which web application toolkit to use though. Should I use GWT, DOJO...other recommendations? I am open to any server-side language but am looking at RoR, Php or even Java (J2EE to be precise). I am not much of a Javascript/CSS guy so a toolkit that might make it relatively easy on me on those fronts would be preferable.
Also, I am a mac user at home. What IDEs go along with the framework you would recommend?
Any recommendations guys?
If you're open to doing Java, GWT is the way to go. It allows you to have a relatively uniform codebase across client-server, and to only use one language on both.
There are some limitations to doing very off-the-beaten-path AJAXy things (which GWT makes difficult, but not impossible), but it doesn't sound like that's your use case anyway.
GWT will allow you to scale up by using more of its features as your app gets more complex - and your prototype won't be throwaway code.
If you want to write the front and back end in JAVA, and want to do complex ajax type thing, then GWT is a great way to go.
The easiest way to think about it is that building a GWT app is kind of like building a JAVA swing application that hooks into a server. Just like a swing app that uses a server you can make it fat or thin. When you're done it all compiles down into HTML and javascript, and has very good modern browser support (ie6+ ff, opera, safari).
It does abstract all the javascript and HTML away, but if you want it to look good you'll still need to understand CSS.
I think anyone who says that that it ruins MVC or that it's a muddying of client vs server doesn't understand GWT. GWT is a CLIENT side framework. And it is only used on the CLIENT. GWT does provide an RPC mechanism to hook it into JAVA (and other) back ends, but that's just a communication protocol, it doesn't mean that your server code magically becomes your client code. Sure you can write a whole bunch of business rules into your UI if you really wanted to, but you can do this with any framework, so it would be silly to say that GWT is somehow different in that respect.
GWT is a good choice, while if you choose more powerful JavaScript framework based on GWT (e.g. SmartGWT), the compiled stuff is too heavyweight.
Choose direct JavaScript if you need a compact project.
I am a fan of GWT, however I am very familiar with Java. I found it to be intuitive, and surprisingly easy to get good results quickly. If you are to use GWT, then you'll definitely want to use the free, and immensely powerful Eclipse IDE.
One disadvantage of GWT is that it requires Javascript to be supported by the browser, there is no "graceful degradation".
We have evaluate a large list of frameworks and have decide us for Echo2.
You need only to code in Java. Javascript you need only if you want write your own components.
There are no startup performance problems with large projects like GWT.
You can use the full range of Java in your client code because it run on the server. In GWT you can use only very small set of Java classes.
The IDE for Java is Eclipse. This is independent of the used framework.
I'm a fan of jQuery, the chainability of actions, traversals, and commands is really powerful. A good friend of mine is crazy about Mootools, he works at a Java shop FWIW. He mentioned a cool feature of Mootools is that you can specify the functionality you want the framework to include and it will generate the entire library on a single line in a file that you can include on your page to minimize the weight of the framework (pretty cool feature). Really it just depends on what you are most comfortable with. jQuery has great tutorials, is super fast, and can be used along with other javascript frameworks.
Not related to GWT, but have you considered other backends that GWT could work nicely with?
Grails is one backend that ties quite nicely with GWT.
Personally, I would avoid server-side frameworks that try to embed or hide the client-side framework. I'm sure that GWT is great for getting something going quickly, and is probably fine for certain kinds of applications, but you'll probably run into lots of problems "on the edges" for more complex applications. Decoupling the client framework from the server-side framework avoids those problems.

Categories

Resources