Angel \”Java\” Lopez on Blog

May 18, 2012

Parallel Programming: Links, News And Resources (2)

Filed under: Concurrency, Links, Parallel Programming, Programming — ajlopez @ 8:26 am

Previous Post

More links about this interesting topic. I think parallel programming is the way to explore new algorithms, specially in artificial intelligence and distributed computing.

Dryad – Microsoft Research
http://research.microsoft.com/en-us/projects/Dryad/

Ville Tuulos on Big Data and Map/Reduce in Erlang and Python with Disco
http://www.infoq.com/interviews/tuulos-erlang-mapreduce
Ville Tuulos talks about Disco, the Map/Reduce framework for Python and Erlang, real-world data mining with Python, the advantages of Erlang for distributed and fault tolerant software, and more.

ICSE 2011: Danny Dig – Retrofitting Parallelism into a Sequential World
http://channel9.msdn.com/posts/ICSE-2011-Danny-Dig
Dr. Danny Dig is a Principal Investigator at the Universal Parallel Computing Research Center (UPCRC Illinois). UPCRC’s stated mission is to make parallel programming synonymous with programming.

Patterns for Parallel Programming: Understanding and Applying Parallel Patterns with the .NET Framework 4
http://www.microsoft.com/en-us/download/details.aspx?displaylang=en&id=19222
A document providing an in-depth tour of implementing a variety of parallel patterns using the .NET Framework 4.

Haskell: First results from GHC’s new garbage collector
http://hackage.haskell.org/trac/ghc/blog/new-gc-preview
For a number of months now, we have been designing and developing a new garbage collector for GHC, with the primary goal of improving scaling on multicores.

Actor-based Programming
http://www.infoq.com/presentations/Actor-based-Programming
Jamie Ridgway explains what actors are, why we need them, what they are helpful for, the languages built around this programming paradigm, along with some demos showing actor-based apps.

Functional Programming eXchange 2011: Simon Peyton Jones on Managing parallelism: embrace diversity, but control side effects
http://skillsmatter.com/podcast/scala/talk-by-haskell-expert-simon-peyton-jones
If you want to program a parallel computer, it obviously makes sense to start with a computational paradigm in which parallelism is the default (ie functional programming), rather than one in which computation is based on sequential flow of control (the imperative paradigm). And yet, and yet … functional programmers have been singing this tune since the 1980s, but do not yet rule the world.

Articles on Parallel Programming with the .NET Framework 4
http://www.microsoft.com/en-us/download/details.aspx?displaylang=en&id=12594
A set of articles that provide information on parallel programming with the .NET Framework 4.

Dynamic parallel async requests in MVC
http://petemontgomery.wordpress.com/2011/05/12/dynamic-parallel-async-requests-in-mvc/
Thanks to AsyncControllers, it’s quite easy to make several asynchronous requests in parallel to different web services, and have MVC gather the results.

GPars
http://gpars.codehaus.org/
Groovy Parallel Systems
The GPars framework offers Java developers intuitive and safe ways to handle Java or Groovy tasks concurrently. Leveraging the enormous flexibility of the Groovy programing language and building on proven Java technologies, we aim to make concurrent programming for multi-core hardware intuitive, robust and enjoyable.

InfoQ: Parallel Programming Patterns: Data Parallelism
http://www.infoq.com/presentations/Parallel-Programming-Patterns
Ralph Johnson presents several data parallelism patterns, including related Java, C# and C++ libraries from Intel and Microsoft, comparing it with other forms of parallelism such as actor programming.

Task Parallel Library: 5 of n – CodeProject
http://www.codeproject.com/KB/cs/Tasks5.aspx
A look into using the Task Parallel Library.

Mired in code: Easy parallel processing in Clojure
http://blog.mired.org/2011/03/easy-parallel-processing-in-clojure.html
For those not familiar with it, the eight queens problem is to place eight queens on a chess board such that none of them are attacking each other. Since queens attack in eight directions, this means that none of them are in the same row or column, and that none of them share a diagonal. It’s interesting, but not incredibly difficult, to do this.

W. Daniel Hillis
http://en.wikipedia.org/wiki/W._Daniel_Hillis
William Daniel "Danny" Hillis (born September 25, 1956, in Baltimore, Maryland) is an American inventor, entrepreneur, and author. He co-founded Thinking Machines Corporation, a company that developed the Connection Machine, a parallel supercomputer designed by Hillis at MIT. He is also co-founder of the Long Now Foundation, Applied Minds, Metaweb, and author of The Pattern on the Stone: The Simple Ideas That Make Computers Work.

Scala Team Wins ERC Grant | The Scala Programming Language
http://www.scala-lang.org/node/8579
The Scala research group at EPFL is excited to announce that they have won a 5 year European Research Grant of over 2.3 million Euros to tackle the "Popular Parallel Programming" challenge. This means that the Scala team will nearly double in size to pursue a truly promising way for industry to harness the parallel processing power of the ever increasing number of cores available on each chip.

Organizing Functional Code for Parallel Execution; or, foldl and foldr Considered Slightly Harmful
http://vimeo.com/6624203
Guy L. Steele, Jr.; Sun Microsystems
International Conference on Functional Programming (ICFP)
Edinburgh 2009
ACM SIGPLAN

InfoQ: How to Think about Parallel Programming: Not!
http://www.infoq.com/presentations/Thinking-Parallel-Programming
Guy L. Steele Jr. believes that it should not be the programmer’s job to think about parallelism, but languages should provide ways to transparently run tasks in parallel. This requires a new approach in building languages supporting algorithms built on independence and build-and-conquer principles rather than on linear decomposition of problems.

Parallel Programming with .NET
http://blogs.msdn.com/b/pfxteam/
All about Async/Await, System.Threading.Tasks, System.Collections.Concurrent, System.Linq, and more…

await anything;
http://blogs.msdn.com/b/pfxteam/archive/2011/01/13/10115642.aspx
One of the very cool things about the new await keyword in C# and Visual Basic is that it’s pattern based.  It works great with Task and Task<TResult>, and awaiting those two types will represent the vast majority of uses, but they’re by no means the only types that can be awaited.  The languages support awaiting any instance that exposes the right method (either instance method or extension method): GetAwaiter.

