Java 10 released!

There is a bunch of new features in this release, but I have a clear personal favourite: local variable inference. Just have a look:

1
var obvious = 1;

What is the type of obvious?

Over time we evolved a bit:

1
2
3
4
List jdk4 = new ArrayList();
List<String> jdk5 = new ArrayList<String>();
List<String> jdk7 = new ArrayList<>();
var jdk10 = new ArrayList<>();

There is, naturally, a catch: where are the generics in the last example? I think it’s fair not to expect the compiler to use a crystal-ball.jar, so

1
var generics = new ArrayList<String>();

Generics will be a

1
ArrayList<String>();

now, as expected. One last catch – this will trigger IntelliJ et al to suggest returning an ArrayList instead of List, but I guess this will get better over time.

Time to upgrade (part 2)

Continuing https://andrzejgrzesik.info/2017/09/17/time-to-upgrade/

Let’s look at ebay.co.uk (the website, not the company). As of October 2017, a workstation with two Xeons can easily be found for under a Threadripper. What’s needed? Lots of RAM, multiple CPUs, some PCIE slots. Some drive slots. More than 1 network socket, to isolate experiments.

Loose thoughts: Dell T630 seems to have lots of disk space, lots of PCIE, should be quiet… but, after a bit of search, it’s also loud when multiple GPUs are inserted. I could try to quiet it down replacing fans, but that’s a bit too much hackery for what I want to build. For the same reason, a rack server is not being sought.

Adventure #1, amazing deal. I thought I won the ebay auction, seller sadly has sold elsewhere. As in, on gumtree. “Normal” people sometimes buy workstations and sometimes sell just to get rid of them.

So, ebay/gumtree/…. Browse often, browse regularly. There are deals that will show up. Write the components down, price them to asses the worth of the setup, don’t overspend.

Adventure #2, good (not stellar) deal. I’ve “bought now”, seller doesn’t write any messages AT ALL, but their paypal (I am fond of buyer protection) email address, which is googlable, which leads to his blog, and there is a  phone number. Which, upon texting, responds with “computer sold elsewhere”. Disappointment.

An option is to pick a dual motherboard, buy RAM and ES/EQ CPUs, if one is willing to risk. As in, ES/QS (Engineering Samples) will be similar to models known from ark.intel.com, but not the real thing. They will, most probably, offer a better power for money. Also, browsing a lot, there are chips not present in Intel’s library, thanks to cloud providers, who get them customised. But this means a PSU, fans, making it quiet, and a workstation motherboard that might have a very different set of connectors to what consumer grade purchaser is used (why would you NOT need a 5.1 sound card in a workstation?).

Adventure #3, decent computer, bidding 2/3 of total value, just in case. Few hours later, got a “2nd chance offer”, which means the winner resigned and I can follow through. This is when pricing and bidding conservatively has helped. Also, I now have a desktop, still under warranty.

 

Time to upgrade (part 1)

There comes a time in which hardware is not enough. I like my macbook pro, but it’s not the class of machine I run code on, which means inferred intuition is incorrect. Ideally, I’d like a dual-Xeon with >32GB RAM. A kind of machine everyone had at ebay – and as people turned over, I accumulated 3, before also changing banners.

My home desktop is an i7. Luckily Intel wasn’t really doing too muchanything in the consumer CPU space. It’s fine, runs occasional Civilisation or PUBG/Overwatch/StarCraft (a beer prosthetic across timezones). I need cores, RAM and numatop.

Why now? Threadripper! Competition in the CPU space! I had huge hopes AMD would at least stir the market a bit. Also, was a bit afraid of “here goes nothing” scenario, in which Threadrippers turn out to have hardware bugs. It’s September, Intel responded with i9s. Good, let’s look around. I don’t want to burn a lot of $ immediately. In the worst case, I can always buy more 🙂 After all, 7900x and 1950x are 1k GBP each for the CPU itself. Plus DDR4, motherboard.. it adds up. Here came the thought of “maybe a 2nd hand workstation”?

Europe a bit disadvantaged (compared to the US) when it comes to 2nd hand hardware. It’s still so much better than if I would limit myself to polish market/allegro – is it because all the outsourcing companies only lease laptops for their staff?

After going through ebay, I’ve narrowed myself down to: Dell Precision 5810, 7810, 7910, HPs Z620/Z820 workstation, or a similar Supermicro tower server

I gave E7-4* a moment of thought, especially as I’m OK to hunt for ES. But then, a rack is a commitment, so this will wait.

Container types

