Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 6 years ago.
Improve this question
Joel Spolsky praised native-code versions of programs that have no dependencies on runtimes.
What native-code compilers are available for functional languages?
This post is really quite unclear. The question appears to be "Are there compilers for functional languages which can produce native executables without the need to install additional software?"
The answer, generally, is yes. For example, Haskell has a compiler that produces native binaries. Many other functional languages have similar compilers.
Yeah, also:
ocamlc is the bytecode compiler, and ocamlopt is the native code compiler.
GCL compiles Common Lisp to native binaries.
There isn't anything for F# since, for what I am aware of, .NET doesn't have a native compiler, like Joel mentions. Actually, CSML can be used to call C# from ocaml, uhh, not sure if you can compile this down to native code --it doesn't seem likely-- although the documentation alludes to it, yet it is very incomplete.
A lot of functional languages are compiled just like any other language.
For example in Clojure:
The reader translates the source code text into a data structure that represents the program (an s-expression)
If required, macros are then applied to transform the code
The Clojure compiler then translates the code into Java bytecode - this is the same machine-portable format used by Java, Scala and other JVM languages
Finally, the JIT compiler in the JVM converts the bytecode to native machine code, possibly performing various optimisations on the fly. This is the code that then gets directly executed on whatever platform it is running.
One interesting point is that all this happens dynamically, i.e. at any point during program execution you can write new source code, pass it through the reader and various compilation steps and run the new compiled native code without having to restart the program. This is important as it enables interactive development at the REPL while still providing the benefits of fully compiled code.
PLT Scheme has got a JIT compiler.
Stalin is a Scheme compiler which does ridiculously aggressive optimisation.
All Common Lisp implementations that I know of except CLISP compile to native code. (Whether one ought to consider CL a functional language depends on what is meant by the term “functional”, however.)
MLton is a highly optimising compiler for Standard ML.
Functional languages can be and have for some time been compiled very effectively. There is no difference to imperative languages in this regard.
Related
Which programming languages provide the best support for self-modifying code?
In particular, since the program will need to make extensive use of self-modifying code, I am looking forward at the ability to remove from memory some parts of code, after they are no longer needed, thus freeing that memory. Also, it would be a plus if there was the ability to identify and index the routines (procedures, functions, etc) with some sort of serial number, so that they could be easily managed in the memory (deleted, cloned etc) at runtime.
Operating systems need to have some more-or-less "self-modifying code" in order to load programs and dynamic link libraries from storage into RAM and later free up that RAM for other things, do relocation fix-ups, etc.
My understanding is that currently the C programming language is by far the most popular language for writing an operating systems.
The OSDev.org wiki has many tips of writing a new custom operating system, including a brief discussion of languages suitable for writing an operating system -- C, Assembly language, Lisp, Forth, C++, C#, PL/1, etc.
Just-in-time (JIT) compilers also need to have some more-or-less "self-modifying code" to compile source text into native instructions and run them, then later free up that memory for the next hot-spot.
Perhaps you could find some OS project or JIT project and use their code with relatively little modification.
A few people, when they say they want "self-modifying code", really want a language that supports homoiconicity such Scheme or some other dialect of Lisp, Prolog, TCL, Curl, etc.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 2 years ago.
The community reviewed whether to reopen this question 1 year ago and left it closed:
Original close reason(s) were not resolved
Improve this question
I have been looking into micro-controllers and was wondering if the majority of them are C/C++ based? I am quite proficient in java and want to ask you guys if anyone knows of a good cost efficient, java-based micro-controller I could look into.
All answers are appreciated!
The difference between a language like java (or c#) and a lower level language like c or c++ is the fact that they have a virtual machine.
This has many advantages, like making the application platform-independent. But it also means that each platform has to have the vm for it.
Now, microcontrollers are not uniform and vary in power, memory, and many other features. So adopting the JVM (java's virtual machine) for them is not easy even when possible.
Most of the time its just impossible - most of the uc have very low memory capacity (part of what makes them cheap) - this would make fitting any general-purpose JVM there impossible, not to mention also with the application code.
I am aware of some partial-implementations of java for microcontrollers. For example "java-based" sim cards (which have a very small controller inside) are there, but they have a very limited version of java.
So basically I think your best bet to write "embedded java" (especially if you're a novice) is to work on top of microcontrolers that are basically a small fully functioning computer, that runs a proper OS that already has a JVM. Just look into one of the new "micro computer" open source projects like raspberry pi or beaglebone. Both cost around 2x of an arduino and are much more powerful.
Hope I helped.
Have a look at the Java-ready STM32 microcontrollers or Renesas RX.
As an alternative, you can run a stripped-down JVM on AVR/Arduino using Haiku-VM, NanoVM or uJ.
You can also write Arduino sketches in Java and cross-compile them to C using VBB.
JArduino might be a good starting point for you, as it would allow you to write Java programs that interact with an Arduino board. The Java API provided by JArduino is fully aligned with the Arduino API. Then, once you get used to the Java API, it should be easy to switch to plain Arduino programming (as pointed out, the C/C++ -based Arduino is not that far from Java, anyway). Be aware that with JArduino you do not really program the micro-controller itself (your main logic would run on your PC and the Arduino would simply be "controlled" without any advanced logic running on the board).
There are Java alternatives, but I think they are costly. For example ST Microelectronics has this java IDE based on eclipse:
Java SDK
I have no experience with java on microcontrollers, but Java have many similarities (C based language) to C++ (which is more supported with microcontrollers), but it is still C that is dominating. It should be possible to learn this quite fast if you already know Java.
Arduino uses C++ and are easy to use for people inexperience with C/C++.
I suggest you also try the STM32 Java forum to see if there are users already sharing their experiences:
STM32 Java forum
You can look at Java on a Chip (JoC Module) is the java programmable controller-module
JoC have a reference Board Javaino for easy development
Also Demmel iLCD product have the Java VM on board, it's a smart display with JVM
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking us to recommend or find a tool, library or favorite off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.
Closed 9 years ago.
Improve this question
I'm still a newbie programmer and I am looking at some garbage collected languages that are suited for writing desktop GUI applications. The language must be available on Windows, OSX and Linux. I say "garbage collected" instead of high level since a language like D isn't quite high level (imo) but is garbage collected, compiles to native code and gives near C++ performance. However the most developed GUI toolkit for D is DWT, wich is a port of SWT. The few SWT apps I have used look ugly on every platform. If D had a Qt binding that would be great, but the only thing I could find was QtD which seems to be a dead project.
Languages I am aware of:
Java
Python
D
I'd rather not use C# with Mono and syntax-wise I prefer languages similar to C/C++.
Are there any others, and what would you suggest?
EDIT: The language doesn't have to compile to native code, compiling to bytecode and running in a VM is just fine.
Every programming language that I know, that has a compiler to the native code, uses some C or C++ GUI toolkit for GUI. SWT/DWT uses GTK on Linux/Unix for an example. If SWT applications look ugly to you, then either you did not configure the GTK theme or you did something with the look&feel initialisation. SWT applications look exactly the same as any "native" GUI application.
Even though I am a former C++ programmer, and no matter how I dislike it now, I would still recommend C++ to you because you asked for programming language with compiler that compiles to native binary. Additional requirement you specified is the garbage collector. Use the libgc in your C++ applications, and that is all you need. More about it here: http://developers.sun.com/solaris/articles/libgc.html .
In the field of programming languages with native compilers I am more/less settled with D, but unfortunately, D has no actively-developed GUI ToolKit as we speak. That will be solved soon, but until then, use C++.
What about vala?
Vala is an object-oriented programming language with a self-hosting
compiler that generates C code and uses the GObject system. Vala is
syntactically similar to C# and includes useful language features like
anonymous functions, signals, properties, generics, assisted memory
management, exception handling, type inference, and foreach
statements.2 It is being developed by Jürg Billeter and Raffaele
Sandrini. It aims to bring modern language features to C[clarification
needed][peacock term], with no added runtime needs and with little
overhead, by targeting the GObject object system. Rather than being
compiled directly to assembly or to another intermediate language,
Vala is source-to-source compiled to C which is then compiled with a
platform's standard C compiler, such as gcc.
Go there is as well some bindings for GTK, FLTK and WALK. Check out this thread.
On Java you can still modify the Look and Feel of your UI. Java gets also a port of Qt called Qt Jambi.
And then there are very stable languages like Free Pascal/Lazarus and PureBasic that work well (same source code compiles on all platforms) on Win, OS X and Linux
Real Studio uses reference counting for automated memory management. It's not garbage collection, but better in many ways.
And of course Real Studio runs on Windows, OS X and Linux and can create apps for Windows, OS X, Linux and the web.
You could use Qt Quick. It has a declarative UI language called QML and it's scriptable with javascript.
I am looking for a JIT compiler or a small compiler library that can be embedded in my program. I indent to use it to compile dynamically generated code that perform complex number arithmetics. The generated code are very simple in structure: no loops, no conditionals, but they can be quite long (a few MB when compiled by GCC). The performance of the resulting machine code is important, while I don't really care about the speed of compilation itself. Which JIT compiler is best for my purpose? Thanks!
Detailed requirements
Support double precision complex number arithmetics
Support basic optimization
Support many CPUs (x86 and x86-64 at least)
Make use of SSE on supported CPUs
Support stack or a large set of registers for local variables
ANSI-C or C++ interface
Cross platform (mainly Linux, Unix)
You might want to take a look at LLVM.
Cint is a c++(ish) environment that offers the ability to mix compiled code and interpreted code. There is a set of optimization tools for the interpreter. ROOT extends this even further by supporting compile and link at run-time at run-time (see the last section of http://root.cern.ch/drupal/content/cint-prompt), though it appears to use the system compiler and thus may not help. All the code is open source.
I make regular use of all these features as part of my work.
I don't know if it makes active use of SIMD instructions, but it seems to meet all your other requirements.
As I see that you are currently using the compile to dynamic library at link on the fly methond, you might consider TCC, though I don't believe that it does much optimization and suspect that it does not support SIMD.
Sounds like you want to be able to compile on the fly and then dynamically load the compiled library (.DLL or .so). This would give you the best performance, with an ANSI-C or C++ interface. So, forget about JITing and consider spawning a C/C++ compiler to do the compilation.
This of course assumes that a compiler can be installed at the point where the dynamically generated code is actually generated.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking us to recommend or find a tool, library or favorite off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.
Closed 9 years ago.
Improve this question
A few years ago I looked into using some build system that isnt Make, and tools like CMake and SCons seemed pretty primitive. I'd like to find out if the situation has improved. So, under the following criteria, what is currently the best build tool:
platform agnostic: should work on windows, linux, mac
language agnostic: should have built-in support for common things like building C/C++ and other static langs. I guess it doesn't need to support the full autotools suite.
extensible: I need to be able to write rules to generate files, like from restructuredText, latex, custom formats, etc. I dont really care what language I have to write the rules in, but I would prefer a real language rather than a DSL.
I would prefer to avoid writing any XML by hand, which I think for example ant requires.
Freely available (preferably open source)
The term "best" is slightly subjective, but I think answers can be rated objectively by the criteria above.
I'd definitively put my vote up for premake. Although it is not as powerful as it's older brothers, it's main advantage is absurd simplicity and ease of use. Makes writing multi-compiler, multi-platform code a breeze, and natively generates Visual Studio solutions, XCode projects, Makefiles, and others, without any additional work needed.
So, judging purely by the criteria set forth in the question, the build system that seems like the best fit is probably waf - pure Python, provides support for C++ and other languages, general, powerful, not a DSL.
However, from my personal experience, I prefer CMake for C++ projects. (I tried CMake, SCons, and waf, and liked them in roughly that order). CMake is a general solution, but it has built-in support for C++ that makes it nicer than a more generic solution when you're actually doing C++.
CMake's build model for C++ is more declarative and less imperative, and thus, to me, easier to use. The CMake language syntax isn't great, but a declarative build with odd syntax beats an imperative build in Python. Of the three, CMake also seems to have the best support for "advanced" things like precompiled headers. Setting up precompiled headers reduced my rebuild time by about 70%.
Other pluses for CMake include decent documentation and a sizable community. Many open source libraries have CMake build files either in-tree or provided by the CMake community. There are major projects that already use CMake (OGRE comes to mind), and other major projects, like Boost and LLVM, are in the process of moving to CMake.
Part of the issue I found when experimenting with build systems is that I was trying to build a NPAPI plugin on OS X, and it turns out that very few build systems are set up to give XCode the exact combination of flags required to do so. CMake, recognizing that XCode is a complex and moving target, provides a hook for manually setting commands in generated XCode projects (and Visual Studio, I think). This is Very Smart as far as I'm concerned.
Whether you're building a library or an application may also determine which build system is best. Boost still uses a jam-based system, in part because it provides the most comprehensive support for managing build types that are more complex than "Debug" and "Release." Most boost libraries have five or six different versions, especially on Windows, anticipating people needing compatible libraries that link against different versions of the CRT.
I didn't have any problems with CMake on Windows, but of course your mileage may vary. There's a decent GUI for setting up build dependencies, though it's clunky to use for rebuilds. Luckily there's also a command-line client. What I've settled on so far is to have a thin wrapper Makefile that invokes CMake from an objdir; CMake then generates Makefiles in the objdir, and the original Makefile uses them to do the build. This ensures that people don't accidentally invoke CMake from the source directory and clutter up their repository. Combined with MinGW, this "CMake sandwich" provides a remarkably consistent cross-platform build experience!
Of course that depends on what your priorities are. If you are looking primarily for ease of use, there are at least two new build systems that hook into the filesystem to automatically track dependencies in a language agnostic fashion.
One is tup:
http://gittup.org/tup/
and the other is fabricate:
http://code.google.com/p/fabricate/
The one that seems to be the best performing, portable, and mature (and the one I have actually used) is tup. The guy who wrote it even maintains a toy linux distro where everything is a git submodule, and everything (including the kernel) is build with tup. From what I've read about the kernel's build system, this is quite an accomplishment.
Also, Tup cleans up old targets and other cruft, and can automatically maintain your .gitignore files. The result is that it becomes trivial to experiment with the layout and names of your targets, and you can confidently jump between git revisions without rebuilding everything. It's written in C.
If you know haskell and are looking for something for very advanced use cases, check out shake:
http://community.haskell.org/~ndm/shake/
Update: I haven't tried it, but this new "buildsome" tool also hooks into the filesystem, and was inspired by tup, so is relevant:
https://github.com/ElastiLotem/buildsome
CMake
CMake is an extensible, open-source
system that manages the build process
in an operating system and in a
compiler-independent manner.
Gradle seems to match all the criteria mentioned above.
It's a build system which took the best of Maven and Ant combined. To me, that's the best.
The Selenium project is moving over to Rake, not because its the best but because it handles multiple languages slightly better than all the other build tools and is cross platform (developed in Ruby).
All build tools have their issues and people learn to live with them. Something that runs on the JVM tends to be really good for building apps so Ant, Maven (i know its hideous), Ivy, Rake
Final Builder is well known in Windows world
smooth build matches most of your requirements.
platform agnostic: yes, it's written in java
language agnostic: it doesn't support c/c++t yet, only java but it is extensible via plugins written in java so adding more compilers support is not a problem
extensible: yes, you can implement smooth function via java plugin, you can also create smooth function via defining it as expression built of other smooth functions.
I would prefer to avoid writing any XML: you won't see a single line of it in smooth build
Freely available: yes, Apache 2 license
disclosure: I'm the author of smooth build.