# January 4, 2011

## QuickConnect family Release for Windows, Linux, etc.

I have put together a QC 1.6 release for non-Mac users. It includes a jar file for QCNativeAndroid, files for QCPHP, QCErlang, and the 1.5 release of QCHybridAndroid. As soon as I can get to it I will be updating the hybrid iOS and hybrid Android environments to include the multi-threading now available in the native iOS and native Android environment. It will be interesting to see how the available threading effect what we can do in JavaScript.

# August 29, 2009

## QuickConnectiPhone 1.5.0 is now available

QCiPhone 1.5.0 has just been uploaded to sourceForge. They are saying that it may take about 15 minutes to become visible as the default download for OS X machines.

*A note to 3.0 API users.* The dashcode QC template no longer appears as an option. I am looking for ways to get it to show up again.*End*

Because of the 3.0 Dashcode changes I have not been able to update the Dashcode examples to the latest QC source. All of the Xcode examples are updated.

The release includes examples of how to use the video and audio tags in booth QCiPhone and QCMac applications.

QuickConnectMac 1.0 is also included in this release. It allows you to create hybrid applications that run on Mac machines just like you do for the iPhone and iPod touch.

QuickConnectPHP 1.0 is another template that can be used on the Mac side. It isn’t used to create hybrid applications but is used to create PHP web applications.

Also included, for those interested, is QCErlang 1.0. It is an updated version of an Xcode template for developing erlang applications. It includes auto-completes for most of the commonly used functions.

Defect fixes in this release include:

1. UIWebView no longer ends up with a black background after re-displaying the Default.png file while the page loads.

2. DataAccessObject in-browser database use fixed and updated to new methodology for the retention of which BCF in the stack is to be called next.

3. Updated the embedded map code to use the current data passing scheme from and to Objective-C

4. HTML Elements with touch events inside of Elements made scrollable no longer react to ontouchstart, ontouchmove, and ontouchend unless the event is not due to scrolling

# August 13, 2009

## QuickConnectErlang now available for OS X

The latest version of QuickConnectiPhone includes QuickConnectErlang in the installer. QCErlang uses an Xcode plugin to speed and ease Erlang development on OS X. The plugin is based on the great work of Jón Grétar Borgþórsson and his xcode erlang plugin. I have used it to create a project template for erlSim. erlSim is a massively parallel discrete event simulator written in Erlang.

The plugin allows you to run your Erlang application from within Xcode and all terminal input and output happen in the Xcode Debugger Console. Compilation errors and warnings are displayed as bubbles in the source code files just like all other Xcode project types.

The plugin is not as complete as I would like it. I am identifying and fixing defects related to Code Sense. Currently the functions in the standard modules such as io, math, etc. are not working correctly with code sense. Hopefully I can identify the underlying problem soon and it will be fully up and running.

The installer also includes a template for a standard Erlang application without the QuickConnectErlang framework if you want to go that route.

# November 28, 2008

## Why QuickConnect?

Recently in a response to a previous blog posting I was asked about what I see as the reason behind and the future of QuickConnect. I am posting my response here to make it easier for all to find.

Brad,

I have as yet not created a web page describing the intent of the QuickConnect platform. It basically comes down to this:

For the last 4 years I have been working on a framework implemented in multiple languages to speed up development of different types of applications. This is why you see QuickConnectPHP and QuickConnectYaws and will soon see QuickConnectJava and QuickConnectJ2EE. You don’t need them to write for the phone or the Mac but you may want to use them if you need to create a web application.

Why should an engineer/developer need to learn one framework for installed applications and another for web applications?

And why should an engineer/developer need to learn one framework to use in a web client and another for the server side of their web application?

And why again should this engineer/developer have to learn a different framework when moving from one language to another?

What I have attempted to do is to boil down all the engineering work I have been doing in the last 4 years to a lean, easy to use framework for multiple platforms, multiple situations, and multiple languages.

I can only hope that it will be of use to someone. I decided to make this work public since it has dramatically increased my productivity when writing apps.

Also, after years in the industry I came to teach in the Computer Information Technology department at BYU-Idaho. We teach the basics of the engineering behind QuickConnect to our undergraduates. This knowledge has given them a distinct advantage in the workplace when it comes to jobs so I felt it should be shared with a wider audience.

I hope this explains why I created QuickConnect.

# September 5, 2008

## erlSim Beta Released

erlSim, a discrete event simulator written in erlang, has been released and is available at

sourceForge.

This simulation engine takes advantage of erlang’s high concurrency and speed of execution. It also includes several random distributions that are typically used in simulations such as the triangular and normal distributions.

