Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 1 year ago.
Improve this question
This is a question of interest, There are a number of interpreted languages that can be used to create an OS, Can one create an Operating system using PHP or JS.
It does not have to be a fully-fledged OS, at least the one that prints Hello World.
Regards
All three of those languages are Turing-complete, so they can simulate any other Turing-complete language. An operating system written in one (or a few) Turing-complete language can also be written in another, assuming that sufficient access to the underlying hardware is provided.
Whether such a thing could be made to be run any any reasonable speed is another matter entirely.
The number of things you can do in programming is virtually limitless, but many of those things require a lot of effort.
The main purpose of an operating system is to provide an interface between application programs and the computer hardware, often abstracting away details. In order to do this, the OS code must be able to access the hardware directly (or almost directly, e.g. by calling BIOS functions).
High-level languages like PHP and JavaScript don't have any mechanisms to do this. They depend on an operating system to provide access to hardware at a high level: files, network sockets, etc.
These languages do allow you to link in extension libraries, which give them extra capabilities. But then you're not actually writing the OS in these languages, you're writing it in the language that the extension is written in.
I don't think even C can be used to write an OS if you just stick to the portable features of the language. Operating systems written in C depend on implementation-dependent features such as casting integers to pointers, they use extensions like asm(), or they occasionally link with subroutines written in assembly, on order to get direct control of the hardware.
Related
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I am not able to understand why and in what kind of scenario I would like to run scripting language inside JVM at server side. I mean we already have great libraries available in JAVA... why wouldn't I use use them to do stuff instead of running scripts in JVM?
Please help me understand this concept, Can someone please tell me one or two use cases where running scripting in JVM at server side will have advantages over using JAVA libraries.
The more general question here is "Why would I want to execute code in <some scripting language> in Java?", where Javascript is simply one example of such a language.
Quoting this article:
Some Java applications' requirements make integration with a scripting language necessary. For example, your users may need to write scripts that drive the application, extend it, or contain loops and other flow-control constructs. In such cases, it's sensible to support a scripting language interpreter that can read user scripts, then run them against your Java application's classes.
Basically: if you want to allow your users to customize your application in a way that requires the richness of a programming language.
Why Javascript specifically? That depends upon your application. There may be reasons to pick that (e.g. your target users already know Javascript), or not (e.g. Lua is more popular for scripting in the games industry).
One use i can think of is:
Javascript engine can be used to evaluate arithmetic expressions
which are in a String format.
example :: String expression = "2+4";
The below is the link to a example which uses java script engine to do this.
https://stackoverflow.com/a/3423360/4626402
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 7 years ago.
Improve this question
I am curious as to the fundamental reasons why we choose MongoDB, Node.js, Express.js, and AngularJS?
Here are the reasons I can think of:
MongoDB works well with JSON and data models, is faster than SQL;
Express and Angular gives the stack one language in Javascript;
Node.js is non-blocking, event based, and supports concurrency;
Angular is a wonderful front end framework.
Any other reasons? Also, how would you address the people who have an innate disdain for server side Javascript?
Thanks!
Well, people wanted to replace the LAMP stack (Linux, Apache, MySQL, and PHP/Python/Perl) for a very long time. When JavaScript was made possible to run on the Server side ie NodeJS, it paved way for a full development stack which is the MEAN stack.
The first advantage of the stack is the single language throughout the whole application - JavaScript. This made it easier for a person with JS knowledge to create a full on working application. This also made way for front end developers to explore more into how server side programming works.
Some startups and organizations thought that using a stack with one language will help them in limiting their resources. And easy delegation of work among the developers.
Even though MEAN stack is an awesome alternative to the traditional LAMP stack, it is still in its early stages. It is adopted only by few ambitious startups, but not by bigger organizations. They are still sticking to the legacy technologies. Also the components of the MEAN stack which is Angular, Express and Node are still in their childhood stages. There are no proven and complete use of the MEAN stack on a full scale solution.
Well organizations like Walmart etc. used Hapi.js and were successful in it, it tempts the other organizations to go forward with it , but also makes them skeptical on using it since replacing the already existing technology will be a bigger headache.
Also since a lot of the current employees are trained in Java, Python etc, developers in JavaScript are very few and JS is almost considered as an additional language to be known for a Java developer and the likes. JS hasn't been considered as a single language on its own.
Maybe few years down the line, the MEAN stack will prove itself a noteworthy alternative to the traditional stacks.
I work in the Retail Domain and a big organization. We are actually planning to use the MEAN stack for our inside projects. But no one ever gave a simple thought of using the MEAN stack in PROD.
EDIT: One more important reason these stacks are tempting is because they are all Open Source. Say MongoDB for example. Owning the software license every year is a big hit on the profits of the organizations with DB's like Oracle SQL etc. Going with an Open Source DB is a very cost effective option. But still they are skeptical on using it for Production.
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 8 years ago.
Improve this question
There is no universal bytecode for JavaScript, but most JavaScript engines have their own bytecode. Since JavaScript files travel as source code string, they have to parse/compile source code string into bytecode at before execution.
However, as we can specify a user agent type (e.g. browser type and version) in HTTP request, can't we make the server keep bytecode for each browser and respond accordingly to save some time at client?
What's preventing us from taking this approach? I don't think browsers will have no problem even if some JavaScript files are given in bytecode and others in source string. Similarly, we have .pyc files in Python, and it runs well with .py files.
[Update]
Potential benefits I can think of are below.
You could save parsing time at client. Parsing is fast, but it may be worth to do it for low-end devices.
You could put some hints in bytecode. For example, JavaScriptCore (WebKit's JavaScript engine, JSC for short) patches bytecode with information gathered during runtime, such as types. JSC's bytecode is designed in a way that it has slots for such information.
In terms of maintainability, the server can always send the original source code string if the client's browser is unsupported, and there are not so many different JavaScript engines. Supporting four most popular browsers (Chrome, Firefox, IE and Safari) seems feasible to me. In addition, I don't see bytecode instruction set changing frequently.
All engines would need to make their byte code format public
The server would need to hold very many different byte code files, or even compile them on the fly
Browser detection is fraught with peril (user agents lie, proxies cache)
Bytecode rules might change between minor versions of a browser
The performance gains probably wouldn't be all that significant (especially when compared to network transfer times)
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 9 years ago.
Improve this question
As far as I know, JavaScript can be used to do everything that is possible in Scheme.
Every functional programming paradigm I've learnt in Scheme is doable in JavaScript.
I know that one may end up using JavaScript to write ungood code (ones with global variables, too many states and side effects) where as Scheme restricts one to write functional code.
But apart from that, is it really necessary to use Scheme anywhere over JavaScript?
For those of you who say JavaScript can be interpreted only on a browser kindly draw the same question to Python and Scheme.
Let me pose a similar question:
Is there a reason to use French over English? Anything that you can express in French you can express in English, so is it really necessary to use French over English? Kindly draw the same question to Russian, German, Spanish, or any other spoken language you choose.
No programming language is completely unique, anything you can do in one language can be done in a different language, some implementations might require a bit more creative thought but it can still be done.
Some reasons to use Scheme instead of JavaScript or Python:
You appreciate the simplistic and minimalist structure of the
language
Ease of implementation when compared to expressive power (lambda
expressions)
You are more familiar with Scheme
The client has existing code in Scheme
Specific implementations or algorithms might have a min/max calculation available to give exact benchmarks, but you would have to look at specific algorithms. In general there is no way to define one language as always better in all situations (or even 'never worse'), and trying to pigeon hole oneself into a single language is dangerous. In my opinion, open mindedness is one of the biggest strengths a programmer can have. Being able and willing to use different languages or techniques can be a powerful tool.
I personally suggest further reading by looking up Polyglot Programming. It isn't directly related to your question, but it is a mentality that speaks to the benefits of knowing and using a variety of languages.
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 9 years ago.
Improve this question
I am going to work on my new project where client has demanded to use 'Lua' if possible, I have never used it before and by searching on it I found it is fast compare to javascript and getting popular nowadays.
As I am very confused I had never use it before so I want to know something
Is it really better(in terms of performance and use) then javascript?
Will I get enough resources(because I don't want to move over after starting development due to lack of resources or it becomes hard to me develop)?
Will it needed anything other than C compiler to run?
Please guys it is really important to know about such thing before starting. Any help will be appreciated.
I'm assuming you're writing a standalone application in C or C++, and you're looking for a language to enable people to extend that application by embedding another language. That's pretty much Lua's territory.
Lua's strong point is that it's very easy to embed in your (C) application. It compiles quickly, it's tiny, licensing is liberal and using C functions from Lua is relatively easy. Standard Lua has enough performance for most things you'd use a language like this for; if you need more raw speed you could look into LuaJIT, the JIT-compiler for Lua.
As for your questions:
LuaJIT will probably be pretty much as fast as you can get for a dynamic language. Lua is used in games (Sim City, Far Cry, World of Warcraft), where performance is very important.
If by 'resources' you mean documentation: sure. Lua is a very simple language, much simpler than JavaScript; the manual should help you get started with the language itself, the wiki is tasty for tips about the embedding process. This article has an example you can copy/paste.
Lua pretty much runs everywhere a C program will run. It doesn't even need an operating system, and it doesn't depend on anything at runtime if you bundle it correctly.
Embedding a full JavaScript environment in your application, and interfacing your application to the JS environment, can be a lot of work (even though Google's V8 engine has some functionality to help you; see here).