11 Oct 2010

Programming Language Support to Succinct Code

In general, a programming language determines a general idea (semantics), how input data is transformed to output data, and a syntax, the rules how the the contemplation that adheres to the general idea, is written down. APIs don't usually determine syntax, but they do determine semantics.

Leaving a long introduction to aside, the point of this blog post is to point out that in addition to the number of compulsory semicolons, commas, braces, keywords, etc. the succinctness depends heavily on the statistical profile of the code. The number of characters that a construct, let's say, loop clause, function declaration keyword, call to some API subroutine or operator, etc. contributes to an application code depends on the number of times the construct is used in the application.

For example, a code that is written in Maple or Mathematica probably has considerably more calls to various symbolic calculation routines and statistics routines than software that controls industrial robots or runs a customer self service web site. This means that an inefficient, clumsy, API of more "complex" math routines does not have much of an impact on the succinctness of the code of the web application, but it has heavy impact on math intensive data analysis related code.

The conclusion is that one can not assess the succinctness support of a programming language or API without actually measuring the usage frequencies of its different parts in an "average" real life application.

Secondary conclusion is that API-s have to be updated, changed, after they have been in use for a little while and more is known about their "real life usage".

Third conclusion is that if some party comes up with some new technology, programming language, API, etc., then the aiding capability of that technology probably depends on the application domain. It's a bit like comparing antibiotics with a pain killer: taking a pain killer to treat infection might not give as good results as the antibiotics would give and vice versa.

25 Sept 2010

How to Differentiate Oneself in Business

Actually, as of September 2010 I don't know a firm answer to that question, but I think that the contemplation that leads to the hypothesis is probably inspiring.

Suppose we compare passenger cars that fit 2 to 5 passengers. Almost all of them have a staring wheel, 4 tyres, they're more or less of the same size and get the passengers from point A to point B. Usually they all get the job done, technically speaking, they're practically all the same, just switch the car on and drive. In an average non-highway commuting route the cars have roughly the same speed. Probably the skills of their development teams are also equal: an engineer from one of the companies can probably move to another company and be able to handle the job after about a year of learning.

However, obviously, there is a very big difference between Fiat, Mercedes, BMV, Toyota and Ferrari, despite the fact that they're all just cars that take roughly the same amount of fuel and get their passengers from point A to point B.

My hypothesis is that one way to differentiate something is to differentiate it in style, bias, not functionality or technically fundamental properties(i.e. a flying car or an amphibious car). There are different ways of achieving the same goal and there's always the matter of taste. It doesn't make sense to argue that apple juice is somehow better, more innovative, more effective, more functional, etc., than pear juice, but the two definitely differ and people have their preferences.

If the hypothesis held, the conclusion for me would be that even though I'm just an "average" software engineer/developer/whatever-nice-name and even though it probably is possible to find some other person that has at least as good or much "better" (whatever that means) skill set than I have, I can differentiate myself by the style of my software. For example, I can create software that solves a common problem that is already solved by my "competitors", but I can target people with certain habits or preferences, just like BMV and Toyota do it with their products.

Actually, it is also extremely simple to come up with totally UNIQUE products, ideas, by taking something that already exists and giving it A BIAS.  On can just pick anything one likes and quite randomly pick some field, let's say, gardening, military, medical aid, etc., and combine the two. Probability that a thing like this already exists on the market, is pretty low or if it's not low enough, combine something existent with 2 biases in stead of 1, etc.

Examples:
scissors -> gardening scissors,
tongs -> nut crackers,
cup -> coffee cup.

What regards to the business success of unique things, then that's probably subject to marketing and trial and error. After all, even the usefulness of cellphones was considered questionable at their early days. At early days of computing very few could imagine, how a house-wife or a teenager uses a computer, a personal one even, or that a granny needs a strong, military grade, cryptography for paying her utility bills from her living room, over a computer network.

For a halve joke I point out that what I've been describing in my current post is in line with the saying that every great scientist stands on the shoulders of giants. (I'm not a scientist, but development work is what software developers do.)


++++++++++++++++++++++++++

Added in May 2013: "Everything has been Done!

21 Sept 2010

About Domain Specific Algorithms and Software Development Labor

The point of this blog post is to claim that by inventing new programming languages it is not possible to eliminate the labour of describing domain specific algorithms.

For example, an assertion that a file that does not exist, can not be written to, holds regardless of programming language. It is possible for the language designer or library author to make sure that the file is automatically created, if it does not exist, but this is already a labour of describing a domain specific algorithm.

