Do VMs like LLVM or PARROT allow usage of the same library from multiple languages? - virtual-machine

Is it possible to use one framework written in one Parrot (LLVM) language in any other Parrot (LLVM) language?
(Like usage of .NET Framework from any CLR language)...

Parrot and LLVM are two different things made by two different organizations.
Parrot is a VM, and LLVM is a VM that can also compile statically.
Edit
Assuming the comments to my answer are correct:
LLVM allows you to call other LLVM code and also external C like libraries.
Parrot allows you to call other Parrot code, but not external C like libraries.
http://en.wikipedia.org/wiki/Comparison_of_application_virtual_machines

LLVM
Stands for low-level virtual machine. It uses low-level opcodes that easily map to native machine code.
Languages: Fortran, C, C++
Applications: Systems Programming, Compiler Development
Parrot:
This is a high-level virtual machine. Its opcodes are much higher level then those in most virtual machines. This allows Parrot to generate efficient native code for dynamic languages.
Languages: Ruby, Perl, PHP
Applications: server-side scripting

Related

Why is Objective C runtime needed if appl is compiled as native

New to Swift/Objective-c and coming from Java, C# and C++ background. My understanding is that a runtime is needed if the code is non-native as in case of Java or C# an intermediate code is generated which would at Runtime need an environment which translates code to the machine language and we call that a runtime environment (like JRE).
So having read some Q and As on stack overflow it is clear that Swift and Objective-C both are compiled as native binaries. But they need Objective-C runtime to execute them.
I don't know why a runtime is needed if code is already in machine language ?
Is it like a library linked to the program ?
Or Is this objective-C runtime a separate environment which hosts the objective-C/Swift program ? just like JRE ?
Can someone please shed some light on this ?
Thanks,
Ahmed
Many programming languages rely on runtime libraries, including C++. These consist of low-level routines to support the programming language's model on that of the hosting operating system. Objective-C's runtime library implements core features such as dynamic method lookup.
Java and C# require a virtual machine, these are much more involved than runtime libraries.
HTH

Is Google's Golang an interpreter or compiler?

I have been researching Golang and I see that it has a compiler.
But is it compiling Go into assembly level code or just converting it into BYTECODES and then calling that compilation? I mean, even in PHP we are able to convert it into BYTECODES and have faster performance.
Is Golang a REPLACEMENT for system level programming and compiling ?
This is really a compiler (in fact it embbeds 2 compilers) and it makes totally self sufficient executables. You don't need any supplementary library or any kind of runtime to execute it on your server. You just have to have it compiled for your target computer architecture.
From the documentation :
There are two official Go compiler tool chains. This document focuses
on the gc Go compiler and tools (6g, 8g etc.). For information on how
to work on gccgo, a more traditional compiler using the GCC back end,
see Setting up and using gccgo.
The Go compilers support three instruction sets. There are important
differences in the quality of the compilers for the different
architectures.
amd64 (a.k.a. x86-64); 6g,6l,6c,6a
A mature implementation. The
compiler has an effective optimizer (registerizer) and generates good
code (although gccgo can do noticeably better sometimes).
386 (a.k.a. x86 or x86-32); 8g,8l,8c,8a
Comparable to the amd64 port.
arm (a.k.a. ARM); 5g,5l,5c,5a
Supports only Linux binaries. Less widely used than
the other ports and therefore not as thoroughly tested.
Except for
things like low-level operating system interface code, the run-time
support is the same in all ports and includes a mark-and-sweep garbage
collector, efficient array and string slicing, and support for
efficient goroutines, such as stacks that grow and shrink on demand.
The compilers can target the FreeBSD, Linux, NetBSD, OpenBSD, OS X
(Darwin), and Windows operating systems. The full set of supported
combinations is listed in the discussion of environment variables
below.
On a server you'll usually target the amd64 platform.
Note that Go is well known for the speed of compilation. When deploying my server programs, I don't build for the different platforms on the development computer : I deploy the sources and I compile directly on the production servers. Since Go1 I never had a code compiling on one platform and not compiling on the other ones.
On Windows I had no problem in making an exe on my development computer and simply sending this exe to people never having installed anything Go related.
Go compiles quickly to machine code yet has the convenience of garbage collection and the power of run-time reflection. It's a fast, statically typed, compiled language that feels like a dynamically typed, interpreted language.
Source - golang.org
Golang is a compiler-based language, it can easily be compiled on the development computer for any targeted system such as linux and mac.
A golang project when have compiled turns to a self-sufficient executable and can be ran on the targeted system without anything additional. It's because the golang compiler turns your code into bytes ready to execute on a system which can run compiled c code.

What is Java runtime multilanguage for?