During a discussion with Konrad Malawski about typesystems.

Consider a Fruit.

class Fruit {}

There are different kinds of fruit. Explicitly:

Fruit<E> {}

So far so good.

Fruit<Apple> apple;  
Fruit<Orange> orange;

Which allows:

apple.compareTo(orange) 

Does this make sense? Well, no 🙂 What to do? Well, Types to the rescue.

Dear types, please make comparing Fruits of different kinds illegal.
The types listen, and respond. Or actually it’s already in the JDK.
java.lang.Enum, which does

class Enum<E extends Enum<E>>

Generalizing

class Container<Type extends Container<Type>>
	
Why? To save the types. Applied to the example:
[code lang="java"]class Fruit<E extends <Fruit<E>> {}  

now makes

orange.compareTo(apple)

illegal. As expected and while still in Java.

JavaONE, day zero

It’s the best JavaONE I’ve been to so far 🙂
Where to begin.. well, lots of friends and faces, even more people I don’t know. And since Oracle OpenWorld takes place at the same time,
city is redecorated to look like an Oracle stronghold (cabs, buses, streetposts have Oracle ads). It is an experience.

My and Konrad’s session went well, we had a full room with not a single chair to spare.
Slides are up on SlideShare or just below

More news after the event, there is SO MUCH happening in here all at once, I wish I could bi- or tri- locate. 🙂

ps. Apparently, if I link to OTN from my blog, I will get a t-shirt, the choice was obvious. 😀

Autumn = fun, fun, fun!

Yay, I’m going to JavaONE. But it’s actually a bit better, since I’m actually speaking there! (Together with Konrad) a session called Java 8: The Good Parts [UGF10520].
That’s a news of its own, but it gets better! So, altogether, there is:

Should be a lot of fun, see you there!

Git – push to multiple remotes

Once upon a time, there comes a need to push to multiple remotes.
This time.. it’s because of Jacek Laskowski.
Specifically, this tweet:

And well, let’s see.

[00:48][ags@ags-mbpro:~/temp/git_for_jacek]
$ git init repo1 --bare
Initialized empty Git repository in /Users/ags/temp/git_for_jacek/repo1/
$ git init repo2 --bare
Initialized empty Git repository in /Users/ags/temp/git_for_jacek/repo2/
$ git init repo_base
Initialized empty Git repository in /Users/ags/temp/git_for_jacek/repo_base/.git/
$ cd repo_base/
[00:48][ags@ags-mbpro:~/temp/git_for_jacek/repo_base]
$ git remote add dla_jacka file:///Users/ags/temp/git_for_jacek/repo1
$ git remote help
error: Unknown subcommand: help
usage: git remote [-v | --verbose]
   or: git remote add [-t <branch>] [-m <master>] [-f] [--tags|--no-tags] [--mirror=<fetch|push>] <name> <url>
   or: git remote set-url [--push] <name> <newurl> [<oldurl>]
   or: git remote set-url --add <name> <newurl>
   or: git remote set-url --delete <name> <url>
[00:49][ags@ags-mbpro:~/temp/git_for_jacek/repo_base]
$ git remote show dla_jacka 
* remote dla_jacka
  Fetch URL: file:///Users/ags/temp/git_for_jacek/repo1
  Push  URL: file:///Users/ags/temp/git_for_jacek/repo1
  HEAD branch: (unknown)
[00:50][ags@ags-mbpro:~/temp/git_for_jacek/repo_base]
$ git remote set-url dla_jacka --push --add file:///Users/ags/temp/git_for_jacek/repo2
$ git remote -v show
dla_jacka	file:///Users/ags/temp/git_for_jacek/repo1 (fetch)
dla_jacka	file:///Users/ags/temp/git_for_jacek/repo2 (push)

Not exactly right, again.

[00:51][ags@ags-mbpro:~/temp/git_for_jacek/repo_base]
$ git remote set-url dla_jacka --push --add file:///Users/ags/temp/git_for_jacek/repo1
[00:52][ags@ags-mbpro:~/temp/git_for_jacek/repo_base]
$ git remote -v show
dla_jacka	file:///Users/ags/temp/git_for_jacek/repo1 (fetch)
dla_jacka	file:///Users/ags/temp/git_for_jacek/repo2 (push)
dla_jacka	file:///Users/ags/temp/git_for_jacek/repo1 (push)

Hmm, seems like it’s what I need. Let’s try!