Another example is matrix multiplication. A programming language with its semantics determines the notation, i.e. multiply(a,b) or aTIMESb or a.times(b) or whatever, but someone, be it the hardware designer, programming language designer or a library designer, has to describe the essence of the matrix multiplication at least somehow. The various kinds of implementation details and optimizations do not change the fact that someone has to do actual development labour to get the multiplication to work.

In practice it entails that whenever a new programming language is designed, a new "standard library" is created, the very same work of describing the domain specific algorithms has to be done all over again, unless the previous descriptions are reused.

From intuitive point of view, and yes, according to my personal subjective taste and impressions, software development productivity depends a lot on the notation and semantics of the programming language. As of 2010 I believe that the preferences for a programming language (read: preferences for notation and semantics) is subjective and depends on the chooser's background.

By noticing that most programming languages that are in use in 2010, share a subset of common basic data types, namely arrays/vectors, hashtables, whole numbers, rational numbers, boolean values, I have a hypothesis that a probably withstandable, but imperfect, solution to the reuse and the notation-switch problem is to share memory space (the common data structures) between different programming language implementations. A program would start in one language, then, without exiting, switch to another programming language and then switch to whatever other programming language. The programming language switch regions might, probably would, contain data structure mapping code.

A vague, raw, preliminary, syntax example, where a hashtable named "symbolspace" is reserved in all language implementations:

# We'll start in Ruby
s=(4+5).to_s

LANGSWITCH to PHP

$s_output='The answer is'.$symbolspace['s']
echo $s_output

LANGSWITCH to JavaScript

s3="From PHP we've got:"+symbolspace('s_output')
document.write(s3)


I believe that the .NET and Java virtual machines allow that sort of functionality, but it won't work out socially, because Java got acquired by Oracle, .NET runs practically only on Windows (no, in 2010 the Mono won't do) and in the end many projects, like Haskell, Python, Perl, etc., have their mainstream implementations on "bare C or C++", not to mention the extra work that it would take to port them and how a single virtual machine implementation would limit developer creative freedom. May be a solution is a set of automatically inserted, language specific, library calls that dump and load the values of the common data structures to and from something like the Memcached.

I'll update/modify this article, if I have changed my mind on this or made a working implementation of the Memcached biased solution. So, this blog post will probably be modified.

13 Sept 2010

Array Indexing by Separators

In the case of arrays and strings one often needs to extract a sub part of them.

If one uses the indices of the virtual separators between and at the "edges" of the array elements in stead of the indices of the array elements themselves, one can eliminate conditional statements that check indices for critical values at the "edges" of the array.

Explanation by an example:

# Array indices:       0   1   2   3   4
               array=["H","e","l","l","o"]
# Separator indices: 0   1   2   3   4   5


#           0   1   2
GetSubarray(["H","e"],0,0)==[]         # 0-0=0
GetSubarray(["H","e"],0,1)==["H"]      # 1-0=1
GetSubarray(["H","e"],1,1)==[]         # 1-1=0
GetSubarray(["H","e"],1,2)==["e"]      # 2-1=1
GetSubarray(["H","e"],2,2)==[]         # 2-2=0
GetSubarray(["H","e"],0,2)==["H","e"]  # 2-0=2
GetSubarray(["H","e"],2,2)==[]         # 2-2=0


GetSubarray([],0,0)==[]          # 0-0=0

The thing to notice is, how it is possible to mark empty intervals, including the start edge of the string and the end edge of the string, by using the very same 2 indices that describe a substring start and end positions.

A more permanent version of this post resides here.

25 Jul 2010

The Meaning of Life

As of July 2010, I've come to a conclusion that the ultimate meaning of life, for me at least, is to have as much fun, entertainment, as possible. The amount of fun is equal to a definite integral of fun-power over time. The fun-power is never negative, but it is zero before birth and after death.

Why is that? Well, think of what would one do or want to do, if one could live forever and have perfect health all the time and one could just change one's capabilities, mental and physical, to whatever one wants to, except to remove the capabilities changing capability? What's left then? Entertainment and nothing else and the loss of fun and loved people around me would decrease the amount of entertainment. (Loss does not always have to mean death or "destruction". One does lose every-day objects without destroying them.)