I'm dealing with a software vendor who says that, application needs JVM multilanguage. But I read about java locale and java 6 support almost(if not ) all country locales. So what's the difference between jvm multilanguage and, just the jre installer on Oracle site?
In the old days, you could download a US-English version of the JRE and an Internationalized version. For example: http://www.oracle.com/technetwork/java/javasebusiness/downloads/java-archive-downloads-javase11-419415.html#7452-jre-1.1.8_15-oth-JPR
They discontinued the English-only JRE bundles with Java 1.5. So the vendor's requirement is moot ... unless you are using a really old JVM.
JVM Multi-language refers to support running code from other programming languages like Ruby/JRuby, Groovy, Scala, etc. Oracle JVM is one of them. Probably, the software you're dealing with need support to other programming languages for some reason.
Ask the vendor what they mean - do they mean internationalized support (i.e. multiple human languages) - or do they mean that some components of the vendor software are written in a non-Java JVM computer language (e.g. Scala, Jython, Clojure, etc), and that you will also need the runtime support components for those non-Java languages.

How to set up a dev. environment for ARM board AT91SAM7-EX256 under x86 Linux?

I am a newbie to embedded developement, as figure shown. I have a small ARM board, AT91SAM7-EX256. I have also a JTAG programmer dongle, too. I am using Linux (Ubuntu x86_32) on my notebook and desktop machine. I'm using CodeSourcery Lite for cross-compiling to ARM-Linux.
Am I right that I can't use this Linux-target cross-compiler to make binary or hex files for the small ARM board (it comes without any operating system)? Should I use the version called ARM EABI instead?
As I see, it's a "generic" ARM compiler. I've read some docs, and there're lot of options to specify the processor type and instruction set (thumb, etc.), there will be no problem with it. But how can I tell the compiler, how should the image (bin/hex) looks like for the specific board (startup, code/data blocks etc.)? (In assemblers, there're the org and load directives for it.)
What software do I need to capture some debug messages from the board on my PC? I don't want to on-board debugging, I just need some detailed run-time signal, more than just blinking leds.
I have an option to use MS-Windows, I can get a dedicated machine for it. Do you recommend it, is it much easier?
Can I use inline assembly somehow in my C code? I dunno anything about that. Can I use C++ or just C?
I have also a question, which don't need to answer: are there really 4096 kind of GNU compilers and cross-compilers (from Linux_x86_32 -> Linux_x86_32, Linux_x86_32 -> Linux_ARM, OSX -> Linux_ARM, PPC_Linux -> OSX) and 16 different GNU compiler sources (as many target platforms/processors exists) around? The signs says "yes", but I can't believe it. Correct me, and show me the GNU compiler which can produce object file for any platform/processor, and the universal linker which can produce executable for any platform.
While Windows is not a "better" platform do this kind of embedded development on, it may be easier to start with since you can get a pre-built environment to work with. For example, Yagarto (which I would recommend).
Setting up an embedded development environment on Linux can require a considerable amount of knowledge, but it's not impossible.
To answer your questions:
Your Linux cross-compiler comes with libraries to build executables for a Linux environment. You have hinted that you want to build a bare-metal executable for this board. While you can do this with your compiler, it will just confuse things. I recommend building a baremetal cross-compiler. Since you're building your own baremetal executable (and thus you are the operating system, the ABI doesn't matter since you're generating all of the code and not interoperating with other previously built code.
There are several versions of the ARM instruction set (and Thumb). You need to generate code for your particular processor. If you generate the code for a newer version of the instruction set, you will likely generate code which generates a reserved instruction exception. Most prebuilt gcc cross-compiler toolchains for ARM are "multilib" and will build for a variety of architectures in both ARM and Thumb.
Not sure exactly what you're looking for here. This is a bare metal platform. You can use the debugger channel to send messages if you're debugging on target, or you'll need to build your own communication channel into the firmware you write (i.e. uart support).
See above.
Yes. See here for details on gcc's extended inline assembly syntax. You can do this in C++ and C. You can also simply link pure assembly files.
There is no universal gcc compiler / linker. You need a uniquely built compiler for each host / target combination you use.
Finally, please take a look at Atmel's documentation. They have a wealth of information on developing for this target as well as a board package with the needed linker directives and example programs. Note of course the package is for Atmel's own eval board, but it will get you started.
http://sam7stuff.blogspot.com/
I use either of the codesourcery lite versions. But I have no use for the gcc library nor a C library, I just need a compiler.
In the gcc 3 days newlib was great, modify two files worth of system support (simple open, close, read, putc type stuff) and you could compile just about anything, but with gcc 4.x you cannot even go back and cross compile gcc 3.x, you have to install an old linux distro in a virtual machine.
To get the gcc library yes you probably want to use the eabi version not the version with linux gnueabi in the file names.
You might also consider llvm (if you dont need a C library, and you will still need binutils), hmm, I wonder if newlib compiles with llvm.
I prefer to avoid getting trapped in sandboxes, learn the tools and how to manipulate the linker, etc to build your binaries.

