hjertnes.blog

Clojure needs its Django / Rails moment.

01.08.2018 02:00

I’m not a huge fan of Django and Rails, I don’t think they are bad either, the languages they use are not a good fit for how I think any more. I also think they have not managed to integrate the whole web app moment in as well as they should.

But that is a blog post for another time.

Both frameworks are very important in the history of web development because they managed to turn a lot of difficult or complicated topics in a way that was very easy to deal with, in a way that felt very native to their respective programming languages.

Having a proper way to deal with databases, database schema changes, login, and solid implementations of the MVC.

The Clojure world might not be into the idea of frameworks, but neither was the Python world. Most of it outside Django are more about putting together various different libraries with your own code to get what Django would give you out of the box.

A bare minimum solution of what Clojure would need is:

  • A solid way to write API’ and the controller side of a server side rendered web page
  • A way to define how the database looks in code
  • A way to query the database you modelled in code.
  • A template language
  • A middleware system (to make it easy to make reusable component to deal with common stuff)
  • A login system that just works without any config, that you can configure if you need to.

And all of this have to feel natural for a Clojure programmer.

Having all the lenses I need.

31.07.2018 02:00

Less than a year after I got this camera, I finally have all the stuff I “need”. While there are still some stuff that I would like to have in addition to what I have, I now feel like I have everything I need.

It would be nice to have a zoom, or to have something wider than a 23, and something longer than 50. But still, if I bring my X-Pro and three primes + plus my Fish eye I have all I need: really fucking wide, kind of wide, normal and kind of long. And my favourite thing about the lenses (except the fish eye) is that they are all usable as my only lens, even though they may not always be the ideal.

I don’t want to add any huge lenses to my kit, because I know myself well enough to say that I would not bring them with me much, if at all. But I would totally love it if Fuji came out with a 16mm f2 and a fast and compact prime between 70-90mm.

Here is the thing, I bring my cameras everywhere. My X-Pro 2 is on my laptop bag with some kind of lens every single day I go to work. And I have a dog. Having a huge lens on my camera would mean that I did not bring it as often with me to work, if at all. And having someting so big that I could not shoot one handed would mean that I could not use that combo when I walk my dog. Shooting while talking the dog is a large portion of my shooting.

When I don’t shoot while walking my dog, I do street shooting or shoot while I hang out with my girlfriend, and in either situation I want as little attention as possible. And walking around with a huge lens brings a lot of attention.

Like I have written many times before: I want the fastest lens I can get that is still light and has fast auto focus. You might not need fast auto focus or light, and should make your own choices based on what your needs are. # Burst shooting on the X-Pro 2.

I’m a burst shooter, and I have been for as long as I can remember.

That doesn’t mean I end up with 70 pictures of every “scene” I shoot. That could be the case if you use the fastest burst mode on the X-Pro 2. Instead I use the slower one. And that works exactly how I want it to be. It is slow enough to control exactly how many frames you want. The problem with some of the faster burst mode is that you get at least three or four frames before you get a chance to lift your finger.

I always shoot more than one image of each thing, because I hate not having something usable. And using a burst mode just makes it easier. My current fear is that the burst modes will become so fast that they aren’t really useful for how I like to use them. Because I’d hate to have to go through like 15 pictures instead of four.

Battery Hell

30.07.2018 02:00

The first thing I do when I get into the office in the morning is to plug in my iPhone and my Apple Watch. Because I use the latter to monitor my sleep, and the former as a alarm clock; and then I start to charge my AirPods. First the right, then the left. And when my iPhone is fully charged I charge my case, before I plug in my iPhone again and leave it like that until I leave for the day.

I really hope that the charging pad thingies take off soon. Because all of this battery crap have started to get kind of annoying. There are so many things I use every single day that needs charging.

My AirPods, iPhone, Watch, Laptops, Nintendo Switch, power banks etc. It would be great if some of it could be solved by just placing it on a charging area. It doesn’t need to be fast, but it should not require you to place it at a exact place, and it should support many devices.

Editors I use

27.07.2018 02:00

I currently use three different text editors. My main one is Emacs. This is where I work when I write new code or spend a larger amount of time in one single file. While I use Visual Studio Code when I have to jump between files a lot. And my go to tool when I just need to go into a file fixing a few minor things is VIM.