[00:52][ags@ags-mbpro:~/temp/git_for_jacek/repo_base]
$ touch test
[00:52][ags@ags-mbpro:~/temp/git_for_jacek/repo_base]
$ git add test
$ git commit -m "first commit, to check things"
[master (root-commit) 39d428d] first commit, to check things
 0 files changed
 create mode 100644 test

Empty file ready, let’s push!

[00:52][ags@ags-mbpro:~/temp/git_for_jacek/repo_base(master)]
$ git push dla_jacka master
Counting objects: 3, done.
Writing objects: 100% (3/3), 224 bytes, done.
Total 3 (delta 0), reused 0 (delta 0)
Unpacking objects: 100% (3/3), done.
To file:///Users/ags/temp/git_for_jacek/repo2
 * [new branch]      master -> master
Counting objects: 3, done.
Writing objects: 100% (3/3), 224 bytes, done.
Total 3 (delta 0), reused 0 (delta 0)
Unpacking objects: 100% (3/3), done.
To file:///Users/ags/temp/git_for_jacek/repo1
 * [new branch]      master -> master

Bang, works 🙂

Proguard, jdk7 and OS X

[INFO] ------------------------------------------------------------------------
[INFO] Building XClient 1.2.34-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- maven-clean-plugin:2.4.1:clean (default-clean) @ xclient ---
[INFO] Deleting /Users/ags/vcs/paysforblogging/XClient/target
[INFO] 
[INFO] (...)
[INFO] (...)
[INFO] (...)
[INFO] (...)
[INFO] --- android-maven-plugin:3.3.2:proguard (default-proguard) @ xclient ---
[INFO] (...)
[INFO] java.io.IOException: Can't read [/Library/Java/JavaVirtualMachines/jdk1.7.0_09.jdk/Contents/Home/Classes/classes.jar] (No such file or directory)

No such? I’m using Oracle JDK, should work. Let’s see.

cd /Library/Java/JavaVirtualMachines/jdk1.7.0_09.jdk/Contents/Home
cd Classes/: No such file or directory

Ah, ok, seems we’re not going the old OSX way of putting things inside JDK anymore.

mkdir Classes
cd Classes
sudo ln -s ../jre/lib/rt.jar classes.jar
sudo ln -s ../jre/lib/jsse.jar 
sudo ln -s ../jre/lib/jce.jar 
[03:18][ags@ags-mbpro:/Library/Java/JavaVirtualMachines/jdk1.7.0_09.jdk/Contents/Home/Classes]
$ ls -al
total 24
drwxr-xr-x   5 root  wheel  170 Nov  2 17:42 ./
drwxrwxr-x  16 root  wheel  544 Nov  2 17:19 ../
lrwxr-xr-x   1 root  wheel   17 Nov  2 17:38 classes.jar@ -> ../jre/lib/rt.jar
lrwxr-xr-x   1 root  wheel   18 Nov  2 17:42 jce.jar@ -> ../jre/lib/jce.jar
lrwxr-xr-x   1 root  wheel   19 Nov  2 17:40 jsse.jar@ -> ../jre/lib/jsse.jar

And.. works!

After jdd 2k12

Once again, I’ve been to JDD.
Sixth time out of seven (I like saying I’ve been to all Krakow editions, since 2nd took place far from the city centre).
This year’s event started with mine and Marcin Sawicki‘s Jenkins and Continuous Delivery workshop. We wanted to show how and where to use Jenkins for the greater good and world peace.
Judging from feedback, we succeeded. Even though faulty network forced us to change plans and improvise a bit.

On Thursday, I’ve visited almost all the lectures I wanted. “Catcher in the Code” by Paweł Badeński, a noteworthy talk about telling a story with code. I really admire the way in which Paweł talks from such a huge perspective. Before that was Jarek Pałka’s “Deconstruction of Architecture”. It’s obvious Jarek experiences the same
pain I express as “I hate computers”. Another good thing to see.

I also enjoyed MetaYoda‘s Meta Cloud Architecture talk.
As much as it contained more than a few buzzwords, it didn’t put me off, especially as I had a conversation
with the speaker on the next day.

Then came Friday, day during which I talked in the lobby more and visited talks less.
The only talk I’ve seen in full was “Git Happens” by Jessica Kerr.
I’ve presented Git the previous year (together with Konrad Malawski),
but IMHO Jessica’s way was a bit more interesting, even though it explained basics. In a lively (jumping!), colourful way,
which maybe is what a git talk should include.

It was a good conference. Lots of interesting people met, some very solid talks, all very inspiring.
I definitely enjoyed it and will try to come next year as well. 🙂