Professional Parallel Programming with C#: Master Parallel Extensions with .NET 4 (Wrox Programmer to Programmer)
http://www.amazon.com/Professional-Parallel-Programming-Master-Extensions/dp/0470495995

No Callbacks Required: StratifiedJS Returns Sequential Programming to Javascript
http://www.infoq.com/articles/stratifiedjs
Javascript is fundamentally single threaded, no parallel threads in sight. Asynchronous programming is necessary for any task that might block; Javascript programming usually involves creating and passing around a lot of callbacks, essentially forcing the developer to manually translate sequential code into continuation passing style.

Parallelism: In the Cloud, Cluster and Client
http://blogs.msdn.com/b/amit_chatterjee/archive/2010/12/19/parallelism-in-the-cloud-cluster-and-client.aspx
Software and digital experience is now becoming ubiquitous in our lives. Software is everywhere – it is stocking supermarket shelves, delivering electricity and water to our homes, storing our personal information in computers around the world, running nuclear plants and even controlling doomsday weapons! Moreover, with the popularity of the Internet and mobile devices, and with the advances in graphical and natural user interfaces, the creative human minds and the innovative companies are making the digital age more personal, social and indispensible.
This is leading to three fundamental trends in the world today:
Data explosion – the phenomenal growth of raw digital data
Demand for computational power for transforming raw data into meaningful information
Exponential growth in the number of users getting on to the digital super highway

My Links
http://delicious.com/ajlopez/parallel

More links are coming.

Keep tuned!

Angel “Java” Lopez
http://www.ajlopez.com
http://twitter.com/ajlopez

April 27, 2012

Parallel Programming: Links, News and Resources (1)

Filed under: Concurrency, Links, Parallel Programming, Programming — ajlopez @ 8:12 pm

Next Post

Parallel programming, leveraging multicore processor, or even distributed machines, is an actual topic. Some of the links I read/collected about this topic.

Patterns for Parallel Programming: Understanding and Applying Parallel Patterns with the .NET Framework 4
http://www.microsoft.com/download/en/details.aspx?displaylang=en&id=19222

ztellman’s calx at master – GitHub
https://github.com/ztellman/calx
Calx is an idiomatic wrapper for OpenCL, which is an abstraction layer for parallel computation.

Workshop on Parallelism, and a “breakthrough” in combinatorial geometry
http://geomblog.blogspot.com/2010/11/workshop-on-parallelism-and.html

Back to (Parallel) Basics: Don’t Block Your Threads, Make Async I/O Work For You
http://www.hanselman.com/blog/BackToParallelBasicsDontBlockYourThreadsMakeAsyncIOWorkForYou.aspx

The Renaissance Virtual Machine
http://soft.vub.ac.be/~smarr/rvm-open-source-release/

smarr’s RoarVM at master – GitHub
https://github.com/smarr/RoarVM
RoarVM, formerly known as the Renaissance Virtual Machine (RVM) is developed as part of a IBM Research project to investigate programming paradigms and languages for manycore systems of the future.

YouTube – Clojure Demo
http://www.youtube.com/watch?v=CFCYVfApPUc&feature=share

Thinking about massively parallel Smalltalk
http://wiki.squeak.org/squeak/537

InfoQ: Functional Approaches To Parallelism and Concurrency
http://www.infoq.com/presentations/Functional-Approaches-To-Parallelism

Threading in C# – Free E-book
http://www.albahari.com/threading/
C# supports parallel execution of code through multithreading. A thread is an independent execution path, able to run simultaneously with other threads.

Helios: Heterogeneous Multiprocessing with Satellite Kernels
http://research.microsoft.com/apps/pubs/default.aspx?id=81154

Threading in C# – Part 5 – Parallel Programming
http://www.albahari.com/threading/part5.aspx
In this section, we cover the multithreading APIs new to Framework 4.0 for leveraging multicore processors:These APIs are collectively known (loosely) as PFX (Parallel Framework).

CRDTs: Consistency without concurrency control
http://pagesperso-systeme.lip6.fr/Marc.Shapiro/papers/RR-6956.pdf

The Weekly Source Code 56 – Visual Studio 2010 and .NET Framework 4 Training Kit – Code Contracts, Parallel Framework and COM Interop
http://www.hanselman.com/blog/TheWeeklySourceCode56VisualStudio2010AndNETFramework4TrainingKitCodeContractsParallelFrameworkAndCOMInterop.aspx

J-Machine Project Page
http://cva.stanford.edu/projects/j-machine/
The J-Machine is a fine grained concurrent computer designed by the MIT Concurrent VLSI Architecture group (now located at Stanford University) in conjunction with Intel Corporation.

Parallel Programming with Hints
http://bartoszmilewski.com/2010/05/11/parallel-programming-with-hints/
Wouldn’t it be nice to be able to write sequential programs and let the compiler or the runtime automatically find opportunities for parallel execution?

Beyond Locks and Messages: The Future of Concurrent Programming
http://bartoszmilewski.com/2010/08/02/beyond-locks-and-messages-the-future-of-concurrent-programming/

Parallelism in .NET – Part 18, Task Continuations with Multiple Tasks
http://reedcopsey.com/2010/07/19/parallelism-in-net-part-18-task-continuations-with-multiple-tasks/

InfoQ: Multicore Programming in Haskell
http://www.infoq.com/presentations/Multicore-Programming-in-Haskell

Microsoft Biology Foundation 1.0 Released
http://blogs.msdn.com/b/pfxteam/archive/2010/07/12/10037496.aspx

Designing Parallel Algorithms: Part 1
http://drdobbs.com/go-parallel/article/showArticle.jhtml?articleID=223100878

Dr.Dobb’s Go Parallel
http://drdobbs.com/go-parallel/

DataAllure: Hadoop for DNA sequence analysis
http://blog.dataallure.com/2010/04/hadoop-for-dna-sequence-analysis.html

A Pattern Language for Parallel Programming
http://www.infoq.com/presentations/Pattern-Language-Parallel-Programming
Ralph Johnson presents a pattern language that he and his colleagues are working on in an attempt to solve the hard issues of parallel programming through a set of design patterns: Structural Patterns, Computational Patterns, Parallel Algorithm Strategy Patterns, Implementation Strategy Patterns, and Concurrent Execution Patterns.

