Is there a dynamic feature of the language available for every platform?
Dart:js is there, however it is not clear if it is only for Web now? Maybe it is possible to call JS VM through WebView which in theory should be available everywhere?
The requirement is to compute a formula dynamically, i.e. user enters a way of computation:
User enters a math formula - think Excel
User enters a pure function
User enters a function to modify an object in memory
Is there an approach for every platform with Dart?
Old languages like Java are used to even have native VM implementations of other languages, think Jython or Java JS VM Engine - Rhino, Nashorn (Java has two JS Engine implementations)
Related
I’m trying to use Lua/Moonsharp API scripting. There’s a command library, but there isn’t a function that I need. My question is, am I able to create my own function, or am I limited to what’s been written?
Specifically, for a software called BobCAD a Lua plugin is available. There are lists of commands like Bcc.SetCamObjParameter, though, there isn’t the command that I need. I’m assuming that some aspects of the BobCAD software are inaccessible to API, but am I limited to the library in this plugin, or can I add my own commands? I thought that there would be some C# file somewhere in the program directory where I can read the functions and possibly learn how to create my own, but I don’t see anything like that. (Or are scripting functions set up internally to the software, and I’m only given access to what has been provided?)
(N.b. I'm not familiar with BobCAD specifically, but this answer should be generally applicable.)
Generally speaking, for use cases like this (where Lua scripting is provided as part of a larger program, or by a plugin for a larger program), it's the developer of the program or plugin who decides what API is available to Lua. In the latter case they may also be limited by what the program's plugin API allows; in the case of BobCAD you are likely limited to what the BobCAD plugin API permits, and then further limited by what parts of that API the developers of the Lua plugin chose to make available to Lua itself.
You can of course write your own functions in Lua, but in terms of actually talking to the host program you are restricted to the API that program makes available, unless they make available some mechanism (like LuaJIT's Foreign Function Interface) for reaching into the program from Lua and calling functions that were not made explicitly available -- which most do not.
As for finding "a C# file somewhere in the program directory" -- C# is a compiled language; C# libraries are generally shipped as pre-compiled CLR binaries (with a .dll extension) and do not contain source code. If the source code for BobCAD and/or the Lua plugin is available you could always modify it and re-compile it, but as BobCAD is commercial, closed-source software, I would not expect it to be available.
At that point, your options are basically:
figure out a way to do what you need with the commands that are available;
try to reverse engineer enough of the program to do what you need without access to the source code;
or look for another program that has the features you need.
Can someone explain what does this phrase mean in this sentence?
Dart is a client-optimized programming language for apps on multiple platforms.
The first thing you need to understand is that it is about optimization by the Dart developer (that is, Google).
This means that Google does not optimize Dart for use in applications other than client-oriented applications.
For example, in Dart there is no such thing as RDBMS (Relational Database Management System) and Google does not plan to contribute to this kind of development (to optimize the use of this type).
All software like this is very fragmented and not compatible with each other due to the lack of optimization from the developer’s side.
Simple, dart use a Dart Virtual machine that helps to optimize the code and compile just in time super fast and render or re-render UI very easy, Dart VM works very similar that JVM with Java, Dart Virtual Machine compile your code to low level very fast so if you want to build web apps, mobile apps o desktop apps you will has a full optimized machine code, for Flutter, dart VM compile from Dart to C++, for the web Dart VM compile from dart to Javascript, Dart is a good robust language designed to make very easy characteristics like Hot reload and Hot restart.
A programming language optimised for building user interfaces with features such as the spread operator for expanding collections, and collection if for customising UI for each.
For example spread operator
var list = [1, 2, 3];
var list2 = [0, ...list];
assert(list2.length == 4);
To clarify, the "Client" in Client-Optimized is referring to the actual user client, same idea as as Client/Server in web technologies.
Here it refers to the part of the App that is responsible for sending requests to the rest of your App for it to do all the functions you've built it to do.'Client' here includes the front-end parts that the person using your application is interacting with
For many reasons (including the ones mentioned in the other answers), Dart is really well suited to make all things Client run super smoothly. Its Optimized how it renders the UI, the layout, the animations, the load times, how it compiles, etc so everything the user (or "Client") does is Optimized.
As mentioned before, it lacks optimization for things that are not client facing such as database management.
I'm trying to understand why adding traits to Dart would cause the shape of objects in memory to change, and am therefore curious how it loads in code right now.
Dart is a dynamically typed language that generates its own machine language equivalents straight from source code with no intermediate byte-code step. There is no generic bytecode (like the JVM or llvm) and instead it is directly compiled into machine code.
I would add that despite compiling straight to machine code, the language itself is not designed in a way that would allow a C/C++ style compiler to effectively generate fast efficient code. This is by design as Dart seems to be an attempt to fill the gap between JavaScript and Java rather than the gap between Java and C/C++. Dart addresses many issues that make JavaScript hard to optimize most importantly typing of numeric variables.
There are some efforts to port the Dart environment to various platforms beyond Windows/Mac/Linux but I have yet to see an actual straight to machine language compiler for Dart. That doesn't mean they don't exist, I just haven't seen anything other than ports of the Linux Dart environment onto Beagleboard and other small Linux distros.
From the Dart FAQ
Q. Why didn’t Google build a bytecode VM targetable by multiple
languages including Dart? Each approach has advantages and
disadvantages, but we feel that in the context of Dart it made sense
to build a language-specific VM for the following reasons:
Google already works on a multi-language bytecode: LLVM bitcode in
PNaCl.
Even if a bytecode VM is specialized for Dart, a language VM will be
simpler and faster because it can work under stronger assumptions—for
instance, a structured control flow. These assumptions make the
implementation cleaner and optimizations easier.
A general-purpose bytecode VM would be even larger and slower, as it
generalizes assumptions and adds functionality that for Dart is dead
code: for example, multithreading with a shared heap.
No bytecode VM is truly general-purpose; they all make assumptions
that privilege some class of languages. A language VM leaves more room
to improve the VM and make deep changes to optimization of the
language. Some Dart engineers wrote an article talking about the VM
question in more detail.
A pretty good presentation on Compiling Dart to Efficient
Machine Code
I'm currently starting to integrate "Delphi Web Script" in my application basically only as a scripting engine (interfacing with functions, classes, etc.); awesome software for the standard delphi open source quality in my opinion, but just for curiosity,
What's exactly the "web part" of the project?
How is intended to be used?
It was used somewhere with some success commercially?
Thanks!
As ain said, the original use was for PHP-like, ASP-like server-side web-page generation, but it was also capable of general purpose use, which is what I used it for. And as I did not use the "web" side of DWScript, most of the "web-oriented" features haven't been ported over (only the HTML Filter was ported actually).
The Web functionality is still available in the SourceForge repository, if someone wants to tackle the port. Though, they may be outdated beyond simple renamed methods and classes, as since DWSII, the script engine has gained various features. For instance, it is now capable of multiple thread-safe executions of a single compiled script, while the old codebase is built around the limitation that a compiled script can be executed by only one thread at a time.
On the other hand, there are some new features that could simplify the porting, the simple WebServer demo recently added uses RTTI to expose TWebResponse & TWebRequest f.i. (was manually exposed in DWSII). On the down side, that's only possible with recent Delphi versions.
AFAIK the main focus of the original author of this scripting engine was to make it possible to embed Pascal scripts into HTML pages, just like ie PHP does it. Hence the name "Delphi Web Script". While the focus of the current maintainer, Eric Grange, is on using it as a general purpose scripting engine, it should still be possible to use it for web purposes as well - for that you use the "filters" feature of the library. Check out the dwsHtmlFilter unit for HTML filter.
How can I get the meomory of any Process in Lua?
Is it possible in Lua? Is C# it is possible but I am not sure.
In C# we can use PerformanceCounter class to get the
PerformanceCounter WorkingSetMemoryCounter = new PerformanceCounter("Process",
"Working Set", ReqProcess.ProcessName);
What is equivalent of this in Lua?
Suppose there are 5 process of IE (Internet Explorer) running . How to get a List of those process?
To elaborate on what others have said, Lua is a scripting language designed for embedding. That means that it runs inside another application.
Lua.exe is one such application. But it is not the only application that Lua scripts can be written to be executed on.
When within a Lua script, you have access to exactly and only what the surrounding application environment allows. If the application does not explicitly allow you to access things like "files" or "the operating system", then you don't get to access them. Period.
Lua's standard library (which an application can forbid scripts to use. Lua.exe allows it, but there are some embedded environments that do not) is very small. It doesn't offer a lot of amenities, which make Lua ideal for embedded environments: small standard libraries mean smaller executables. Which is why you see a lot more Lua in mobile applications than, say, Python. Also, the standard library is cross-platform, so it does not access platform-specific libraries.
Modules, user-written programs (either in Lua or C/C++) can be loaded into Lua.exe's environment. Such a module could give your Lua script access to things like "processes", how much memory the process is taking, and so forth. But if you do not have access to such a module, then you're not getting that info from within a Lua script.
The most you are going to be able to do is get the size of the memory that this particular Lua environment is directly allocating and using, as #lhf said: collectgarbage "count".
To get the memory allocated by Lua in Kbytes, use collectgarbage"count".
Lua does not comes with this built-in functionality. You could write a binding to a library that provides you that or you could interface with a program to do that (like reading the output of "ps -aux | grep firefox").