Friday, April 1, 2016

Boy do I love working with Lisp

And in the strangest turn of events, working with Lisp and Java together has turned out to be...

A Lot of Fun

Who knew?  Actually... Guy Steele does.  He probably keeps hoping a lot of somebodies keep finding ways to put his chocolate (Lisp) with his peanut butter (Java) and make something awesome.

If I can keep chugging away on this Lisp implementation, which is starting to take shape and look interesting, I might have something to share when it's my turn to present:

What I Did This Summer...

Well... let me tell you, my summer was awesome.  But this one thing with Lisp & Java was really cool.  It all started with a thought experiment.  I was wondering, "What would happen if I wrote this piece of my calculator program so I could make it look and work like Lisp."

Wow. I sound like a nerd. :-)

Thursday, March 24, 2016

Reader Update and Other Stuff

I reworked the reader code in my Lisp.  It's complete in that it's handling all the required cases for a commercial Lisp now.  I'm putting in the details for each case and building the test cases to ensure each type of Lisp symbol is parsed right.

Getting into the heart of the language is fun.  Understanding how it all fits together and why certain decisions were made and how things work is worth the frustration of learning.  Now that the reader is getting solidified, it'll give me a sense of how to modify eval, get the last core routines written in Java, and start thinking about the core Lisp code written in Lisp.

After that?  I've been looking at m-expressions, or the idea of m-expressions.  I think there's some kind of...something... that can live in between something and something else and make it easier to code Lisp in a way that expands the language.

One other thing I've been squeezing my brain over is R&D on an idea to build interfaces.  I think it's the first stable starting point to being constructing some of the concepts I've been kicking around over the years.  It looks like, as the idea grows, it'll be possible to start carving in the idea I've had for packages and an oop concept I was considering a long time ago while creating interfaces quickly. Some kind of interfaces. I never know how things are going to turn out, but this project is the most stable R&D I've done in a while, so I'm hopeful I won't paint myself into a corner.

Thursday, March 17, 2016

Now with More Pinhead & Less Sleep

I've been revisiting this Lisp implementation that hatched last year.  It's still rough, but it's not so rough.  Moving it into a Java development environment is going to turn out to be a smart move.  Whoever came up with that idea and the brilliant idea to move it all to NetBeans?  They deserve a pat on the back, because code turnaround is significantly faster and the frustration level has vaporized.

I was brain-locked about what to do because I'd tried but failed miserably to move the code to Eclipse.  I know it was user-error, but Eclipse really helped a lot by tripping me up and pinning me down every time I tried to simply move the code in.  It's just a relief to be working at a faster clip and in a stable world.  Android is cool and all, but waiting for code to launch is agonizing.

It took a while to get my head back into the implementation, but now that I'm there, it's starting to feel good.  I've been putting the code in place for normal packages and adding parsing code to the reader.  It's been really fun considering how to put the editor on top of it along with some of the other useful utilities that come with Lisp, like documentation and trace and such.  One of my primary goals is to start working out the details of actually implementing my package idea.  I also have some conceptual ideas for some OOP-related modifications for method dispatch that will have to find their way into the mosh pit so they can either become something or be shelved.

For now, I'm cleaning up some redundancy and building a project plan with the initial goal being to implement the Java code that comprises the core of Lisp.  I'm pretty sure I have about 10 more functions to write to make that a reality.  Once there, it's Lisp and turtles and test-cases (300 so far) and bug fixes all the way down.  If I can add even a rudimentary editor that has tools that enable some quick text gyrations?  Maybe it'll all have some kind of probabilistic chance greater than 0.00000000001 to turn into a usable program for someone other than yours truly.

Wednesday, March 16, 2016

I'm Such a Pinhead (and my own worst critic)

I've been working on a Lisp that's built as a native Java app with a layer on top for Android.  Fine.  It's all fine.  It's all fine and going a bit slow and that's okay.  At least I thought it was.  Until last night, when I realized it wasn't fine and was taking too long and going too slow and I started freaking out so I looked for solutions.