Back to (Parallel) Basics: Do you really want to do that? or Why doesn’t the new Parallel.For support BigInteger?
http://www.hanselman.com/blog/BackToParallelBasicsDoYouReallyWantToDoThatOrWhyDoesntTheNewParallelForSupportBigInteger.aspx

InfoQ: Billy Newport Discusses Parallel Programming in Java
http://www.infoq.com/interviews/billy-newport-parallel

Multi-core Parallelization in Clojure – a Case Study
http://www.slideshare.net/adorepump/multicore-parallelization-in-clojure-a-case-study

Patterns of Parallel Programming: A Tutorial on Fundamental Patterns and Practices for Parallelism
http://www.microsoftpdc.com/2009/Patterns-of-Parallel-Programming

The Design of a Task Parallel Library
http://research.microsoft.com/pubs/77368/TheDesignOfATaskParallelLibrary(oopsla2009).pdf

My Links
http://delicious.com/ajlopez/parallel

Keep tuned!

Angel “Java” Lopez
http://www.ajlopez.com
http://twitter.com/ajlopez

August 29, 2011

Lambda Calculus: Links, News and Resources (1)

Filed under: Functional Programming, Lambda Calculus, Links, Lisp, Programming — ajlopez @ 9:52 am

"Everything is a lambda in the end" ajlopez (past century)

http://en.wikipedia.org/wiki/Lambda_calculus

In mathematical logic and computer science, lambda calculus, also written as λ-calculus, is a formal system for function definition, function application and recursion. The portion of lambda calculus relevant to computation is now called the untyped lambda calculus. In both typed and untyped versions, ideas from lambda calculus have found application in the fields of logic, recursion theory (computability), and linguistics, and have played an important role in the development of the theory of programming languages (with untyped lambda calculus being the original inspiration for functional programming, in particular Lisp, and typed lambda calculi serving as the foundation for modern type systems).

Closures + Lambda = The key to OOP in Lisp « Learning Lisp
http://lispy.wordpress.com/2007/07/18/closures-lambda-the-key-to-oop-in-lisp/

Papers | Lambda the Ultimate
http://lambda-the-ultimate.org/papers

Notas sobre el Cálculo Lambda
http://ajlopez.zoomblog.com/archivo/2009/04/14/notas-sobre-el-Calculo-Lambda.html

Presenting AjLambda, lambda calculus in C#
http://ajlopez.wordpress.com/2009/02/25/presenting-ajlambda-lambda-calculus-implementation-in-c/

Funarg problem
http://en.wikipedia.org/wiki/Funarg_problem

The lambda calculus
http://faculty.knox.edu/dblaheta/research/lambda.pdf

Fixed point combinator
http://en.wikipedia.org/wiki/Y-combinator

Introducction to Lambda Calculus
http://www.cs.chalmers.se/Cs/Research/Logic/TypesSS05/Extra/geuvers.pdf

Introduction to Lambda Calculus
http://citeseer.ist.psu.edu/barendregt94introduction.html

Lambda Calculus
http://www.cs.bham.ac.uk/~axj/pub/papers/lambda-calculus.pdf

A Tutorial Introduction to the Lambda Calculus
http://www.utdallas.edu/~gupta/courses/apl/lambda.pdf

Knights of the Lambda Calculus
http://en.wikipedia.org/wiki/Knights_of_the_Lambda_Calculus

A Hacker’s Introduction to Partial Evaluation | The Lambda meme – all things Lisp, and more
http://www.ymeme.com/hackers-introduction-partial-evaluation.html

To Dissect a Mockingbird: A Graphical Notation for the Lambda Calculus with Animated Reduction
http://users.bigpond.net.au/d.keenan/Lambda/index.htm

http://www.defmacro.org/

λProlog Home Page
http://www.lix.polytechnique.fr/Labo/Dale.Miller/lProlog/

Church’s Type Theory
http://plato.stanford.edu/entries/type-theory-church/

Lambda Calculus Schemata
http://cs-www.cs.yale.edu/homes/fischer/pubs/lambda.pdf

Lambda Animator : animated reduction of the lambda calculus
http://thyer.name/lambda-animator/

Peter Selinger: Papers
http://www.mscs.dal.ca/~selinger/papers.html

Mike Taulty’s Blog : Anonymous Methods, Lambdas, Confusion
http://mtaulty.com/CommunityServer/blogs/mike_taultys_blog/archive/2009/01/28/anonymous-methods-lambdas-confusion.aspx

Lecture Notes on the Lambda Calculus (pdf)
http://www.mscs.dal.ca/~selinger/papers/lambdanotes.pdf

A Security Kernel Based on the Lambda-Calculus
http://mumble.net/~jar/pubs/secureos/

System F: Second-order lambda calculus
http://en.wikipedia.org/wiki/System_F

(Mis)using C# 4.0 Dynamic – Type-Free Lambda Calculus, Church Numerals, and more
http://community.bartdesmet.net/blogs/bart/archive/2009/08/17/mis-using-c-4-0-dynamic-type-free-lambda-calculus-church-numerals-and-more.aspx

Type-Free Lambda Calculus in C#, Pre-4.0 – Defining the Lambda Language Runtime (LLR)
http://community.bartdesmet.net/blogs/bart/archive/2009/08/30/type-free-lambda-calculus-in-c-pre-4-0-defining-the-lambda-language-runtime-llr.aspx

Jim McBeath: Practical Church Numerals in Scala
http://jim-mcbeath.blogspot.com/2008/11/practical-church-numerals-in-scala.html

My Links
http://www.delicious.com/ajlopez/lambda

Angel "AjLambda" Lopez

August 2, 2011

TDD: Links, News and Resources (1)

Next Post

You know, I’m a big fan of Test-Driven Development. I think that any production code should be written using TDD. These are some of my links.

TDD = Test-Driven Development
http://en.wikipedia.org/wiki/Test-driven_development

Test-driven development (TDD) is a software development process that relies on the repetition of a very short development cycle: first the developer writes a failing automated test case that defines a desired improvement or new function, then produces code to pass that test and finally refactors the new code to acceptable standards. Kent Beck, who is credited with having developed or ‘rediscovered’ the technique, stated in 2003 that TDD encourages simple designs and inspires confidence.[1]

