Angel \”Java\” Lopez on Blog

July 27, 2014

AjTalk Implementing Smalltalk In C# (4) The Project

Filed under: .NET, AjTalk, C Sharp, Programming Languages, Smalltalk — ajlopez @ 5:48 pm

Previous Post

Year and a half since I didn’t write about this project in C #, but I was working on it, and the parallel implementation I have in JavaScript (in fact, I introduced some concepts of both the Smalltalks 2013 conference, Rosario, Argentina).

The project is at:

https://github.com/ajlopez/AjTalk

Current structure:

The projects are:

AjTalk: class library, with a compiler to bytecodes implementation. There is a compiler to JavaScript too. There is an interpreter of those bytecodes.

AjTalk.Compiler: a console project that uses the compiler to JavaScript.

AjTalk.Console: a simple REPL (Read Eval Print Loop)

AjTalk.Gui: a work-in-progress example using windows

AjTalk.Tests: the test I wrote, followin TDD (Test-Driven Development) flow.

I guess now I don’t need the compiler to JavaScript, because I have a native JavaScript implementation at:

https://github.com/ajlopez/AjTalkJs

It can compile to bytecodes or to JavaScript. The project is written in JavaScript.

The window implementation is very primitive. I plan to replace it for direct AjTalk program using .NET types and object.

