Showing posts with label cross-platform. Show all posts
Showing posts with label cross-platform. Show all posts

Wednesday, April 12, 2017

Interesting programming links of the week

By Vasudev Ram


I've been seeing a good number of interesting posts about programming topics lately, on various forums, particularly HN, so I thought of sharing them here (both for my readers and for myself to look up again later). Here are some selected posts or threads that I think are interesting to programmers:

Electron is flash for the desktop (2016) (josephg.com)

Web Development in Go (inburke.com)

Ask HN: Will Rust ever become a mainstream systems programming language?

Computer Programming Using GNU Smalltalk (2009) (canol.info)

Ask HN: What would you use to make cross-platform desktop application?

The reference D compiler is now open source (dlang.org)

The Power of Prolog (metalevel.at)

I also commented on some of the threads.

Enjoy.

- Vasudev Ram - Online Python training and consulting

Get updates (via Gumroad) on my forthcoming apps and content.

Jump to posts: Python * DLang * xtopdf

Subscribe to my blog by email

My ActiveState Code recipes

Follow me on: LinkedIn * Twitter

Are you a blogger with some traffic? Get Convertkit:

Email marketing for professional bloggers



Thursday, February 21, 2013

Lua inside Python, Python inside Lua - Lunatic Python


(Fixing the no newlines issues in the post, with this edit. If any reader still notices any issue with formatting, please leave a comment and I'll check it again - thanks.)

Lunatic Python - Labix

As the title of this post says, Lunatic Python (nice name - see below for why :-), is a software bridge, that enables two-way communication between Python and Lua.

From the site: "Being two-way means that it allows Lua inside Python, Python inside Lua, Lua inside Python inside Lua, Python inside Lua inside Python, and so on."

I only saw it today, so have not tried it out much yet, but from reading some of the code examples, it looks pretty interesting. Here are a few examples from the site (pasted from mobile, some characters may get changed, check site for exact code):

[
Lua inside Python

A basic example.

>>> import lua
>>> lg = lua.globals()
>>> lg.string

>>> lg.string.lower

>>> lg.string.lower("Hello world!")
'hello world!'
Now, let's put a local object into Lua space.
>>> d = {}
>>> lg.d = d
>>> lua.execute("d['key'] = 'value'")
>>> d {'key': 'value'}
Can we get the reference back from Lua space?
>>> d2 = lua.eval("d")
>>> d is d2
True
Good! Is the python interface available inside the Lua interpreter?
>>> lua.eval("python") 
Yes, it looks so. Let's nest some evaluations and see a local reference passing through.
>>> class MyClass: pass
...
>>> obj = MyClass()
>>> obj <__main__.MyClass instance at 0x403ccb4c>
>>> lua.eval(r"python.eval('lua.eval(\"python.eval (\'obj\')\")')")
<__main__.MyClass instance at 0x403ccb4c>
Are you still following me? Good. Then you've probably noticed that the Python interpreter state inside the Lua interpreter state is the same as the outside Python we're running. Let's see that in a more comfortable way.
>>> lua.execute("pg = python.globals()")
>>> lua.eval("pg.obj")
<__main__.MyClass instance at 0x403ccb4c>

]

Though it is an experimental project, the author of Lunatic Python, Gustavo Niemeyer, says that it is being used in some real world applications.

Lua.

Lua on Wikipedia.

Lua is a (buzzwords ahead :) cross-platform (*), extensible, multi-paradigm, lightweight scripting language.

It is used a lot in real world applications, including games, an Adobe product, and other areas.

Lua means moon in Portuguese (it was developed at an institute in Brazil), that's why the name Lunatic Python is a good one, since lunatics are supposed to be influenced by the moon ...

I had first come across Lua some years ago when checking out various new or less known programming languages. Tried it out a bit at the basic level, not the extensibility aspects.

(*) It seems to have developed a lot since then, at least in platform support; the Lua home page says it runs on OS's from many mobile ones up to mainframes. When I first saw it, it only worked on Linux and Windows, IIRC.

- Vasudev Ram