How to integrate Rails with PhoneGap? - javascript

I've been looking at PhoneGap recently and I would like to use it for one of my projects, but I'm a little confused as to how it works. It says you can use HTML, CSS and JavaScript. But what can I use for the backend? What I want to make is pretty basic, I want users and for them to have basic profiles, but I use Rails for that. Can I use Rails with PhoneGap or will I have to learn a new JavaScript framework?

Phonegap is client side only. It gives you a Javascript API to access hardware features and other phone specific stuff. It has no connection with, or opinions about what you use for your server backend. It doesn't even need a server backend at all.
It is your Javascript code that you write for your client that communicate with your backend, so you can have it any way you want. Sure, Rails will be just fine.

Related

Electron GUI with C# backend

Use case
I've got an existing project developed in C# using WinForms with custom controls for the GUI. We are amazed by the approach to write GUIs using HTML/CSS/JS and we are looking for the best way to write a GUI for our desktop application using the above mentioned languages. We only need to support Windows devices.
My worries:
It doesn't take long to come across recommendations using electron-edge. While I am not so worried to get everything working, I am worried about:
Debugging my C# code (I still want to be able to start my whole application right from VS and debug it look I am used to it). I read that I would need to attach to the node.js application in order to debug my C# code afterwards. Since the whole program language is written in C# that sounds like a pain?
As far as I got edge will let it run as just one process. Can I consider the electron application as an own thread which would still run while my C# code is stuck somewhere?
My option:
I am still positive I want to write my desktop GUI with HTML/CSS/JS. What I considered instead of using electron-edge is writing an own electron application which does communicate with my C# backend using named pipes. I wonder if there are larger roadblocks why I wouldn't want to do this and use electron-edge instead?
My question:
I would like to get feedback for my two concerns mentioned above and I also would like to get input about my option to create the GUI as own electron process, so that I have two processes (GUI+Backend) when someone runs my application.
Electron.NET may be a option for you. You can write c# code with electron.
You can do it in many ways
1) COM. Create C# COM DLL. Create wrapper functions for the DLL using N-API (Native node module) or use FFI. You can access the functions from JS.
2) Create a .Net web server and include your functions as REST endpoints. From UI make http request to communicate (Clear separation of UI & BEnd)
You can checkout my github repo for a few alternatives to electron.
I think a most import question would be how your frontend interacts with the backend? Is there any notifications need push to the frontend?
WebSocket could be a good option for two ends communication.

Single Page Application - Should I use MVC Framework on the server side?

I'm developing a SPA application and I can't decide, whether to use server-side MVC framework or not.
I have chosen AngularJS as the client-side framework. I was thinking I could use Symfony 2 on the server side, but I also considered using pure OOP oriented PHP. Something like this - database class, model classes (User, UserDbManager, ...). I would use something like Slim to create the REST API.
It seems counterproductive to basically write the same code twice, once on the client side and once on the server side, if I could just use the server to serve the data from the database.
If anyone had done similar decision, I'd be happy, if you'd share your thoughts and tips about it.
I would decide depending on the complexity of the requirement.
If it's a very simple I don't see a huge difference in using a framework or plain old php.
But if it's a complex project, I would definitely go with a framework considering the fact that most of the core functions one might need are already there and quicker development.
Again, it would come down to personal preference too.
Codeigniter has been said easy to learn for beginners in framework.
Symfony and zend are more commercially used (I am not saying others are not, but I see more vacancies asking for symfony or zend development experience).
My suggestion will be if you are having angular js as clientside framework. Then take advantage of it and use some api on server side to just return some json kind of response. Why send html on network when you have angular js on clientside to work with dom. just send data from server to client.
I have also done same. I have jquery for clientside and i am using spring mvc to send response as json.

Socket.io/Node.js & SCTP?

I am developing an web application that will use web sockets to dynamically update the website for the user. The idea is to have changes in the back-end engine be dynamically transmitted. In order to do that, I want to use a Node.js server as a link between the web browser and back-end engine. Unfortunately, Node.js/JavaScript does not support SCTP sockets, which is what the back-end engine is using. Can you think of any way around this? It would be a shame if I couldn't use Socket.io and would have to deploy my own Javascript plugin & Java websocket server.
You can write the SCTP part in C or C++ and then write an addon to make it available in Node.js. I am currently trying that for one of my projects using SCTP.
Of cource, this is not super elegant, not very portable and it is some extra work, but if you really want to use Node.js, this is one of the possible ways...

Understanding Node.js use cases

Trying to understand using node.js for a web applications.
Are there basically 2 major uses cases, i.e.:
The entire system is written in node, so you have functions for login, logout, password recover, and whatever else the web app does. All of this is written in javascript?
You use node.js only for sending the client updates, to have a real-time effect on the app. But the rest of the application is written in e.g. rails or django
Please tell me if I understand this correctly:
In terms of other technologies used with node.js, you tend to see people using node.js as the backend server, socket.io on the client side to establish a cross-browser long running ajax call library, and then you might use backbone.js for your client mvc pattern.
Is this right?
Basically speaking, it is just a tool to run javascript code server side. What you do with it is up to you. Many are using it as a complementary system since it's relatively new, but it's perfectly possible to run an standalone app with node.js.
It's said to be particularly good at handling concurrent connections, which is why it is often recommended to handle real-time jobs within an app, but there is no "obligation" so to speak to use it for this specific use case, it's just one thing you can do.
As with everything, the best way to understand it is to use it, so don't be afraid to play around with it.
Use case for Node js as we are using in our Application
Skype like voice & video chat on chrome browser using node js

Dilemma... Which Program & Language to develop my Android and iOS App

I'm developing an app for both the android and ios platform. I'd like to take a route that allows me to only have to code once for both platforms. There are 2 options I've come across:
Develop in Flash builder 4.5 with flex (actionscript, or I've heard javascript also?)
Develop using Phonegap (javascript)
The app is very simple - it will use the google api and the phone's geolocation function, then also display more information about the business listings from google map's api. Downloaders of the app will also have to register to become free members. All of this information will have to be put into a mysql database on my server.
So my question is, which is the best route to take with what I am hoping to accomplish? If using Flash builder, is it best to learn actionscript or javascript? What's the best way to connect with the mysql server if I'm writing in javascript, ajax?
If you are serious about it and want to create other apps as well in the future, you should learn the native frameworks/languages for each of the platforms. If not, and you just want to make one quick app I would choose Phonegap rather than Flex/Flash.
Firstly, get familiar with HTML and Javascript to understand what they are even capable of. There's no point in trying to complete a project with tools that you don't understand. As for the options you named, I'd definitely go with the Phonegap method as it is much simpler.
However, you also need a backend for your solution if you're trying to use a MySQL or other database to store any data. For this you'd need some server-side language like PHP, JSP (or you could use NodeJS, if you want Javscript on the server too) etc, that retrieves information from the database according to the requests received from your app.
In conclusion, I'd suggest you to read more about PHP/MySQL, Javascript and making webpages, since this is what you are actually trying to do if you use Phonegap, even though you might look it as an app. Do some tutorials, get to know the languages before you try to take on something that surpasses your skill level just yet.
For a nice small db-interface I'd rather suggest using ruby (with sinatra as mvc-framework and activerecord on top of mysql, or just use rails) than using php!
http://guides.rubyonrails.org
http://www.sinatrarb.com/

Categories

Resources