Can one make CUSP use one's own SBCL? - common-lisp

I've already got slime+emacs+sbcl running (SBCL 1.0.23) on my Windows XP machine. CUSP installs with SBCL 1.0.6.
Is there a way to make CUSP use the existing SBCL installation instead of its own?

You can, I don't have it installed on this computer; but in the options (maybe preferences) section (where Java, Lisp, and other tabbed panels to the left are listed) there is a sub section under Lisp called implementation.
In that section you can select which SBCL binary to use and which image file to load. It doesn't work with the latest SBCL implementation (At least as far as I know).

Related

New to Coq: How to compile .vo files and run command line?

I'm new to working with Coq, and I'm progressing through the first volume of the Software Foundations book, but I can't for the life of me figure out how to compile the Basics.v file for the second chapter on induction.
I've seen things floating around about using the Coqc command on the command line, but I don't know how to access the terminal, or at least the windows terminal doesn't recognize the command. If anyone could walk me through this it'd be much appreciated!
In case you are using CoqIDE, there is a menu item "Compile/Compile buffer", which creates a .vo file for the currently loaded .v file. For a few files and early stages of learning, this might be the easiest way.
Then SF likely comes with a make file which you can just run with make. You didn't say what OS your are using - on Linux and Mac this should be trivial, on Windows it depends on how you did install Coq. The Windows installer doesn't come with make, but if you used the Coq Platform scripts to setup Coq on Windows, everything is there.
Otherwise it might get a bit complicated - you need to pass the right options to coqc (which CoqIDE and make do automatically for you).

How to do image-based development in Common Lisp?

I am new to Common Lisp. This is how I develop programs in other languages, and also how I now develop programs in Common Lisp:
Open a text editor (e.g. vim or emacs) to create/edit a text file.
Write source code into the text file. (If unsure about the behavior of a snippet of code, and an REPL is available, then evaluate the snippet in the REPL, verify that the snippet evaluates as expected, and then go back to writing more code.)
Save the text file.
Ask the compiler/interpreter to load and run the source code in the text file. (e.g. sbcl --script myprog.lisp)
Go to step 1 if needed.
This is the conventional write-compile-run development cycle for most programming languages. However, in the lisp world, I hear things like "interactive development" and "image-based development", and I feel that I am missing out on an important feature of Common Lisp. How do I do "image-based development" instead of "write-compile-run development"?
Can someone provide a step-by-step example of "image-based development" similar to how I described "write-compile-run development" above?
(Note: I am using SBCL)
In typical Common Lisp implementations the runtime, the compiler, parts of the development environment and the program you are developing reside in the same program and share the same object space. The compiler is always available while you develop the program and the program can be incrementally developed. The development tools have access to all objects and can inspect their state. One can also undefine/remove, replace, enhance functionality from the running program.
Thus:
don't restart the program you are developing. Stay connected and update it. Even days, weeks, or months - if possible.
write code in such a way that the program can be replicated and built from scratch if necessary. Build it from time to time and fix any build problems.
once you use our program and there is an error -> fix the error within the program, while being able to inspect the full error state
creating a running program is either loading all code into a plain Lisp all the time or saving an executable image with the loaded code/data
Fixes to program bugs can also shipped to the user as compiled Lisp files, which gets loaded into the delivered program and update the code then.
Let's say that you are using SBCL with Emacs and SLIME (e. g. through Portacle).
Open Emacs
Start SLIME (M-x slime) — this starts a “plain” Lisp process in the background and connects the editor functions provided by slime to it; then gives you a REPL that is also connected into this process (image)
Open a text file (e. g. foo.lisp)
Type some code
Press C-c C-k to compile the file and load it into the running Lisp process
Switch to the REPL, try it out
Switch to the Lisp file (step 4).
This is just very basic usage. Further things to do/learn
You can also compile and load just a single toplevel form (C-c C-c)
Learn about packages
Learn about systems (ASDF)
Learn how to use Quicklisp to get the libraries you want
Learn how to access inline documentation from the REPL
Note that you never need to unload your program, you just modify it, even when downloading and loading new libraries. This makes the feedback cycle instantaneous in most cases. You also never need to switch away from the IDE (Emacs).

Why does UPX break compiled SBCL apps?