OK Programming language from USB stick with no installation

I'm looking for a compiler or interpreter for a language with basic math support and File IO which can be executed directly from a memorystick in either Linux or Windows. Built in functionality for basic datastructures and sorting/searching would be a plus.
(I've read about movable python, but it only supports windows)
Thank you
Not sure what are the issues there for the other languages, but I am pretty sure that Lua will work fine on such environment.
It is perfect for your requirements: basic I/O, math functions, excellent data structures (all based on numeric and associative array, with any kind of key/values, allowing the most complex operations).
Bonus: very simple to learn (for the bases, at least), readable, and powerful when you start to dig. And it starts to have a number of useful libraries, sockets, regexes and parsers, GUI, etc.
It is just a single binary file, no install at all, no registry access, no file access (beyond reading the binary and script!) if not requested, totally transparent: it is often used in embedded system, often memory constrained, on Roms, etc.
There is a python distribution called Movable Python which is designed to do exactly that. It might do what you want. Also, MinGW/MSYS will run on Windows with no registry entries or other installation beyond placing the files in a directory tree - all you need to do is set up the relevant directories in the path, which can be done in a batch file.
The Java JDK easily fits on a stick, and does not require installation; You can install it to a PC first and then just copy the install directory to the stick. I presume you can do the same for the Linux JDK.
And there's a ton of good text editors that don't require installation.
Not sure if it still applies to current versions, but I have an ancient perl.exe (version 5.001, from 1994 or 1995) that still works perfectly fine as a no-installation single executable.
If you can tolerate TCL, it's hard to beat a tclkit
TCC (the Tiny C Compiler) is a full implementation of C in a really small package. You can even write shell scripts in C:
#!/usr/local/bin/tcc -run
#include <stdio.h>
int main()
{
printf("Hello World\n");
return 0;
}
TCC is available for any Unix-like platform, and also for Windows.
I've done exactly that with Ruby. Worked well.
I'm way late for this party, but I thought I'd weigh in anyway.
I currently have a Windows-usable USB stick with the following installed on it (for Windows):
Languages
Java
Erlang
Fantom
Groovy
Haskell
jacl (JVM-based Tcl)
JavaFX
JRuby (JVM-based Ruby)
Jython (JVM-based Python)
NASM
nice
pnuts
Rexx
Scala
SISC (JVM-based Scheme)
Sleep
Tcl
Prolog
gawk (via GnuWin32 and MinGW/MSys)
jawk (JVM-based AWK)
ANTLR
Clojure
JBasic (JVM-based BASIC)
Tuprolog (JVM-based Prolog)
Rhino (JVM-based Javascript)
YASM
Lua
Kahlua (JVM-based Lua)
C (via GnuWin32 and MinGW/MSys)
C++ (via GnuWin32 and MinGW/MSys)
Fortran77 (via GnuWin32 and MinGW/MSys)
Ada (via GnuWin32 and MinGW/MSys)
Programming Tools
jEdit (JVM-based programmer's editor)
Ant (JVM-based build tool)
Maven 2 (JVM-based build tool)
vi (via GnuWin32 and MinGW/MSys)
Vim
CMake
gmake (via GnuWin32 and MinGW/MSys)
Leiningen
Subversion
Fossil
ANTLRworks
ctags/etags
Geek Toys
All SIMH emulators, with networking if available
Several operating systems, utilities, etc. for same
And a cast of dozens in key libraries, plus the Geronimo application server.
Yes, this is a single USB stick, and I probably missed an item here or there while making this list. It's amazing what you can run off of a USB stick these days.
http://smallbasic.sourceforge.net/
Runs anywhere (even mobiles) and has everything you need.
You could use DevCpp, it comes with Mingw 3.x or CodeLite (Mingw 4.x) for C/C++. For Pascal you can use DevPas, for Python web development try InstantDjango or better yet Web2py (very nice indeed!), for Ruby you have InstanRails, for Perl you got a complete enviroment (even a C compiler!) with StrawberryPerl. You could install cygwin on the USB drive. There are a lot more options out there. Interested in a LISP like portable/cross-platform and little language? Try newlisp (its a gem!). Also you could run almost anything (linux or windows based) on a portable VM under Portable VirtualBox/VMplayer or QEmu with a performance tax ;).
Why not C++? You can statically link in any external librarys assuming there lisence allows it, and you won't have any external dependencies.