For Erlang code, I use rebar. For Elixir code, I use the built-in mix tool.
Now I want to have a mixed Erlang/Elixir project. Can I use rebar to compile Elixir code? Or can I use mix to compile Erlang code?
If so, how?
Mix can compile erlang files if you put them in src. There is a rebar_elixir_plugin to compile Elixir code from rebar but it is not as efficient at it as Mix.
Related
I'm very new to Haxe, and specifically want to use it to produce C++ code from Haxe (actually the flow would be AS3->Haxe, then Haxe->C++). My understanding is that Haxe compiles Haxe directly to a (C++) executable. But does it explicitly output the generated source?
Can/does Haxe supply the C++ code that it produces in this process? -- As I could then take and use this source within another C++ cross-compiler such as Marmalade (with modifications, of course).
I'm wondering about the intensiveness of the conversions, also. If Haxe does produce/supply the C++ source, then what does this source look like? Is e.g. memory management all packaged up into native DLLs/SOs? In that case, it seems like Haxe wouldn't be an ideal option.
(Disclaimer: I'm just trying to get some preliminary information before I go down this road. In fact, more specifically, I want to port from AS3 to C++ for Marmalade. So I want to know if it is worth writing my own converter or if Haxe provides a viable alternative.)
If you're looking to go from AS3->C++ through Haxe, then you should check out NME. It allows you to use the Flash Player API to write applications to compile to native ones (through the C++ backend), swfs and html5 applications.
Also it offers a whole workflow for assets and such. And it has pretty good integration with FlashDevelop (windows only) and MonoDevelop, but you can of course use any IDE.
Yes, Haxe outputs the source for you. Haven't ever looked into it very deeply, but it's there. When you compile for a C++ target (e.g. Windows) the source can be found under bin\cpp\windows\obj.
Currently, I embed lua in my c++ code.
I wonder if the same is possible with c++. That way I can pass objects and use libraries within the script. to do this, I think I would need the following from the master c++ code:
execute the running of the script
compile the script
run the script
the script passes pointer to it's data objects
the script is done and the program uses the data objects.
is this possible? small example?
For me it is useful as I ran science calculation that I don't want to stop but i want to add functionality on the fly. I also see this being useful for servers in c++ that don't want to shut down but want to make a change.
You may choose to use some kind of C++ interpreter but they can't do every thing. C++ is one of the hardest to implement(if not that hardest) languages. Just think about macros, templates and every other thing that make C++ as powerful as we know they are really hard to parse and understand and beside all of that we have optimization that create such fast and thin codes for us, so how an interpreter can be such powerful and understand all of this? Even best known compilers may fail to understand all of the standard or at least have errors for understanding complicated C++ codes. In one of my projects that heavily use templates using MSVC 2010, it take about 10 minutes to compile the code! So interpreters usually simplify their task and only support a subset of full C++, so if you are cool with this use some interpreter. I never used one of them but I heard cint is good.
The other option is you have a free compiler like g++ and actually compile your code into some kind of shared library and then load it dynamically and call some functions from it based on some kind of configuration.
Are there any build systems that don't use a DSL but actually use C++ as the build language?
Yo Dawg, I heard you like C++, so I added C++ to your build system, so you have to compile before you compile.
I've written a build system that I use in my projects in Python called pybake. It's designed to be a bit smarter than make, with less magic. The build is also defined in Python, thereby reusing an existing language, rather than generating a new DSL for that purpose. Here's an example of it in use.
None that are popular, if anyone was crazy enough to even write one. C++ would be an incredibly clumsy language for that.
If you're looking to create one, instead pick a language such as Python or Lua in order to use something popular and not invent a new DSL.
Are you asking if there are any build systems, like Make or Ant that use C++ code as the directives rather than specialized commands? While many higher level languages have such a system, there aren't any in C++ that I am aware of. Certainly not the popular ones. This is probably because C++ is a compiled language and not one that is trivial to parse. This makes it less suitable for what is essentially a lightweight scripting task.
There is probably C++ code in there somewhere but if you mean you would have to write a C++ program and compile it then run it to build a different source tree, I don't think that would really work in the scheme of things. What would you build your build script with? It goes on and on.
Compilers and the commands behind the scripting languages are often written in C or C++.
Since C++ is compiled, this would give you the problem of needing a build system for your C++-based build system. I am not aware of any C++-based build system and would be surprised to find one. For interpreted languages like Python, bootstrapping isn't an issue (and so you will find scons, for example).
If you are looking for something better than Make, though, check out CMake. Though somewhat out-of-date, you may find the C++ Project Template helpful as an example for creating CMake-based projects.
I came here to ask this question because this site has been very useful to me in the past, seems to have very knowledgeable users who are willing to discuss a question even if it is metaphysical at times. And also because googling it did not work.
Java has a compiler and then it has a JDT library that can compile java on the fly (for example used in JasperReports to turn a report template into Java code).
My question: Does anyone know of a library/project that would offer compiling as a set of library classes in c/c++. For example: a suite of classes to perform Preprocessing, Parsing, CodeOptimization and of course Binary rendering to executable images such as ELF or Win format. Basically something that would allow one to compile c or c++ scriptlets as part of an application.
Yes: llvm. In particular, clang. At least, that's how they advertise the projects. Also, check this question. It might be relevant if you decide to use llvm.
You might be able to adapt something from the LLVM project to your needs.
You can just require that a compiler be installed, then call it. This is a fairly hefty requirement, but about the only way to truly "embed" C or C++. There are interpreters that you may be able to embed, but that currently seems a poor choice, not the least because any libraries used in the script must have development versions (i.e. headers and source/compiled-libraries) installed, and those libraries could be restricted to the feature set supported by the interpreter (e.g. quality of template implementation).
You're better off using a language like Python or Lua to embed.
There is the ch interpreter but I have not used it. Generally for scripting type applications a more natural scripted language is used.
Great. It looks like LLVM is what I was after.
Thanks a lot for your feedback.
I am not primarily after C++ as a scripting language. I have noticed that Python is used as an embedded script engine.
My primary reason is two fold:
Get rid off Make,CMake and the hell that is Autoconf and replace it with something like Scons that binds into and interacts with all phases of compiling
Hook into the compiling process after parsing and auto generate code. Specificaly meta related code. In my case I have been able to implement almost every feature of Java in C++ except one: Reflection.
Why impose on your code uneeded bload like RTTI that is often inadequate. Instead one could selectively generate added features. But developer would have to choice when and how to use this extra code.
C/C++ would be good option to write some of the performance critical aspects of a Ruby Application. I know this is possible.
I would like to know how to add C/C++ code into Ruby code; any other language for that matter.
Are there any practical applications of this which you noticed in open source projects or else?
Besides "Extending Ruby", here are two other resources:
README.EXT (extension.rdoc) - shows you more about how to build C extensions. A good compliment to "Extending Ruby"
Ruby Inline - This is a library that tries to make it easier to build C extensions by having you call methods in ruby to compile C code.
Look in the "Extending Ruby" section of the Pickaxe book:
http://www.ruby-doc.org/docs/ProgrammingRuby/html/ext_ruby.html
you should have a look at SWIG - it allows you to create ruby extensions in C/C++.
We use ffi in one of our projects.
Ruby-FFI is a ruby extension for
programmatically loading dynamic
libraries, binding functions within
them, and calling those functions from
Ruby code. Moreover, a Ruby-FFI
extension works without changes on
Ruby and JRuby.
It works quite well.
Compile your high performance code into a system service/executable, and call it from inside Ruby...?
Seems like you need to read up on Extending Ruby