Having been around the block (and around and around and around), I knew I had to step away from building it on Android.  Old computer, old tablet, bad cable, (some any all) was all it takes to slow things down.  It's Lisp, it should be fast.

Problem one, I can't plain old Java on Android Studio.  I can Android Java on Android Studio, but not regular old Java.  At least that's what I believe in my tired, confused, Android Studio brain.  So I decided I had to look elsewhere.

Was considering a saunter back into Emacs, but the thought of getting tempted to do anything in Emacs Lisp had me repulsed like magnetic polarity.  Emacs Lisp and all that politics is what frustrated me into Common Lisp and I've never returned since 1997.

In looking desperately for a solution, I arrived at the awareness that I've given up on Eclipse.  Every time I tried to import, export, build, or do anything that resembled work in it, I never knew where to look to see what happened.  Or it didn't know where to look to find anything.  It was like two old people trying to find a pair of shoes, coat and glasses and neither one knew what day it was.  Not that the day would matter, it's just meant to highlight the disconnect between knowing what you're supposed to be doing and how you ended up here forgetting what you were supposed to be doing but not really caring.

Because Matlock, that's why.

I had NetBeans installed on my computer from a million years ago, but it looked like it was somebody's Junior High School editor project and WITH REALLY BIG FONTS so I never opened it again.  But while Emacs and some editor I was loathe to use was downloading, I fired the Jr. HS project up, moved my Lisp code in and in a couple of hours of minor tweaks, had the Lisp repl up and running.

I was chameleon eyeing Guy Steele's Common Lisp book somewhat simultaneously, trying not to let my heart sink at the recognition of the mountain of work building a real Lisp is while wanting to cry at it and the notion of building it in a JHS editor project, or finding an editor that worked, because I gave up on making Hemlock work on Ubuntu, because Wire hoarks up a hairball and some other error I can't remember but lacked the knowledge and/or patience to dig into kept arriving with every five keystrokes demanding I drop into the repl and type 5 and (ed) each and every time (but now in the fog of my mind I seem to recall it's a configuration problem, but I still can't figure out the wire problem but none of this ever happened on FreeBSD, so I hate Ubuntu, but need it for Android development.)

And while looking at the configurations and my target build and my desire to just create a program that showed either my insane stupidity or possibly not so stupid maybe almost cleverness, I felt like I was surrounded by a pile of Ikea furniture boxes that were all missing parts and screws and had one set of pictorial instructions and text written in Mandarin and I just wanted to build something to show my stupid kid that I was somehow a capable dad and we could have a table, or sofa, or he could have a bunk bed where the bed didn't hang through the hole where the bed was supposed to be supported, but the part had to be here somewhere, let me just check the directions but it wasn't and I couldn't read it and I just wanted to curl up in a ball in the corner and rock myself into a state of mild discomfort while sobbing uncontrollably at the impending downfall of earth at the hands of people who think murder is somehow a solution to any problem at all.

For a bunch of engineers, we really can't build shit that's very good, stable, or easy.  What the fuck is up with that?  I feel like I'm running a gauntlet of demonic proportion that's a constant beat-down in my very precious mind.  And Apple is building military-level encrypted devices in Communist China that law enforcement in the USA can't open and I'm not supposed to be wondering how it is we think we're smart, capable, or even very good and the first amendment and the Constitution AND us aren't seriously under attack?  These systems are a tragic mess that we somehow organize just enough to be able to get our work done and forget how hard and stupid configuration and where it all is is...at... and we are.  What happened to us and that sentence?  I have an excuse because of my high school diploma, but all the education you smart people have... what is it for if not making things easy to use and understand?

Software is a train wreck.  Except for Quicklisp.

Whatever, this is all so stupid I wish I'd followed that cute lady Irene into dentistry and a lifetime of vacations and helping the poor and chasing her on the powder slopes of Utah and Colorado and I can't even see what I'm typing, my retinas are both burning from the radiation and flooded with tears.  How'd it all go so wrong?  Freedom isn't some abstract concept, it's only available here in the USA, and in small doses at that unless we all work together to make it grow to make really big freedom.  If we understood the import, we'd never let anybody or anything separate us free people from our freedoms with name-calling.

