Friday, November 21, 2014

Indirect Generics

I've been rethinking an old programming language idea I've had. I don't know if anyone else does things this way. (But probably, because Ecclesiastes 1:9.)

The goal is to allow generic code. Or said differently, to code in a domain dependent fashion. And to do it with as little pain as possible. Let's start with a commonly generified structure: arrays. And let's use standard templates/generics syntax:
class Array<Item> {
  Item get(Integer index) ...
}

// Declaring an instance.
Array<String> strings = ...;
With my idea, I could just treat them as different types:
class Item {}
class Array {
  Item get(Integer index) ...
}
I'm not getting too deep into syntax I might like to use for these examples. Instead, I'm staying approximately in Java land.

Here, Item is an abstract type (ignoring differences between classes, interfaces, and whatnot). And other types and functions in this module could use it just as easily. And it enforces no constraints, just as you might expect for the kinds of items you could put in an array.

In fact, this looks a lot like Lists in Java before generics came along, except that they reference the standard type Object. But how to make a specialization without explicit type parameters on Array? Easily enough:
Array<Item: String> strings = ...;
I'm usually a fan of named params anyway. Because this could get bulky, there might also be some syntax to allow positional arguments. And typedefs could also be handy for commonly used specializations.

Note also that we assume String can take the place of Item, so we're assuming structural typing or some such here, since String will not have been defined as a subtype of our domain-specific Item.

Of course, for more interesting situations (constrained generics), simply put other members in the types you want to use.