Test-driven development is related to the test-first programming concepts of extreme programming, begun in 1999,[2] but more recently has created more general interest in its own right.[3]

Programmers also apply the concept to improving and debugging legacy code developed with older techniques.[4]

TDD for unbelievers | Agile Zone
http://agile.dzone.com/news/tdd-unbelievers

Real Developers Don’t Need Unit Tests
http://www.wakaleo.com/resources/presentations/288-real-developers-dont-need-unit-tests

Interaction-based testing and stable expectations – Vagif Abilov’s blog on .NET
http://bloggingabout.net/blogs/vagif/archive/2010/08/08/interaction-based-testing-and-stable-expectations.aspx

TDD Adoption Strategies Article | Agile Pain Relief
http://agilepainrelief.com/notesfromatooluser/2009/01/tdd-adoption-strategies-article.html

TDD adapted for mere mortals | Agile Zone
http://agile.dzone.com/news/tdd-adapted-mere-mortals

Purple Plutonium: Are TDD and Polyglot Programming a Poor Combination?
http://purpleplutonium.blogspot.com/2011/06/are-tdd-and-polyglot-programming-poor.html?spref=tw

HunabKu: C# OAuth for TESTardi
http://fabiomaulo.blogspot.com/2011/06/c-oauth-for-testardi.html

See? We Don’t Need a Database … Yet | xProgramming.com
http://xprogramming.com/articles/see-we-dont-need-a-database-yet/

But We Need a Database … Don’t We? | xProgramming.com
http://xprogramming.com/articles/but-we-need-a-database-dont-we/

The various meanings of TDD – Blog – Osherove
http://osherove.com/blog/2007/10/8/the-various-meanings-of-tdd.html

DirigidoPorTests
http://www.dirigidoportests.com/

Getting Started with TypeMock Isolator (in VS2010) | The McDev Blog
http://www.mcdev.za.net/2011/06/getting-started-with-typemock-isolator-in-vs2010/

Escribiendo mejores Test II
http://weblogs.javahispano.org/artesanodeprimera/entry/escribiendo_mejores_test_ii

Test Driven Development in PHP | Web Builder Zone
http://css.dzone.com/news/test-driven-development-php

How to Start Unit Testing .NET Projects: A Guide to Writing Unit Tests
http://www.typemock.com/unit-testing-dot-net

pyDoubles Framework | Test doubles framework for the Python platform
http://www.pydoubles.org/

planetgeek.ch» Clean Code and Clean TDD Cheat Sheets
http://www.planetgeek.ch/2011/01/04/clean-code-and-clean-tdd-cheat-sheets/

InfoQ: Representing Agile Testing
http://www.infoq.com/news/2011/04/representing-agile-testing

JavaScript: Unit testing asynchronous functions : Algorithms for the masses – julian m bucknall
http://blog.boyet.com/blog/javascriptlessons/javascript-unit-testing-asynchronous-functions/

Script Junkie | jQuery Test-Driven Development
http://msdn.microsoft.com/en-us/scriptjunkie/ff452703.aspx

andybeeching/qmock – GitHub
https://github.com/andybeeching/qmock
QMock is a standalone, lightweight mocking framework that facilitates the testing of JavaScript programs

QUnit – jQuery JavaScript Library
http://docs.jquery.com/QUnit

Script Junkie | Test Driven Development: Top-Down or Bottom-Up?
http://msdn.microsoft.com/en-us/scriptjunkie/gg650426.aspx

TDD for Managers with J.B. Rainsberger on Vimeo
http://vimeo.com/4396476

Test-Driven Development and Embracing Failure | Steve Freeman
http://www.m3p.co.uk/blog/2011/04/25/tdd-embracing-failure/

My Links:
http://www.delicious.com/ajlopez/tdd

My Posts:
http://ajlopez.wordpress.com/category/test-driven-development/

More links are upcoming.

Keep tuned!

Angel “Java” Lopez
http://www.ajlopez.com
http://twitter.com/ajlopez

June 28, 2011

Algorithms: Links, News, Resources (1)

Filed under: Algorithms, Programming — ajlopez @ 9:56 am

Sometimes, I found an article or paper about an algorithm, or a class of algorithms. These are some my recent discoveries:

Texture synthesis
http://en.wikipedia.org/wiki/Texture_synthesis#Patch-based_texture_synthesis

First results from GHC’s new garbage collector – GHC
http://hackage.haskell.org/trac/ghc/blog/new-gc-preview

Superformula
http://en.wikipedia.org/wiki/Superformula

FunctionSource: Path finding with Canvas
http://functionsource.com/post/path-finding-with-canvas

F# Code: Hindley Milner Type Inference Sample Implementation
http://fsharpcode.blogspot.com/2010/08/hindley-milner-type-inference-sample.html

What is Hindley-Milner? (and why is it cool?) – Code Commit
http://www.codecommit.com/blog/scala/what-is-hindley-milner-and-why-is-it-cool

compiler – implementing type inference – Stack Overflow
http://stackoverflow.com/questions/415532/implementing-type-inference

LEGO Mindstorms Rubik’s Cube Solver
http://tiltedtwister.com/index.html

Algorithmic Game Theory and Artificial Intelligence
http://agtb.wordpress.com/2011/01/15/agt-and-ai/

Eternity II Solver
http://www.shortestpath.se/eii/index.html

the { buckblogs :here }: Maze Generation: Growing Tree algorithm
http://weblog.jamisbuck.org/2011/1/27/maze-generation-growing-tree-algorithm

Sorting Obsession
http://pepijndevos.nl/sorting-obsession/

Las máquinas poéticas de los libros imaginarios (i): Raimundo Lulio (Spanish)
http://laexcepciondelaregla.wordpress.com/2010/01/05/las-maquinas-poeticas-de-los-libros-imaginarios-i/

How many numbers are squares mod m
http://www.johndcook.com/blog/2008/11/19/how-many-numbers-are-squares-mod-m/

Maze Generation: Prim’s Algorithm
http://weblog.jamisbuck.org/2011/1/10/maze-generation-prim-s-algorithm

