Tuesday, September 1, 2015

Getting Around to Things

I find that the most difficult thing about being productive is Consistency.  I am extremely flighty with my attention.  I get excited & ramped up about things very easily.  I revel in the Raw Potential of things.

I will find myself down for the marathon investment of time to get something bootstrapped & running and I will gleefully throw myself into new endeavors this way.

The problem comes when the neat nifty newness wears off & I find myself level-grinding to keep things going.  My momentum - which I dumped so much energy into in order to fight the inertia that keeps things from starting to begin with - peters out - along with my interest level.

To combat this - I try to compartmentalize projects and to keep several of them going at any given time.  This was when I find myself fed up with something there are many other shiny things to compete for my attention - all of which require time, effort & attention and which would be productive to work on.

So I suppose that I work cyclically.

At this time I have finally circled back to Python and web2py.

That being said I found it extremely interesting to learn that web2py will run on Jython.

I have no idea what the performance is like. 
Would it run comparably to C-based-Python? 
What are the implications for hosting?

What is compelling about this is the ability to leverage existing Java libraries which are themselves inherently more performant than Python equivalents.  Since I write a lot of Java & am still gaining confidence in Python - this provides me with emotional security.  The question is - at what cost?  Performance of Python code is likely to take a hit and hosting costs will undoubtedly go UP significantly.

Just what is the acceptable price tag for my feelz?

Monday, April 27, 2015

#nerdshaming SUCKS

The Cultural Appropriation of Nerds is going strong and frankly it stings.
40 years ago I started going to public school and was harassed and beaten down verbally, emotionally, and yes - physically on a constant basis for being a nerd.

I was belittled for being obsessed with things that no one else cared about (Computers, for example) and regularly called out in the open for throwing the grading curve.