One point that I find very interesting (in both projects, C # and JavaScript) is to have a modular implementation: instead of loading an image yet defined, my plan is to define modules to load, as happens in the Node.js environment . The modules would be published in the NPM (Node Package Manager’s), and each could indicate which modules need in your program instead of lifting all Smalltalk.

Another topic in this C # project I have implemented that can run more than one AjTalk machine at the same time. And I can even make a machine “help” to the other. For example, if the machine does not have to compile methods to new methods, machine B can go to his aid. Thus, A machine (and his image, I’m already recording binary image) can be kept small.

Another feature that I have implemented: the ability to send a message to an object, without waiting for a response, a “fire and forget”. And that the target object can attend ONE OF those messages as models of actors.

I have to review the implementation of remote objects (now based on the old Remoting. NET). But I think it is an important feature to maintain and explore.

Well, you see, many issues remain for other posts, such as implementation details Smalltalk concepts such as Object, Class, ClassDescription, Behavior, MetaClass, etc..

Nos leemos!

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

April 27, 2014

Smalltalk from Scratch

Filed under: AjTalk, Smalltalk — ajlopez @ 4:21 pm

I think Smalltalk is a wonderful technology that influence the past decades in programming. But not directly: its influence is not via its killer apps. Smalltalk influenced programmers. The Smalltalk mark can be traced in Python and Ruby design decisions. And many programmers have been touched by Smalltalk ideas. But Smalltalk, as technology, didn’t exploded. We can discuss the reasons: early “balkanization” of providers, no early open source implementation. My thoughts: it is too couple to its own “GUI IDE”, and it is a bit overwhelming (too many pieces).

I think that is time to explore alternatives path. In the past decades, I visited many technologies and languages, and in the past ten (more or less) years, I took again Smalltalk and tried to follow an alternative path.

My position: we should try a simpler Smalltalk. An Smalltalk not tied to GUI IDE, not tied to thousands of classes. A simple implementation that can access the rest of the world advances in programming.

So, I started three own implementations: Smalltalk hosted in .NET, in Java and in JavaScript/Node.js:

https://github.com/ajlopez/AjTalk
https://github.com/ajlopez/AjTalkJava
https://github.com/ajlopez/AjTalkJs

More info in http://ajlopez.wordpress.com/category/smalltalk/.

But this post is not dedicated to review those implementation. Its purpose is to write down some ideas about how to create an Smalltalk, without struggling with the shrinking of a previous image.

The Core

I think that a new Smalltalk from scratch could be developed. An Smalltalk that runs in a host environment, like .NET, Java or JavaScript. Or another one. But it’s time to have an Smalltalk that is not an autism program: it should leverage the work of other technologies. For example, an Smalltalk running on JavaScript could access the JS ecosystem, via browser modules and libraries, or using Node.js or other engine package ecosystem.

The core Smalltalk should implement:

Object: the base object and class, with some base methods, like #subclass:.

Array: for arrays with numeric index, starting from 1 (to not break with Smalltalk tradition)

Dictionary: to map keys (names) to values

Primitive types: the underlying language (.NET, Java, JavaScript) could implement numbers (integers and floats), bytes, chars, strings, etc.

Access to native objects and types: to create them, to call type methods, to call instance methods.

The Library

First, a minimal implementation of some classes, that can be shipped with the initial implementation.

But then, and this is important: try to live in an ecosystem of packages. Instead of having all classes in the image, try to have an ecosystem of packages. Each Smalltalk application could define the needed packages, and then, the packages could be installed from the package ecosystem. In my implementations, I started to explore the use of NPM (Node Package Manager) to publish new package, and to install them per application, even with the use of explicit package version, so we have a less brittle ecosystem.

Package candidates:

- Test library (with an initial assert method)
- HTTP server
- MVC web framework (I have a minimal sample using Node.js Express)
- Distributed messages (I have a naive implementation in C#)
- etc.

In this way, the adoption of a package will be easy: not need of porting a package, only consume it, given the right dependencies in place. And, as in other technologies (Python, Ruby with gems, and notably, Node.js with NPM), each package can keep the description of the needed dependencies (NPM takes care of versions too).

Additional Items

I want to have an environment feature: that a class/package can load other classes, but only for internal use, without pollute the global Smalltalk environment.

I want to have an image running with the help of other image. That is, the Smalltalk VM should manage MORE THAN one running image. And one image could help another one. For example: one minimal image could have no compile method, but this method could be provided by the host image. In this way, a minimal image could be created, without any convoluted “shrinking” step. I already implemented this feature in my C# implementation.

In some implementations, I want to have an image (save and restore). But it is time to explore the development without the need of an image.

Any GUI should be created over the host environment. Use Windows.Form if your Smalltalk is running over C#. Or use another library, in Java (Swing? SWT?). But the idea is that the GUI management should be something clearly separated from the core implementation. Current popular Smalltalk implementations are too coupled with GUI management. Look at other technologies: Python, Ruby, Node.js, Go, etc.. There are lots of developers not using a technology so tied to a GUI IDE. And they are producing useful applications.

As I usually say: explore. That is the verb. We must explore alternative path, even when the outcome and gains are not clear. If I had seen killer applications in Smalltalk, or the use of Smalltalk in the creation of application that are really used by other developers (like in Python, Ruby, Java, JavaScript, Node.js, and others), I should stop thinking in this way. But, for some reason, Smalltalk is not taking the world by storm. Alternatives are here, floating around us, ready to be taken and to be explored.

Keep tuned!

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

January 31, 2014

Smalltalk, JavaScript, NodeJs, C#, and Tutti Li Fiocci

Filed under: AjTalk, C Sharp, JavaScript, NodeJs, Smalltalk, Talks, Video — ajlopez @ 5:43 pm

Past year, I gave a talk at Smalltalks 2013, Rosario, Argentina. The conference was a great experience to me, and there were many interesting talks, implementations and ideas.

My talk was about implementing Smalltalk, in C#, and JavaScript. The main repos are:

http://github.com/ajlopez/AjTalk (I presented it at Smalltalks 2010)
https://github.com/ajlopez/AjTalkJs (I presented it at Smalltalks 2011)

My recorded talk:

http://www.youtube.com/watch?v=-KFjSneVE2s

The presentation:

https://github.com/ajlopez/Talks/tree/master/Smalltalks2013
http://ajlopez.github.io/Talks/Smalltalks2013/index.html
More talks at http://ajlopez.github.io/Talks/

The first project is an interpreted based on byte codes, written in C#. It can compile to JavaScript, but the key features is to have a VM based on bytecodes, that have access to native .NET types and objects, remote execution, actors, and more. See my posts.

The second project is an implementation of Smalltalk but in JavaScript. Internally, it have a compiler to JavaScript, but also a compiler to bytecodes and then, an interpreted VM written in JavaScript. Both projects now supports NPM (Node.js package manager) for new modules.

In 2013, I added Node.js support and access to AjTalkJs, so I can run an Express application from Smalltalk:

 

Next experiments: distributed message. That is, an object in one machine sends a message to an object in a remote machine/process,  in a fire and forget way. I think Node.js ecosystem is a good plate to host such experiments. My previous work at Distributed Applications with Node.js. I want a distributed Smalltalk machine/application. Maybe, if the communication protocol is easy or pluggable, I could add clients/servers implemented in other Smalltalk dialects. But baby steps first ;-)

Keep tuned!

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

November 19, 2013

November 4, 2013

End Of Iteration 2013w44

Filed under: AjTalk, Iteration, JavaScript, NodeJs, Open Source Projects, Python, RedPython, Smalltalk — ajlopez @ 6:27 pm

Previous Post
Next Post

The main outcomes were: a talk, about my Smalltalk implementations, new sample code and a new project, inspired by Python and Smalltalk conference.

AjTalk Implementations

I reviewed and improved my implementations:

https://github.com/ajlopez/AjTalkJs
https://github.com/ajlopez/AjTalk

I added a sample using AjTalkJs, Node.js, Express.

My talk for Smalltalks 2013 at

https://github.com/ajlopez/Talks/tree/master/Smalltalks2013

RedPython

I want to implement a compiler/transpiler from reduced (subset of) Python to C, at first using JavaScript.

The project:

I have two samples running: simple hello world, and primes.py

https://github.com/ajlopez/RedPython

More ideas to implement this week. I should improve my Ruby in C# implementation, and maybe, write a Ruby implementation in JavaScript.

Keep tuned!

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

November 2, 2013

New Month’s Resolutions: November 2013

Time to review my October resolutions:

- Give a talk about PHP and Node.js [complete] see post and PHP/Node repo and PageJs repo at PHP Dev Argentina 2013
- Give a talk about TDD with ASP.NET MVC [complete] see repo
- Give a talk about Scala implementation [complete] see slides and simple samples
- Give a talk about Python in JavaScript [complete] see repo and slides at PyCon 2013 Argentina
- Give a talk about Smalltalk in JavaScript and C# [complete] see repo and slides at Smalltalks 2013

This new month’s resolution:

- Start compiler reduced Python to C, using JavaScript
- Give a talk about Ruby in C#
- Start Ruby to JavaScript compiler
- Complete variable scope in Mass language
- Give a talk about compiling languages to JavaScript (to be confirmed)
- Write web framework for AjTalkJs (to be used in Node.js) (plain? MVC?)
- Improve NPM modules in AjTalkJs and AjTalk
- Improve unit test support in AjTalkjs and AjTalk
- Improve match and data structure in AjErl

More fun is coming ;-)