Maze Generation: Kruskal’s Algorithm
http://weblog.jamisbuck.org/2011/1/3/maze-generation-kruskal-s-algorithm

The Craig Web Experience: Understanding the Halting Problem
http://www.cgl.uwaterloo.ca/~csk/halt/

Amazon.com: Protein Structure Methods and Algorithms (Wiley Series in Bioinformatics) (9780470470596): Huzefa Rangwala, George Karypis: Books
http://www.amazon.com/Protein-Structure-Methods-Algorithms-Bioinformatics/dp/0470470593

Algorithmia
http://algorithmia.codeplex.com/
Algorithm and data-structure library for .NET 3.5 and up. Algorithmia contains sophisticated algorithms and data-structures like graphs, priority queues, command, undo-redo and more.

Azul’s Pauseless Garbage Collector
http://www.artima.com/lejava/articles/azul_pauseless_gc.html

Rete Algorithm
http://en.wikipedia.org/wiki/Rete_algorithm

Next generation of algorithms inspired by problem-solving ants
http://www.physorg.com/news/2010-12-algorithms-problem-solving-ants.html

Langton’s Ant
http://www.youtube.com/watch?v=1X-gtr4pEBU

An Events Based Algorithm for Distributing Concurrent Tasks on Multi-Core Architectures
http://geonumerics.mit.edu/publications/FinalReport01.pdf

YouTube – What different sorting algorithms sound like
http://www.youtube.com/watch?v=t8g-iYGHpEA

To Trie or not to Trie – a comparison of efficient data structures
http://bhavin.directi.com/to-trie-or-not-to-trie-a-comparison-of-efficient-data-structures/

How to differentiate a non-differentiable function — The Endeavour
http://bhavin.directi.com/to-trie-or-not-to-trie-a-comparison-of-efficient-data-structures/

The greatest program ever written
http://www.kuro5hin.org/story/2001/8/10/12620/2164
http://users.ox.ac.uk/~uzdm0006/scans/1kchess/

My links:
http://www.delicious.com/ajlopez/algorithm

Angel "Java” Lopez
http://www.ajlopez.com
http://twitter.com/ajlopez

June 30, 2010

AjGenetizing an Application

Filed under: AjGenesis, Code Generation, Programming, Software Development — ajlopez @ 2:59 pm

Recently, I blogged about:

Code Generation with AjGenesis in a Real Project

In that real project, I applied what I say it’s “ajgenetizing” an application. What does it mean?

The basic idea is:

- Start writing a working application, that resolves your tech problems, like persistence, security, distribution, etc..
- Begin to discover the repetetive and/or “bored” parts: configuration files, project and solution files, directories, data access classes, logic classes, domain classes, other text files, etc…
- Extract an initial model: maybe, entities description with some tech parameters, like database to use, etc…
- Write tasks and templates to generate a similar application, automatically.
- Specify clearly, what text artifacts

- are re-generated each time the model changes
- are generated once, and then, it’s evolve manually
- are created manually

- Alter the model, and regenerate: all is still working.
- Write another model, to produce another application, but using the adquired knowledge (about logic implementation, and used technology).
- Another “litmus test”: change once of the selected technologies (data access to ORM, manual validation rules to validation framework, no IoC to IoC container, etc…), and test the “new” application

I could begin to write a serie of posts, adopting such approach. But I guess, a more “tutorial” approach is needed, for the current state of AjGenesis (lack of supporters, bloggers, etc..). The approach I will follow is: start with a minimal model, generate few files, and then iterate, commenting in detail the taken decisions.

Keep tuned!

Angel “Java” Lopez
http://www.ajlopez.com
http://twitter.com/ajlopez

January 9, 2009

The Clean Code Talks — Inheritance, Polymorphism, & Testing

Filed under: .NET, Programming, Software Development — ajlopez @ 8:55 am

I’m a fan of Twitter. One account I’m following to, is @delicious_prog, that sends many tweets each day, related to programming and software development in general. In one of that tweets, I found the post

The Clean Code Talks — Inheritance, Polymorphism, & Testing

by Daniel Wild, where he includes a Google Talk video:

by Misko Hevery in Google Tech Talks.

