Showing posts with label Programming languages. Show all posts
Showing posts with label Programming languages. Show all posts

Thursday, December 20, 2012

Music with LEGO

''BEAT BRICKS – A LEGO STEP SEQUENCER'' [source]

Thursday, December 06, 2012

What language for learning programming?

''A Comparison of C, MATLAB, and Python as Teaching Languages in Engineering'' [source]

It seems that Python wins this one :)

Sunday, July 22, 2012

Interactive videos

''Create Your Own Interactive Videos
Have you ever wanted your media to interact with your audience? We'll show you how easy it is to turn your ordinary YouTube videos into interactive experiences. ...'' [source]

In general interactive videos are considered a kind of non-linear narrative. A list of non-linear editing tools is here.

New languages ... by the dozen


'' altJS is a collection of languages and tools aimed at rebooting JavaScript and making it better. '' [source]


'' Move is a modern and simple programming language which can run on virtually any computer. Move is primarily aimed towards people not previously familiar with programming computers. '' [source]

Evaluation and circular evaluation

Take an interpreted programming language (say javascript), then implement an interpreter of another programming language (say BASIC, if anybody still remembers it :D ). Doable.

Now what about implementing a javascript interpreter in javascript? Or a python interpreter in python?
Also doable ... but why?

'' The Metacircular Evaluator ...
Our evaluator for Lisp will be implemented as a Lisp program. It may seem circular to think about evaluating Lisp programs using an evaluator that is itself implemented in Lisp.
...
Given the evaluator, we have in our hands a description (expressed in Lisp) of the process by which Lisp expressions are evaluated. One advantage of expressing the evaluator as a program is that we can run the program. This gives us, running within Lisp, a working model of how Lisp itself evaluates expressions...
'' [source]



'' PyPy is a fast, compliant alternative implementation of the Python language (2.7.2). ...
PyPy's sandboxing is a working prototype for the idea of running untrusted user programs.'' [source]


'' Its name is based on the mythical figure of Narcissus, who fell in love with himself. This relates to the fact that this JavaScript engine is a metacircular interpreter, because the engine itself is also written in JavaScript, albeit using non-standard extensions that are specific to SpiderMonkey. ''  [source]






Fact1: A meta-interpreter must have a representation for all the instructions of its language: a data structure (a tree possibly) is used to represent code.
Fact2: JSON is used to serialize data and de-serialize it, also across different languages (e.g. Javascript and python).
Question: Would it be possible to write/modify a meta-circular interpreter for python and one for javascript, so that I could take a program in python, represent it as a data-structure, pass it to javascript via JSON, then run it as javascript code?
That would be a quick way to translate python into javascript, and the data-structure passed in JSON would probably be like an AST (abstract syntax tree)...

Functional programming ... in mainstream languages

JAVASCRIPT
''An Introduction to Functional Programming in JavaScript '' [source]
and
'' Functional Programming ... from Eloquent JavaScript'' [source] 

PYTHON
'' Charming Python: Functional programming in Python, Part 1... [source] 


 And to understand monads, check out this great article (with code in javascript):
''Translation from Haskell to JavaScript of selected portions of the best introduction to monads I've ever read'' [source]
Terrific examples!


Saturday, July 21, 2012

Non-Turing-Complete languages

''Practical non-Turing-complete languages?'' [source]

''... BlooP and FlooP are simple programming languages designed by Douglas Hofstadter to illustrate a point in his book Gödel, Escher, Bach.BlooP is anon-Turing-complete programming language whose main control flow structure is a bounded loop (i.e. recursion is not permitted). All programs in the language must terminate, and this language can only express primitive recursive functions.'' [source]




Perhaps the many editor and environments to define games in a high-level fashion can also be considered non-TC languages :)

Tuesday, July 03, 2012

A page with all the 1D games... so far :)

Here is a page with all the 1D games I have so far, but I'm working on a few more :)

Monday, July 02, 2012

Bloxorz remake in 1D on its way...

This is an initial attempt to recreate a bloxorz-like game, but with only 1 dimension.
The trick here is to find a way to transpose the key elements and play dynamics of bloxorz to a poorer, 1D  space. [game]

Friday, June 22, 2012

Tetris 1D now exists :)

I guess I wanted to challenge the idea (nicely expressed here http://www.kongregate.com/games/zigah111/tetris-1d-2-0?referrer=zigah111 ) that a 1 dimensional tetris is obviously stupid.

In the standard 2D tetris you have shapes and colors, and the feeling you have when playing is that you control the way your pieces fall, sometimes their speed, their position and rotation.
I wanted to see if some of the feeling could be kept in 1D. I think colors are clearly allowed in 1D, so I decided to use them as shapes are used in 2D, to classify the pieces.
Rotation would not make sense with simple square pieces in 1D, so I went for swapping the falling piece with the top of the pile below; I thought this might keep the impression of being in control of the falling piece during its fall. However swapping alone was too limited to make the game fun or non-trivial :)
So I (and the nice folk that suggested so many variations on facebook) explored a few other options: a good one is reversing of the pile, which to me has a kind of formal-methods, string-manipulation feeling that fits well with a single dimension. Other operations that were considered are right shift of the pile, swap of the first and second half of the pile, and randomization of the pile.