So nowadays when I see people affecting "Nerdy" things based on stereotypes perpetuated by shows like Big Bang Theory or Portlandia I see people "trying to be cool".  (And that's called "Cultural Appropriation" when some people do it)
Much like racial slurs that have been reclaimed & worn like a badge "Nerd Culture" is a defense mechanism against "The Norms" whom have beaten us down & locked us out and now that the societal value of nerds has been proven, those same "Norms" want to raid the cupboards and claim ownership of what they once ostracized.

Allow me to level-set with this anecdote: I dressed as Wolverine for Halloween in Junior High - and No One Knew Who I Was Supposed To Be.  (They just knew that those claws I made in metal shop should get me suspended)

I was the (now) "infamous" cis-white skinny male who "couldn't get laid in a whorehouse with $100 bill hanging out of my fly."
So I ended up huddled defensively at That Table in the lunchroom with all of the other people who took such crap regularly.

I can't imagine what that experience was like for girls - because none ever spoke to us except to put us down.

The exception that I remember was the "Big Win" of being asked to the Sadie Hawkins dance!

But of course what I didn't know what that I was "settled on" so that the girl wouldn't have to deal with the shame of going alone.
I got eyerolls from her from the minute I showed up (with my mother driving) to pick her up.

And as soon as we walked in the gym where the dance was held, she ditched me & ran over to her friends where she stayed the entire time & they all made sure to let me know I wasn't welcome.

I honestly don't even remember if I brought her home or not. (I think that she just ditched me)  I just remember awkwardly standing around by myself the whole time - just like every other day.
I felt worthless and used.

Since I don't recall ever seeing "girl nerds" clump together in groups I don't know if there was such a group - so I can only guess that such an existence would have been an even more lonely one than mine.

All that I remember was that Girls Hated Nerds and if you wanted to ever get a date - you needed to lock away anything about yourself that resembled that and keep it hidden.

My way out of social ostracization was music.  Acid Rock & Heavy Metal were "cool" back then & by learning to play bass & wearing a denim or leather jacket suddenly I wasn't seen as a nerd anymore.  "Burnouts" were much higher on the social pecking order.  (see The Breakfast Club for reference)  But of course I still had to hide the nerdiness from the Other Burnouts - who remembered me for what I really was & wanted nothing to do with me unless I "got cool".  (Which included also hiding any interest in "New Wave" music, incidentally)

Fast forward to today - where 'many' modern feminists have picked up the old habit of nerdshaming by labeling a group that already has massive social anxiety - who might have been slowly gaining mainstream acceptance (by way of providing tech-support) and then branding them as misogynists with a wide brush.

As I understand it the label was earned at comics and video game conventions when vendors started hiring "booth babes" i.e. attractive women dressed in costumes to attract the attention of a demographic desperate for female interaction.  There they were - actually paid to talk to them...  And what do those nerds pick as a subject to talk about?  Why their costumes of course!  And when those actresses failed to have the background material on whomever they were portraying -- the nerds reacted to being "played" with hostility.

That such hostility spilled over onto the other females at such conventions is, I agree, wrong.  But the idea of establishing a nerdy pecking order based on how many obscure facts that you know about a given subject is not something with which only female nerds have to endure.  That is universal treatment that we all do to each other since what other currency is there in such a culture except knowing obscure things?

Such super-fan mentalities extend to everything.  I can clearly remember school-bus crucibles where I needed to be able to name Van Halen or Led Zeppelin songs that weren't hits to prove that I was in fact a True Scotsman and thus prove myself worthy of acceptance.  If you are not a sports fan & ever speak to one, you will no doubt have had a similar experience.

In the spirit of No True Nerds - I will offer these simple missives:
  1. The cis-hetero-male-nerds that I have known did not hate women (& thus by definition are not misogynists) but they have been mistreated by women (girls actually, but the distinction invites more arguments) and so are wary of being further mistreated.  This added to the endemic lack of socialization skills/inclination makes them walking disasters waiting to happen & perhaps worthy of a molecule or two of compassion/understanding/help/lending a clue.
  2. If you find yourself in the group that I am talking about - today is the best time in history to be a nerd.  Bullying is actually taken seriously when you ask for help.  (I actually switched classes to avoid bullies several times) And physical abuse is no longer tolerated.  I will take a Tweet-storm over an actual pummeling any day.  So don't take it out on other people and at least try to learn some social skills.  They will only make your life easier.
  3. Using a computer a lot doesn't make you a Nerd.  Liking movies based on comic books or watching Star Trek/Wars doesn't make you a Nerd.  Thick glasses that you wear by choice don't make you a Nerd.  If you haven't been abused for liking unpopular things - you aren't a Nerd.  A "nerd" is not something that anyone wants to be - but when you wake up with that Albatross around your neck - the only thing to do is to own it.  So let the nerds be & go be whatever you are.
And to make one last distinction - I never wanted to wear "Nerd" as a label.  I settled for "Geek" - because "Paid Geek" is a term that garnished some modicum of respect.  And if you think that the term "Nerd" has lost all of it's teeth today - then substitute the word "Dork" and re-read to get the spirit of what I am trying to convey.

In closing, feel free to shit on my story.  I'm an adult now and I can take it.  But don't for one minute assume that reliving & talking about this wasn't painful.  I do not want other people to have to live through that.

Wednesday, March 11, 2015

!2Swift: Catch A Rising Star

According to Tiobe, Swift's popularity is on the rise.

Ruby has slipped a notch to #18 & Swift has risen to #17.

To put this in perspective, ObjectiveC is currently #3 behind C & Java.

To further put this in perspective, Swift ranks just below R, Transact-SQL, PL/SQL, Pascal, & Delphi/Object Pascal.

Coming into the community at this point is somewhat surreal.  There are a lot of grizzled ObjectiveC veterans who are grumbling about having to get on the learning curve again.

I see them as whiners - mostly because I am jealous of their experience and knowledge of the Cocoa and Foundation frameworks which I am struggling to come to terms with from a Swift-only perspective.  To me, they already understand the hard parts of app development.  Syntax-wrangling is just a way to keep things interesting.

But then I suppose that the mindsets are very different.  Objective C is a product of the 1980's and it shows.  Java was more of a 1990's mindset.  Looking backwards through the lens of time that doesn't see like very much of a difference numerically but from a technical viewpoint they are very different indeed.

Friday, March 6, 2015

When Politics Chooses You

I have waited a long time to comment on this topic because it is explosive and people generally prefer to react than to Think or to scream rather than to Debate.

I mention it now because it is directly relevant to the IT Industry and further has growing relevancy in many facets of modern culture.

I have plotted the arc of hashtag-activism and the impact of Modern Feminism for a few years now: from #elevatorgate to #gamergate to #metalgate there has been a repeated pattern of behavior that results in conflict.

How I characterize that behavior dictates what side of the battle I am on so I am going to try to avoid the logical fallacy that there are only two sides for as long as I can.

What makes this relevant to the IT industry is the Ellen Pao case.

Though it was filed in 2012 the day to day reports are seen through the lens of current controversy.

It by no means mediates the situation that the plaintiff in the case is the current CEO of Reddit.  I am truly interested in the profile of the selected jurors and what the composition of the rocks that they were living under so that they are unaffected by that fact.

What is clear to me throughout is that ideologues are speaking past each other & there is not much in the way of resolution. Court cases however eventually end & thus force closure.

While I by no means expect activism to end - legal precedents have a way of setting a tone for future discussion.

A safe prediction is that no matter which way the lawsuit goes there will be a #backlash campaign of some sort and a #backlashResponse counter-campaign that will seek to discredit the first - and people will retreat to their corners to reload their trebuchets with fresh dogma to launch on Twitter.

I find it all too unfortunate that part of this case revolves around a broken monogamous relationship and a love-polygon.  That raises a Fog Of War that makes it more difficult to focus on the core legal issue : "Was there systemic sexism?"

From the perspective of a lawyer - it would be better to have more clear-cut examples when trying to establish legal precedent.

Without casting judgement on the involved parties - part of the beginning of #gamergate involved a story about a love-polygon - which only poured accelerant onto a heat-source.  It is my opinion that this was not helpful at all when trying to focus on Issues.

What people choose to do in their love-lives should be their own business.  Full stop.

That being said - there are still limits - for example when you trade sex as a commodity for favor - a recurring theme in the news.

So how do we deal with that reasonably?  If people's sex lives are their own then how do we make sure that no "funny business" is going on trading favors of one kind for another?

It would appear that in the modern age, not everything that is old-fashioned is obsolete.

The traditional answer was not to have anything to do with each other thereby removing the potential appearance of an improper relationship.  Therein lies the heart of Victorian Values - the relishing of appearances.

Unfortunately there was a lot of "turning away" from human beings in an effort to keep up appearances at that time and so we don't look back so fondly on that sort of pretentious behavior anymore.  However, in small doses a little prudence can go a long way.

You will notice that I am still walking the tightrope of not calling people out nor taking sides.

For now I will cleave to the loneliest path - right down the middle - swatting away opportunities to form an opinion in the way that a Buddhist monk swats away stray thoughts while meditating.

They are only distractions that keep us away from The Truth:
We all live in the same world & must continue find the optimal ways to get along with each other.

These are Trigger Issues and even mentioning them raises the risk of conflict.  I have had this happen already with friends of mine who immediately went into ears-closed-mouth-yelling mode.  So do be careful.

Tuesday, January 20, 2015

Give Up The func

There is a Thing about learning new languages - it tends to make you Think Differently.

I've written a lot of perl and Java over the years & so it took me a while to get the whole Functional Programming thing...

It basically took me learning Swift.

That being said - I don't write Swift code for a living.

As a result there strange new ideas have been seeping out into my perl & Java code.

I recently found myself, for example, emulating functional programming in Java by using an Enum as a return-type which would trigger a variety of different methods with a switch statement.  

Each different element of the Enum is treated as a case inside the switch.  

Then for the last line of the switch I added:
throw new AssertionError(this.name());

Which is essentially the compiler saying "WTF?"...

Admittedly this is, at best, a very weak example of Functional Programming - but I'm not here to demonstrate the Java implementation of a Closure - others have done that far better than I could.

The point of this is that simply that rather than limiting myself to the constraints of managing a return-type - that type itself might reflect a relationship to varied behavior.

Does that mean that we can pass around references to functions?  Not exactly, but usually what you are trying to accomplish can still be done with some code contortionism.

Loose functions are simply methods in Java so an Enum of triggers could fire cases in a switch, all of which behave differently & call various methods.

Depending on what data those methods need to access dictates if they are Class methods or if you need to define a Class to generate object instances.

Wednesday, January 14, 2015

Old Dog Learns New Trick: The NCO

While learning Swift I came across something to which I was not accustomed: the Nil Coalescing Operator.

For example:
optionalValue ?? valueIfNil

Which more or less translates to: "The value of optionalValue unless it isn't defined, in which case default to valueIfNil"

Usually this would be written as:
(optionalValue != nil) ? optionalValue! : valueIfNil;

I liked what I saw & looked into it and to my surprise it also exists in perl as the Null Coalescing Operator / Logical Defined-Or operator.

In perl the above example is rewritten as:

$optional_value // $value_if_null

Which is in turn shorthand for:
defined($optional_value) ? $optional_value : $value_if_null

However there is more - because in perl there is a shorthand notation for this:
$optional_value //= $value_if_null
Which is the equivalent of:
$optional_value = $optional_value // $value_if_null

Tuesday, January 13, 2015

How to utf8 with perl

I have had a good deal of trouble working with utf8 with perl scripts.

It is extremely easy to mess things up - in fact all you have to do try to add two strings together (aka concatenate).

As such I have had to come up with a simplified solution for my team.

I will share:


use open qw( :std :locale );
use Encode qw(decode is_utf8);

my $a = "\xc2\xa9\xc2\xae\xe2\x84\xa2";
my $b = "Any old thing.";

print "a:",$a,"\n";
print "b:",$b,"\n";

my $c = jibe($a,$b);
print "c:",$c,"\n";

sub jibe {
  my($s,$t) = @_;
  my $r = join('', (is_utf8($s)?$s:decode('utf8',$s)), (is_utf8($t)?$t:decode('utf8',$t)));
  return $r;

And the output is:

$ perl ./simple_utf8.pl
b:Any old thing.
c:©®™Any old thing.

The key thing here is that the jibe sub will allow you to safely concatenate two strings and produce a proper utf8 result.

If you include the use statements and the jibe subroutine you can use this in your code.

It is designed to analyze your input & only decode as necessary - so it gives you a bit more license to mix & match input strings.

Monday, January 5, 2015

!2Swift:Of lumpy carpets & loose wires...

Welcome to the newly branded !2Swift (not-too-swift) branch of my blog.

Since I have been talking about just about nothing else besides Swift for days on end it seems fitting that I make a *thing* out of it...

But let's be real now for a moment: I am neither a zealot/fanboi nor am I a hater/assassin.  

I am a Skeptical Software Developer.

It is difficult to keep your politics out of your code these days as we have to endure endless wrangling over licenses.  To be politically neutral is to be intentionally clueless.

I am therefore going out of my way to behave in the way that I have seen many old people use to good effect:  I am filtering out things-I-don't-want-to-hear and only focusing on the interesting parts.

"Adapt what is useful, reject what is useless, and add what is specifically your own" - Bruce Lee

But that also means that I sometimes, just out of pragmatism, I will have to point to things & say "WTF?"

One of those things is the Coccoa framework.  There was a serious WTF moment that I experienced when switching gears from trying to learn Swift to finding the state of affairs that is the Core Libraries we need to depend upon in order to write *Everything*.

 I will provide further examples in coming posts, but looking below to my cargo cult posting about accessing files - you can see some hints there to the wires hanging out of the back and they are all of the ObjectiveC variety. (Anything with the 'NS' prefix for example)

You will come up against this every time you cross the language barrier in terms of features.  For example, in Using Swift with Coccoa and Objective-C in the section on Working with nil it points out that ObjC works with raw pointers that could be NULL.  Swift however guarantees all values are non-nil.  Thus Swift wraps the class-types in imported ObjC API's in an implicitly unwrapped optional type.  So before you use an ObjC object you need to check that it is not missing.

In their example when importing this ObjectiveC method:

- (NSDate *)dueDateForProject:(Project *)project;

You have to do this in Swift:

func dueDateForProject(project: Project!) -> NSDate! 

So you might be thinking either:
  1. WTF? ::facepalm::
  2. What's the big deal?
And to you in the second group I will point out this simple truth:
Everything that you want to do requires that you import ObjectiveC code.

[EDIT: It was pointed out that I should explain my point a little further if I am not going to force people to Do The Work to get it...]

The Big Deal is the '!' at the end.  Whenever you use them you are essentially bypassing the safety built into the language.  This is a crash waiting to happen every time that you do it & these frameworks require that we do it all over the place.

Saturday, January 3, 2015

Java <-> Swift : a Niche Market?

If you followed along at all with the last post then you probably have some programming chops.

I'm going to keep up my journey of learning Swift for as long as I can.  These things have a way of running out of gas after a good long binge - usually when life catches up & starts demanding that you spend time paying attention to all of the things you have been neglecting in order to do heads-down-programming.

That being said, while I know many, many programming languages already, the two that I have been paid to write the most often have been Java and perl.

One thing that I have often lamented was the complete culture clash that existed between those two communities.  I could never fathom it since both communities purported to have the same goal: i.e. a cross-platform programming language.

Now that I've drunk enough Apple Kool-Aid to start sweating the stuff out of my pores I can truthfully say that I am *not* over the fact that Swift is completely inwardly-facing with regards to the Apple technology stack.  This is a major failing & it will dog this technology for as long as they continue to behave this way.

But I am determined not to let that fact keep me out in the cold again.  I made this mistake once with ObjectiveC already.

So what immediate benefit can I provide?  That is, if I wanted to get paid today to add value with the Swift language, what could I do?

Well the simple answer is that I can provide Java/Swift conversion services.  I am fully fluent in Java and I am coming up to speed on Swift as quickly as I can.  What I find interesting is that, as in many other languages, you can use the Java style when writing code.  What that amounts to is class-based namespaces and encapsulated functions that only return a single data type.

But how would you go the other way?  That is from Swift to Java?  The simple answer as I mentioned in the prior post is to make liberal use of Tuple as a return type.  Also you will want to have basic default 'Global' class to contain any standalone functions as class methods. 

What this amounts to is that people will end up falling into camps : those who regularly port to other platforms and those who choose to write in idiomatic Swift.  

The latter camp will predictably be snobs & will do everything possible to break external compatibility.  

That isn't me throwing rocks at Apple, merely at language zealots - because this pattern has been replayed in any language that you can mention during its adoption cycle.

What is all of this talk about writing code for other platforms?  If you are actually planning on releasing a "Mobile Application" and think that iOS is "enough" - then you're missing at least half of the potential market for your app.

THAT more than anything is the main reason to resent Apple's decisions regarding Swift - but as I have pointed out before - resentment can be overcome with tolerance.

Friday, January 2, 2015

A cup full of Swift for Java Programmers

I am imbibing the Apple Kool-Aid.  

I have upgraded from a shot-glass to a coffee cup.

I'm just going to jump in here today with an example of a function so that we can compare the method signature of a Java method with a function in Swift:

//for your playground
func calculateStatistics(scores: [Int]) -> (min: Int, max: Int, sum: Int) {
    var min = scores[0]
    var max = scores[0]
    var sum = 0
    for score in scores {
        if score > max {
            max = score
        } else if score < min {
            min = score
        sum += score
    return (min, max, sum)
let statistics = calculateStatistics([5, 3, 100, 3, 9])

The first line right away there's the keyword func.

This is necessary since a function can be defined as a standalone thing without the OOP-fetish containing object that Java requires.

Then we have a name, done in camelCapsStyle.

Then we have the input signature which (can have two names, one for internal & one for external use but) in this example only has one name "scores" which is an array of type Int.

Then there's the -> symbol which denotes the Output.

And in this example we see that Swift allows you to return multiple named values inside a Tuple.

Then there is the code block inside of the {} brackets which explains how that output comes to be.

The last 3 lines are specifically for your playground - the first calls the function with an array of sample data to construct the reply, the second references one of the returned output values by name and the last line returns the same value by index value of the returned tuple.

In java the method signature would look something like:

public Tuple calculateStatistics(int[] scores){}

And you would have to know to decode the 3 values in that returned Tuple without any hints. 

This method would need to exist inside some kind of container object, if only for namespace considerations.

More likely you would create 3 distinct methods, one for minimum, one for maximum and one for average and if you really needed the Tuple then a third method which would in turn call the first three.

All of that is of course still possible, but the point is that it is no longer necessary since Swift gives you this flexibility.