2017-05-21 Update

The big news in the JDK space this week is that Android now supports Kotlin. See this page, on the Android site and this post on Hacker News. So I will start learning Kotlin.

I don’t want to turn into one of those Scala weenies who goes on about how much they hate Java (see Note 1 below), but Android development was always pretty ghastly. Lots of XML, lots of anonymous inner classes (at least the last time I looked).

When Java started, it was basically: We took C++, and removed the hard parts you don’t like. Android is pretty much: We are using Java, but mostly the hard parts you don’t like.

I might look into React Native and ClojureScript at some point. But for now I am going through the Kotlin koans. Back when I was living in Chicago (back when Google told you to use Eclipse for Android), I spoke to a mobile developer who wrote apps for both Android and iDrone. He did not use any of the Javascript wrappers. He said the best way to do it was to just do it the way Google and Apple tell you to do it.

Maybe I will love Kotlin, but to be upfront I am not too happy with it at the moment. It is kind of a competitor to Groovy. I have spent a lot of time with Groovy, and I wish that it had more traction. But the world isn’t going to change for me. A lot of people at my job think every gosh darn thing has to be in a Word file. We make a web app for our client, why not make one for ourselves? But whatever.

There is no Kotlin group in Austin at the moment. Officially, there is a Groovy group, but there hasn’t been a meeting since January. The past two companies that hosted are no longer give the group the space. The group organizer works for OCI, the company that supports Grails. He works with clients all over Texas. I guess there is more Groovy out there than people think. Groovy is one of those languages where the user group is full of people who think the language is great, but their companies won’t even look at it. At the last meetup when he said he works with companies large and small all over Texas,  everyone got pretty excited. But he couldn’t give out any more info because of NDAs.

I know this sounds like I am not oozing with enthusiasm about leaving a language I like for one that I do not know very well. Frankly, at this point, I am not. But it looks like this is where the world is going. Kotlin had already gained a lot of momentum on Android before this (more than Groovy, certainly). If Google is willing to listen to its developers, then maybe Google is a vendor to pay attention to. Unlike Shiny-Wrapper-Microsoft (aka Apple).

Kotlin does have some similarities to Scala, which I do not like, so we will see how this all goes.

So, not a whole lot on the Clojure front.

I am still going through Simply Scheme.

You’re welcome.

Note 1: I always found Scala developers’ hatred of Java odd for two reasons: 1. The language you say you love was/is implemented in the language you say you hate, and 2. Why does Javascript get a complete pass from everybody?

2017-05-14 Update

It’s time for another regular update.

Lately I have been getting more into Scheme again. I am going through Simply Scheme. Maybe it won’t help me get a job right away if I need one (who knows what could happen at a large corporation), but I have read and heard a lot of people say that Lisp/Scheme makes you a better programmer. I don’t simply want a good job and lots of money, I also want enlightenment.

I tried to use Kawa for Simply Scheme, but I could not get it to read the simply.scm and functions.scm files, so I decided to just go with Chicken Scheme. Both that and Guile can run the example files. Simply Scheme pushes itself as a prequel to SICP. One thing I find a bit odd is the talk of “word” and “sentence” as data types. But I am getting used to it.

I worked a bit on the Groovy Validator project. I might re-do it using run-time metaprogramming instead of compile-time. Using compile-time I had to use string interpolation to create another class with the same package and name as the class I am working on. It works, but it feels kind of dirty. If I go with strictly run-time, I will only be able to get it to work with Groovy properties:

and not with setters:

It is not as flexible, and it does not with using the “with” method, but using properties seems more idiomatic.

Not too much happening on the Clojure front for me lately. I think Simply Scheme exhausted my Lisp quota for the week. Hopefully I can do Clojure and Scheme at the same time. I started changing my emacs environment using the tools from Brave Clojure, and so far they seem pretty nice.