Anyways...
The current version of the game is playable with keyboard or mouse, it works at least on chrome for windows.
HERE IS THE GAME.



New features:
- audio
- experimental support for touch for android
- levels

It would be nice to have the time to clean up the code (which is so horrible that it might have been written by a bunch of visually impaired monkeys, with limited understanding of scripting), and improve the levels. I would like to be able to change few things from a level to the next:
- how many colors are possible for the blocks in that level
- speed of the falling block (a classic!)
- enable or disable special operations, like in some levels you might have the randomize button active
- mirror the game left-to-right
and more advanced things could be:
- have many pieces to fall at the same time (a very interesting suggestion from Arturas)
- bonus pieces that allow to destroy all pieces in the pile with a specific color (for example)
- pieces falling from both sides


Also adding a few special effects, like rotation of pieces when swapped or splash screens between levels.
Perhaps using a spline instead of a straight line, to align the pieces in a more creative way, also to play a bit with the fact that it is a 1D game, but the screen is 2D anyway ... :D

Wednesday, May 09, 2012

Make my own games for Nintendo 3DS via browser

There might be a "simple" and legal way to develop free games for the Nintendo 3DS platform.

'' A coder has discovered that Nintendo's launch of a browser for the 3DS allows basic homebrew apps and games to be created in JavaScript. 
... Andy Smith, who also happens to be the brains behind the excellent Spotibot, noticed that it comes with just enough functionality to get basic JavaScript apps to run. "I reckoned it was a ported browser, so lazy porters would likely just map some of the buttons to ASCII codes," Smith told Thinq. "Turns out they did. I've only got Up, Down, Left, Right, and A, but that's enough." ... 
He's put together a basic tech demo for people to experiment with, which you can find here (it'll work in a regular browser as well as the 3DS's). ... '' [source]

And a javascript library to work with 3DS games is also under development  [see here].

It would be great for things like e-learning, since researchers could develop games and educational programs and deploy them on the 3DS platform. (btw that's what I do in my work :D )

Monday, April 23, 2012

Interactive computation (part 2)

''First-order interactive programming

Interactive programming is a method for implementing programming languages that supports an interactive, exploratory style of program development and debugging. The basic idea is to reify the steps of a computation into a persistent data structure which can be explored interactively, and which reacts to changes to inputs like a spreadsheet.
Reifying the computation associates the computed value with provenance information, which is essential to effective program comprehension and debugging. Making the data structure persistent means that it can evolve incrementally, preserving existing structure where possible, allowing the programmer to apply fixes to a program in the middle of a complex debugging activity without having to restart the program and lose browsing context. Interactive programming lies at the intersection of incremental computation, software visualisation and reactive programming.'' [source, more details here] by Roly Perera.


The ideas presented in the paper above are great, and I would really like to implement some of them, via a meta-interpreter of some simple language like javascript (i.e. using an interpreter design pattern).
However many of the concepts relate to functional programming, while I would be more interested in imperative languages. BTW: I created a GUI where many of the ideas discussed by Perera are implemented, only it was very complex to model term rewriting with branching in a visual environment, so I got stuck in various occasions. The project is called FreeSketch and it is still going on... actually after reading the great work of Perera I'm more stimulated in resuming the work on FS :)

''Self-Adjusting Computation
Self-adjusting computation refers to a model of computing where computations can automatically respond to changes to their data.   The basic abstractions and algorithms for self-adjusting computation were invented during my Ph.D. jointly with Guy Blelloch and Robert Harper.  In subsequent work, we have extended these techniques to imperative (effectful) computations and traceable data structures, developed programming languages and systems support  self-adjusting computation. ... '' [source] by Umut A. Acar.


I will read more, then whenever I have time I will try to implement a fragment of an imperative language that enables interactive programming, to show how it could be done, in a practical unoptimized way ;)

Friday, April 20, 2012

Interactive computation

''A Theory of Interactive Computation (Presentation)
...
Modern computer systems are built from components that communicate and compute, while interacting with their environment. 
- Web Server & Client (Server/Client Model)
- Ubiquitous computing


Traditional Model is incomplete! ... 
Purpose of Interactive System ... 
   Not to compute some finial result
   React to environment or Interact with environment 
   Maintain a well-defined action-reaction behavior'' [source]

''Computers today are not only the calculation tools - they are directly 
(inter)acting in the physical world which itself may be conceived of as the 
universal computer (Zuse, Fredkin, Wolfram, Chaitin, Lloyd). In expanding its 
domains from abstract logical symbol manipulation to physical embedded and 
networked devices, computing goes beyond Church-Turing limit (Copeland, 
Siegelman, Burgin, Schachter). 
Computational processes are distributed, reactive, interactive, agent-based and concurrent. The main criterion of success of computation is not its termination, but the adequacy of its response, its speed, generality and flexibility; adaptability, and tolerance to noise, error, faults, and damage. Interactive computing is a generalization of Turing computing, and it calls for new conceptualizations (Goldin, Wegner). 
In the info-computationalist framework, with computation seen as information 
processing, natural computation appears as the most suitable paradigm of 
computation and information semantics requires logical pluralism.'' [source]