Included in the downloadable package are test harnesses for the simulation engine as well as some of the distributions. These distributions are a work in progress. Many of them have not even been run let alone tested. Those that have test harnesses should be working.

The intriguing idea behind using erlang as a discrete simulation environment is that each tool, object, person, etc. in the simulation could be an individual process. Or, if you wanted, each process that acts on simulation entities could be an erlang process. The engine doesn’t care how you chose to create your simulation.

# May 24, 2008

## Handling very large integers in Erlang

As mentioned in a previous post, Erlang appears to handle very large integers whose limit is RAM and other hardware limitations of the machine. In fact I have calculated 50,000! several times on my machine.

Multiplication, subtraction, and addition all work with these numbers without any programmer interference in Erlang. Division and other functionality uses the underlying OS functionality and so do not work with these large numbers.

I have written some code that allows division to work with these large numbers as well as a few other items such as m_choose_n, factorial, and floor. I have not spent time to evaluate speed optimizations for the code other than to use bit shifting to handle the actual division.

The division functions are:

- big_rem – similar to mod. It returns only the remainder of the division
- big_div_with_rem – returns both an integer quotient and remainder
- big_divide – returns a floating point value if it is possible to calculate it or an integer quotient and remainder if it is not possible

The code below is part of my simulation engine written in Erlang and is used in conjunction with the sim_dist library that contains random number distribution streams such as normal, binomial, negative binomial, and other types of streams the code for which will become available on sourceforge when I have finished testing it.

`%% Copyright 2008 Lee S. Barney`

```
```%% This file is part of erl_sim.

%% erl_sim is free software: you can redistribute it and/or modify

%% it under the terms of the GNU Lesser General Public License as published by

%% the Free Software Foundation, either version 3 of the License, or

%% (at your option) any later version.

%%

%% erl_sim is distributed in the hope that it will be useful,

%% but WITHOUT ANY WARRANTY; without even the implied warranty of

%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the

%% GNU Lesser General Public License for more details.

%%

%% You should have received a copy of the GNU Lesser General Public License

%% along with QuickConnectiPhoneHybrid. If not, see http://www.gnu.org/licenses/.

%% Description: This file contains functions for doing division with very large numbers as well as some other

%% useful functions

-module(sim_math).

%%

%% Include files

%%

%%

%% Exported Functions

%%

-export([big_divide/2, big_div_with_rem/2, big_rem/2, floor/1,

factorial/1, m_choose_n/2]).

%%

%% API Functions

%%

%%

%% TODO: Add description of div_with_rem/function_arity

%%

big_div_with_rem(Dividend, Divisor) ->

if

Divisor /= 0 ->

{ok,New_divisor,Cnt} = count_div_shifts(abs(Dividend), abs(Divisor), 0),

case big_div_with_rem_helper(abs(Dividend), abs(New_divisor),Cnt,0) of

