Is there Dart VM available? - dart

Just read news that Google had announced an early preview of the new web programming language Dart. The documentation on the dartlang.org states:
You will be able to run Dart code in several ways:
Translate Dart code to JavaScript that can run in any modern browser:
Chrome, Safari 5+, and Firefox 4+ (more browser support coming
shortly).
Execute Dart code directly in a VM on the server side
Use Dartboard to write, modify, and execute small Dart programs
within any browser window
And I'm curious is there already VM available to run Dart code? Can't find it anyway, maybe it is available through some beta program?

A pre-built binary of the Dart VM is available in the Dart SDK. Alternatively, you can checkout the source to the whole Dart project, which includes the VM.

Dartium, Chromium with a Dart VM, is now available.
http://www.dartlang.org/dartium/

You can download precompiled binary runtime for Windows, Linux and Mac from Dart Force. Another way is to run node.js-style HTTP server using Fling.

Related

Create Windows 95, 98, 2000, XP NT, 7, 10

I come across the following link - https://github.com/felixrieseberg/windows95
Running windows 95 as Electron APP
Is it possible to create any existing application as portable or cross-platform using electron like above?
Can we use Windows 7 or 10 like above without Oracle Virtual Box or VM in an existing Windows 8 machine ?
Need more details on how it is possible to bring an application via electron
Thanks.
If I'm hearing you right, you're wondering if you can put a whole OS into a JS VM running in Electron - and then run your app on top of that.
Please don't do that. Electron is a fantastic cross-platform solution, but my project windows95 was mostly an educational experiment showcasing how powerful modern JavaScript and Electron can be.
This project uses another project called v86, which is capable of virtualising a x86 platform and display its output on a HTML element. Electron is browser-based so that is why this works.
But there are some limitations: It virtualises the x86 platform, which is pretty old by now, and when you have a look at the specification, it says it is at a Pentium-1 state. The demo links on the project's GitHub ReadMe also do not contain any "modern" OS because v86 does not support SSE(2). And since Microsoft requires its users to have a SSE2-compatible CPU* it is not possible to run anything like Windows 7 or newer (Linux may work, anyway).
OSses which support this kind of (deprecated) hardware, may work. As you can see from the "Compatibility" section of the project's ReadMe, some Linux versions and Windows XP "work" but older software, like OS/2, and even newer stuff, like Android, don't (really). So you can't say that everything will work as expected because the execution environment is really limited.
Now to answer your first point, no, I don't think that you can wrap every existing app into an Electron application and run it on new hardware. It may work with old software (which do not require SSE, if you use v86, and that would require a lot of hackery on the v86 side because it is designed to run OSses), but don't quote me on that.
* The section in question reads (at the time of writing) like this:
A Stop error occurs on computers that don't support Streaming Single Instructions Multiple Data (SIMD) Extensions 2 (SSE2).
Upgrade your machines with a processor that supports SSE2 or virtualize those machines.
(emphasis mine, source: https://support.microsoft.com/en-us/help/4088875/windows-7-update-kb4088875)

Is the Dart VM still used?

I've been using dart/flutter for a few projects, and I'm really enjoying it.
I've read that when building a mobile app, dart builds a native app with native code. But I've also read that dart has its own VM for performance.
What I'm trying to understand is if that VM is what is used when you build a mobile app, or is it building other code that it compiles for the native app. And if its doing something else, what is the dart VM still used for?
Short answer: yes, Dart VM is still being used when you build your mobile app.
Now longer answer: Dart VM has two different operation modes a JIT one and an AOT one.
In the JIT mode Dart VM is capable of dynamically loading Dart source, parsing it and compiling it to native machine code on the fly to execute it. This mode is used when you develop your app and provides features such as debugging, hot reload, etc.
In the AOT mode Dart VM does not support dynamic loading/parsing/compilation of Dart source code. It only supports loading and executing precompiled machine code. However even precompiled machine code still needs VM to execute, because VM provides runtime system which contains garbage collector, various native methods needed for dart:* libraries to function, runtime type information, dynamic method lookup, etc. This mode is used in your deployed app.
Where does precompiled machine code for the AOT mode comes from? This code is generated by (a special mode of the) VM from your Flutter application when you build your app in the release mode.
You can read more about how Dart VM executes Dart code here.
When the Dart VM is used in release mode, it is not really a VM (virtual machine) in the traditional sense of a virtual computer processor implemented in software, which has its own machine language that is different from the hardware's machine language.
This is what causes the confusion in the original question. In release mode, the Dart VM is basically a runtime library (not much different than runtime libraries required by all high level languages).
The Dart VM is perfectly good for server-side applications, particularly using dart:io to access local files, processes, and sockets.

How to test google dart for web development?

As of this year, how do I test google dart for web development?
I downloaded a special chromium version and the dart sdk. I know I can convert dart code to javascript as well but is there any way for dart to directly interact with my html code? Like append dart in my html script and let it do its job.
Im coming from javascript and I really want to learn this language and support its growth.
Dartium is
a special Chromium version, that can execute Dart code directly
shipped with the Dart SDK.
for development only, for faster edit-reload cycles
For production Dart always needs to be compiled to JS.

Dart in a stand-alone app that does NOT require Chrome to be installed

electron, node-webkit, brackets-shell and atom-shell are frameworks that allow a user to create stand alone executables that use HTML, CSS, and JavaScript (Node) for all code in the app. They don't require any prior installation of any software, as I understand it. I want to use Dart instead of JavaScript. I don't want a chrome app because that requires the installation of Chrome, if I understand correctly. Is it possible to make a stand-alone application using Dart? Will DartToJs be able to do this for me?
You need to have a Dart-VM (Dart-Runtime) installed in order to be able to execute Dart applications on the command line/server.
As far as I know there is no way to create a standalone executable, at least no easy one.
It is technically possible to create an executable that contains the Dart-VM but there are no tools available yet that generate that for you.
I don't think the path using Dart2JS will help much. Dart2JS aims primarily at browsers but I have heard that some try to use Dart2JS to run Dart code with Node.js but I don't know if that really works.
This similar question contains some links that may be of interest to you: Embedding Dart into application
dart2js + node-webkit will definitely do this for you. Just compile your webapp to js, make a proper package.json file and follow the standard directions on the node-webkit github page.
There's even a pub package that let's you use the node-webkit API from dart (filesystem access, window controls, and whatnot).
Search pub for node_webkit and you'll find it.
Good luck.

Dart VM - foreign browsers (non Google)

I have played a little with Dart and I think it's great. I understand that it can output native JS and that the VM will likely be supported by Google in their browser. As it is possible that other browser suppliers won't support the Dart VM, is it at all possible to install the Dart VM on client machines for use in foreign browsers?
is it at all possible to install the Dart VM on client machines for use in foreign browsers?
It is, however it is easier to supply the Dart VM yourself.
Javascript is perfectly able to:
Find a script of a specific type
Convert the script into Javascript
Execute the compiled script
While this is technically not a Dart Virtual Machine, it will get your Dart code executed at full speed. However, you do have to wait for the compilation to complete. The usual way is to do the compilation on the server (once), and only send the compiled javascript to clients.
Another option is interpreted code. Instead of compiling to javascript, the Dart instructions are executed one-by-one. Dart is not a machine-level language, so it needs parsing, but what follows is interpretation. The downside is reduced performance. This will get you as close to having a full-blown virtual machine (separate from the Javascript one) as possible.
Normally, you don't care which one you get (maybe you'll even get a just-in-time compiler), but it does make a difference in terms of a Dart virtual machine being present (rather than just getting your code executed).
The Dart compiler needs to be present on the page somehow (unless you precompile).
The easiest way is to just write <script src="path/to/your/dart-compiler.js"></script> into the head.
The Dartium browser does support Dart natively, but it is not designed for common use. Wikipedia says:
In the Dartium Browser: The Dart SDK ships with a version of the Chromium web browser modified to include a Dart virtual machine. This browser can run Dart code directly without compilation to Javascript. It is currently not intended for general-purpose use, but rather as a development tool for Dart applications.[7] When embedding Dart code into web apps, the current recommended procedure is to load a bootstrap JavaScript file, "dart.js", which will detect the presence or absence of the Dart VM and load the corresponding Dart or compiled Javascript code, respectively,[8] therefore guaranteeing browser compatibility with or without the custom Dart VM.
If you want the ability to run Dart be dependent on the client machine rather than on the page, there are a few ways too.
One way is to include the compiler as a user-script. This will work in all both modern desktop browsers. However, I'm not sure if there's an existing way to add user-script support to Internet Explorer.
One way is to add a browser extension. All modern desktop browsers support extensions, and Internet Explorer has Browser Helper Objects.
All of these will require the extra Javascript step. If you want native interpretation that bypasses Javascript, you need a plugin. Plugins require a specific mime-type to run (not sure if the script type counts), but you can install an extension that will trigger the use of the plugin. However, DOM manipulation still needs the extra Javascript step. There is no way around it.
A desktop installer can definitely install a plugin into a browser. Indeed, this is the way plugins normally get installed. Installing extensions from a desktop installer might be possible as well, but I can't confirm or deny this last claim for now.
As far as I know there is no way to just simply install a plugin (like Flash) for Dart. For Internet Explorer one could install Chrome-frame, but I haven't seen something similar for Firefox and Safari.

Resources