It’s very clear and interesting. It’s a talk explaining the uses of polymorphism, and the way to test it. I pleased to find in this video many similar arguments to the ones I use in my dev talks. Recently, I was using polymorphism in my AjCat interpreter (a cat-like programming language interpreter written in C#)

http://code.google.com/p/ajcodekatas/source/browse/#svn/trunk/AjCat

This is my Integer Binary Operation: 

public abstract class IntegerBinaryOperation : Expression { public abstract int Apply(int op1, int op2); public override void Evaluate(Machine machine) { int op2 = (int) machine.Pop(); int op1 = (int) machine.Pop(); machine.Push(this.Apply(op1, op2)); } }

The Add and Subtract operations override the Apply method:

public class IntegerAddOperation : IntegerBinaryOperation { private static IntegerAddOperation instance = new IntegerAddOperation(); private IntegerAddOperation() { } public static IntegerAddOperation Instance { get { return instance; } } public override int Apply(int op1, int op2) { return op1 + op2; } public override string ToString() { return "add_int"; } }
public class IntegerSubtractOperation : IntegerBinaryOperation { private static IntegerSubtractOperation instance = new IntegerSubtractOperation(); private IntegerSubtractOperation() { } public static IntegerSubtractOperation Instance { get { return instance; } } public override int Apply(int op1, int op2) { return op1 - op2; } public override string ToString() { return "sub_int"; } }

It’s very similar to the example presented in the video. I was a bit lazy in my operator implementation in AjPython (an interpreter, again, in C#, work in progress):

http://code.google.com/p/ajcodekatas/source/browse/#svn/trunk/AjPython

 

public class BinaryOperatorExpression : BinaryExpression { private Operator @operator; public BinaryOperatorExpression(Expression left, Expression right, Operator oper) : base(left, right) { this.@operator = oper; } public override object Evaluate(Environment environment) { object leftvalue; object rightvalue; leftvalue = this.Left.Evaluate(environment); rightvalue = this.Right.Evaluate(environment); switch (this.@operator) { case Operator.Add: return (int)leftvalue + (int)rightvalue; case Operator.Subtract: return (int)leftvalue - (int)rightvalue; case Operator.Multiply: return (int)leftvalue * (int)rightvalue; case Operator.Divide: return (int)leftvalue / (int)rightvalue; case Operator.Power: return System.Convert.ToInt32(System.Math.Pow((int)leftvalue, (int)rightvalue)); } throw new System.InvalidOperationException(); } }

but I’m confident in refactoring, I have a test base covering this operators.

It’s good to find this talk, I recommend it, thanks to @delicious_prog and Daniel Wild!

Angel “Java” Lopez
http://www.ajlopez.com/en
http://twitter.com/ajlopez

December 24, 2007

Genesis Studio: an IDE for AjGenesis

Filed under: .NET, AjGenesis, Code Generation, Programming, Software Development — ajlopez @ 9:05 am

Thanks to the excellent work of  Jonathan Cisneros, now we have an IDE to use with AjGenesis. Developed with CSharp2, it edits projects, model and template files, even with syntax color!!.

It’s an application, ready to use, without rough edges. It will evolve: Jonathan has some ideas for extensions, to complete its program.

You can download Genesis Studio from the group Code Generation page:

Code Generation Google Groups

or you can try this link. In that group there are many files to download, with new templates, models and examples. Genesis Studio is at:

It comes with source code, in a Visual Studio 2005 solution. It’s compilation is easy, it have all the required libraries:

With this application we can edit a project directory, its entities, model, technologies. Remeber, AjGenesis has a free model that you can define for each project. Genesis Studio can read and edit template ant task files.

Some options:

When you choose a project directory, a project explorer appears, showing folders and content:

XML, templates and task files have sintax color support:

 

My thanks to Jonathan Cisneros, for this useful application.

Code generation is technique that has power uses. In an technology change environment, with complex application, it is important to delegate the menial and repetitive tasks to the software itself.

Angel “Java” Lopez
http://www.ajlopez.com/en

November 12, 2007

Application Generation using AjGenesis

These days, I wrote new examples for my open source project AjGenesis

http://www.ajlopez.com/ajgenesis
http://www.codeplex.com/ajgenesis

Using AjGenesis, we can produce, starting from our own model, applications for ASP.NET 1.x/2.x, JSP, using SQL Server in .NET, with ADO.NET or NHibernate, or MySql with Java and Hibernate. The sample generated applications use a layered architecture (but remember: these are sample applications, you can write and use your own models, tasks, and templates). Other option: it can generate layers following ideas from Eric Evans’ Domain-Driven Design.

I’m still writing those examples, but now, you can download the current version from

AjGenesisExamples3New.zip

The examples require the use of AjGenesis last release:

AjGenesis Version 0.4.3

but you can try the current version under development:

AjGenesis Version 0.5

In this post, I want to comment how AjGenesis works and some of its inner structure, using one of those examples. Although I will concentrate in producing VB.NET code, you’ll find that the example is able to produce C Sharp and Java/JSP solutions, as well.

First, let’s review first some points about the project. The big picture:

AjGenesis Version 0.4.3 is written using VB.NET V1.x, but version 0.5 is the current version under development, and it was rebuilt using .NET 2.0. The project is open source, and has a BSD-like license, that allows to use it in any project what you want: you only need to comply with the license (in short, put some reference to the original project). It is possible to be used like a library, invoked from your own project, or it is possible to be invoked from command line, or even it can be used from using NAnt (this tool gives you a better organization of the code generation tasks).

There are several samples in the page of the project (inside the project zip source file and in additional files). They generate code from a model, invoking tasks and processing templates. The samples generate code PHP, Java, JSP, VB.NET, C#, ASP.NET, and even scripts of procedure and data base stored. I want to emphasize two points:

- The model to use is totally definible by you. It’s a free model, it’s not a fixed one. You can model what you want to model.

- The tasks and templates to apply are totally programmable and controlable. You are in charge. 

That’s make a difference from other generators. We can create our own model, and its own templates and tasks, to generate any text artifacts. Other systems start from the data base, and they only generate a group of predefined text files (as POJOs, plain old java objects, or DAOs, Data Objects Access). But with AjGenesis you can generate any text file you need.

In order to better understandind the free model concept, read a previous post:

Generating Code Hello World with AjGenesis

In that post, the initial steps are described, using a free model, totally oriented to the domain to represent: a typical Hello World application, implemented in different technologies.

Creating an application

Let’s do something more complete in this post. Suppose we need to create a simple solution simple, with two tables, in a MS SQL Server databse, source code in VB.NET 2,0, web interface, layer of services, layer of data, business components and business entities a la Microsoft. We want to generate the solution, the projects, scripts for database creation, and stored procedures. This example is included in the examples AjGenesisExamples3New.zip. First step: to write the model.

The project

In a directory of projects of the examples that accompany this article, there is a Projects/AjFirstExample directory.

In that directory it is the Project.xml file that contains the model.

<Project>
    <Name>AjFirstExample</Name>
    <Description>First Example
    using AjGenesis</Description>
    <Prefix>AjFE</Prefix>
    <Domain>com.ajlopez</Domain>
    <CompanyName>ajlopez</CompanyName>
    <Model>
        <Entities>
            <Entity
            Source="Entities/Customer.xml"/>
            <Entity
            Source="Entities/Supplier.xml"/>
        </Entities>
    </Model>
</Project>

Remember: the model is free. Here we define the templates that we are going to use. The model contains two simple entities: customers and suppliers.

The entities

The XML file is not terribly long: AjGenesis allows that any node of the model is specified apart in a file. This is a criterion that I have used to define how the model is written: the resulting XML does not have to hurt at sight, must be understandable and abarcable in a reading.

In the Project.xml, that feature is used in the case of the entities, with the Source attribute. Let us examine an entity, written in Entities/Customer.xml:

<Entity>
    <Name>Customer</Name>
    <Description>Customer Entity</Description>
    <SetName>Customers</SetName>
    <Descriptor>Customer</Descriptor>
    <SetDescriptor>Customers</SetDescriptor>
    <SqlTable>customers</SqlTable> 

    <Properties> 

        <Property>
            <Name>Id</Name>
            <Type>Id</Type>
        </Property> 

        <Property>
            <Name>Name</Name>
            <Type>Text</Type>
            <SqlType>varchar(200)</SqlType>
        </Property> 

        <Property>
            <Name>Address</Name>
            <Type>Text</Type>
            <SqlType>text</SqlType>
        </Property> 

        <Property>
            <Name>Notes</Name>
            <Type>Text</Type>
            <SqlType>text</SqlType>
        </Property> 

    </Properties>
</Entity> 

There are attributes of the entities, like its name and description, in plural and singular. This data serve to name them in the resulting pages, or within the code. The properties are the fields to maintain in each entity..

Aside from the entities, in another directory, Technologies, specifies the dependent model of the technology, like VbNet2:

The templates

The templates to use are at the Templates/VbNet2 directory:

They are the templates for generation of code VB.Net 2.0. Also we will find groups for C# 1/2, Vb.NET 1,2, Java (although I’m thinking to drop templates for .NET 1.x: I don’t see any reason to maintain these). There are templates to use Nhibernate, Hibernate, JSP, MySql, and concepts of Domain-Driven Design, too. Let’s review a template as an example, the one that generates the organization in Visual BASIC, EntityVb.tpl:

<# 

message "Generating Entity ${Entity.Name}" 

include    "Templates/VbNet2/VbFunctions.tpl" 

include    "Templates/VbNet2/Prologue.tpl"
#> 

'
'    Project ${Project.Name}
'        ${Project.Description}
'    Entity    ${Entity.Name}
'        ${Entity.Description}
'    
'

Public Class ${Entity.Name} 

'    Private Fields

<#
for each Property in Entity.Properties
    message    "Procesando Campo ${Property.Name}"
#>
    Private m${Property.Name} as ${VbType(Property)}
<#
end for
#> 

'    Default Constructor

    Public Sub New()
    End Sub 

'    Public Properties

<#
for each Property in Entity.Properties
    message    "Procesando Propiedad ${Property.Name}"
#>
    Public Property ${Property.Name}() as ${VbType(Property)}
        Get
            Return m${Property.Name}
        End Get
        Set(ByVal Value As ${VbType(Property)})
            m${Property.Name} = Value
        End Set
    End Property
<#
end for
#> 

End Class 

Like before, control structures are used. XML is the serialized format of the model. During the code generation process, the model is loaded in memory, ready to be accesible via dynamic variables.

The steps

We have more files to generate: from the pages ASPX, and their associated code, the projects of facade on watch, organizations, access to data, the file of solution, and more. In order to automate this generation, the example has several files of tasks, in the Tasks directory, where the steps are described to execute. There are two great tasks: the steps to execute independently of the chosen technology, like completing the model, reviewing it, and the employees of the technology, like generating such file JSP or ASPX, depending on if we want Java or .NET.

The task of completing the model is in charge of Tasks\BuildProject.ajg, that begins with:

'
' Build Project
'    Complete the Project Data
'    Project must be loaded in global variable Project
'

PrintLine "Completing Project ${Project.Name}" 

include "Templates/EntityFunctions.tpl"
include "Templates/Utilities.tpl" 

if not Project.Title then
    Project.Title = Project.Name
end if 

if not Project.Version then
    Project.Version = "1.0.*"
end if 

if not Project.SystemName then
    Project.SystemName = Project.Name
end if 

The template includes some auxiliary functions, and then, it begins to complete the model that resides in the Project variable. For example: if the project lacks Project.Title the program set Project.Name as Project.Title. The program continues:

for each Entity in Project.Model.Entities
    PrintLine "Entity " + Entity.Name 

    for each Property in Entity.Properties
        PrintLine "Property " & Property.Name
        if Property.Type="Id" and not Property.SqlType then
            Property.SqlType="int"
        end if
        if Property.SqlType and not Property.SqlColumn then
            Property.SqlColumn = Property.Name
        end if
        if Property.Type="Id" and not Entity.IdProperty then
            Entity.IdProperty = Property
        end if
        if Property.Reference then
...

After that process, the technology tasks are executed. The example use Tasks\BuildVbNet2.ajg, here a fragment:

<# 

include "Templates/Utilities.tpl"
include "Templates/VbNet2/UtilitiesVb.tpl" 

message "Creating Directories..." 

FileManager.CreateDirectory(Project.BuildDir)
FileManager.CreateDirectory("${Project.BuildDir}/Sql")
FileManager.CreateDirectory("${Project.BuildDir}/Src/${Project.Name}.Entities")
FileManager.CreateDirectory("${Project.BuildDir}/Src/${Project.Name}.Entities/My Project")
FileManager.CreateDirectory("${Project.BuildDir}/Src/${Project.Name}.Data")
FileManager.CreateDirectory("${Project.BuildDir}/Src/${Project.Name}.Data/My Project")
FileManager.CreateDirectory("${Project.BuildDir}/Src/${Project.Name}.Services")
FileManager.CreateDirectory("${Project.BuildDir}/Src/${Project.Name}.Services/My Project")
FileManager.CreateDirectory("${Project.BuildDir}/Src/${Project.Name}.Business")
FileManager.CreateDirectory("${Project.BuildDir}/Src/${Project.Name}.Business/My Project")
FileManager.CreateDirectory("${Project.BuildDir}/Src/${Project.Name}.WebClient")
FileManager.CreateDirectory("${Project.BuildDir}/Src/${Project.Name}.WebClient/App_Themes")
FileManager.CreateDirectory("${Project.BuildDir}/Src/${Project.Name}.WebClient/App_Themes/Default")
FileManager.CreateDirectory("${Project.BuildDir}/Src/${Project.Name}.WebClient/Admin")
FileManager.CreateDirectory("${Project.BuildDir}/Src/${Project.Name}.WebClient/Controls")
FileManager.CreateDirectory("${Project.BuildDir}/Src/${Project.Name}.WebClient/MasterPages")
FileManager.CreateDirectory("${Project.BuildDir}/Src/${Project.Name}.WebServices")
FileManager.CreateDirectory("${Project.BuildDir}/Src/${Project.Name}.RemoteServices") 

message "Defining Solution and Projects..." 

...

In this fragment, the directories necessary are created to lodge the solution. The name of the directory is extracted of the model from Project.BuildDir. Note that ${ } in a string is used to expand the inside expression into the string value.

Technology Model

Under the directory Project\AjFirstExample\Technologies they are some models that describes the technology parameters to use:

 

Let’s examine VbNet2.xml:

<Technology>
    <Programming>
        <Dialect>VbNet2</Dialect>
    </Programming>
    <Database>
        <Dialect>MsSql</Dialect>
        <Name>AjFirstExample</Name>
        <Username>sa</Username>
        <Prefix>ajfe_</Prefix>
        <Host>(local)</Host>
    </Database>
</Technology>

These data is used during the template generation phase. It indicates the language, and the database to use.

Generating the solution

We could send the tasks from the command line, but we have a .build file for Nant, one for each technology to generate. We execute the tasks build, buildsql, and deploysql of AjFirstExampleVbNet2.build with the command line:

nant -buildfile:AjFirstExampleVbNet2.build build buildsql

(You must adjust the line

<property name=”ajgenesis.dir” value=”…./AjGenesis-0.5″/>

to reflect your AjGenesis installation directory)

Note the following lines in the build file:

    <target name="loadtasks" description="loads AjGenesis tasks">
        <loadtasks assembly="${nanttasks.dir}/AjGenesis.NAnt.dll" />
    </target> 

    <target name="init" depends="loadtasks" description="init the AjGenesis model, create build directory">
        <mkdir dir="${build.dir}"/>
        <loadmodel model="${project.dir}/Project.xml"/>
        <loadmodel model="${project.dir}/Technologies/${technology}.xml"/>
        <executetask task="${tasks.dir}/BuildProject.ajg"/>
        <executetask task="${tasks.dir}/BuildTechnology.ajg"/>
    </target> 

These tasks load an AjGenesis NAnt tasks, load the models, and execute the tasks.

In the Build/AjFirstExample/VbNet2/Sql directory they are left scripts of creation of the base and stored procedures. And in the directory Src brother, surprise! We’ll have the generated solution:

There were generated several projects, into a solution. We can load the solution into the Visual Studio 2005:

Using another NAnt file, AjFirstExampleCSharp2.build, we can generate the same solution in CSharp:

You will find other projects and examples of .build files, that generate solutions using NHibernate, Hibernate use, JSP, and concepts of Domain-Driven Desing a la Eric Evans.

Reflections

Sure, everything cannot be generated automatically. It is important to remember always that fact. But in the day to day, we recognize that we have amount of repetitive text, tasks that we can well delegate to software.

A key point: the model in AjGenesis is free. The presented examples are only examples: we can general the model that we want, and to write the templates we need. It is important to write the templates so that the generated code is similar to what we had manually generated. If we don’t feel comfortable with the generated code, if it does not have our style, our experience, we’ll end up generating something that we do not understand.

Another thinking: the model must be independent of the technology. In the final example, we have seen how, from the same model, we can generate solutions for VB.NET, CSharp and other technologies.

Software can help us to generate software. More: it MUST help us. Our experience counts: what we learned to make applications, we can overturn it in this species of expert system, code generation tools. In the future, I hope to be able to incorporate to the project, in the templates and tasks, more decision making: as well as we gain experience in writing of applications, we can incorporate our accumulated knowledge on patterns, architecture and styles of programming.

And as it is an open source project, AjGenesis allows us extend it, to our taste and necessity.

Suggestions, use case stories, comments are welcome. You can write as comments to this post, or write directly to me. Thanks to all that tested and adopted this project, and helped me to write it.

Angel “Java” Lopez
http://www.ajlopez.com/en

June 18, 2007

Installing Squeak

Filed under: Programming, Smalltalk — ajlopez @ 12:06 pm

In the last century, sometimes I was studying Squeak. Now, in these days I have returned to visit it, and wanted to write a simple, introductory article, on its easy installation.

Squeak is an open source implementation of Smalltalk, that has been developed for years. The internal implementation of its virtual machine is interesting, to a great extent written in Smalltalk, with tools to produce its own virtual machine.

Like in other implementations, one needs to install the virtual machine of the operating system that will use. In this article, we will install a version (the 3,9) for Windows. Also we will need an image, a file with the state of the active instances. Smalltalk has been characterized from always, by being able to write and to raise an image, a species of “snapshot” of the state of the system.

The page of Squeak is

http://www.squeak.org

For somebody not warned of the existence of virtual machines and images, it is a little confused explanation of its installation:

http://www.squeak.org/Download/

because there are several options. For example, to lower the versions from

http://ftp.squeak.org

But there is multitude of archives. The one that we are going to use is a file .zip that contains the virtual machine for Windows and image 3,9 (at the moment already there is a developing image 3,10), directly from:

http://ftp.squeak.org/3.9/win/Squeak3.9-win32.zip

This file contains:

We see a Squeak.exe, that it is the feasible virtual machine. The SqueakV39.sources file is of text, of more than 4 megas of size. It contains the source code of the classes that compose this version. The file Squeak3.9-end-7067.image is the image, “snapshot” that contains the instances of this system.

We can expand the content of this .zip in a directory, and make double click on the feasible one of the virtual machine Squeak.exe. Automatically it detects the image. Alternatively, we could drag from the Explorer de Windows the file image on the file .exe. It appears our first welcome to the Squeak world:

All within this window, is created by the own Squeak. Following the tradition of the original Smalltalk, the graphical aspect, the controls, windows, and others “widgets” are drawn by the own system. The appearance of this window and its contents, then, is independent of the operating system.

In the right lapel titled tools, we found a series of tools. Raising the classic one “to browser” of Smalltalk, we found:

The four superior lists, show, in sequence:

  • categories of classes
  • classes of the selected category
  • categories of methods (of instance or class)
  • methods
  • In the screen capture it appears the classic Object, of Kernel-Objects.

    If you have interest on the virtual machine, can visit

    http://www.squeakvm.org

    He is interesting to see the instructions to produce a virtual machine, in Win32:

    http://www.squeakvm.org/win32/compiling.html

    Well, for today, enough. I hope that it serves to you, as an start in the use of this implementation of Smalltalk.

    Angel “Java” Lopez
    http://www.ajlopez.com/en

    Older Posts »

    Theme: Shocking Blue Green. Blog at WordPress.com.

    Follow

    Get every new post delivered to your Inbox.