Keep tuned!

Angel “Java” Lopez
@ajlopez

October 28, 2013

End Of Iteration 2013w43

Previous Post
Next Post

The week was dedicated to prepare and give a talk, and prepare this week next talk.

JPyScript

My Python to JavaScript transpiler, written using JavaScript. It runs on node.js and browser.

https://github.com/ajlopez/JPyScript

It can use Node.js modules using import, and it can run Python scripts in the browser.

I gave a talk at PyCon Argentina 2013. My slides at:

https://github.com/ajlopez/Talks/tree/master/PythonJavaScript

AjTalkJs

My Smalltalk-like VM in bytecodes and JavaScript, written in JavaScript.

https://github.com/ajlopez/AjTalkJs

Now, I can use Node.js modules, run in server and browser. Example:

I was working in minor refactoring of:

https://github.com/ajlopez/RubySharp
https://github.com/ajlopez/PythonSharp

And I was working on two non-public projects: one in C#, in-memory OLAP, and another one in Java, with agile team.

This week I will give a talk about my Smalltalk implementations at Smalltalks 2013 Argentina:

http://www.fast.org.ar/smalltalks2013

More fun is coming.

Keep tuned!

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

October 21, 2013

End Of Iteration 2013w42

Filed under: AjTalk, Iteration, JavaScript, JPyScript, Open Source Projects, Python, Smalltalk — ajlopez @ 2:22 pm

Previous Post
Next Post

The past week was dedicated to two non-public projects, and prepare of my next talks.

SimpleBeams