{ok, Quotient, Remainder} when (Dividend < 0) xor (Divisor

{ok,-Quotient,-Remainder};

{ok, Quotient, Remainder} ->

{ok, Quotient, Remainder};

{error,Why} ->

{error,Why};

true ->

{error,"Unknown error"}

end;

true ->

{error,"Division by Zero error"}

end.

%%

%% TODO: Add description of big_divide/function_arity

%%

big_divide(Dividend, Divisor)->

%double limit. Erlang uses underlying system algorithms for floating point mathematics

Limit = math:pow(2,1023),

case big_div_with_rem(Dividend, Divisor) of

{ok,Quotient,Remainder} ->

if

Remainder == 0 ->

{ok, Quotient};

%the quotient must be less than the limit or else and error will happen

%when the result floating point value is added to it

%the remainder and the divisor must be less than the limit or else the

%division will fail.

Remainder < Limit andalso Divisor < Limit andalso Quotient

Result = Remainder/abs(Divisor),

io:format("Remainder/Divisor:~p Quotient:~p~n",[Result,Quotient]),

{ok, Quotient+Result};

true ->

{ok, Quotient,Remainder}

end;

{error,Why} ->

{error,Why}

end.

%%

%% TODO: Add description of big_rem/function_arity

%%

big_rem(A, B) ->

if

B /= 0 ->

{ok,New_divisor,Cnt} = count_div_shifts(abs(A), abs(B), 0),

case big_div_with_rem_helper(abs(A), abs(New_divisor),Cnt,0) of

{ok, Quotient, Remainder} when (A < 0) xor (B

{ok,-Remainder};

{ok, Quotient, Remainder} ->

{ok, Remainder};

{error,Why} ->

{error,Why};

true ->

{error,"Unknown error"}

end;

true ->

{error,"Division by Zero error"}

end.

%%

%% TODO: Add description of floor/function_arity

%%

floor(X) ->

T = trunc(X),

case X - T T - 1;

false -> T

end.

%factorial of N

factorial(N) ->

fact_helper(N, 1).

fact_helper(0, Product) ->

Product;

fact_helper(1, Product) ->

Product;

fact_helper(N, Product) ->

%io:format("N: ~p Product: ~p~n",[N, Product]),

fact_helper(N - 1, Product * N).

m_choose_n(M,N) ->

if

N > M orelse N < 0 orelse M 0;

true ->

factorial(M)/(factorial(N)*factorial(M-N))

end.

%%

%% Local Functions

%%

big_div_with_rem_helper(Dividend, Divisor, Count, Quotient) ->

%io:format("Dividend:~p Divisor:~p Count:~p~n",[Dividend, Divisor, Count, Quotient]),

if

Count

{ok, Quotient, Dividend};

true ->

if

Divisor =

big_div_with_rem_helper(Dividend-Divisor, Divisor bsr 1, Count-1, (Quotient bsl 1) +1);

true ->

big_div_with_rem_helper(Dividend, Divisor bsr 1, Count -1, Quotient bsl 1)

end

end.

`count_div_shifts(Dividend, Divisor, Cnt) ->`

if

Divisor =

count_div_shifts(Dividend, Divisor bsl 1, Cnt+1);

true ->

{ok,Divisor bsr 1, Cnt -1}

end.

# May 22, 2008

## Numeric Limitations in Erlang

The debugging process for the erlang distribution code continues. While debugging the binomial distribution last night I wrote a naive factorial calculator the code for which is common.

`%factorial of N`

```
```

`factorial(N) ->`

fact_helper(N, 1).

fact_helper(0, Product) ->

Product;

fact_helper(1, Product) ->

Product;

fact_helper(N, Product) ->

fact_helper(N - 1, Product * N).

Out of curiosity I started plugging in large numbers. The largest I have tried is 50,000! It took about 1.5 seconds to calculate and the result is much to large to post here. In fact, I was going to post it here but the number is too large to fit in the clipboard on my machine. Even if the sequence of digits was divided into 6 segments the segments still don’t fit in the clipboard.

This seems to indicate that for integer addition, subtraction, and multiplication the upper numerical bound is limited only by your hardware.

Division is different. It appears to use standard floating point type algorithms. Floating point numbers appear to have a limit similar to other languages and causes an error if the numbers are too large.

For example

`sim_dist:factorial(20)/sim_dist:factorial(19).`

yeilds 20 as expected.

`sim_dist:factorial(200)/sim_dist:factorial(199).`

** exception error: bad argument in an arithmetic expression

in operator '/'/2

throws a bad argument exception for the division operator. Floating point numbers therefor must have a maximum size that is less than 199!

An amazing language.

# May 19, 2008

## Erlang Simulation Testing Times

The Erlang simulation engine, which I now call erlSim, is running. I have some test results that show the concurrency capabilities of the Erlang language and the erlSim simulator.

Num Processes | Events per Process | Total Events | Seconds per Event | Total Time |
---|---|---|---|---|

1 | 1 | 10 | 0.000079900000 | 0.000799 |

5 | 1 | 50 | 0.000009260000 | 0.000463 |

1 | 10 | 100 | 0.000016520000 | 0.001652 |

25 | 25 | 6250 | 0.000014700640 | 0.091879 |

100 | 100 | 100000 | 0.000014360140 | 1.436014 |

200 | 200 | 400000 | 0.000015691415 | 6.276566 |

50 | 1000 | 500000 | 0.000015591182 | 7.795591 |

This information indicates that as the number of concurrent processes increases there is not a significant increase in the speed each process requires.

This data was generated on :

2.4 Ghz Intel Core 2 Duo

2 GB RAM

OS X MacBook

Erlang (BEAM) emulator version 5.6.1

This is looking very promising as a basis for discreet event simulations. I am working on a series of random number streams (triangular, normal, beta, etc.) to go with this basic engine. It is nearing completion for eight different random number stream types.

# May 16, 2008

## Erlang Simulator

Erlang is an interesting language. It appears to be hugely concurrent without threads in the language. It has its’ own strangeness such as the lack of variables, loops, etc. but overall very interesting.

I have created a modular discreet event simulation engine that takes advantage of the languages possibilities. It has allowed me to make full use of both cores on my machine and have thousands of concurrent simulation events executing. I have not noticed much of a per event execution penalty either. Very interesting.

I am looking forward to creating a factory scheduling simulation package based on this work.

There are now testing times available in this follow up entry

Erlang Simulation Testing Times.