Sigh, where was I?  Cars are easy.  Computers are stupid-hard.  But I digress.

Whatever.  Fine.  Whatever!  The point?  The point is, JHS NetBeans worked like a pro.  The editor is almost crisp.  It'd be way more fun if it was Hemlock and I could start hacking Lisp to make it bend to my (very tired) will.  But compared to all the other crap I've had to do to get a Java program built, configured, and whatever else one does with Java, it was almost pleasant.  I was surprised.  I'd say pleasantly, but there's nothing pleasant about crying with burning retinas at the recognition of lost Irene and all that lost time building software that mostly doesn't totally suck because I have to squint to make it look good.

Now that I have a second build, I can start making the cross-platform code and the interfaces, so the Lisp and the UI can ship on anything Java.  Hopefully.  Maybe.  If the configurations and builds and jar files and calls aren't tied to some stupid idea of write once run anywhere that doesn't run everywhere.

The first and very noticeable thing was that the code turnaround is going to be insanely fast compared to Android Studio, which goes into a deep trance during builds, like a Google Guru, and returns with great insight that sounds like, "Gradle Build completed in 3 minutes and 47 seconds".  WTF?  WTF?  WTF?!  Java.  Half-way to Lisp from C++...  The equation is not commutative.  Halfway back to C++?  Might as well be halfway to Hell.  And halfway to Hell is way too far inside the gates of Hell (and a trip back to code generation circa 1995) for anybody who's ever had their code loaded into the repl and tested in the time it takes to type it and press a key on a mechanical keyboard.

Does this rant make my ass look fat?  I can never tell.

Coffee is my only friend.  And Lisp.  And they're all I need.

Now if you'll excuse me, I'm old and very tired and need a nap.

Tuesday, March 15, 2016

Ahh, Lisp

Spending some time today working on my Lisp implementation while reading Common Lisp by Guy Steele in combination with Ansi Common Lisp by Paul Graham.  Been writing a website for a while that is Lisp-based and SQL-backed and it's a nice change to step out of Java and into Lisp, and then back into Java to write Lisp.

I've been putting the Lisp implementation off because all the other stuff (Android) takes so much longer to put together and I keep thinking it's going to be difficult to get back into and find the narrative thread, as it were.  But it's been a pleasant surprise to remember how stable the language is to build, how fast the features come together, and how easy and quick it is to debug.

My short-term goal is to get what's written into my calculator, so it becomes possible to program math functions in Lisp.  Then, I'll start extending the application into something even more fun and interesting.  Sometime soon-after the programmable calculator, I'm going to test my implementation of packages.  It's taken me forever to get to the place where I can start plugging that code in.  It's kind of intricate, but I think it has merit.

Thursday, February 25, 2016

Just Ramblin' On

I've been juggling projects the last few days.  Aside from the two Android products I'm alternating between, there are (currently) two lisp projects.  The first is the Android Lisp I started a while ago and the second is a website I prototyped years ago for real estate that's finally getting some attention.  The website will also be a web-app or Android app and merge with the commercial app I wrote (with the circa 1995 manual-data-entry-UI.)  Maybe.  Hopefully.  Probably.

I'd like to be building iPhone apps, too, but I'm not there yet.  Maybe once I get organized enough to find a volunteer intern willing to work for experience, future possible stock options, and coffee.  One day.  Sooner rather than later would be great.

You know you're using Lisp "old-school" when you spend an hour or so writing some code, then you turn it loose on a computer and it runs forever.  I had a friend in the early 90's who was fond of saying, "Lisp is one of the best ways to abuse a computer."  He'd often describe writing small chunks of Lisp or Scheme code that would take minutes to write and hours or days to process as they brought computers and networks to a grinding halt.  Different times.  My scripts have been running for a while now and they're definitely pushing my tired old laptop into an overheated frenzy.  It's strangely gratifying, though I tend to prefer working on interfaces over large datasets, but haven't really minded either way.  It's all problem-solving.