I have been going to the Austin Ruby Microservices Meetup (which is totally separate from the Austin Ruby Meetup and Austin On Rails). They are teaching people how to build microservices using event-sourcing. This is kind of new to me. I have never heard of event databases before. But if I can build thread-safe systems, then I am interested. A lot of it sounds like the sort of thing I hear from the Clojure and functional camps: immutability, thread-safety.

I might re-implement it in Groovy (and later Clojure). The group organizer said that was unnecessary, since JRuby runs on the JVM. I told him that in my opinion JRuby people seemed mostly like Java programmers jumping through a bunch of hoops they don’t need to jump through just so they can tell their friends they are using Ruby. He said JRuby is only tough if you are doing Rails, but I do not care. I had to do it in the past, I am not touching it again. Besides, agile and dynamic scripting on the JVM is why Groovy was invented. JRuby is trying to stick a square peg in a round hole and fill a niche that another language has already filled. It’s a solution looking for a problem. No thanks.

You’re welcome.

2017-05-01 Update

Per the advice of Nathan Marz and Dan Vega, I will try to blog more often.

I got a new laptop. At least new to me. My main laptop was starting to use the battery even if the charger was still plugged in. I took it to Discount Electronics, and they couldn’t find anything wrong. But I saw a used Dell for a good price. I asked how much would it cost with more memory and a 500GB hard drive, and it was still a good price. Cheaper than a new one.

From what I understand, UEFI and Secure Boot have made installing Linux a bit trickier than before. It used to be that you could just go to Best Buy, get a random laptop, put in an install DVD, and keep hitting “Next” until you had Linux installed. This seems like a step backwards. Some admins say “all you need to do is hit F$RANDOM_NUMBER, so into the BIOS and disable Secure Boot.” I am tired of going into the BIOS. That reminds me of what installing Linux used to be like.

If I buy a laptop with Linux pre-installed, I will probably go to System 76.

After installing, I locked myself out of my laptop because the GUI would not start. I went with Ubuntu, and usually one of the first things I do is get rid of Unity. I have never liked it. I ran a few commands to get rid of it, but when I rebooted I got a black screen. So I had to re-install and try again.

Now it looks like Ubuntu is dropping Unity. Fine with me.

For future reference, the magic command is:

You’re welcome.

Thoughts On Native, GPU, Groovy, Java and Clojure

One interest of mine is math and scientific computing, although I admit right now my interest is far greater than my knowledge.

It seems like for a lot of math and scientific computing, you either need to do stuff in C, C++ or even Fortran, or use a library in a higher-level language that lets you interface with libraries in C/C++/Fortran. Another new trend is to use code that runs on the GPU, like OpenCL.

Lately I have been looking at a few Java libraries that interface with lower level code. I think it is a good idea to keep learning new things. I think AI and machine learning will become more important over time.

I contributed briefly to the SciRuby project a few years ago. One of their main subprojects is a Ruby wrapper around BLAS, ATLAS and LAPACK. I think some of the instructions for compiling BLAS, ATLAS and LAPACK might still have a few sentences written by yours truly. (It’s a very involved process.) Another one of their projects is a Ruby wrapper/interface around the GNU Scientific Library, or GSL.

One huge language in AI and data science these days is Python, with the NumPy and SciPy libraries. Again, some of the functionality is provided by linking to ATLAS and LAPACK. If it worked for them, maybe it will work for the JVM family of languages.

There is at least one project in Clojure that does this: Uncomplicate. It has sub-projects for OpenCL and BLAS and ATLAS. Along with Java and Groovy, Clojure is a language I am interested in. But for the time being I cannot use these projects. I think my graphics card is a bit too old and the drivers are too old for many of these libraries.

Uncomplicate is part of the reason I am looking at this area again. Somewhere on the site, the author points at the for development, it is okay to use pre-baked packages for ATLAS and LAPACK. One of these projects that I mention says for the best performance, you may want to hire someone to install ATLAS and LAPACK and other native libraries optimized for your production hardware. I did not know people made a living doing just that.

