Category Archives: Frameworks

JNIPort for Pharo 3.0

Hi everybody,

JNIPort for Pharo 3.0 alpha is now available at SmalltalkHub.

JNIPort is a Smalltalk library which allows Java code to be invoked from
Smalltalk. It acts as a bridge between the world of Smalltalk objects and a
Java Virtual Machine (JVM) where Java code is executing.

When I first ported JNIPort to Squeak and Pharo 1.x, I used Alien as the FFI
library. As NativeBoost has superseded Alien, the interface to the Java
Native Interface library had to be rewritten. There are still some
undocumented and obscure parts in NativeBoost, so this has taken some time.

If you want to try it, load it via the ConfigurationOfJNIPort. I hope this
works. If it does not, load the packages individually in the order in which
they appear in the ConfigurationOfJNIPort.
http://www.smalltalkhub.com/#!/~JNIPort/JNIPort
The next step is to read the documentation at
http://jniport.wikispaces.com/
Otherwise, you won’t know what to do next. 😉
Download the extra files from the download page at Wikispaces, you will need
two jar files from there.

Start a Java VM attached to Pharo by adapting and executing the following
code snippet:

—-
| jvmSettings |
“You can set the path to the Java VM library by editing the path as
needed.”
JNIPortJNIInterface libraryFile:
‘/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Libraries/libclient.dylib’
.
“JNIPortJNIInterface libraryFile:
‘C:\Programme\Java\jre7\bin\client\jvm.dll’ .”

jvmSettings := JVMSettings new.
jvmSettings usesGhosts: true.
jvmSettings supportsCallbacks: true.
jvmSettings jniPortSettings useJNIHelperLibrary: false.
jvmSettings ghostClassSettings retainMethodSource: true.

“On Mac OS X and Linux, class path entries are separated by colons.”
“On Windows, you have to use semicolons instead. Edit the following line as
needed.”
jvmSettings runtimeSettings classpath:
‘.:/Users/myname/JNIPort.jar:/Users/myname/JNIPort-Tests.jar’.
” jvmSettings runtimeSettings classpath:
‘.;.\JNIPort.jar;.\JNIPort-Tests.jar’.”

“Uncomment the following if you want the Java VM to emit verbose messages.
How to access these messages depends on your platform.
On Mac OS X, they are visible in the Console application.”
“jvmSettings runtimeSettings addOption: ‘-verbose:jni’; addOption:
‘-verbose:gc’; addOption: ‘-verbose:class’.”
Cursor execute showWhile: [JVM newWithSettings: jvmSettings].
—-

Then the fun starts:

—-
| zfClass zipfile entries |
zfClass := JVM current findClass: #’java.util.zip.ZipFile’.
zipfile := zfClass new_String: ‘JNIPort.jar’.
zipfile size. “–> answers an Integer”
entries := zipfile entries.
entries asAnEnumeration do: [:each | Transcript cr; print: each].
—-

And now to the ugly little secret reason why I call it an alpha version:

While everything seems to work, it is *much* slower than it used to be in
Pharo 1.2 with Alien. And when I compare it with VisualWorks, I wonder if
the Pharo version secretly does some additional work for SETI:
– Starting the JVM:
VisualWorks 0.7 seconds
Pharo 7 to 8 seconds
– A benchmark using some methods of java.io.BufferedReader and
java.util.StringTokenizer:
VisualWorks 114 milliseconds
Pharo 12 to 13 seconds

I have not yet found the reason. The TimeProfiler is not very helpful, as
its 1 millisecond resolution is too coarse. It would be nice if it had
microsecond resolution. From the TimeProfiler results, it seems that calling
a JNI method with NativeBoost is extremely slow, but I don’t trust those
profiles too much.

So, give it a try, and if you find something useful concerning the bad
performance, please send me a message.

Best regards,
Joachim Geidel

Tagged

Timezone in ZTimestamp project