This is mostly a stupid question, since UPX (a tool that wrings extra bytes out of your executable files) saves a tiny amount of space over the built in compression in the buildapp tool.
A very small demo application creates a 42 megabyte file. Understandable, since the SBCL environment isn't tiny.
Passing the --compress-core option to buildapp shrinks that down to 9.2MB.
I thought I'd try throwing UPX at the resulting binary, and the savings only amounts to a few more bytes: 9994288 -> 9871360
However, the resulting file no longer runs anymore - it just jumps into the SBCL REPL (with no errors, it's as if I just ran sbcl by hand), and some poking around there reveals that the functions making up my test program no longer exist.
What did UPX do to the binary that resulted in this breakage?
This may not be the answer, but it may serve as a clue: I've found that if you add anything, even a single byte, to the end of an SBCL executable created with sb-ext:save-lisp-and-die, then all the definitions disappear, just as you described.
Perhaps SBCL creates executables by appending the core (which contains your definitions) to a copy of the SBCL ELF (or PE on Windows) binary, plus some metadata at the end so that SBCL can still find the beginning of the core even though it's appended to an executable.
If you hex-edit an executable created with save-lisp-and-die, you'll find that it ends with the string "LCBS" (SBCL backwards), which seems to support my theory. "LCBS" probably serves as a magic number, letting SBCL know that yes, this executable contains its own core.
UPX compresses executables, probably including that magic number at the end. When SBCL opens its UPX-compressed self on disk, it won't find "LCBS" at the end, so it assumes that there is no core appended to the executable.
I can't explain why the standard library seems to still be there if this is the case. It could be that SBCL loads /usr/lib/sbcl/sbcl.core (or its equivalent on Windows) in that case. This could be tested by moving the executable to a machine where SBCL is not installed and seeing if it works at all, and if so, whether you still have car, cdr, list, etc.

deploying a Qt application

In a nutshell, the question is: I just finished my first application using Qt Creator on a computer running under Linux Ubuntu, now how do I make this available for everyone. Now follows the more detailed version ;)
I must apologize for asking this, I am aware that this question has probably been asked many times and that there is official documentation that I can read. I am just completely new to programming and I am very confused by everything I've read so far. If you are kind enough to help, please assume I know absolutely nothing :)
Here we go: I've just finished designing my first application (a scientific program) with Qt creator on my laptop which runs under Linux Ubuntu. It works fine and I'm very proud of it ;)
Here's what my project consists of: 40 header files, 42 source files, 1 pro file, 1 qrc file, 1 html file and 7 png files. In the code, I use #include for a bunch of fairly standard Qt classes (QWidget, QTextBrowser and so forth, maybe like 40 of those).
Now I'd like to make it available to other people. For Linux and Mac users, I've figured a way to do that: I can compress the folder containing my project, tell them to install Qt on their computer, then download and extract the files on their hard disk, open a terminal in the folder and run
qmake myProject.pro
qmake
make
That seems to work fine (by the way, does it matter that this is not precisely what Qt creator does? The qmake step there is qmake-qt4 myProject.pro -r -spec linux-g++ and the make step is make -w). Now, I assume there is a solution where I don't ask them to download and install something like 200Mo of Qt material. As for Microsoft Windows users, I don't have a clue.
I would be very grateful if you could explain to me in a very concrete way what I need to do. Needless to say, I'll go for the best and easiest solution, I don't need to understand everything about deployment. Many thanks in advance!
Edit: In case that's useful : I've been using Qt Creator 2.5.0 based on Qt 4.8.1 (64 bit), I'm working on a laptop with Ubuntu 12.04 64bits
For Linux and Mac users, I would compile the software for them in 32 and 64bit formats - no-one likes compiling unknown software from source. Obviously keep the source code option for those on more unusual architectures/OSs (and provide a shell script for them that mimics the commands Qt Creator calls!). As Qt runtimes are available from package managers on just about every distro (and come pre-installed on most anyway, KDE requires them for example), by not asking them to compile from source your users will have a much smaller download (if any) and won't require them to download software from a website potentially unknown to them. Of course the best way would be to try to get your software added as a package into the major distros' repositories, but that may take some time to organise.
Compile your software for Windows users for both 32 and 64bit formats. It's generally frowned upon to ask users to download runtime libraries they potentially don't know, and put them into their system32 folder... So most applications bundle all the libraries they need with their application. Qt-based applications are no different, and so put the runtimes into the folder where the executable is. Also it is much more professional to create a proper installer, there are a few free installer applications for Windows, a web search will give you the most popular (I think I saw a thread on SO about it as well).
As you can see the platforms aren't too dissimilar, the main point I would make is: Do not force people to compile from source! The vast majority of people on Earth do not even know what compiling is, so provide for the major arrchitectures/OSs yourself.

Is there a library for Visual C++ that renders math formulas?

I've been looking all over, but I can't find anything free that will let me simply display math formulas on a window. I found one for Visual C++.net, but no APIs. Are there any out there?
What format are the Math formulas in?
My first impulse would be to try and find a LaTeX library for C++ which will let you render out LaTeX to an image. That way you could display most basic formulas, but the formulas would have to be in the LaTeX format.
Try ReforMath (http://reformath.webnode.com). Runs under both Windows and Linux. It is unfinished though, but can render a number of elements.
What a great question! Yes, there is now: latexpp.
You'll have to install VS 2017 Community first with the minimal amount of C++ features checked (so it doesn't take all day).
Then you install Boost using the binary (try the latest).
But you still have to build boost. By using the VS > Tools > Visual Studio Command Prompt. CD to your boost directory and run .\bootstrap.bat, then .\bjam.exe. This will take all day.
Good news is it seems to be working so far on Windows 7, 64-bit with VS 2017 community and the latest boost 1.6.x.
The Latex library has other requirements, and I still haven't tried it but will post my notes here if any hickups.
Make sure all your directories are short, such as C:\VisualStudio2017. However, boost will then fail if you use your regular windows command prompt unless you do the vcvarsall.bat trick. The VS Command Prompt does that for you, so that boost can find your MSVC stuff. Boost would still probably fail if you used the default directory and didn't use the VS command prompt.
So, again, my boost is in C:\boost_{blah version} which you should shorten to C:\boost assuming you'll only use one version of boost.
One reason is that if you have to add the respective /bin directories to your system Path, then you won't fail by maxing out the length of Path value (yes, it has a max length). Also stuff is easy to find and especially from the command line so you can cd quickly there. If you don't want everything in C:\ then make a C:\__TOOLS or something short.
I will post my notes here when I've gotten LaTeX rendered.
Notes
When building boost with bjam, if it seemingly hangs for more than 10 mins on one item, then hit ctrl-C at the command line once. This seems to unhang it without canceling the install.
TODO

Resources