Another reason I am looking at this is GPU computing was mentioned in one of the side talks at the most recent ClojureConj. This is second- or third-hand, but apparently Goldman Sachs runs a nightly report analyzing the market (or some part of it, I am not too clear). It used to take nine hours to run. It was refactored to run on the GPU, and now it takes 20 minutes. I think all developers should become familiar with some of these technologies.

Will any of this gain traction in the Groovy space? I know things have been rough for Groovy for the past couple of years, especially after getting dropped by Pivotal. It seems like a lot of Groovy developers are happy making web apps with Grails. I like Grails, and it has worked out well for a lot of people. I will go through the Groovy Podcast backlog; perhaps Groovy developers are looking into this and I am just not aware of it.

Groovy developers can use the Java wrappers for native and GPU computing. No need to re-invent the wheel. Maybe going from Groovy to Java to native is not quite as fast as going from Python or Ruby to native, but I don’t think so. Even Ruby developers joke that Ruby is pretty slow. They say that sometimes the speed of the programmer is more important than the speed of the program. (But for some reason the Ruby devs who are moving to Elixir are now saying performance and concurrency are important after years of saying they were not. Whatevs.)

I do not have much experience in native or GPU programming. I am not too clear how NumPy and SciPy are used. I don’t want to swallow the Python ecosystem to get the answers to just a few questions, but: Are NumPy and SciPy programs (or bare-metal math/science apps in general) rewritten frequently? Or do they stay the same for years at a time? It seems to me if a GPU program does not change, you might be better off biting the bullet and doing things in C or C++.

But given the success of NumPy and SciPy, perhaps Groovy and Java can be used in this space. Maybe it’s not the end of the world if a bank’s nightly report takes 22 minutes. (How successful is SciPy? Not only are there conventions for general Python, there are also conferences for just SciPy). I doubt any technology will dethrone Python anytime soon, but it is an area to look at.

Having looked a small bit at some of these libraries, I do wonder how much can the unique features of Groovy be used. A lot of the tests deal with arrays of primitive types.  Someone on the Groovy mailing list wrote: I’ve found that you can really shrink down the lines of code just by using the basics that Groovy provides around collections, operator overloading, Groovy truthiness, etc.. Maybe that is enough reason to use Groovy for high performance computing (or at least higher performance). Can we make code calling native and GPU libraries better with features from Groovy, or will we just get Java without semicolons? Some of these functions do not want an ArrayList of objects, they want a fixed-length array of integers. Granted, you can make primitive arrays in Groovy:

but I think that is more keystrokes than in Java.

Just looking at a small part of TensorFlow, here is a line from the original Java test:

Here are two Groovy versions that both work (meaning the tests still pass):

Granted, it’s one line, but I’d say that’s idiomatic Groovy. Perhaps this could be a (small) market opportunity for the Groovy community. Or maybe I’m just crazy.

If you google “groovy jni” the first hit is this page from Object Partners. It mentions JNA and BridJ which I think are used by a lot of the libraries mentioned below. Frankly, it sounds like a lot of work making this sort of thing happen.

Regardless, even if I have to stick with Java and Clojure, I will still keep an eye on these libraries and this space. I don’t think I can become an expert in all of these, but as I said, I think it is important for developers to keep an eye on this spae. I might start some pages about the different libraries, and perhaps share my thoughts on them. Below are a few notes on what I have found so far.

I started by googling “Java BLAS” or “Java GPU”, and at first I only got a few libraries. But as I kept looking, I kept finding more.

The first two I found where jblas and Aparapi. From the jblas website, jblas “is essentially a light-wight wrapper around the BLAS and LAPACK routines.” (And from what I can gather, the correct capitalization is “jblas”.)

