How to create a node.js application for desktop, web and mobile with a single codebase? - node.js

Is there a way to compile a node.js application for multiple devices? I would like to use Electron for desktop (Chromium), NativeScript for mobile devices and also have a SPA for common browsers. There are many parts of this application that look alike - although those systems are not combatible between each others, there must be a way to share the key parts between each other.
Unfortunately there is not much information on the web about this issue, thanks in advance.

I've voted to close because the question is too broad, but here is some general information to help you develop more specific questions:
There are any number of ways to do what you're asking for. But generally you'll want an API capable of servicing all of your clients (the term API is being used very generally. It may not be a simple REST API you're looking for, depending on what you are trying to do). As for deploying your application to multiple platforms, you'll either need to find a library, framework, language, and/or emulator which supports UIs for all of your desired platforms, or create dedicated clients for each device, or a mix of the two. For simple HTML applications, React is one such front-end library/methodology/framework which can support multiple platforms through its various versions. You could use something such as Electron to pack up your application and make it look like a native app.

Related

Technology advice for mobile application

I would like to develop a mobile game, kind of like an interactive ARG.
The players would see POI-s on a map, and they can interact with them in various ways. Some interactions on a POI should be visible to other players real time, and players should receive push notifications when a new POI appears in their area.
Up until now, I mostly worked with web technologies, so I figured a Node.js for backend, and a React Native for the application would be nice choices and I could learn both along the way. Since I have little experience with both, and don't really know about their capabilities performance-wise.
Are these technologies a good choice for an application like this? Is there a reason to go full native iOS/Android instead of React Native?
Could Node.js and React Native handle like 1-200k players daily? (It will probably never get there, lol)
I know it's just a pet project, but I'm interested in what would be the "industry standard" stack for something like this?
I would think using React native should be fine for this genre of game for your frontend/client. Where it seem to involves a lot of point click, drag and drop, present player with information. If more real time rendering and interactivity then you may need to use a library/framework that are suitable for more real time rendering and interactivity.
As for the backend using Node.js is fine for handling your data requests. For scaling to support lots of user, then that's quite a big topic that you'll need to work out. You'll typically have to look at how complex your data/requests are and so how much your server can handle the load. From there you will need to load balance on multiple servers.
For game or any type of application, where you need a backend it's very similar in needs. You'll use a language that's best for backend development and performance. From there you have to serve it and scale accordingly base on your loads. You can leverage AWS or other cloud providers to do a lot of these.
Hopefully this answer some of the things you're asking for.

How to gather user metrics for an Electron desktop app?

I would like to gather some metrics about usage for an Electron-based cross-platform desktop app. This would consist of basic information on the user's environment (OS, screen size, etc) as well as the ability to track usage, for example track how many times the app is opened or specific actions within the app.
These metrics should be sent to an analytics server, so they can be viewed in aggregate. Ideally I could host the server-side component myself, but would certainly consider a solution hosted by a third party.
There are various analytics solutions for the web (Google Analytics, Piwik), and for mobile apps, as well as solutions for Node.js server-side apps. Is it feasible to adapt one of these solutions for desktop Electron-based apps? How? Or are there any good analytics solutions specifically designed for use with desktop apps which work with Electron / javascript?
Unlike a typical webpage, the user might be using the app offline, so offline actions should be recorded, queued, and sent later when the user comes online. A desktop app is typically loading pages from the file system, not HTTP, so the solution needs to be able to cope with that.
Unlike a Node.js server-side application, there could be a large number of clients rather than just a single (or a few) server instances. Analytics for a desktop app would be user-centric, whereas a server-side Node.js app might not be.
Ease of setup is also a big factor - an ideal solution would just have a few lines of configuration to gather basic metrics, then could be extended as necessary with custom actions/events.
The easiest thing will be to use Google Analytics or a similar offering.
For most you'll have two major issues to solve over hosting on a website:
Electron does not store cookies or state between runs. You have to store this manually
Most analytics libraries ignore file: urls so that they only get hits from the internet
Use an existing library and most of these issues will already be solved for you.

What is absolutely necessary to have a website running on the web?

After a couple hours of searching top lists of free "web servers" and "web frameworks" on google, I realized I'm not sure what I'm looking at.
Let's take a couple of example softwares I have come across :
IIS
Apache HTTP server
Apache Tomcat
Socket.io
Node.js
Django
Questions :
Do all these work on the same scope/do the same thing?
If not, what is absolutely necessary to have my "helloworld.html" acessible from anywhere with internet? Let's consider I already have a dedicated server and a domain
Also if not, how do these work together/compliment eachother?
Each of this software has a different description on their website for what it does, what it is, who should use it, it really gets confusing when you're trying to find what is "fresh", what the cool kids are using
IIS and Apache are web servers that support a variety of different technologies for plugging code into the web servers. So, if you were using one of these web servers, you would also use some other framework and language runtime to plug into them.
Apache Tomcat is a Java-based server framework for web applications. From the wikipedia page: "Apache Tomcat, often referred to as Tomcat, is an open-source Java Servlet Container developed by the Apache Software Foundation (ASF). Tomcat implements several Java EE specifications including Java Servlet, JavaServer Pages (JSP), Java EL, and WebSocket, and provides a "pure Java" HTTP web server environment in which Java code can run." It may be used independently of the Apache Web Server. The "Apache" in the name has to do with it being part of the Apache open-source organization. So, if you want to program your server in Java, this is one of your options.
node.js is a Javascript-based framework that is both a framework and it's own web server. So, if you want to program your web server in Javascript, this is your main option. There are additional frameworks you might use with node.js such as Express to make programming your web server simpler.
Django is a python-based framework. If you want to program your web server in Python, this is one of your choices.
socket.io is really not like any of the others. socket.io is a layer on top of webSockets that gives you a whole bunch of additional features over webSockets. This would run in whatever server-side language and framework you were already using and you would have to select a socket.io library that was compatible with your server technology. You can see a list of features that socket.io adds on top of a webSocket here: Moving from socket.io to raw websockets?. webSockets themselves are used for continuous communication between server and client (more efficient than repeated Ajax calls) and for push notification from server to client.
So, if you were looking to select a technology from scratch, there are a number of different ways you could start your selection process.
If you have a preferred language (Java, Python, Javascript, Ruby, C#, etc...) you either know already or want to learn, then you can look at the frameworks that support your language and start there. The framework will indicate whether you need a companion web server or whether than is already part of the framework.
If you have an existing hosting company that you want to use, you may need to understand which technologies they support so you don't select something that would require you to change hosting companies. Not all hosting companies support all technologies and some are better specialists in some technologies.
If you have specific 3rd party code or libraries you want to use, you may want to investigate which languages/frameworks it can more easily be used with.
What is fresh and what the cool kids are using changes pretty regularly. I would suggest that's a crummy criteria. What makes more sense is to understand which technologies and frameworks are doing well with accelerating growth and a rich development community behind them vs. which ones may be falling out of favor. I haven't myself done any sort of overall survey to offer any sort of list of what's on the upswing and doing well vs. what is more stagnant.
I'm personally partial to node.js and the huge NPM library of open-source and compatible code you can draw from and the ability to use one language for both front-end and back-end. It is certainly one of the choices that is growing rapidly and has a vibrant development community behind it. But, it is not the only choice that would meet those qualifications.

Resources/Explanations on Current Web Architecture & Technologies across the stack?

I am building a new web app but i feel i don't have the big picture representation that I wish to have before building it so I am looking for resources to really understanding the web as whole throughout the full stack.
I've been a self-taught web developer since 2006 but I took a long break during university in 2010 and finished in 2014 and came out and the whole picture of web had changed.
I was familiar with the LAMP architecture and back then as long as you understood PHP, JavaScript, JQuery, MySQL, HTML & CSS you were fine; now MEAN is making a lot of noise and i just took a look at what Facebook is built with and it talks of HipHop which I have never heard of before and i feel quite lost with frameworks and languages popping out every other week.
I basically am looking for resources to understand the web as a whole, not just to create web pages so I can make informed decisions about building this and any other web app in the future. I want to know how all these new technologies are fitting into the picture.
Thank you
The big picture is you need a database, a data access layer that talks to that database, something to route the requests and something to display the result to the page.
There are lots of frameworks / technologies. IMO the LAMP stack is a bit old school. Not that it's not fit for purpose, it's just there are faster, better, easier stacks than that.
In terms of development languages and frameworks I would check out
Ruby-on-rails,
Spring-boot (with MVC, JPA, freemarker + mysql),
ASP.NET5
For databases mysql is always really popular because it's free. H2 is a free in memory database, I thinks it's a nice db to get up and running real fast.
Generally these days data access Is done through some sort of 'Object Relational Mapper' framework like Hibernate (if ur using Java), Linq (if ur using ASP.NET) or whatever ruby on rails uses.
For the view technology html, css is obviously standard but lately Bootstrap3 is really popular as a front end UI framework to make things a lot easier. In terms of Javascript, jQuery is basically a defacto standard these days. Something like Knockout.js or Angular.js provides nice data binding between your model and your view to make things a lot easier.
Not to mention as an extra layer these days people are also putting their apps inside Docker containers and deploying them that way for maximum portability. So that is something that is new and to you won't have seen before if you've been away from the game for a while.
Anyway, my favourite is the spring-boot stack. It has an embedded instance of the Tomcat web server and it comes all auto configured.
I believe the main changes that affected the course of current web development scenariois related to cloud based services, like Amazon AWS, Google Cloud, Microsoft Azure, and Virtual Private Servers (VPS).
Now is cheaper and possible to plan and develop a distributed environment to achieve a massive numbers of users. Servers are adapting their technologies to this new scenario and to providing easy webservices endpoints for mobile clients via REST APIs (like Google, Facebook, Soundcloud and almost every other service provider) using JSON for small data transfers between server ans clients.
This is the present and near future of web development. And we can no more close our eyes to mobile. Te mobile first era is comming.
You can use LAMP stack for webdevelopment, with or without frameworks like zend, cakephp and others, but the end product will be a REST or RESTfull service provider and a client to consume the services and integrate with many 3rdParties like Google, Yahoo, Facebook, Amazon services to build modern applications.
As for databases, there are now distributed non relacional noSQL hadoop, mongodb, mariadb bring more options to plan robust infra-structure and flexible ajustable for all needs.
To create a great web platform is necessary to know the existence of all this tools and possibilities, but specialize and deep learn only the tools you will choose to develop, because it is impossível learn everything, our brain cant handle :) and all se em to update very fast in this area.
Choose right one is difficult, there is a lot of options, but the main concept will be always the same, there will be a provider and consumer fronts, distributed or non-distributed, and a multi layered development involving UI, integration, business and data (big data) manipulation. But now on the Cloud.
You can find good official material for Php, amazon webservices, nonSQL databases, common 3rdparty APIs like Google Apps, Facebook...REST clients end framework, JSON...and there is a lot of good alternative sources too...get some open-source project example on Github (GIT is another mandatory tool to learn).
I particulary develop in Java now, Linux/MySQL/Tomcat on amazon AWS infra-structure, using Java-JSP for server and web client, and Java for Android..I just have to deal with Java environments and one language for Server (webserver and SO programs) and clients (web and mobile) development.
Well I hope I could help, I dont know if this is exactly the answer also if I made it clear cause my english is basic...
Well, have a nice weekend.
Leo

What are the best development tools to use in this project?

I am currently devising 3 database desktop applications for different users in a manufacturing company (one for the accounting department, sales department, production department). All applications have different functions but they should be able to access the data of the other department to reflect business transactions. What is the best programming language and database to use for this kind project? The three computers are not physically connected so I was thinking of having them to access a remote database. The language I am most familiar with is Java but I am very open to learning others if it would be more beneficial to the company. I was also thinking of having to use Adobe Air as I am adept with web programming but could still run as a desktop app but I can't seem to find sufficient resources of distributed systems using Adobe air. Any ideas would be very much appreciated. Thanks!
Lots of languages will do this just fine, including Java. You're familiar with that so my advice is stick to it with one caveat: depending on your requirements I would seriously suggest examining the possibility of making it a Web app instead. Desktop database apps are somewhat... old-fashioned. More to the point they'll create a bunch of headaches for you such as installation, Swing is annoying and tedious, etc.
As for what database, barring requirements you haven't specified, anything will do so pick something free like MySQL.
So for a desktop Java app I would:
Put the database on a remote server;
Put an application server or Web container on that same server;
Create a Webapp on the app server for handling RPC;
Pick a method of RPC, be it Web services or whatever, and use Spring to implement it;
Create a desktop Java app in Swing and distribute it to clients from the app server via Webstart (JNLP).
If it's a Web app:
Put the database and appserver or Web container on one server;
Pick a Java Web framework and create a bunch of Web pages that do what you want.
In all cases, have it be the same app but just act differently on the user type. This is much better than maintaining three different apps.
Also if you do a Web app, you might want to consider using PHP as it's a fast and proven way of knocking up Web pages and probably sufficient for the kind of internal application that you're doing.

Resources