Sven (the author of many cool Pharo packages: JSON, STON, CSV, HTTP, HTTPS) released a new version of ZTimestamp. Here is his announce:

I just added a first version of timezone support to the ZTimestamp project – a small, lightweight, non-intrusive, self-dependent alternative to DateAndTime and friends. With this addition, it is now possible to work with UTC/GMT timestamps internally yet present correctly localised timestamps in any timezone, based on the standard Olsen database. ZTimestampFormat was extended with optional timezone support.

About ZTimestamp

https://ci.inria.fr/pharo-contribution/job/PharoProjectCatalog/HTML_Report/ZTimestamp.html

https://github.com/svenvc/docs/blob/master/neo/ztimestamp.md

ZTimestamp can be loaded most easily from the Pharo 2 or 3 Configuration Browser.

StHub

http://www.smalltalkhub.com/#!/~SvenVanCaekenberghe/Neo/packages/ZTimestamp

CI job

https://ci.inria.fr/pharo-contribution/job/ZTimestamp/

From the class comment of ZTimezone

https://github.com/svenvc/ztimestamp/tree/master/repository/ZTimestamp.package/ZTimezone.class

===

I am ZTimezone, representing the timezone information in the standard Olsen database.

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

Usage

You reference timezones by their ID. The list of supported identifiers is accessible using

ZTimezone timezoneIdentifiers.

To access a timezone do

ZTimezone id: ‘Europe/Brussels’.

The necessary information will be loaded, parsed and cached from a binary file of the zoneinfo database (see also man tzfile). This should work automagically on Mac OS X and Unix, on Windows you have to download the necessary files and specify their location

ZTimezone zoneInfoLocation: FileLocator C / ‘foo’ / ‘bar’ / ‘zoneinfo’.

Once you get a handle on a timezone, the main operation is to query the sub timezone that is applicable at a certain point in time

(ZTimezone id: ‘Europe/Brussels’) subzoneForTimestamp: ZTimestamp now.

The ZSubTimezone instance returned contains information like the UTC offset. Since you’ll probably only be interested in that aspect there is a convenience method

(ZTimezone id: ‘Europe/Brussels’) offsetForTimestamp: DateAndTime now.

The flow is that for every GMT timestamp, you get the concrete offset to use for a specific timezone. Note that this is not a constant, it depends on the time periode the timestamp falls in.

The are 2 more convenience methods to quickly convert between GTM and local wall time