In an effort to do something that wasn't programming, I started referring stuff on my backup Twitter account.  Mostly books for starters, but I'll probably expand into other areas.  Will be using it as an alternative to a website or blog until I get some of the software I'm working on into more doneness simply because it's quick and meaningful, though concise.  My first recommendation is a bit of nostalgia, mixed with practicality - a book I've owned forever (bought at Borders at the WTC in NYC somewhere around '97) & I still refer to often: ANSI Common Lisp by Paul Graham.  I've always appreciated how concise and approachable the book is.

Now it's back to juggling projects.  I just uploaded an apk for DangAlarm!, my Android alarm clock.  And the data to the database for the website is finally in and now I have to remember how SQL works so I can start putting a couple of web interfaces on top of it using Lisp.  I'm pretty sure things started as one website, but once I have the queries and views built, it'll probably morph into at least two.  Will share more detail soon.

Monday, February 22, 2016

Lisp as a Scripting Language

My first car was an old '59 Ford pickup truck I bought back in high school.  It had been a three-generation truck, owned by a grandfather, father, and then the son.  But it'd been in an accident and they didn't want to repair it.  I bought it for all the money I had; $300.  It wasn't pretty to look at, but that truck was solid.  It ran like a top, had hydraulic assist brakes, granny first gear, and I could fix most anything in a pinch, even on the side of the road.  If I'd been less of a disaster at that age, I'd have done the work to make it look good again.

I'm not sure what it has to do with Lisp.  I think I'm just adding copy to take up space.

I wrote some Lisp code today.  It wasn't much, just a little script to do a little work and generate some Java classes.  I could have used any scripting language, but having a body of work ready to leverage makes Lisp the easy candidate.  That I can return to the code later and understand it just adds to the allure of Lisp.  In the end, it saved me a lot of time to have Lisp write the classes for me.  Especially since the alternative in Android Studio is mind-numbingly slow and manually intensive.

That's all I got.  Maybe more soon.  I might be building a website in Lisp this week.  It'll likely freak me out to spend a whole day in Lisp.  I'll be sure to post something more interesting if/when that actually happens.

Monday, February 8, 2016

This Old Android Colors App

I wrote an app last year.  It was written in Common Lisp.  It generated colors and selectors for an Android app.  It had an interface.  It kept colors related by degree.  It worked.  I put it away.  I forgot about it.

I can't imagine how Hemingway wrote in such short sentences.  It makes me nuts to feel all constrained by a single thought and not be able to use a conjunction to extend a thought to something maybe meaningful like...

I forgot what I was saying.  Then again, Hemingway wrote amazing books which have withstood the tests of time and I write marginal software and blog posts (also likely marginal.)

The point, the point... what is the point?  I wrote a color app for Android last year.  I wanted to make buttons with stroke and fill colors and lots of them.  But being a total color spaz, I wanted them to look like they had some kind of relation other than "lots of them".  Because we all know from emacs, hmm, editors in general, that lots of colors ends up looking not brown, like in art and oil painting or pastels, but like three vibrantly colored meals suddenly evacuated from... well, you get the point.

So I wrote an app in Lisp to see if I could write an app in Lisp that might help me work with colors while making said colors look visually appealing.  It worked.  Pretty much.  I used well-defined color relationships to create the color relationships.  I think I should have to find a way to put it on the web.  Because I think other people might want to generate the same thing I did, only for their own super-cool apps.  Not that it's the only app like it or that my apps are any great shakes (yet.)  But it's good to have choice and maybe it could be something somebody might want to use.  Maybe.  I never know what anybody wants anymore.

The app allowed for a variable number of controls, a stroke color and a fill color.  Each could be defined by color relations and then the degree/intensity could be modified:

  • analogous
  • triadic
  • split-complement
  • complementary
  • lightness

