I am quite new to V-rep and while I'm reading the documentation, in the section Regular API, all the provided script functions are written for both Lua and C, but officially, Lua is the supported language for scripting.
My question is, can I write the scripts in C ?
No, the only thing you can do is to use the remote API to write an external C++ program that handles the simulation.
Related
I am recreating a new Fortran90 environment using vscode with extensions (formatter, modern fortran, fortls & FORD documentation generator). I would like to use fortls features fully and easily document my code using FORD style. In the Fortran Language Server Github, the following feature is specified :
Documentation parsing (Doxygen and FORD styles)
FORD is installed and working well independently but I dont see any interaction with fortls and its vscode extension.
I tried to write some FORD comments but I don't see anything special:
subroutine example(i)
!! This is a subroutine description
!!
!! I created this subroutine to test ford documentation parsing by fortls
implicit none
integer, intent(in) :: i
!! Integer to be printed
print*, i
!! Prints i
end subroutine example
Does anyone know what this feature really does and how to use it properly?
What I mean is what does this feature bring to the basic operation of FORD?
As I mentioned in my comment, what that statement means is that the language server is able to parse and display the FORD documentation of functions, subroutines, module procedures and variables while hovering, completing argument lists of functions, subroutines and methods and while using autocompletions. This is inline with the language servers for other programming languages (C, C++, Python, Javascript, Typescript, etc.).
It does not mean that you are able to run FORD or Doxygen through the language server
Does choosing a programming language decide performance when all of it is compiled to some 1's and 0's
Eg: printf (in C) vs cout (C++) vs print (in Python)
Do all of the above have same binary compiled code ?
Appreciate any help in understanding this concept of programming language and role on hardware in detail! Thanks in advance
The choice of programming language can have many impacts on the performance of your code, how portable it is, the comparability and among other things, how easily the objective can be put into code. To answer you question directly, C and C++ would likely produce the 'same binary' when printing an output, if they were both done for the same target environment. Python is different because it is an interpreted language, meaning the code is read by a program written in code native to the architecture and acted upon accordingly. Python is something of an edge case in this regard because it is technically compiled at execution time (and can be before distribution) but into an intermediate code similar in principle to Java byte code that is only understood by the Python interpreter.
The difference you bring up between lower language's like C and higher ones like Java, Python and even JavaScript is the nature of their execution being done by native hardware or by the interpreter. Language's running on bare metal are generally understood to be faster than those on interpreters as the interpreter takes time to understand the code and uses it's own system resources. Java tends to break this rule because it's interpreter is a full virtual machine that understands very simple byte code, making it competitive in speed to language's like C.
To what kind of binary code they are compiled depends on the compiler. For C and C++ there are dozens of different compilers which might generate different binary code. Besides that, most compilers even have optimization flags that influence the generated binary code a lot.
Python isn't even directly compiled into "machine code", it's compiled into bytecode for a python interpreter. The Python interpreter itself is a program that runs on the machine, then reads the python-bytecode and executes it probably by internally calling predefined functions (that already exist in machine-code)
I have an old piece of Fortran f77 code that I would like to understand and edit for future reuse. For that purpose, I would like this code to be translated to either C or Matlab / Octave language. I have found an instance of f2c exe online, but it wouldn't run because of inappropriate OS ( my OS is Win 7 x64, f2c wanted older x32 ).
My main concern is being able to understand the code. Translation in terms of execution efficiency is not of importance. I am open to any suggestion, apart from learning Fortran 77. I am aware of that option myself, but would do it only as a last resort. Thank you.
Just learn Fortran. The output of machine-translated code may well be functionally correct and suitable for compilation and execution, but it's going to be really hard to understand and maintain. (Just look at what generated code targeting a single language, like the output of a GUI builder wizard, looks like.) In particular, while Matlab is built on Fortran, its idioms at the M-code level are different enough that it would be pretty incomprehensible. If you already know C or any other Algol-like language, picking up Fortran is not that hard. And the idioms and features that are particular to Fortran – that is, the new stuff you'd have to learn – are probably going to be especially weird and incomprehensible when sent through a translator.
The one translator that might actually be useful is a Fortran 77 -> Fortran 90 translator. The modern '90 dialect would be easier to learn and more succinct, and since the translation is within the same language family the output probably wouldn't be too ugly.
Since are using Octave, you can call Fortran code, there is no need to rewrite it. You will need to write a very simple C++ wrapper to it but Octave already provides macros to do all of the hard work. It is all documented on the manual. Actually, Octave itself calls on many fortran subroutines, so this is perfectly normal.
If you want to modify it, you should be learning Fortran then.
I have a project written in C which I wish to convert to Perl. A friend of mine suggested to use LLVM. I compiled my C code to LLVM assembly using Clang. Now I'm trying to convert this intermediate representation into Perl but I can't seem to find any backend for it. Would someone point me in the right direction?
No, there isn't such a backend. At least not directly. Emscripten converts LLVM IR to Javascript, and maybe you can use something else to convert that to Perl.
It's a pretty bad idea for moving a project from one language to another. The code will be completely unreadable and un-maintainable. Either do a honest rewrite or wrap your C as a library with Perl's foreign-function interface tools and use it from Perl.
Converting to Perl is a no go. It hasn't been done because emulating C in Perl would be insanely slow. They have completely different type systems, for starters. However, it's wholly unnecessary to convert the code to Perl to call it from Perl. You can load compiled C code from Perl.
What you'll have to do is tell Perl how to call those C functions. Perl deals with scalars and so on, but C deals with ints and so on. This is done using XS.
perlxstut contains the documentation on how to do all this.
I'm looking for a library or command line script that will allow me to create custom templates that I can generate from the command line. The ruby on rails scaffolding generator is almost identical to what I am trying to do. I would even prefer that it be written in Ruby (yet it cannot require Rails because I may not be using it on a Ruby application). What sorts of scripts like this are already available?
I've also been on the lookout for something like this -- haven't found what I hoped for. The two approaches I've used instead have been acceptable. But I'm still hoping to find the real thing.
obvious, but sed for simple use cases
for medium-complexity use cases, if you can assume some version of Python is present on the machine, string.Template in the standard library works well. You could write a small Python script that uses this function, and since it is Python, tests / looping etc. that might normally be provided by the template engine could pretty easily be handled in the Python code instead.
I've just discovered Mustache (see http://mustache.github.io/). Seems like a solid, purpose-built solution. From its web site, Mustache has implementations in Ruby, JavaScript, Python, Erlang, PHP, Perl, Objective-C, Java, .NET, Android, C++, Go, Lua, ActionScript, ColdFusion, Scala, Clojure, Fantom, CoffeeScript, D, and node.js. If those choices suit your environment, you could script or compile Mustache support to be a command line utility pretty easily.
UPDATE 15-OCT-2013
Now that I've used Mustache for a while -- it's a great tool, simple but powerful.
Try this one: https://gomplate.hairyhenderson.ca
Rich set of functions and just a stanalone binary (written in Go)
For simple use cases you can use envsubst fom the gettext GNU package.
Basically, it reads any (text) file from stdin, replaces all occurrences of $VARIABLE or ${VARIABLE} from environment and writes the result to stdout. Little more, nothing less.
Full documentation is here.
Pros:
It is a small binary, no python (or other runtime) required
It is very fast and has tiny memory footprint
Cons:
It does just that. No special interpolations and functions (like loops, conditionals etc.)
It doesn't support special bash-like "Parameter Expansion"
For more advanced use cases I recommend j2cli, a "standalone" Jinja2 templating engine you can install from pip as it is in Python. Code can be found here (though it looks like a little bit stale...) and documentation is there too.
Pros:
It's Jinja2 with all bells and whistles!
Cons:
You need full Python runtime to run it and PIP to install it.
Computing resources could not be negligible in constrained environments.