So the way to maximize fun is to prolong one's life and to increase the fun-power. People differ in how they try to achieve that. For instance, some find it most efficient to rob or kill or just tease, if no one is capable of dying. Others find it beneficial to have an environment where everyone tries to treat others the way they self want to be treated. The idea being that one can better maximize one's own fun by not attending in a zero-sum like game, where the increase of one's own fun entails a decrease of someone else's fun. So, it takes quite a theory and skill to be happy in a paradise. :-)





++++++++++++++++++++

Update at 2013_04_27: There exists "The Meaning of life, Version 2".



20 Jul 2010

The Core of Software Development

In the context of this article a computer program is a function and a "description" means "function description". The computer program as a function gets some input, from wherever, and it produces some output, to wherever in whatever form. So, practically all of the time that software developers spend, is spent on the name of creating that function description.

Summary of the previous section: software is a function description, being a productive software developer means minimizing the time spent on creating the function description. That's the reason, why I speak of functions in this post. :-)

A function can contain a mixture of calls to other functions and to oneself. To minimize the time spent on the assembly of the function description(read: to be a more productive software developer), one aims to minimize the following parameters:


A) number of functions to describe;
B) "mean" number of function calls within a single function;


The point B also covers "simple things" like assignment operators, multiplications, additions, etc.

As we do not live in the world of infinitely fast Turing Machines, additional conditions of memory usage patterns, bandwidth usage patterns, "outer memory" access patterns,  algorithm complexity, hardware speed, energy consumption, sizes of various memories, etc. apply, but as of summer 2010 I believe that it really helps to keep the points A and B in mind while doing practical software development. Software design patterns, which in the end migrate from "pattern" status to programming language specification, are just fine-grained, time-dependent, details of the craft.

Cheers!!!

2 Mar 2010

JavaScript Closure by an Example


function func_c() {
var s_c1 = ' the word "funcy" means ';

function func_b() {
var s_b1 = "http://www.urbandictionary.com/define.php?term=funcy";

var func_a = function() {
var s_a1 = 'According to the <a href="'+
s_b1 + '">' + s_b2 + '</a>' +
s_c1 + s_c2 + s_this;
return s_a1;
} // func_a

var s_b2 = "Urban Dictionary"
return func_a;
} // func_b

var s_c2 = ' actually "trashy", but ';
var ff_a=func_b()
return ff_a;
} // func_c

var s_this = 'it sure sounds like "dirty" in a sexual context.';
var fun = func_c();
var s_sentence = fun();
document.write(s_sentence);


The example can be executed online over here and it outputs a string

According to the Urban Dictionary the word "funcy" means actually "trashy", but it sure sounds like "dirty" in a sexual context.

The thing to notice is how the variables, s_b1,s_b2,s_c1,s_c2,s_this are available to the function func_a, even when the func_a is called outside of the func_c. According to Justin Rogers that can cause memory leaks.

20 Feb 2010

About Physical Appearance, Clothing, hair Style and Preferences for sex Partners and Business Partners

This post probably just shows my stupidity and lack of social intelligence, but I am, what I am. So, in the evening of February, 19'th, 2010, I just wondered about 2 things. Well, may be 3 things, depends on how to look at it.

Firstly, why is it that even though I'm not that interested in sex and disqualify anyone, who is not able to provide me a stunningly intelligent conversation or does not leave me an impression that I can rely on his/her intelligence and understanding of the limits of this world, I still pay a great deal of attention to the physical appearance of him/her?

Like, I try to imagine, how he/she would be in bed, how I would cope with him/her in bed and that's with leaving sexual compatibilities like fast versus slow, etc, to aside. To me it seems that if I'm primarily looking for a sole-mate, then physical appearance shouldn't matter, but the fact is that it does matter. Actually, it even matters with my own case, but that's a different story, which can be handled by fixing the shortcomings, and I do take an assertion that before one loves anyone else, one has to love oneself, for granted.

The second thing that I started to wonder, is that why I still do not have my hair colored to blue, like the Estonian flag colour, and then have my pony-tail coloured black and white, giving blue-black-white, like the Estonian flag colours? One of the thoughts that might occur is that I won't "live it up", or, in Estonian: "kanna seda välja". Well, I think that that's not an issue, because I can be just like I am: dead-serious and deep-sceptical most of the time, without smiles, giving scary looks that are colder than ice, and then, suddenly, laugh from my heart so that people that drive by or whom I walk by, give me shy, but sincere, smiles. Strangely, I guess that the answer to this, the second, issue, is that I'm afraid that people might jump to conclusions that are not favourable to me and that might limit my possibilities to communicate with them in a manner that is favourable to me. Think business. Currently it seems to me that I have to get my business going well before I can afford such personal expressions. (NB! I guess that I just said it all. :)