Inspired by a work by @darachennis  (https://github.com/darach/beam-js) I wrote a simpler implementation of beams (piped message processors

https://github.com/ajlopez/SimpleBeams

I should write the README.md, but the tests are self-explanatory. A beam receives messages and emit messages. It can have a filter function, filtering the message to process. And a transform function, that can emits new messages.

JPyScript

It compiles a Python-like language to JavaScript. The compiler is written in JavaScript

https://github.com/ajlopez/JPyScript

Notable, I can write controllers in Python for Express web apps. See samples

AjTalkJs

My Smalltalk VM in JavaScript. Using JavaScript, it compiles Smalltalk fileouts to bytecodes. It started to compile directly to JavaScript code, instead of only bytecodes.

https://github.com/ajlopez/AjTalkJs

It can run from Node.js, and from the browser, too.

I worked on two non-public projects, one using C# with Visual Studio 2010, and other using Java, with Maven, Eclipse, JBoss 5.x

This week I will give a talk at Python Argentina 2013 http://ar.pycon.org/

Keep tuned!

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

January 6, 2013

New Month’s Resolutions: January 2013

The first month of a new year! I’m was busy coding a lot. It’s time to review past month resolutions:

- Work on PythonSharp [pending]
- Work on AjTalk for C# [complete] see repo and see my posts
- Give a Node.js course [complete] Spanish post
- Start .md pages Java tutorial [pending]

Additionally, I was working on:

- Start Py2Script Python to JavaScript compiler [complete] see repo
- Update my Node.js samples [complete] see repo
- Start and publish version 0.0.1 of SimpleWeb, my middleware layer [complete] see repo
- Start BasicScript [complete] see repo
- Start and publish version 0.0.1 of CobolScript [complete] see repo and see my posts
- Update AjConsorSite [complete] see repo
- Start Inmob [complete] see repo

For this new month, these are my new resolutions (some are already started):

- Start SimpleScript
- Start SimpleBoard
- Start SimpleChess
- Start SimpleGo
- Start and publish a version of SimpleMapReduce, with local and distributed sample
- Start and publish a version of SimpleFunc, object with functions serialization
- Start Memolap, C# in-memory multidimensional OLAP-like library and sample
- Start SimpleMemolap, the same but in JavaScript/Node.js
- Start SimpleRules, forward-chaining rule engine, that compiles to JavaScript

A lot of fun! ;-)

Keep tuned!

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

December 26, 2012

AjTalk in C# (3) Environments

Filed under: AjTalk, C Sharp, Open Source Projects, Programming Languages, Smalltalk — ajlopez @ 4:46 pm

Previous Post
Next Post

Some weeks ago, I added environments to my open source AjTalk Smalltalk Virtual Machine, C# version. What is an environment, in my jargon? It’s a dictionary for named artifacts, like classes. Smalltalk global is a classical environment. But I want to add support of other named environments, to avoid class name collisions. Usually, classic Smalltalk have pool dictionaries, but I want something more dynamic. Then, I added Environment, see my tests:

https://github.com/ajlopez/AjTalk/blob/master/Src/AjTalk.Tests/AssertTests/EnvironmentTests.st

At first, Smalltalk is the current environment:

"Current environment is Smalltalk"
[Environment current == Smalltalk] assert.

You can create new environments:

env := Environment new: #MyEnvironment.

Automatically, the new environment is registered/added to the current one, in this case, Smalltalk:

"The new environment was defined as global at Smalltalk"

[(Smalltalk at: #MyEnvironment) isNil not] assert.
[(Smalltalk at: #MyEnvironment) == MyEnvironment] assert.
[(Smalltalk at: #MyEnvironment) == env] assert.

[MyEnvironment isNil not] assert.
[MyEnvironment == env] assert.

Every new Environment has an entry to Smalltalk:

"Dotted expression syntax sugar for MyEnvironment at: #Smalltalk"

[MyEnvironment.Smalltalk == Smalltalk] assert.

You can switch to a new environment:

env setCurrent.

"Current environment check"

[Environment current == env] assert.
[Environment current == Smalltalk.MyEnvironment] assert.

And then, this is the key feature, the class definitions define a new class AT CURRENT environment:

"Define a class at current env environment, no change to syntax"

Object subclass:#MyClass
    instanceVariableNames:''
    classVariableNames:''
    poolDictionaries:''
    category:''
.

[(env at: #MyClass) isNil not] assert.
[(Smalltalk at: #MyClass) isNil] assert.

Orthogonally to environments, I implemented modules: a way to search and load file outs, and running them at a new environment (similar to Python import, or (more or less) to Node.js/CommonJS require). But this is a topic for another post ;-)

Keep tuned!

Angel “Java” Lopez

http://www.ajlopez.com

http://twitter.com/ajlopez

Older Posts »

Theme: Shocking Blue Green. Get a free blog at WordPress.com

Follow

Get every new post delivered to your Inbox.

Join 67 other followers