Aparapi is a wrapper around GPU and OpenCL code. If you cannot get your GPU drivers installed properly, it will do everything on the CPU. Sometimes I get core dumps running the tests on my Ubuntu laptop. It is about six years old, and has 6 GB of memory, so perhaps that is the issue. But on my 8 GB Windows laptop two of the tests fail. I plan on getting a new laptop soon, so I will try this again when I do. I bet getting all this set up on an Apple laptop is really easy; for the first time in my life I am thinking about buying an Apple product.

TensorFlow has some Java APIs, although they warn that there may be API changes and breakages for languages other than Python and C. This can use either the CPU or the GPU, but for GPUs it can only work with NVidia cards.

The Lightweight Java Game Library works with OpenCL, OpenGL, Vulkan, EGL and a lot of other stuff I have never heard of. As the name suggests, it is primarily for game development, and the wrappers around the underlying native libraries and standards require more knowledge of those underlying native libraries and standards than most libraries.

There is ND4J (N-Dimensional Arrays for Java) and Deeplearning4j. I am not sure if they are related somehow, but they were both started by developers at a company called Skymind.

And then there is the granddaddy: ByteDeco. There is a lot of stuff here. Some of the contributors work on ND4J and Deeplearning4j, and also work at Skymind. This project provides Java interfaces to 21 different C/C++ libraries: video, math, science, AI, robotics, facial recognition, lots of good stuff here. And after looking at their list, yes, I think “Skymind” is a bit too close to “Skynet”. But at least they’re giving you a hint.

You’re welcome.

No Longer Using aTunes

First off, that is not a typo: I really meant aTunes and not iTunes.

For the past few years, I have used an application called aTunes to fetch and listen to podcasts. One reason is I am pro-Java, and I generally prefer to use Java technologies where and when I can. Another is that it is NOT something from Apple. I have always found it strange that lot of people in technology will say they are pro-open source, and they don’t trust Microsoft or other big corporations and think are they too smart to let The Man tell them what to do, yet they will buy anything from Apple without question. I like to strive for consistency.

aTunes has not been updated for a couple of years. I know that the makers of the JDK strive for backwards compatibility, but I think at some point it might be best to use something that is maintained. Plus I had a hard time getting aTunes to work the last few times I tried it. I think I had to go a couple of versions back on one of my laptops.

There is another music player written in Java called Jajuk, but that has not been updated for a while either.

I did some digging, and I found a multi-platform music player called Clementine. So far I like it.

So far, I am still using jEdit, but I am getting more into emacs lately. There is an emacs Meetup here in Austin. For a long time it met around noon, but now it meets in the evening.

You’re welcome.

Image of aTunes from Wikipedia, image of Clementine from Wikipedia. Images assumed allowed under Fair Use.

Notes On Using Emacs Buffers

A few keyboard commands to use multiple buffers in Emacs:

You’re welcome.

boot-new Makes Boot Usable

As I mentioned, I am going through Functional Programming in Java. I have a couple of github sub-repos for it. I am going through the Java code, and then re-implementing it in Groovy and Clojure. The Java and Groovy parts are here inside a repo called “my_groovy_apps_001”, and the Clojure part is here inside a repo called “clojure_apps”.

I started doing the Clojure inside the Gradle app inside “my_groovy_apps_001” using the Neptune Gradle plugin for Clojure. It was okay, but I could not get the REPL to work, and I could not figure out how to run only some of the tests.

So I decided this might be a good time to learn Clojure Boot, the new build tool that is an alternative to Leiningen and seems to be gaining some momentum.

Frankly, the docs are terrible. You kind of need the docs to do anything since it doesn’t do a lot out of the box, kind of like Eclipse when it was first released. Until plug-ins were developed, Eclipse was not very useful, and Boot seems the same to me at this point. Boot doesn’t even have a way to run tests out of the box.

One reason I think the docs are terrible is that in the “Getting Started” section on the Boot github page, they redirect you to a ClojureScript tutorial, telling you that it is “an excellent introduction to Boot and ClojureScript”.

