Author Archives: admin

Your first JavaFX app

Complete JavaFX installation

Before making a barebones JavaFX application under Clojure, you need to make sure the Lein program can find the appropriate jar files.  For this, we need to…

Install Maven

Maven is a java-based build system.  I really don’t know anything about it, except it uses a bunch of xml files.  Fortunately we won’t have to get into that here.

Download and install Maven from here.  Scroll down to the Windows installation instructions.  Basically you unzip the file, then set the M2_HOME and M2 environment variables to the directory where you installed it, and the bin/ directories, respectively, and add %M2% to your PATH.  Verify it works at the command line with
mvn --version.


Add javafxrt.jar to Maven repository

It appears Maven and therefore Lein operate on the idea of a repository, which can be remote or local.  In most circumstances when you set up your Clojure project you will point to some remote repository for Lein to get the latest .jars from.  However for JavaFX you need Lein to know that javafxrt.jar is on the local machine so it will automatically include that .jar file in your Clojure JavaFX projects.  Otherwise you’d probably have to manually monkey around with the CLASSPATH to get it to work.  You only have to run this Maven thing once.  After the initial set up, your Clojure JavaFX projects will just work.

Go to the command prompt and type this (example taken from here):

mvn install:install-file -Dfile="C:\Program Files\Java\jdk1.7.0_45\jre\lib\jfxrt.jar" -DartifactId=jfxrt -Dversion=1.7.0_45 -Dpackaging=jar

Of course this makes some assumptions about where your java installation is; modify the above command as necessary for your system.  After a bunch of messages and downloads it should give you some successful message:


Create Minimal JavaFX Clojure program

Go to your code directory (eg c:\users\Admin\code\clojure) and create a new lein project with:

lein new myproject

This creates a bunch of folders, an initial project.clj, and an initial src/myproject/core.clj which contains the barebones minimal clojure app.  Actually it’s not even sufficient because you can’t run it directly from the command line.  For that you have to add the :aot and :main options at the bottom of the project.clj file.  The :main tells Lein the namespace to use, and then within that namespace it looks for a function called -main.    So in other words you also need to modify the core.clj file so it has the -main function, which we’ll do next.  The :aot tells Lein to do ahead-of-time compiling.  This is necessary so you have the .class files already available at runtime, instead of compiling on the fly as Clojure would normally do.  This also enables you to compile the source from within an Emacs nrepl session.

Edit the project.clj file so it looks like this:

(defproject myproject "0.1.0-SNAPSHOT"
  :description "FIXME: write description"
  :url ""
  :license {:name "Eclipse Public License"
            :url ""}
  :dependencies [[org.clojure/clojure "1.5.1"]
                 [ "1.7.0_45"]]
  :aot :all
  :main myproject.core)

Then run lein deps. This somehow does some magic behind the scenes to pull in the dependencies you specify in project.clj.  You can find that the required jfxrt.jar file has been copied to c:\Users\Admin\.m2\repository\com\oracle\local\jfxrt\1.7.0_45\ .  I’m not sure if Maven put it there or if Lein put it there, and I’m not sure how Lein encodes the fact that myproject needs to use that .jar file.  In older versions of Lein it would copy the .jar files to a subdirectory of myproject, but I’m not sure what it does in the version I’m running now (lein version gives me 2.3.3) .

You can dive right into the repl based on this with lein repl .  This starts the application and gives you this:


You can test the default foo function with (foo "you there!").  This yields


You can also verify the jfxrt.jar file has been included in the classpath with this line I got from here.

(println (seq (.getURLs (java.lang.ClassLoader/getSystemClassLoader))))

Here it yields the following. Highlight shows the .jar file we care to include.


Type (quit) <enter> then edit the src/myproject/core.clj file by adding the highlighted lines.

(ns myproject.core)

(defn foo
  "I don't do a whole lot."
  (println x "Hello, World!"))

(defn -main []
  (foo "You there"))

Then go back and type lein run from the the myproject directory.  Actually it’ll work from anywhere within the myproject folder structure.