Well, all in all, I came to a thought that the physical appearance (think of wearing a huge swastika on a back and front of ones T-shirt or drawn to the sides of ones' car) and physical interaction (like, sexually, but also "innocent" hugs, pats, etc.) is part of communication. As of 19.02.2010 that thought gives quite a new meaning to semiotics. To me it seems that the semiotics is all around us all the time, like applied art. One might even call it "applied semiotics", or, may be, I don't know, applied semantics? Semiotics in the context of hair dresses might be quite interesting. Or cars, the may-be-third thing that I started to wonder about. I mean, it does make a difference, if one rolls to or from a business meeting with a beetle, Harley-Davidson, limo or a tuned BMV.











The next thought from here is marketing. As a matter of fact I started to see ordinary, every-day, communication astonishingly differently during a series of marketing lectures that were part of a introductory business course that was held within the Mainori Kõrgkool and conducted by Mrs. Aet Kull. Aren't we doing marketing duering dates? As a matter of fact I've been comparing job interviews with (blind) dates since at least 2004. I find them remarkably similar.

In the context of this post, namely, "applied semiotics" point of view combined with my likes and dislikes, I find the George Michael's video, "Fast Love", very interesting.




23 Jan 2010

My Personal Programming Skills Enhancement Strategy Since January 2010 till ... I Come up With some Better idea

In the end source code is a series of bits that tells the computer, what to do. No matter, what the methodology, be it functional, OO, logic, procedure oriented, etc.

So, putting those 2 claims together, I'm looking for a NOTION, how to EXPRESS myself as concisely as possible, while keeping the rule set as simple and concise as possible. After I've figured that out (there are probably very many different possibilities), I can start to think about the compromises that are probably needed in order to use the currently existing technologies. For instance, I will probably need to use JavaScript for browser side software development, PHP for server side development, C++ for systems programming, etc.

So, it's a conquest for language development. And, by the way, doesn't the real, natural, languages pose exactly the same problem? As of January 2010 I think that they do.

It seems to me that predicate logic is quite inspiring, if just something similar could be defined for cases, where OO or loops or conditional sentences are used. May be one key-phrase is also “order-sorted logic”, whatever that means. (As of January 2010 I still need to learn the “order-sorted logic” stuff.)

So, finding a concise way to express myself is definitely something that I as a programmer need quite direly. I think that I'm not going to make it successfully without that knowledge, but the programming language that I have tried so far, mainly Ruby, C++, Java, Delphi, JavaScript, PHP, but also Prolog, a little bit of Haskell and Clean (and a bunch of others that I've just tasted a little bit), just “don't cut it”. I don't know Scala yet, but according to the introduction it seems to be just another morphism of the existing OO and functional technologies.

Now, one thing that I definitely do know is that the size of vocabulary that I'm able to remember is limited. This infers that the most concise solution, where one just assigns one number to a whole program or code block, is not usable by me.

The search for a solution is probably by trying to manually translate an existing, production, system to that concise version and to see, what constructs there exist. Practically, one tries to do some very wild refactoring, identify the common parts, etc., but without the limitation of a concrete syntax, as the syntax is the one that is being searched for. Also, for every part of the production system, one also analyzes the REASON, why the code segment is necessary, why it has been written in the first place and is it possible to just eliminate the reason, refactor the “reason” out of the code or to do the search for common parts in the context of the “reasons”. For instance there's no reason to install light switches to lights that are in places that do not receive any light from windows and are lit up by energy saving LED light bulbs.

It seems that the ideal specification for the new language is something that is not laborious to implement in the currently existing programming languages. It should be something like the ProgFTE specification. May be some kind of an interpreter that can be very easily and efficiently implemented in JavaScript, PHP, Ruby, etc. and then the software that has been written in that new languages can run truly everywhere. IN PRACTICE. For example, the Java runs only in places where the Java language developers have taken the great effort to port it to. I, for instance, do not always have the luxury of choosing a programming language by myself, because due to the amount of labor my software, very often, has to interface with some legacy parts or just parts that have been written by others or even by myself. Typical cases: GUI, network, sound, hardware access, file access, image file format reading, etc.