I’m going to get rid of VS Code when I change jobs. Because 99% of what I use VS Code for is related to work stuff.

This is not a VIM vs Emacs discussion, both of them are more or less the same kind of thing when you enable a lot of third party code in them, and my Emacs setup is very much a “full featured” one, while my VIM setup is very minimal. That is on purpose to make sure that I can get in and out of VIM faster than it would take me to launch Emacs or VS Code (or VIM itself if I set it up to have the same kind of features my Emacs setup has).

Everyone else is not an argument

26.07.2018 02:00

I often see people doing stuff just because “everyone else” are doing it. Both in life and in software projects. You should not use React or Vue or what ever just because everyone else are doing so. Everyone else is not an argument. It might be a good idea to look into it. But it is not an argument.

Clojure: Macro vs Function

25.07.2018 02:00

I’m not going to get very deep into this, because there have been written entire books on the difference between the two. But I’m going to look into two aspects of the difference between the two.

  1. A function returns data, while a macro returns code.
  2. A function runs when the program runs, while a macro is expanded into code during compilation.

Macros are one of the more powerful aspects of programming languages in the LISP family. You can use them to extend the language. Like I said a Macro returns code, and you can control how and when they are evaluated. Parts of it may be evaluated in the macro, while other parts may be evaluated during when you the code runs. This is what I mean by it returning code. This means that it may depend on some variable that isn’t available to the macro, but is available where it is expanded into.

Other languages have similar concepts to this. But none of them are as elegant. Because at the surface there are no differences between a macro and a function. This is why they are so awesome and important.

Another important thing to remember is that because a macro is expanded into code, it may be a performance improvement over functions in certain situations because instead of being a bunch of function calls it is expanded into code.

Using the Cloudinary APIs from Clojure

24.07.2018 02:00

There are a few advantages to Clojure running on the JVM. One of the biggest is that we can use any Java library in our Clojure projects. Two other is that we can take advantage of all the awesome server infrastructure stuff that exist for Java services and that we can build a .jar file that runs everywhere with a Java Runtime installed.

Most of the time you want to use something that is packaged to be nice to use in Clojure. But you don’t always have that option, and it is really nice to just import some Java libraries when that occurs. The way you do this is that you add the dependency to lean like any other dependency. Lein will look in both Clojars and Maven for packages you add. And then you load the classes or packages you need using “(:import)” instead of “(:require)” in your code. Now you can just do something like (.methodName className) or (.methodName objectName). I’m going to write more about this in the future.

I have put together this GitHub repo, with some code showing the basics of interacting with the Cloudinary API’s from Clojure using the Java SDK.

Minimalism

23.07.2018 02:00

Minimalism is a subject I have been obsessed with since I was an avid listener of the Enough Podcast. My impression is that a lot of people have a misleading impression about what it means. You probably think about some Steve Jobs like person sitting in an empty apartment drinking tea and meditating.

The idea is not to have nothing, the idea is to have less. If you take everything you own, and you question everything, and get rid of everything that doesn’t fulfil one of two purposes: you need it; it makes your life better in a meaningful way. For example I need a few pairs of shoes, but I do not need 100 of them. I do not need a large computer screen, but it improves my life in certain situations in a meaningful way. Like for example making it easier to work at home.

#

21.07.2018 02:00

I can’t wait until Flickr and the Yahoo account crap are gone.

Clojure on the Apple Runtime.

20.07.2018 02:00

You can write iOS apps using various different programming languages. You have Swift and Objective-C; and you various ways you can do it with Javascript. There are ways where you can use C#, and of course game engines are used to make the same game for many different platforms.

But I’d love to see Apple extend this. One of the awesome things about .NET and Java(the real kind, not the Android thing) is that the virtual machine or the run time is designed in a way where you can use Java libraries in other programming languages running there, without having to implement specific packages allowing it.

I want to write native iOS and Mac apps using Clojure. Someone else might want to do so using Ruby or even PHP. I have no idea if this is possible with the current iOS or Android runtime, but I’d love it if we moved against a world where all the app development stuff wasn’t so tied two a couple of programming languages on each platform.