The overall idea is that when you are coding some module, just invent the types you need as you are going. Work in your own domain. Let the adaptation come later. (So, you might want to pay some attention to standard interface members, etc., but don't die over it.)

Wednesday, July 9, 2014

Three Aspects of God

When people debate the existence of God, I think there are at least three different aspects (semi or fully orthogonal dimensions) of discussion:
  1. God as creator. Did the universe just come about, or is there an intelligent designer behind it? (I'm not talking about 6-day creation specifically here.) This question is hard to resolve logically. On one hand, you have science that seems to make further and further progress answering questions that were previously just "God made it that way." On the other hand, however far the mechanisms get discovered, there are always more questions behind them of how things got to that point in the first place. And then there's the meta question of why anything exists at all (including either God or eternal inflation or whatever else).
  2. God who interacts. Is there some all-powerful, intelligent being who maintains active involvement with the universe and especially with people. Some entity that understands our language and can alter the natural course of events or, in some perspectives, maintain them. If I pray, can God enlighten me? Can God heal an illness or part the Red Sea? For many, this is an individual question who feel God's influence. My understanding is that some research exists on how people who pray or meditate or participate in church actively or other social groups might outlive or be happier than those that don't. That's vague enough, I'm not sure what can be said specifically on this matter based on research. Some believe they've seen miracles in their life. Some would say it's post-hoc analysis or selective attention. Also, if God is active and for some reason wants to stay hidden from scientific inquiry, could this being purposely choose only to be active in ways that aren't easily investigated? Maybe with occasional Red Sea partings or highly witnessed resurrections? (I reference Christian themes best because I know them best, but there might be others to consider.) And is it possible that God leaves memories of himself in us for delayed interaction. That is, do we interact with God's imprint rather than using some underlying faster-than-light universe-spanning interaction? Or if God does interact, does this being care about whether we are happy or not?
  3. God who defines right and wrong. There's no inherent meaning in objective science. Certain behaviors might lead to happier people or animals or plants or whatever, but who says people matter anyway? We could be coincidentally here, and if earth gets destroyed and we all die, oh well. So, what does it matter if we all kill and abuse each other to begin with? We don't want to do that too much, if social coordination promotes propagation, but it doesn't affect things being inherently right or wrong. If there are really such things are right and wrong, then there's some unchanging standard at the core of existence on which to base things.
Anyway, just having fun with these matters. I'm a fairly orthodox Latter-day Saint (Mormon), so it's not too hard to guess where I am on matters. But I still think it's worth considering different aspects of God when people discuss central matters, especially of God's existence. I've hopefully also raised enough matters to show it's not easy to say that logically the answer must be so-and-so.

Also, I'm sure that folks more familiar with classical theology or philosophy (from any part of the world) probably know more official terms for all of this. I'm not well versed in such things.

Sunday, June 22, 2014

English translation for "Placentero nos es trabajar"

As a missionary in Guatemala in 1995-1997, I wrote an English translation of the popular Spanish LDS hymn "Placentero nos es trabajar". This version is as literal as I could figure out how to make it while retaining rhyme and meter. I have to admit that even using recent Internet information, I have some trouble finding even the best translation ignoring the musical concerns for a few parts, but I've done my best anyway. The version here is updated some from my original effort. I'm actually working from memory right now, so it might vary some even from previous versions.

There seems to be some additional background on the song here and here.

Anyway, I hope this turns out to be of value to someone someday:

In the vineyard of Jesus our King,
Working hard is for us a delight,
And in honor we'll preach and we'll bring
To his people his law and his light.
For his light, for his light,
In the vineyard of Jesus our King,
For his light, for his light,
We will die in his work as we sing.

Listen ye to the word of the Lord,
With the loy'lty and fervor thereof,
And fore'er in your hearts do record
All his purity, truth, and his love.
With his love, with his love,
Listen ye to the word of the Lord.
With his love, with his love,
Take ye hold of the banner of God.

Oh, dear brothers and sisters, farewell,
For the moment to go now impends.
If in God we by faith perservere,
Past the veil we shall still meet again,
Meet again, meet again!
Oh, dear brothers and sisters, farewell!
Meet again, meet again.
With our God in his love we shall dwell.
 

Tuesday, June 3, 2014

Apple's Swift aimed at lock-in?

Well, the programming world's abuzz with Apple's announcement of their new programming language Swift. In their developer docs (not the iBook, since that's more effort to access), it says:
Swift is a new object-oriented programming language for iOS and OS X development. Swift is modern, powerful, and easy to use.
With no hint of open source, I suspect they truly mean "for iOS and OS X".

So, while it looks like a nice language, both in large things and small (though I don't agree with all their decisions), there's not much point in this language except for those already firmly in the Apple camp. This very nice system seems aimed squarely at making Apple developers more firmly just Apple developers.

And I distrust Apple as a corporation. Whatever prior art exists, I fear they'll have patents to dissuade 3rd-party implementations, unless they decide cooperation is in their business interests. Nice as it is, I guess I won't be touching it, unless Apple at some point makes a policy about being open with it.

Too bad. Though I do hope they prove me wrong sooner than later.

At least many other good options are already available.

(And on the topic of needing to be nice, I'm really just trying to say the issues that matter to me here. And I really would love Apple to prove me wrong.)

Friday, February 7, 2014

I should be nicer

I just realized my last two posts were in judgment of other people. That's not very nice of me, whatever I believe about the issues involved and whether or not anyone ever reads any of this. I apologize, and I should do better than that.

Wednesday, February 5, 2014

Bill Nye vs. YAGNI

So, here's a famous video of Bill Nye refuting himself:


Why do I say this? Well, he sets it up himself. The US is very successful at innovation despite a lot of people here disbelieving evolution. I don't know what percentage of successful innovators have which belief systems, but this presumed dichotomy exists in our nation.

A somewhat rational conjecture then is that you don't need belief in evolution to be able to innovate, at least in many areas. Even in areas where evolutionary or deep time matters do play a key role, there's perhaps no requirement for uniformity of belief in every aspect. There may even be scientifically testable hypotheses related to my conjectures. I suspect studies even exist, but this isn't my field.

Another way of saying this for me it is YAGNI. As in, belief in evolution isn't a key requirement for much innovation.

Meanwhile, Mr. Nye, you can have your own children if you want to teach them your world view. Or make more YouTube videos. Let me and everyone else teach our own children, too. And our children can also choose for themselves what to do with it. We have all kinds of various beliefs. That's freedom, rather than state indoctrination.

(Also note that I don't state my own beliefs about evolution in this post at all. They're irrelevant to my main point.)

Friday, November 15, 2013

Wolfram discovers OOP

Now, I'm probably being abusive here, but I think Wolfram is overblowing his value in his Wolfram Language announcement. When he says this:
In most languages there’s a sharp distinction between programs, and data, and the output of programs. Not so in the Wolfram Language. It’s all completely fluid. Data becomes algorithmic. Algorithms become data.
... I think this:
In contrast, the object-oriented approach encourages the programmer to place data where it is not directly accessible by the rest of the program. Instead, the data is accessed by calling specially written functions, commonly called methods, which are bundled in with the data.
... or perhaps even things like OpenDoc. He also sounds very Smalltalkish. I don't think he's talking Lisp-like code as data, but maybe he means that, too.

Saying "That there’s a completely general and uniform way to represent things" is also like saying "if S is a subtype of T, then objects of type T in a program may be replaced with objects of type S without altering any of the desirable properties of that program" (Liskov substitution principle).

Would Wolfram be the type to reinvent the wheel without full formal training in a subject matter? Um, yes.

I do love Wolfram Alpha, though.

Having algorithms is great, and for general web user accessibility, flexible language is nice, but when I want to be serious, I like a real programming language. And microkernel at that. Contrast Wolfram's statement that his "concept from the very beginning has been to create a single tightly integrated system in which as much as possible is included right in the language itself."

Hmm.

In more interesting news, Ceylon 1.0 was released a few days ago.