I have a problem with Kotlin. Running external programs - kotlin

How to run external programs in pure Kotlin?
From a program written in Kotlin for Windows, I want to run external programs. I want to do it I want to do it in pure Kotlin (not Java). Please provide sample code.
For example: how to start and open Notepad with .txt file, MyProgram.exe. (in Windows it's the WinExec() function) What to read about it, maybe a few links. :)
I'm a beginner. I've read the kotlin documentation and couldn't find anything.

Related

Does Kotlin have a network REPL like Clojure's `nrepl`?

Clojure's nrepl provide a way to connect to a running remote Clojure program.
Does Kotlin have a network REPL like Clojure's nrepl?
maybe have a look at:
https://github.com/kscripting/kscript#treat-yourself-a-repl-with---interactive
maybe it comes near to what you want to have.
https://github.com/holgerbrandl/kscript
kscript by Holder Brandl adds enhanced scripting support for Kotlin on *nix-based systems. kscript provides an easy-to-use, very flexible, and almost zero-overhead solution to write self-contained mini-applications with Kotlin.
also available via https://sdkman.io/
$ sdk install kscript
For trying out small kotlin code snippets, I sometimes just use the scratches from my favorite IDE Intellij: https://www.jetbrains.com/help/idea/scratches.html
Maybe you find the latter also "helpful" for whatever you "intended" to achieve in using a REPL.
No there isn't - maybe you can define the requirements and what/why you want and someone might develop it

Are there any documented uses of Clojure/Clojurescript for devops and/or automation testing?

I am looking for something along the same lines as this article: "Go With Go(Lang): Features and Testing Frameworks", featuring Clojure/Clojurescript. Similarly, any book(s) that contain examples of Clojure/Clojurescript being used as to create devops/test-automation applications, would also help.
I am the developer behind spire, a clojure DSL for idempotent machine provisioning over ssh. I built it using GraalVM and sci. I have also used it for automated testing.
Presently I am working on making it a babashka pod, so soon you will be able to use its functionality directly from babashka.
I do virtually all my AWS manipulations using aws-api. The dev-ops experience via clojure is much better than using bash/shell scripts and the AWS CLI.
Your question is a bit vague, but Clojure is IMHO the best general-purpose computer language (no surprise since you asked on a Clojure site!).
One solution that might work for you is the Babashka tool. It allows you to turn Clojure code in to a stand-alone executable. So, instead of using quirky, fragile bash scripts, you can write a robust & powerful Clojure program that has the instant startup & low memory usage of a Go or C program.
For more general purposes, you can write a complete general-purpose Clojure program and interop with the outside O.S. with a function like tupelo.misc/shell-cmd or the original Clojure version from clojure.java.shell. I have used this to drive AWS CLI functions, for example listing, cloning, and deleting RDS database instances.
The sky is the limit (along with your imagination).
Update
I forgot to mention GraalVM. It allows you to compile Clojure code into a static executable (the same as produced by a C/C++ program). Here is a Clojure/GraalVM demo project that creates a "Hello World" program even faster and more memory efficient than a Python script! Enjoy!

Plug-and-play Lisp implementation

Is there a Plug-and-play Common Lisp/Scheme implementation?
By Plug-and-play I mean an implementation with an IDE that doesn't require you to play chords with a pianist dexterity(so not Emacs), where you can run a program by pressing a button not writing commands in a console, with modern libraries and that is portable.
Racket supports all the features above EXCEPT portability. I wrote a program in Racket that I couldn't send to friends because it wouldn't run on other computers. I want to make programs that I can send as easily as a Java programmer sends a Jar file and you can run it with double-click.
I also don't like how Clojure looks.
So the big question: if someone doesn't know programming, can he learn LISP using this implementation as easy as someone who would pick Java or C#?
I think you are mixing a lot of different requirements in your description:
If you need something that compiles to a binary executable file, you can use a bunch of CL implementations that compiles to an executable file. You can even use https://common-lisp.net/project/armedbear/ that runs on JVM.
If you need something easy to start with, with editor and runtime embedded, you can use http://www.lispworks.com or things like https://common-lisp.net/project/lispbox/.
But it seems that you are also talking about the language. Well, the syntax is only one part of the language, don't evaluate a language just taking into account its syntax.
Finally, I don't believe that it is easy to start working with Java or C#. You may think that these IDEs make life easier, but in the reality, it takes time to install them, solve dependencies and really learn how to be productive with them. Those IDEs end-up being much less flexible and usable than Emacs that you criticized. I have some experience teaching CL for students that after 1-2 months quickly started to be very productively why Emacs.
Well I think that this days is pretty easy to install common lisp and intall slime with quiclisp then you can have your environment quick and easy
take a look at this question
Setting the SLIME in emacs
and in quicklisp:
https://www.quicklisp.org/beta/#installation
also I recommend you to take a look at the roswell an intend to be a lisp installer and launcher for major environment that just work.
project on github in the wiki section they have an easy form of start emacs with roswell:
https://github.com/roswell/roswell/wiki
require you to play chords with a pianist dexterity(so not Emacs)
One can use emacs like notepad and use menus and buttons to do actions instead of key combinations, that although arbitrary, don't require much dexterity to reach. It is clear to someone that have used SLIME that you SLIME satisfies your requirements but are deadset against emacs. If so, give Allegro Common Lisp a try.
Racket supports all the features above EXCEPT portability. I wrote a program in Racket that I couldn't send to friends because it wouldn't run on other computers. I want to make programs that I can send as easily as a Java programmer sends a Jar file and you can run it with double-click.
In racket you can use raco exe will produce a Stand alone executable, so Racket will also do.

Is it possible to make a DLL plugin for EditPlus to extend the editor like in EditPlug or Notepad++?

Is it possible to make a DLL plugin for the programming editor called EditPlus?
I wish to extend the editor like in EditPlug text editor or Notepad++ where you create a DLL which allows you to talk to the editor. Or another example is Total Commander where you create a DLL to talk to the program from your own code in delphi or visual c++, or any program that can create a windows DLL.
Or is there NO way to make a plugin in Editplus because they have not implemented a plugin system?
I do not see any kind of plugin architecture mentioned in EditPlus's feature list. If it does not expose a plugin API, then you cannot write a plugin for it. All you can do is create a DLL that is injected into EditPlus's address space by an external process and then uses OS API calls to directly manipulate EditPlus's UI and raw memory as needed.
EditPlus does not have a plugin system, so you cannot extend in any way.
EditPlus has no plugin system!
In EditPlus, You can only use Text Filter to do something like plugins do.
Text Filter can execute script file or executable file.
You can use perl, java, python, vbscript, javascript or command line application which support standard input and standard output to write and run as a text filter.
Text Filter only can change the text content in the editor area.
I'll be very glad if a real plugin system come with EditPlus.
See also:
Writing a text filter for EditPlus
Some Text Filters for EditPlus
yes it is possible. it's hard (..not so very hard..but still)
i explain in here the possibility to extend Editplus with php
https://stackoverflow.com/a/61254718/5781320
i see this cause i lookin' for other simplest methods than mine.(just by curiosity and fun) .. i wrote the fastest php framework in the world and I will glad to make it "talk" with editplus
There is possible to compile servers in PUREBASIC.com to interact with applications Android in b4a=open source now (b4x.com) that suppose to interact with google speech recognition so yes is possible to talk from your phone to the server dll or exe to interact with editplus,total commander,and many other stuff.
I did it myself cause i was curious if had delay.
EditPlus hasn't the direct possibility , Notepad++ does and on https://www.purebasic.fr/english/viewtopic.php?f=12&t=65680&hilit=notepad+plugin with the same purebasic i use on that notepad++ version work that pugin can be modiffied how you like to be .On actual version of notepad++ i tryed myself doesn't work : the plugin is obsolete and is rejected so witch method you choose is hard to implement the system you need int this dynamic expansion of open source / or developing.

How to call a MATLAB code from Objective C

I'm planing to write my algorithmic codes in Matlab. And I need to convert .m files into a format where Objective-C can access. When I try mcc, the following error appeared.
The -t switch is no longer supported; the Compiler no longer generates C/C++
source code for M-functions (it generates wrapper functions instead, see
the documenation for -W).
If mcc is not creating C source codes how can i generate wrappers? and do i have to copy both m file and the wrapper in order to make everything working?. And will those wrappers work in iOS??
MATLAB Compiler does not convert MATLAB code into C code, and has not done so for a long time now.
Instead, it archives and encrypts your MATLAB code and creates a wrapper (which could be an executable, a library or, if you have access also to any of the Builder products, a .NET assembly, a Java .jar file, or an Excel add-in). This wrapper dearchives and decrypts your MATLAB code, and executes it against the MATLAB Compiler Runtime, which needs to be included with your application (but is freely redistributable).
You are not going to be able to run the MCR on iOS - its footprint is just too big. If you are targeting another platform with Objective-C, you could produce a library using MATLAB Compiler and call that from your Objective-C.
MATLAB Coder (not the same as MATLAB Compiler) can convert a subset of the MATLAB language into C code. If you are targeting iOS this would be one approach, or you could alternatively run your MATLAB code remotely, and have your app access it via the web.
I'm a little confused by what you have written so I may not be answering your real question:
The Matlab documentation provides clear instructions on how to use the Matlab engine from C programs. Since Objective-C is just C with knobs on, I see no reason why you shouldn't call the engine from an Objective-C program. All that the Matlab engine will see when it is running are valid calls, it has no clue what language the calling program is written in.
I think that for your usage of mcc is irrelevant; what you need is an Objective-C compiler on your Mac. The Matlab documentation suggests that the compiler included in XCode up to v4.1 is OK for Matlab engine applications. In my experience, it may take a little fiddling with compiler options to make a more recent compiler work with your installation of Matlab, but no more than that.
If you plan to use Objective-C calling Matlab, you may not want to start by writing M-files for your algorithmic core. Actually, you probably will, but the Matlab engine doesn't really run M-files, it executes commands sent to it by an external program, such as your Objective-C program. Your development route might be (1) write M file to implement algorithm, then (2) write Objective-C program calling Matlab engine at critical steps when the Matlab functionality is required. You could write your application to make the engine run an M-file (I think) but this is outside my experience.
While you can use Matlab to run a compiler to build your programs, in this case you are probably better using XCode (or your preferred Mac IDE) to build your programs, taking care to ensure that the right linkages are made to the Matlab engine. Again, the documentation explains what you need to do.
No wrappers are involved. No M-files are required. And good luck getting the Matlab engine running on iOS !