I really have no interest in ClojureScript at this time. I do not like Javascript, and while I have heard great things about ClojureScript and its creators/maintainers, I want to avoid the JavaScript swamp as much as possible. As the guy who wrote the Pollen DSL for Racket put it, Lisp makes me smarter, and pretty much any language ending in *Script seems to kill brain cells on contact. The fact that there are so many languages that compile to JavaScript to me is not a good sign for JavaScript. It says to me that people deal with JavaScript because they have to, not because they want to. And that people will go to great lengths to avoid dealing with JavaScript directly. And since the JavaScript community keeps spawning new frameworks all the time, I think on some level they agree. I am sure at some point I will have to learn about ClojureScript, but I would like to put that off for now.

But it’s not just me being anti-anythingScript here. I like the Unix philosophy of a tool does one thing and does it well. I want to learn about Boot. Not ClojureScript. I don’t want to wade through a tutorial for a desert topping to find the bits about the floor wax.

So I did some searching for some blog posts about how to get started with Boot. I found some by a guy named Sean Cornfield (whom I actually met at ClojureConj). He developed a plug-in called boot-new that pretty much does everything you need to get started using Boot. I would argue that you don’t even need a tutorial for Boot. Just use boot-new.

All you have to do is install Boot, and then run this command:

It will fetch boot-new from Clojars (I assume) and make a project called myapp.

One of the things that boot-new allows you to do is to run tests for specific namespaces. You can run just one:

or multiple namespaces separated by commas:

With “–namespaces”, you specify the namespace of the tests. To specify the namespace of the function, use –include:

So if anyone in your local Clojure group wants a presentation on Boot, you can just tell them to look at boot-new. It would be the shortest presentation ever.

I don’t know how to do all the things that Leiningen does, but if you just want to start a project, compile it, run a REPL, run some tests and get a JAR, I think boot-new covers some of the basics. Correctly or incorrectly, it seems like a lot of people (including me) think of Boot as an alternative to Leiningen. So my approach is basically, “I know how to do X in Leiningen, how do I do that in Boot?”

For a lot of basic tasks, boot-new is your answer.

You’re welcome.

Going Through “Functional Programming in Java”

I am starting to go through “Functional Programming in Java” by Venkat Subramaniam. I need to learn more about the stuff that is in JDK 8. We are still on JDK 6 where I work, but I think we will go to JDK 7 soon.

I think a lot of the new features in JDK 8 are similar to stuff that has been in Groovy for a long time.

There is an interesting paragraph in the Foreword by Brian Goetz:

The Java 8 design was heavily influenced by the core principles of functional programming: functions as values, immutability, and statelessness. We didn’t do this because functional programming is trendy or cool; we did this because programs that are expressed as stateless transformations on immutable data, rather than as modification of mutable data structures, tend to be easier to read and maintain and less error-prone, and to parallelize more gracefully.

You’re welcome.

2016-12-06 Tweets

My twitter plug-in seems to have stopped working, so I have copied and pasted in the tweet here.

 

I will look for a better plug-in soon.

You’re welcome.

Rebooting Ubuntu After It Goes Read-Only

Sometimes my Ubuntu laptop malfunctions and the file system goes into read-only mode.

This might mean it’s time to upgrade to a new laptop. Which I will probably do in a few months.

But I want to note how I can get back to normal.

The obvious way is just to reboot. But sometimes the system goes into a initramfs prompt.

To solve the issue, I need the location of my drive in the /dev file system, which I can get by running df -h:

The one I want is “/dev/mapper/ubuntu–vg-root”.

So in the initramfs prompt, I run this:

I got this answer from the Ask Ubuntu site (see another answer here). As long as I can access my site from another machine, I should be able to solve this.

I may need to get a new laptop soon because sometimes my laptop does not detect the power chord is plugged in, so it starts using the battery.

You’re welcome.