''Programming Languages For Interactive Computing.
...
Traditional programming languages are algorithmic: they are best suited to writing programs that acquire
all their inputs before executing and only produce a result on termination. By contrast most applications
are interactive: they maintain ongoing interactions with their environments. ...
I describe a programming model called declarative interaction which supports
interaction directly. The distinguishing feature of the model is its modal construal of state and interaction. ...
We shall rather informally understand an interactive programming language
(IPL) as follows. An IPL allows programmers to build interactive systems that conform to the declarative interaction model { that is to say systems which have a
modal notion of state, that separate stateful reactive computation from a declarative
core language, and that are incremental, concurrent, transactional and persistent {
in an \immediate" or direct way which is qualitatively di®erent both from the batch-
style edit-compile-execute cycle and from the read-eval-print loop of traditional
interactive programming environments such as Lisp. ...

An IPL is neither compiled nor
interpreted in the traditional sense: it is itself an interactive system that conforms to
the declarative interaction model, although it may not have been built using it. The
\state" at any point in time of an implementation of an IPL is a partially terminated
program in the declarative core language: \programming" is just interacting with
its state. Its initial state is just the null program; the user can edit this into any
program in the space of possible programs in the declarative core language.

...

An early experiment [...] showed how the untyped lambda calculus can be made interactive; a more recent investigation (unpublished) suggests that object-oriented languages can be treated similarly. Interactive logic and relational programming languages are presumably feasible.

''[source]

To follow some of these papers one need to know about omega languages (where strings can be infinite):
http://en.wikipedia.org/wiki/Omega_language
''... an ω-language L over Σ is a subset of Σω. '' 
and omega itself comes from Cantor's transfinite numbers: nice intro here.


Thursday, February 09, 2012

Wanna program a bit... and make a game without sweating too much? ;)

Check out these nice and free environments:

 ''Scratch 1.4. Scratch is a programming language that makes it easy to create your own interactive stories, animations, games, music, and art -- and share your creations on the web.'' [source] 2D, very friendly to use for non-programmers

''Kodu. Kodu is a new visual programming language made specifically for creating games. It is designed to be accessible for children and enjoyable for anyone.'' [source, download]

Friday, August 19, 2011

OpenCV in Processing

''OpenCV and Processing'' [source]

Thursday, June 02, 2011

"Softwear" :D

''Readaholic: Open Softwear – wearable computing using Arduino.
...
The book ‘Open softwear’ was written during 2008 by Tony Olsson, David Gaetano, Jonas Odhner, Samson Wiklund and published under the Creative Commons license. Under the same rulez Arduino software is an open source piece of software- intended for most spread platforms: Windows, Mac OS and Linux.
...
As Tony Olsson explains it in the preface ‘Arduino has been a active part of the curriculum in Fashion, body and technology, Light Installation and in the Interaction programs at both bachelors and masters level, since 2005. The goal with Arduino was to create a prototyping platform for designers to be able to realize there ideas by them selfs.
'' [source]

(free) Flash tool

''FlashDevelop is a great general purpose code editor
Easy to use editor with syntax highlighting, bookmarks and tasks (TODO) handling.
Comprehensive Find and Replace Dialog.
Find in Files dialog.
Intuitive and very flexible panel based interface.
Advanced snippet completion (code templates) and integrated snippet editor.
Open plug-in based architecture.
'' [source]

''Flash game creation tutorial'' An intro to ActionScript3 [source, and a nice free game here]

Thursday, May 26, 2011

Tangible interfaces, paper and more.

Various interesting projects made with paper [source]

Via: The low-tech club [LoTeCLB]

Wednesday, May 04, 2011

DSL (domain-specific languages)

Almost done with the book "Domain-specific languages". Great book!

To try out the ideas in the book, I implemented a simple DLS in python then in Java.

The DSL is a simple language describing image processing tasks. The user can define his/her tasks in a friendly "internal DSL" format, which is embedded in Python. That definition is used to populate a semantic model, also in Python, in which objects represent the sequence and type of the operations in the user task.

Once populated, the semantic model can be validated in various ways, and finally code is generated from Python, and a new program is created (written in Processing) that can easily be run by the user.

The same is also re-done also using Java as "host" language, for the DSL. Still the final code is generated in Processing.

The advantage of this approach is that it cleanly partitions the system in a DSL that the user can use directly, a semantic model, that the programmer can improve incrementally; then we have validation of the semantic model and code generation that can also be improved independently from the user, who will still be able to run his/her scripts.
Also, the code-generation part of the system, can be extended to create multiple executable and deploy on different machines.

Thursday, April 14, 2011

Tiles, fonts and text-based rogue-like games

In a previous post [this one] I was talking about using a special font to convert rogue-like games to graphics.

Today I found this great example of this strategy:

[source]