There might have been some other color relationship thing in there, like monochromatic.  It was a decent prototype, so I think as soon as I finish this calculator, I'll add it to the short list of projects to get done, because web projects in Lisp aren't difficult.  At least I don't remember them being difficult.

Not that I'm writing a teaser or anything.  I find if I don't write a note about it for public consumption, I forget about it.  Like I did last year whenever it was I wrote this app and forgot to write a blog post about it.


The fact that the app generated something like 200 color specifiers (I'd said 1500 earlier because that was the last index on the generated colors, but went back after thinking about it and calculating how many unique colors it would have created) and scads of other detail is what has me thinking it might be useful.  I think that's why I built it in the first place; I wanted colors, but I didn't have ten years to generate all the xml by hand, and if I was going to do all the xml by hand, because I wanted colors, I knew I was going to end up with black, white, and charcoal grey and a lot of impatience at that.  And my inner artist wanted something less Seattle winter and more Seattle spring.  I'm from Seattle.  If you've been, you know why coffee is big, winters are depressing, and spring is like waking from darkness into lots of fresh berries everywhere and colors that leave you blinking as you wonder where all the amazing colors came from.  Spring is an amazing season, but spring in Seattle is pretty nice, though it's been twenty years since I've visited.

I wax poetic sometimes.  But I can't write like anybody else.  Except I used to channel my inner Hunter S. Thompson a long time ago.  But that's a story for another time.

Friday, February 5, 2016

I Started with Nothing, and I Still Have a Whole Lot of It, But Look at All the Words!

I never know what I'm going to write here until I start writing.  I'm close to finishing an Android project.  Once that's done, it's back to some kind of Lisp.

I just put out a teaser on my Products blog about an upcoming product I'm going to be working on.  I'm currently a day or so away from releasing an upgrade to a calculator I wrote for Android.  I'm thinking that after that, I'm going to work on another calculator, but something that might have a programmable feel to it.  Something that makes use of this Common Lisp engine I spontaneously erupted into last year.

I still don't know what came over me, but in something like 3-5 weeks, I had a working Common Lisp repl going that did a surprising amount of stuff.  I think I need ten or fifteen more core functions in Java, then I can jump into writing Lisp code on top of it, though I have a bunch of Lisp functions already defined.  Then I can try this experimental package system I've got running around in my head and wow, look at me, I'm all running off at the mouth like an excitable teenager.

The thing I remember about working on that Lisp, was that it wasn't like Android, or really anything else.  Where Android requires groveling over docs, trial and error, figuring, head-scratching, and laps over certain areas of the program, the Lisp engine went like this:  Oh no, a bug!  Where is it?  It's right there.  What is it doing?  It needs a cons or an atom or both.  That's it?  Let me fix it.  Fixed!  Let me test it.  It works!

I'm kind of doing it tongue-in-cheek, but it really was a lot like - logic.  Strange that would be missing in other engineering languages (I'm kidding, a little.)  At first I remember freaking out when there was a bug in read or eval.  Then, I fixed them and they... were fixed... and never came back.  Then a function would break and I'd get stressed but then I noticed the fixes started looking logical and stable and, once fixed, they never broke again and there was test code that built up along with the system and everything ran and if it didn't, nothing broke and it was easy to fix.  I think mapcar tripped me up for a little while, but it was like a couple of hours.

It was weird because I could feel the system growing and at the same time gaining in stability over time.  Unlike the Java syndrome, where things suddenly explode and you're left slogging through a stack trace that's 99% spew and one hyperlink to a null variable, the Lisp code just worked or it returned null and it's not supposed to and it's a small function and not much of a fix.

It was like Programming Nirvana.

It was like a dream last summer that just kind of happened out of a little experiment inside of another program I was working where I wondered how it would look like if I built a data structure that looked like maybe how Lisp would do it, and then I eyeballed Peter Norvig's Python code squinty-eyed like until I went, "Oh, that's what it's doing!" and that showed how a reader worked, and then I thoroughly abused the Java type system, and it was all so fun, even if it was only interpreted for starters.  I think it was the most fun I'd had programming almost anything because it was totally fast and fun and I'm pretty sure my smile grew with each new thing that was added and that doesn't happen often, except in Lisp because I could try it two or three or ten different ways until I got it right and it was satisfying.  Not slogging.