(ZTimezone id: #’Europe/Brussels’) gmtToLocal: ZTimestamp now.
(ZTimezone id: #’Europe/Brussels’) localToGmt: DateAndTime now.

Also note the zoneTab and the timezones are cached in the image. When the TZ database changes, it might be necessary to either call #cleanUp or #reloadAll. When moving images between machines, either all info should be loaded and cached, or it might be necessary to use #zoneInfoLocation: again.

Implementation

A chronological array of transition points in unix time specifies which sub zone is active from that point on to the next.

===

Tagged

Renoir: Programmatic CSS builder

Gabriel Omar Cotelli announced today a new library for Pharo.
I’m announcing the first official release of RenoirSt, a DSL enabling programmatic cascading style sheet generation for Pharo.
For the impatient, you can load it in your 3.0 image evaluating:
Gofer it
    configurationOf: ‘RenoirSt’;
    loadStable
or download a ready to use image from the Contribution CI Server ( a ConfigurationBrowser option comming soon).
Visit the project page and GitHub repository for more information on the supported and planned features, and check-out the online tutorial.
I hope you find it useful. Feel free to ask any questions, suggest ideas and improvements, or report bugs (the issue tracker is in GitHub).
Gabriel
Tagged

NativeBoost by example: X11

NativeBoost is a Pharo library  supporting FFI based on assembly on the fly generation. Today one nice chapter has been announced. Here is the announce:

Hi guys

today igor helped me to understand some hidden parts of NativeBoost and we massively revisited and expanded the chapter started
by L. Laffont this summer. Now you this is up to you to expand your knowledge 🙂 It was really fun to get the X11 window resize and move 🙂

https://ci.inria.fr/pharo-contribution/job/PharoForTheEnterprise/lastSuccessfulBuild/artifact/NativeBoost/NativeBoost.pier.pdf
https://ci.inria.fr/pharo-contribution/job/PharoForTheEnterprise/lastSuccessfulBuild/artifact/NativeBoost/NativeBoost.pier.html

Enjoy.

Stef and Igor

Tagged

New Components for Seaside Bootstrap

Torsten Bergmann announced two weeks ago two new components for Seaside Bootstrap http://twitterbootstrap.seasidehosting.st.

In case you missed it: Bootstrap for Seaside has two new components:

http://pharo.pharocloud.com/bootstrap/browser/Batched%20List%20Widget

http://pharo.pharocloud.com/bootstrap/browser/Offer

For the full demo visit: http://pharo.pharocloud.com/
Here is the old announce of the system made by Torsten

Hi,

there are various frameworks out there helping you to ease common tasks in web development.
One of them is Bootstrap (http://getbootstrap.com) that is used more and more to easily style
web sites and web applications.

We had wrappers for Bootstrap supporting Seaside in the past already:
– the TwitterBootstrap project on SS3 from the Seaside team
– the TBootstrap project from Gaston Dall Oglio

Unfortunately these projects are not up to date with the latest Bootstrap version,
not covered by tests, had no docu or examples, no CI, …

To provide better support for Bootstrap and Seaside3 development I created a fresh project
called “Bootstrap for Seaside” (or “Bootstrap” for short).

This new project is
– nearly feature complete regarding components (Nav, Navbar, Jumbotron, Buttons, Alarms, Layouts, …)
– uses the latest Bootstrap libraries (http://getbootstrap.com)
– covered by more than 160 tests
– completed with an example browser that shows Bootstrap components and according Smalltalk code
– available at STHub (http://smalltalkhub.com/#!/~TorstenBergmann/Bootstrap)
– documented (see mentioned project website on STHub) with docu support for PharoOnlineHelp and catalog
– controlled by CI (https://ci.inria.fr/pharo-contribution/job/Bootstrap/)
– easily loadable using config browser in Pharo 2.0

Attached are some screenshots from the project itself.

More details can be found in the more docu at the project site on SmalltalkHub. Just scroll down at the
info page provided there.

You can easily load it in a fresh Pharo 2.0 as “Bootstrap” from the config browser. It loads Seaside3
as a dependency. After loading evaluate

ZnZincServerAdaptor startOn: 8080

to start the webserver and go to http://localhost:8080/bootstrap to browse the samples.

Feel free to use it for your next Pharo/Seaside/Bootstrap based web project and thanks in advance
for any contribution you may give to the project in the future.

Bye
T.

Tagged

TaskIt: a Task Frameworks

Santiago Bragagnolo designed a task frameworks. Expressing and managing concurrent computations is indeed a concern of importance to develop applications that scale. A web application may want to use different processes for each of its incoming requests. Or maybe it wants to use a “thread pool” in some cases. In other case, our desktop application may want to send computations to a worker to not block the UI thread.

TaskIT is a library that eases the usage of processes in Pharo. It provides abstractions to schedule and/or parallelize of the execution of pieces of code. In this chapter we will explore these abstractions, guided by examples and code snippets.

With Guillermo Polito they are writing a nice chapter on a frameworks to manage tasks in Pharo.

https://ci.inria.fr/pharo-contribution/job/PharoForTheEnterprise/lastSuccessfulBuild/artifact/TaskIT/TaskIT.pier.html

Enjoy.

PDFExporter for ROASSAL

Jamir announced a pdf exporter for ROASSAL. Here is the announce.

I’m currently working on a PDF exporter for
Roassal http://objectprofile.com/#/pages/products/roassal/overview.html

There is still a lot to do and many bugs to squash:

If you want to try it you can get it here:

RoassalPdfExporter http://www.smalltalkhub.com/#!/~Jamir/RoassalPdfExporter/

You’ll also need: Artefact http://www.smalltalkhub.com/#!/~RMoD/Artefact
and Roassal http://www.smalltalkhub.com/#!/~ObjectProfile/Roassal

In order to get the PDF file, click on ‘export’ and then on double click in ‘export as PDF’ . And a new file named ‘test.pdf’ will be created on the root of your Pharo directory.

There are still some missing shapes like arrows and new lines in text, and
there will be bugs. Your feedback is much appreciated!

Best regards.

http://objectprofile.com/#/pages/products/roassal/overview.html
http://www.smalltalkhub.com/#!/~Jamir/RoassalPdfExporter/
http://www.smalltalkhub.com/#!/~RMoD/Artefact
http://www.smalltalkhub.com/#!/~ObjectProfile/Roassal

Tagged ,

PunQLite: another noSQL DB for Pharo

There is a new player in the NoSql world and a bridge for Pharo made by masashi umezawa. This is a nice addition to the Pharo world and I hope that one of you will extend Voyage (that is an abstract layer on top of NoSql databases) to propose PunQLite as a back-end. Here is the announce about PunQLite.

Hi all,

I’ve developed PunQLite. UnQLite NoSQL database binding for Pharo.
https://github.com/mumez/PunQLite
http://smalltalkhub.com/#!/~MasashiUmezawa/PunQLite

UnQLite is a fast, lightweight, portable, embedded KVS with a simple  scripting engine (Jx9).
http://unqlite.org/

Torsen kindly wrote about PunQLite project’s beginning on his blog.
http://astares.blogspot.jp/2013/11/punqlite-for-pharo-using-unqlite.html

At that time, it was only a bare NativeBoost FFI interface. Now it has
become a full-fledged wrapper.

db := PqDatabase open: ‘test.db’.
db at: ‘Smalltalk’ put: ‘COOL’.
db at: ‘Pharo’ put: ‘HOT’.
db at: ‘Smalltalk’ ifPresent: [:data |
data asString inspect
].
Transcript cr; show: db keys.
db do: [:cursor |
Transcript cr; show: cursor currentStringKey; space; show: cursor
currentStringValue.
].
db close.

Moreover, it is quite fast. I wrote a simple benchmark that does many
round-trips (put/get 100000 small elements). The result is 877 msecs
(on my windows laptop). It was impressive.

Enjoy!


[:masashi | ^umezawa]

Tagged

Pillar

One Markup to rule them all.

Pillar is a mark-up language that we use to generate our books in multiple format: tex, html, markdown…. The seaside book http://book.seaside.st was edited and written in pillar format as part of the Pier CMS (developed by L. Renggli). Now Damien Cassou enhanced Pillar and made it a nice standalone application. Here is the latest announce about pillar.

I’m proud to announce the 0.6 release of Pillar, a syntax and associated tools to write and generate documentation and books.

Pillar is currently used to write the Enterprise Pharo book (https://ci.inria.fr/pharo-contribution/job/PharoForTheEnterprise/) and other projects. You can get some pdfs of the new book at: https://ci.inria.fr/pharo-contribution/job/PharoForTheEnterprise/lastSuccessfulBuild/artifact/

Pillar has many features:

  • simple markup-based syntax with references, tables, pictures,captions… (this is the syntax of Pier)
  • export to HTML, LaTeX and markdown (more to come)
  • customization of the export through a dedicated STON configuration file
  • support of templates using the Mustache templating engine
  • syntax-highlighting of generated code blocks (not yet in LaTeX)
  • configurable numbering of section titles and figures
  • emacs style

Pillar has also:

I updated the http://www.smalltalkhub.com/#!/~Pier/Pillar description

You can load it using

Gofer new
   smalltalkhubUser: ‘Pier’ project: ‘Pillar’;
configuration;
loadStable.

Have fun and now you are ready to write nice chapters for the forthcoming books

Tagged , , , , ,