So basically we’ve recreated what an earlier post already had you do — just run a basic clojure program with Lein.  Except now we have the required jxfrt.jar file included in the classpath.

Let’s make the barebones app do something.  For that we need to edit the main file core.clj as follows.

(ns myproject.core
   :extends javafx.application.Application)
  (:import (javafx.application Application)
           (javafx.event ActionEvent EventHandler)
           (javafx.scene Scene)
           (javafx.scene.layout VBox)
           (javafx.scene.control Button)
           (javafx.stage Stage)))

;; This is required to start running from lein command line 'lein run'
(defn -main []
  ;; into-array function creates an empty String array which is passed to Application/launch
  (javafx.application.Application/launch myproject.core (into-array String [])))

(defn -start [this primaryStage]
  (let [btn (Button. "Hello World from JavaFX Clojure!")
        vbox (VBox.)
        scene (Scene. vbox)]
    (-> vbox (.getChildren) (.add btn))
    (.setOnAction btn
                  (proxy [EventHandler] []
                    (handle [ event]
                      (println "Button pressed!"))))
    (.setScene primaryStage scene)
    (.setTitle primaryStage "Hello JavaFX from Clojure")
    (.show primaryStage)))

(defn -stop [app]
  (println "Exiting now"))

Type lein run again at the command line and you’ll see the JavaFX window! Press the button a few times and the text appears on the console.
Congratulations on your first JavaFX app for Clojure 🙂

In the next post I’ll show a cool example from the Pro JavaFX 2 book translated to Clojure, and some macros to help reduce the repeated typing required in Java.

My Emacs init.el

I will join the hoards of Emacs people and put up my Emacs init.el file here.  This should be compatible with the tutorial I posted.  Even though I was first exposed to Emacs over 20 years ago, I didn’t really start using it until about last year.  So I truly still consider myself a newbie.  Everything I learned here is basically just recapping stuff I found online.  There is nothing original here.  My goal is to try to present something that would have helped me when I started out learning Clojure with Emacs.  This is cobbled together and modified from the main home (or github) page of each package, and here:—configure-emacs-for-clojure

Also, I apologize for the syntax highlighting. I’m not sure how to get elisp syntax highlighting to work in WordPress. I’m currently using SyntaxHighlighter Evolved V3.17.