There's some tools that need to get put into it, error handling, and some core functionality that needs to be expanded on, and the package system either has to be the Lisp package system, which is mostly there, or the one I've been wanting to plug in and try out with some sort of Frankeninterface on top of it that might be cool... or just weird.  But it's R&D and it's fun to try things out and play like it's clay except with bits and ideas and how does it work like this, or that, or this other way... not getting all worn out just doing it one way then being too tired and knowing there's nowhere near enough time to even try to do it another way.

Even if it is interpreted, it's Lisp and it's fun and maybe if it can be exposed even a little bit inside of a programmable calculator on Android for starters, it might be fun for others, too.  Maybe?

Monday, January 25, 2016

A Lisp Mind, Trapped in a Java World

You know how it is.  Slogging names like SomethingReallyLongWithItsTypeAtTheEndDialog.  Groveling through docs endlessly while trying to remember how to make the widget work right, but the names and the choices are so similar, you have to try a bunch of them before figuring out the right one, which might turn out to be the wrong one for some configuration or target system, but the docs are so light and confusing, they don't tell you that, you have to find out for yourself while the pressures of life squeeze like a vice and HURRY UP AND SHIP IT is all anybody ever says to you along with I THOUGHT YOU WERE DONE?!  Madness.  As if that's not enough, endlessly waiting for the build to finish and launch before you can agonize over the slow-motion rumblings of a debugger spitting out insane volumes of meaningless crap for an indication of what really went wrong that got set to null for you to find like buried treasure somewhere up there after scrolling around.  Again.  And again.

I wrestled with a simple math problem in Java for a while yesterday.  For far longer than it should have taken.  I was progressively more sure my brain injury was slowing me down.  Or I did think it, because I couldn't believe I couldn't solve a simple trigonometry problem involving a handful of variables.  I spun over it in Java, editing, thinking, compiling, waiting, building, testing as time flew by.  I started thinking I needed to get out of programming and accept I was old, broken, and rapidly losing intelligence and vitality.  I paced the room waving my hands as each held variables and my mind creaked and groaned under the strain and I felt the desire to overcome a simple problem rapidly diminishing.  I never quit, but quit was all I heard in my head, screaming like a Siren into every fiber that was me.  I was almost seduced, but then I remembered...Lisp.

I fired up Clisp.  I wrote an equation and fed it variables.  Then, I wrote a loop with an equation and the output got me... thinking.  Where my mind had been a wildly vibrating pile of gelatin about to implode only minutes earlier, it was suddenly calm, focused, and coming to life.  In two minutes I had carefully considered each step, then prototyped, considered some more, realized, and, eureka, solved what took hours to only confound me in Java.

For a moment, life was good again.

One day, I hope to be able to go forward into Lisp for good and the onto construction of some of these crazy ideas I have, and not get dragged into hell and halfway back to C++ ever again.  Amen.

Wednesday, January 13, 2016

Early January Update

I really need to work on coming up with better titles for articles.

I've been working on Android apps.  It's keeping me from writing my pending Java-based Lisp-thing.  It's not keeping me from working on it at all, because it's the next app in the queue.  I just had to get some apps out of my head and get the flow going - for personal as well as professional reasons.

The last Android app is in the final stages.  Hopefully, not more than a couple of more days.  Then it'll be on to the Lisp thing I'm working on, because I have plans to make it the foundation of a Java-based Common Lisp on every platform kind of thing.  With a slammin' interface that *does things* that'll blow your mind.

I hope, I mean, I really hope so.  But don't hold me to it.  My kind of cool might not be your kind of cool.  Though I'm pretty sure I wouldn't work on it if it wasn't some kind of cool.  It's Lisp, how could it not have some kind of maximum inherent cool in it?

After all this Android coding, I'm looking forward to getting into a Common Lisp groove.