;; Add Marmalade package archive for Emacs starter kit and other Emacs packages
;; This allows ALT-x package-list-packages to return a big list of useful packages
(require 'package)
(add-to-list 'package-archives
	     '("marmalade" . "") )

;; Add Clojure and other supporting packages to the Emacs environment
;; Packages are installed if they are not already present
;; The list includes packages for the starter kit, Clojure and markdown files (used by github)
;; This can be avoided if you have manually installed the packages eg via
;; ALT-x package-list-packages
(when (not package-archive-contents)

(defvar my-packages '(clojure-mode          ;; the major mode for clojure
		      clojure-test-mode     ;; not sure -- I still haven't learned how to write test code
		      paredit               ;; keeps parentheses balanced
		      nrepl                 ;; IDE and REPL for clojure
		      fuzzy                 ;; needed for nrepl
		      popup                 ;; popup tooltips
		      auto-complete         ;; used for ac-nrepl
		      ac-nrepl              ;; autocomplete for nrepl
		      eldoc                 ;; shows argument completion in the echo area for elisp
		      rainbow-delimiters    ;; colors parentheses, etc.
		      undo-tree             ;; undo/redo sanity restored
		      tabbar                ;; tabs at top of window
		      linum))               ;; Line numbers in the border

(dolist (p my-packages)
  (when (not (package-installed-p p))
    (package-install p)))

(add-hook 'nrepl-interaction-mode-hook 'nrepl-turn-on-eldoc-mode ) ;enables eldoc when in nrepl (not sure why this is needed)
(add-hook 'clojure-mode-hook           'turn-on-eldoc-mode)        ;enables eldoc when writing clojure (not sure why this is needed)
(add-hook 'emacs-lisp-mode-hook        'turn-on-eldoc-mode)        ;enables eldoc when writing elisp
(add-hook 'lisp-interaction-mode-hook  'turn-on-eldoc-mode)        ;enables eldoc for scratch buffer

;; Enable paredit mode for clojure, elisp, and nrepl
(add-hook 'clojure-mode-hook    'paredit-mode)
(add-hook 'emacs-lisp-mode-hook 'paredit-mode)
(add-hook 'nrepl-repl-mode-hook 'paredit-mode)

(require 'auto-complete-config)
(define-key ac-completing-map "M-/" 'ac-stop) ; use ALT-/ to stop completion

;; Enable ac-nrepl -- this looks like a mess and doesn't quite work right
;; Not sure how this relates to popup
(require 'auto-complete)
(require 'ac-nrepl)
(global-auto-complete-mode t)
(add-hook 'nrepl-mode-hook             'ac-nrepl-setup)
(add-hook 'nrepl-interaction-mode-hook 'ac-nrepl-setup)
(add-hook 'clojure-nrepl-mode-hook     'ac-nrepl-setup)
(eval-after-load "auto-complete" '(add-to-list 'ac-modes 'nrepl-mode))
;; This doesn't look like

;; colors nearest parentheses
(require 'highlight-parentheses)
(define-globalized-minor-mode global-highlight-parentheses-mode
  (lambda ()
    (highlight-parentheses-mode t)))
(global-highlight-parentheses-mode t)

;; enable rainbow delimiters
(require 'rainbow-delimiters)

;; These allow me to move cursor around using the keys that
;; are naturally under my right hand, while using Dvorak keyboard
(global-set-key (kbd "M-h") 'backward-char) ;; sets ALT-h to left arrow, replaces emacs mail help
(global-set-key (kbd "M-t") 'next-line)     ;; sets ALT-t to down arrow, replaces emacs transpose
(global-set-key (kbd "M-n") 'forward-char)  ;; sets ALT-n to right arrow, replaces down in minibuffer history
(global-set-key (kbd "M-c") 'previous-line) ;; sets ALT-c to up arrow, replaces nothing

;; buffer and tab management
(require 'tabbar)
(tabbar-mode 1) ;; shows tabs at the top
(global-set-key [C-tab]   'next-buffer)       ;; CTRL-tab goes to next buffer
(global-set-key [C-S-tab] 'previous-buffer) ;; CTRL-SHIFT-tab goes to previous buffer

;; Duplicate line function
;; From
(defun duplicate-line-or-region (&optional n)
  "Duplicate current line, or region if active.
With argument N, make N copies.
With negative N, comment out original line and use the absolute value."
  (interactive "*p")
  (let ((use-region (use-region-p)))
      (let ((text (if use-region        ;Get region if active, otherwise line
                      (buffer-substring (region-beginning) (region-end))
                    (prog1 (thing-at-point 'line)
                      (if (< 0 (forward-line 1)) ;Go to beginning of next line, or make a new one
        (dotimes (i (abs (or n 1)))     ;Insert N times, or once if not specified
          (insert text))))
    (if use-region nil                  ;Only if we're working with a line (not a region)
      (let ((pos (- (point) (line-beginning-position)))) ;Save column
        (if (> 0 n)                             ;Comment out original with negative arg
            (comment-region (line-beginning-position) (line-end-position)))
        (forward-line 1)
        (forward-char pos)))))
;; Set duplicate line to CTRL-c d
(global-set-key (kbd "C-c d") 'duplicate-line-or-region)

;; Other stuff
(electric-indent-mode 1)             ;; enables auto indentation
(show-paren-mode 1)                  ;; shows paren matching cursor location
(setq show-paren-delay 0)            ;; ... with zero delay
(global-linum-mode 1)                ;; shows line numbers
(column-number-mode 1)               ;; shows cursor row,col at bottom of window
(global-set-key (kbd "C-z") 'undo)   ;; Sets CTRL-z to undo
(global-set-key [f9] 'nrepl-jack-in) ;; Sets F9 to start nrepl
(setq inhibit-startup-message t)     ;; No splash screen
(setq initial-scratch-message nil)   ;; No scratch message
(load-theme 'solarized-dark t)       ;; Change colors
(setq solarized-contrast 'low)       ;; Change contrast


Setting up Emacs/Clojure environment for Windows

This particular set of steps is done using a freshly-installed version of 64-bit Windows 8.1.  The concepts are largely stolen from here, but I removed anything about really old versions of Windows.

Install Emacs

1. Download Emacs for Windows from the Big Page.  As of this writing (Oct 19, 2013), the current version is 24.3.  Yes, this is “precompiled”.  Why would I want anything else?  Yes I know, yada yada.  I’m more about the gratis than the libre.

2. Unzip it someplace and just keep the inner directory emacs-24.3.  In keeping with other Windows programs, you should put it in C:\Program Files (x86)\.  I’m guessing there is probably some risk in having spaces and stuff in the directory name.  I wouldn’t be surprised if Emacs had a problem with this under some condition, but it seems to work for me. So now your directory tree looks like this, minus the scribbles.


3. At this point you’re supposed to select a “home” where Emacs stores its config information, elisp code that gets downloaded, etc.  My recommendation is to leave your HOME variable undefined.  Normally this would involve setting the HOME environment variable to some directory, but in the absence of this, Emacs picks other locations based on what version of Windows you’re running.  It’s convoluted, so read here.  If you have some other program that defines a HOME variable (such as any of the Unix-based tools running on Windows), you are fucked.  Emacs will pick this location first because it exists and you will be stuck putting your .emacs (or init.el or whatever) file in that location.  I have not found a way to force Emacs to pick another location since HOME is the first place it checks.

Quick tip: In Emacs terminology CTRL-x or C-x means press the CTRL key and x at the same time.  The - is a dash not a minus, and the instruction would be the same if there were  a + as in normal computer text instructions, ie CTRL+x; however using the dash is typical for Emacs instructions so I’ll use it here.  If there is no dash in the instruction, then press the keys in sequence.  So CTRL-x k means press CTRL-x first, then press k.  In this case, this is the sequence to “kill” the buffer, ie close the file.  In this case, Emacs will prompt you at the bottom of the screen to check if you want to save any unsaved changes.

Quick tip: Don’t try using the menus and expect to find anything useful.  It’s the most convoluted piece of junk ever created.  I’ve only ever been able to open/close a file, save-as, and change fonts from there, and sometimes get a keystroke reminder for compiling stuff from the source buffer.  Everything else is complete nonsense if you are trying to use the menu to do normal editor stuff, or explore what’s out there.  Google is your friend for discovering Emacs.

Quick tip: if you are stuck in some Emacs state/mode and you can’t get out of it, press CTRL-G a bunch of times.  This is like pressing ESC in most modern applications, in that it will get you out of whatever thing you’re in and take you back to normal mode.  Pressing ESC usually works too, but this is an after-thought in Emacs history.  In Emacs terminology you will see “Meta-x” or M-x a lot.  This is historic, based on an ancient keyboard that had a “meta” key, and is completely irrelevant in this day and age.  This means “press ESC then press x“, or equivalently it can mean ALT-x, which is preferred.  So if you accidentally press ESC then some other key, you are inadvertently doing the same thing as pressing ALT-<that other key>.  So just press CTRL-G to quit out of whatever state you’re stuck in.

Quick tip: ALT-x is different from most of the other C-<whatever> key sequences.  ALT-x puts you in the little command buffer at the bottom of the screen.  From here you can tell Emacs to do stuff, such as start nrepl so you can live a live Clojure session from the editor (nrepl-jack-in), change how the line wrap works (toggle-truncate-lines), turn on paredit (paredit-mode), etc.  While in this state, you can use the normal Emacs cursor keys (C-f, C-b, C-e, C-k) and recall previous commands  (ALT-p).  You can quit/cancel the current command from here as described above, with C-g, or just complete the command with Enter.

Quick tip: You will be using the CTRL key a lot.  Best to remap your useless caps-lock key to be an additional CTRL key.  Here is the page.  Here is the zip file.  Open up the zip file and double click on ChangeCapsToControl.reg.  This probably needs a reboot to kick in.  Now your pinkie won’t be extra muscular by trying to reach down to the lower left all the time.

Quick tip: You can use the normal arrow keys, backspace, delete, mouse, etc., to edit in Emacs.  This was not always the case, but it’s pretty standard nowadays for modern users.  I tried once setting Emacs to use CUA keystrokes (common user accessibility), but this screws things up as all the other commands have to get rearranged; I don’t recommend this.  Just train your brain.  It doesn’t take long, and once you’re used to moving the cursor around and deleting stuff, compiling, changing buffers, windows, etc., without moving your hands, you’ll be annoyed at other editors for not having this functionality.  I have also switched to Dvorak layout and I find it extremely comfortable and easy to use; you may wish to do the same, although the Emacs keys become a little weirder in terms of the neuromuscular distortions you need to encode in your mind.  Now go out and try to make friends by telling them you write Clojure using Emacs with a Dvorak keyboard.  Observe the funny looks you get.  The requisite xkcd links are here and here.


4.  You can find which location emacs wants to use as its home by starting up emacs directly ("C:\Program Files (x86)\emacs-24.3\bin\runemacs.exe") and then typing CTRL-x d ~\  The CTRL-x d tells Emacs to open a directory.  The ~\ resets the search path back to what it thinks is the home directory.  Forward slash or backward slash doesn’t matter.  (Honestly I’m not sure what the differences are among runemacs.exe, emacs.exe, emacsw.exe, etc.  My fingers like to type emacs at the command line since that’s what I learned in college 100 years ago on Unix machines, but evidently on a Windows machine you’re supposed to use emacsw.exe or runemacs.exe.  Sometimes a client/server thing pops up too.)  At the bottom of the Emacs window you should see this:


Press Enter and you get something like this.  Yes I’m doing this as Admin, but do as I say and not as I do, and run all this stuff from a normal user account.


So in this case Emacs is using the c:/users/Admin/AppData/Roaming directory as the home directory.  This is just FYI; we won’t be using this view now.  Since this is a new install, you don’t have an init file yet.

5. Create a new init file in this home directory.  Traditionally this is called .emacs, but it can also be called .emacs.d/init.el, or other variants.  So type CTRL-x CTRL-f ~/.emacs.d/init.el, and you should see the following at the bottom of  the screen.


Press enter and you get the new blank file in the editing “buffer”.


Type C-x C-s to save the (blank) file.  You don’t actually need to release the CTRL key.  Verify its existence with C-x d Enter.  The correct directory should automatically populate in the little command line area.  If not, add ~/ before pressing enter.


Emacs junks up your directory with #init.el# and init.el~ .  These are backups. 5.  Add the following to your init.el file, then restart Emacs or type ALT-x eval-buffer (From the gitub site)

(require 'package)
 (add-to-list 'package-archives
 '("marmalade" . ""))

5. Start downloading stuff for Clojure mode support.  Type ALT-x package-list-packages  For long commands like this you can press TAB in the middle and it’ll complete, or show you a list of possible completions in the little command line area.  You get a list of packages to download. Use the arrow keys and i to select packages for install, then x to install them.  You can search for a packages with CTRL-s <package name>, then CTRL-s repeatedly to search again.  Select the following: clojure-mode, cljdoc, ac-nrepl, nrepl, paredit. After downloading, you can see these packages in the ~/.emacs.d/elpa directory.  Elpa is the emacs library system.  I really don’t know anything more than that.


6.  At this point emacs will do syntax highlighting on clojure files and probably other stuff based on the above stuff you downloaded.  Create a file called junk.clj  by typing C-f c:\users\Admin\code\junk.clj  (it will give you instructions on creating the code directory) and put in the following:

(println "hi")

This should result in coloring like this:


Install Java

6.  Download and install the JDK and add the bin directory to your path.  As of this writing the JDK version is 7u45.  Actually the installation by itself adds java.exe and some other executables to your Windows/System32 directory, so strictly speaking I don’t think you need to change your path.  However at some point you’ll want javac.exe and other developer stuff which is not in Windows/System32, so best to just get it over with.  I’m guessing that Lein and some of  the Emacs support for Clojure will also want a real home location for Java.

On an unadulterated Windows 8 machine, changing the path is done through the search in the main tile page.  Press the Windows key WindowsKey to bring up the start page (or CTRL+ESC), then just start typing “environment” and the selection will pop up, then select it.  In reality I skip this altogether as I have installed StartIsBack which returns sanity back to the Windows 8 user experience.  Make sure to select “Edit the system environmentvariables” not “Edit environment variables for your account”.


Click Environment Variables, then double click path in System Variables, and edit in the box:

environmentchange pathchange

You’ll probably also want to set up JAVA_HOME, which is done in a similar manner.


Verify the new Java installation works:


Install Lein

7.  Install Lein by downloading lein.bat and placing it in c:\Program Files (x86)\Leiningen, and adding this location to your path.


Then open up a command prompt and run lein self-install.


8. Create a new project with Lein.  Change to your code directory and create a Clojure project with lein new temp_project. leinnew

9.  Update the project so it knows the namespace.  Change to the project directory and open the project.clj file.  Be sure to use tab completion so it doesn’t hurt your brain.  You can of course just start up emacs with the mouse and open the file that way (C-x C-f c:\users\admin\code\clojure\temp_project\project.clj).  And of course I’d recommend putting the emacs bin directory in your path so you can call it up immediately from the command line.



Add a single line to the bottom of project.clj, then C-x C-s to save it.  Notice there is a dash, not an underscore, in the namespace.  This matches the namespace in the source file.

(defproject temp_project "0.1.0-SNAPSHOT"
 :description "FIXME: write description"
 :url ""
 :license {:name "Eclipse Public License"
 :url ""}
 :dependencies [[org.clojure/clojure "1.5.1"]]
 :main temp-project.core)

10.  Update the source file so it has a -main function.  Open up the test file left by Lein:  C-x C-f src/temp_project/core.clj


Add the following highlighted function definition, then C-x C-s to save.

(ns temp-project.core)
(defn foo
 "I don't do a whole lot."
 (println x "Hello, World!"))

(defn -main []
 (foo 3.14159))

11. Run the program from the command line. Change to the project directory (doesn’t matter how deep in the directory tree) and say lein run.

Use Emacs to run Clojure

12. Now that Lein works, open up the source file again in Emacs.  C-x C-f c:/Users/Admin/code/clojure/temp_project/src/temp_project/core.clj

13.  Start up nrepl with ALT-x nrepl-jack-in (again use tab-completion).  Remember the M-x shown below is Emacs’ interpretation of  ALT-x for modern users.


This will open up a new window with the REPL.


14.  Compile the source code.  Change window focus back to the source code by clicking in the source window (or press C-x o) so the bottom of the source window is dark gray, then compile everything with C-c C-k.  This gives you something like this.  Press y.


Then you get something like


15. Press C-c C-z to jump back to the REPL (you could also do C-x o.  The former takes you to the REPL from any window; the latter only jumps to the “next” window, which works when you only have 2 windows open).  Your program is now “in” the REPL, ie the functions have been compiled and are ready to run, except they’re stored in the temp-project.core namespace.

16.  Change to the correct namespace with (in-ns 'temp-project.core).  You can use tab completion with this too.  Then run the main function with (-main):


17.  You can of course run the other function too, with (foo 2.781828) or (foo "You Jerk!").



You have just completed what took me a few weeks of hard labor to figure out.  I obviously didn’t invent this stuff, but I haven’t really seen a direct step by step procedure yet on how to do this; I’ve only found little bits and pieces around the web.  There is a ton more to do.  Specifically, I haven’t set up the Emacs init.el file.  This is almost like getting a PhD in itself.  Since I recently wiped my computer without saving the file, I have to create it again from scratch, so that will take some time.  But in general, I like to enable all the fancy editing features for lisp, specifically paredit mode, enabling the auto documentation for both the editor window and the REPL, changing front and color size, getting rid of the stupid splash screen that comes up, and some other stuff I came across which actually involved some elisp in the init.el file.  Kind of annoying, but it makes the overall usage a little better.

In a future post I will show a simple JavaFX app.

Emacs rant before the tutorial

I originally started in Clojure using JetBrains’ IntelliJ IDEA IDE with the clojure plugins.  This was great for a few hello-world types of programs, but I felt I was missing out after reading what you could do with Emacs.  For example in IDEA I could start a REPL, but I couldn’t figure out how to compile and run stuff from the editor in the REPL, thus keeping a live running version of all my functions and variables.  I didn’t see how to get the IDE to format and manipulate  the parentheses correctly a la Paredit, etc.  There are probably ways to do this, but I didn’t take the time to figure it out, and there wasn’t much documentation available.

I realize now after having “really” used Emacs for some time that Emacs really is (currently) the best tool for lispy programs.  I could easily imagine a more modern GUI/IDE that maintains the lispy support of Emacs, but brings the tool up to the modern era. My first experiences with Emacs were in undergrad (’92-’96), and I hated it.  In fact, in the intervening ~20 years, each and every single time I ventured into Emacs for one reason or another, I really just couldn’t stand the backwards way it did everything, from nomenclature, to discoverability, to the sheer bone-headedness of the concepts involved, when compared to a modern “normal” text editor.

The smug, bearded-birkenstocked-guru “self-documenting” DNA present in Emacs is such a huge turn off that I almost want to vomit.  In fact I have never found anything “self documenting” about it; my best sources for Emacs documentation are Google and StackOverflow. As to functionality, my biggest issues were the logical-vs-physical line breaks, line numbering, text wrapping, etc.  For instance, Yes I get that you can have a hard line break, but when I hit the CTRL-N key, I really just want to move the cursor physically down one line on the screen, not logically down one line, which could be multiple physical lines, for example for a long paragraph.  Oh, wait… what?  I’m typing text? not code?  Oooh, I”m sorry sir (“brother”), you have to change modes.  Major mode?  Minor mode?  Not sure, don’t care.  I really don’t have time for this, but evidently I’m a moron for not figuring it out, and I’m a Windows fanboy if I decide I just want a normal editor with equal accessibility between mouse and keyboard ways of doing things and simple menus for choosing word wrap options.  FWIW, my favorite “normal” text editor is EditPlus.

Finally I always hated how Emacs’ “customizability” meant that there are a dozen ways to do any given thing so everyone’s always trying to send you their .emacs file which you then have to decipher and figure out what parts from it you want to use and whether what they’re doing is compatible with what you’re already doing, and to make emacs usable you really have to set it up first, rather than it just working out of the box.  For example, there have been a handful of line-numbering add-ons… really?  Every other text editor has this built-in, and  and it appears that proper line numbering (with the line numbers in the left margin) didn’t work properly until some very recent version.  I’m not an expert at all; I don’t know Emacs version numbers.  I know there are a lot of them.  This is my point of view as a user from the 21st century, not an Emacs hacker or evangelist; I have better things to waste my time on.

Anyway, now that I’ve been using Emacs for Clojure, and I finally have it setup somewhat customized, it’s not too bad.  I can navigate quite quickly within a file, compile code under the cursor, jump to the REPL, and manipulate parentheses like nobody’s business.  It’s still not as nice for some of the intelligent (ie context-sensitive or type-aware)  help you get with IDEA or Visual Studio, but I suspect this is more about the dynamic typing of Clojure vs. the statically typed languages one normally sees with IDEA (Java) or Visual Studio (C#), than about Emacs itself necessarily or the inline help that is somewhat available.

Currently I have found absolutely zero help with step-by-step debugging.  Yes there are macro tricks and libraries available, but to me it  just adds more noise to my brain.  Actually the best debugging I’ve found for lispy programs has been in PLT Scheme’s IDE, as it has a way of displaying the results of each s-exp as you step through, but I’m pretty sure this has as much to do with Clojure’s current state of development as with Emacs’ support for graphical debugging (both pretty much nonexistent).  Debugging Clojure from IDEA sorta worked, in that I could step through a program, but it would always step me through the Java source, which, while mildly entertaining, is completely useless for actually debugging a Clojure program.  This was my experience with CDT also.  I would like to see something like PLT’s method (which is similar to debugging cells in Excel), where each expression is replaced by its result as you step through.

Anyway, on to the tutorial.

(defn start-blog []…)

Hi, I’m starting this blog after thinking for a while that I need a place to put my thoughts out there and see what comes back.  Primarily this will be a place where I log my various computer or engineering projects, both to share with whomever is willing to read as well as to get feedback from interested parties.  The main efforts here will focus on developing a full-fledged electronic design automation (EDA) tool (aka CAD, ECAD, etc.) using Clojure as the primary language and JavaFX 2.x as the GUI framework.

Initially I’ll be adding some stuff about the Clojure language, specifically as it relates to JavaFX 2.0 and creating all – or portions of – a modern desktop app.  I’ve been interested in GUIs for a while, but I’ve never really dug into creating a full-fledged “real” desktop application.  I have various amounts of experience over the last 15 years in (in no particular order): Clojure, Scheme, Java, Python, SciPy, C/C++/C#, wxWidgets, Matlab, Octave, etc.  I’m a bit of a luddite when it comes to webbish or java-heavy technologies like Ruby, PHP, Perl, ASP, Github, Maven, Eclipse, etc.

Critical to any success is relying on the contributions of others on the internet, so while I will undoubtedly reference others’ contributions, I find that I’m doing stuff I haven’t found online and will share these things as they come.  Basically  I want to share the stuff I wish I’d found and enable others the same joy I’ve had in combining functional programming with GUI creation.

I have a background in electrical engineering and hardware design and have used a variety of EE/cad tools — a few different flavors of SPICE, Orcad, Altium, Tanner, and several of the Cadence and Mentor tools, going all the way back to Viewdraw in 1994, my first university-supported tool in some 200-level digital design course.  While using these tools I’ve often had a running list of gripes and complaints, with everything from license managers (ie LMTools and nickel-and-diming the user down to little things like PDF export) to sweeping notions of design flow and *how* you approach creativity and forcing the user to maintain implementation details in their heads while also trying to think about the project at hand (ie multiple files and multiple tools for each little thing aka Unix style, having to think about different file formats, or single binaries and unified application, or having to “export a netlist” or “compile” the design), to minor nuisance  things like not being able to right-click-copy something out of a text field, or making the distinction between open/save and import/export.  I have not extensively used any of the hobby-ish (or low-cost professional) tools such as Eagle, PCBExpress, or Kicad, but I hope to get into these and see what I can learn and how i can improve on them, and take the good ideas which do in fact exist out there.

The desire to create my own this EDA tool is driven by a very deep and profound hatred for the big tool suites, their licensing schemes, their boneheaded way of approaching the user interaction/user interface, and just the overall feeling that these tools are > 20 years old with patch after patch of false functionality and marketing hype, and the fact that most users are so locked into their junk that there really is no incentive to improve on the user experience.  I want a tool that is *fun* to use, that provides satisfaction when you click on something, rather than frustration and “surprise” at each and every little dialog.  I want something that “just works” with the same level of intuitiveness as some of the smaller shareware utilities out there.  Clearly EDA is a big concept, and there is necessary complexity, but from what I’ve seen, specific implementations of EDA involve a lot of unnecessary or incidental complexity for what I assume are probably legitimate original reasons.

Anyway, this is enough for a first post.  I need to figure out how to get syntax highlighting working, figure out how to use github, post files, publish java webstart stuff, etc. etc.  This is a long project.