News for hackers. Stuff that matters.
Re:Logix: Adding macros to Python by jey on Monday September 10, 2007 @08:35PM (#53056)
Is it just me, or does it seem like everyone and their mother is inventing a new programming language these days?
Re:Logix: Adding macros to Python by mdakin on Monday September 10, 2007 @08:59PM (#53072)
They are and it's a direct result of CS's immaturity.

Python is close to something very, very good but not quite there. Logix in "Base Logix" mode seems to fix some of Python's problems while retaining its redeeming qualities.

If only a real Lisp would come along that had the leadership, library, community and documentation of Python.

Re:Logix: Adding macros to Python by AF on Monday September 10, 2007 @10:44PM (#53128)
> If only a real Lisp would come along that had the leadership, library, community and documentation of Python.

Someone was asking for that just the other day. I was thinking myself that it would be pretty neat to write a Lisp dialect that compiled down to Python, and therefore you could get access to all the Python libraries, a decent VM, and also macros.

I've had trouble figuring out where to start, though. Would be a fun project.

Re:Logix: Adding macros to Python by pc on Tuesday September 11, 2007 @01:02AM (#53176)
"I was thinking myself that it would be pretty neat to write a Lisp dialect that compiled down to Python"

That would be an incredibly bad idea. The implementation of SBCL (and CMUCL, upon which SBCL is based) is second to none--it has an optimizing compiler (available at runtime) with code-generation backends for architectures from x86 to MIPS; fantastic support for type inference, inline expansion, modular arithmetic, unreachable code deletion, constant folding, control optimization, generational garbage collection (doesn't python still use reference counts?)... amongst a bunch of other stuff.

http://shootout.alioth.debian.org/gp4/benchmark.php?test=all...

Benchmarks are of course arbitrary, but no matter what way you dice things, SBCL is vastly superior to Python's crappy VM. In the case of the link above, over 10 times faster.

Re:Logix: Adding macros to Python by AF on Tuesday September 11, 2007 @01:09AM (#53178)
As I mentioned in another post, I'm aware of the qualities of SBCL. I know it is a much better VM. That's not what I am concerned about...what I like about Python is its quantity and consistency of libraries and its overall consistency period. Common Lisp just doesn't have that, and SBCL isn't perfect - its full functionality doesn't work across all platforms.

> That would be an incredibly bad idea.

And I'm just wondering...even with SBCL, why would it be an 'incredibly bad idea' to undertake such a project to convert a Lisp dialect to Python?

Re:Logix: Adding macros to Python by pc on Tuesday September 11, 2007 @01:32AM (#53187)
"I know it is a much better VM."

SBCL isn't a VM. It's a Lisp implementation with a compiler that generates native code.

Admittedly, many dynamic languages folks seem to find this concept odd. The idea that {dynamic typing, garbage collection, your favourite feature from ruby/python/perl/php} requires a VM unfortunately seems strongly ingrained.

[deleted]
Re:Logix: Adding macros to Python by pc on Tuesday September 11, 2007 @01:50AM (#53194)
Well, if you really want to use Lisp code and Python libraries, and are prepared to write a compiler, why not do the translation in the reverse direction? Write a compiler from Python to Lisp, and bring Python libraries to Lisp.

[edit: irrelevant stuff removed since parent was deleted]

Re:Logix: Adding macros to Python by AF on Tuesday September 11, 2007 @12:55PM (#53394)
It is definitely something to consider, and while I don't think translating Python to Common Lisp would be all that difficult, I do think that getting the C libraries that Python wraps working with CL might be a significant effort. A lot of the good libraries like csv, re, etc, are implemented in C if I remember correctly.
Re:Logix: Adding macros to Python by jey on Tuesday September 11, 2007 @01:18AM (#53184)
> And I'm just wondering...even with SBCL, why would it be an 'incredibly bad idea' to undertake such a project to convert a Lisp dialect to Python?

Well...what's the point of compiling Lisp into a language with a slower runtime? If you mean that you want it to compiel to something "pretty", well, the output of a compiler is generally not pretty. It's just meant to be used as opaque object code, not something for human consumption.

Re:Logix: Adding macros to Python by AF on Tuesday September 11, 2007 @01:39AM (#53191)
I thought I made it clear. The point of doing that is because you'd have simple access to Python's massive collection of quality libraries.
Re:Logix: Adding macros to Python by jey on Tuesday September 11, 2007 @01:59PM (#53442)
Oh, ok.
Re:Logix: Adding macros to Python by ced on Tuesday September 11, 2007 @04:23AM (#53220)
I "ported" my app from CLisp to SBCL and got a 4x performance decrease. Granted, I must create code at run-time, so CLisp's fast byte code generation probably ends up making the difference. Still.
Re:Logix: Adding macros to Python by ced on Tuesday September 11, 2007 @04:16AM (#53218)
Wouldn't it be best to just interface Python and an existing Lisp, using FFI, or something similar?

I'm already using matplotlib and scipy with CLisp, communicating through pipes. I can write (plot '(1 2 3)). The communication between the two is really not a speed concern. Most of the time, Lisp is not waiting for an answer, so on my dual core, the other core is handling it.

For all its power though, writing Python code in Common Lisp feels really clunky. I don't do it much. I wouldn't feel comfortable writing (funcall (dot somedict keys)) for instance. Macros can only help so much.

Re:Logix: Adding macros to Python by nearfar on Tuesday September 11, 2007 @02:31AM (#53198)
> it would be pretty neat to write a Lisp dialect that compiled down to Python, and therefore you could get access to all the Python libraries, a decent VM, and also macros.

Ok, I had started just that. It's called Boa Lisp. http://nearfar.org/code/boalisp/ http://nearfar.org/code/boalisp/README.txt

(sorry, site will be down for the next few hours)

Re:Logix: Adding macros to Python by kirubakaran on Tuesday September 11, 2007 @10:48AM (#53312)
Seems really cool. Hope you will build on it further.
Re:Logix: Adding macros to Python by kirubakaran on Tuesday September 11, 2007 @04:46PM (#53527)
Is there a way to get REPL?
Re:Logix: Adding macros to Python by nearfar on Wednesday September 12, 2007 @04:04AM (#53751)
Patches are welcome. :)

OTOH, how are you? remember ugh2yay?

Re:Logix: Adding macros to Python by kirubakaran on Wednesday September 12, 2007 @08:17PM (#54081)
Will email :-)
Re:Logix: Adding macros to Python by mdakin on Monday September 10, 2007 @11:19PM (#53141)
I'm no expert (merely a user of these systems) but it seems to me that the Python runtime is a POS compared to what you find in some Common Lisps like SBCL. The really appealing approach to me would be to pull Python into the Lisp environment rather than the other way around. Python's lib is so nice, coherent and complete but Lisp is nicer to program and the tools seem much more mature.
Re:Logix: Adding macros to Python by AF on Monday September 10, 2007 @11:35PM (#53149)
You are right about the runtimes. SBCL is something else. And there have been attempts to pull Python into Lisp:

http://common-lisp.net/project/python-on-lisp/

The only thing is, I find CL a really baroque language. The issues have been touched upon by many, but CL just has many spots where due to being standardized 2 decades ago, it isn't really consistent.

Python for the most part is extremely consistent and the VM runs on any major OS (SBCL still has issues on Windows). Not to mention the language seems to be evolving naturally (Python 3).

That's the main reason I'd like to see a Lisp on Python.

Re:Logix: Adding macros to Python by mdakin on Monday September 10, 2007 @11:45PM (#53157)
Understood, and I agree about Python's consistency and coherent evolution relative to CL. Thanks for the link.
Re:Logix: Adding macros to Python by omouse on Monday September 10, 2007 @11:25PM (#53144)
I'd prefer a Scheme implementation (or two) getting better libraries than Common Lisp.

Check out Bigloo Scheme...it compiles down to C, JVM and .NET bytecode. I've only had it compile down to C but it was really quick. I'll have to get the computer language shootout guys to add Bigloo to their benchmarks.

Re:Logix: Adding macros to Python by mdakin on Monday September 10, 2007 @11:40PM (#53152)
My first Lisp experience was SICP/Scheme and it always felt cleaner and nicer as a language compared to CL. I gravitated towards CL over time due to perceived runtime and library advantages. If any Lisp could pull it all together like Python has I'd jump on board though. And if it was a Scheme then all the better.
Re:Logix: Adding macros to Python by michaelneale on Tuesday September 11, 2007 @08:24AM (#53261)
I agree. CL carries a lot of weight behind it, that is all legacy that really isn't going anywhere. Scheme has always stayed deliberately less "practical" but I think that means it will last longer.
Re:Logix: Adding macros to Python by icey on Monday September 10, 2007 @09:40PM (#53094)
The library bit is the real killer here. There are a fair amount of libraries out there, but they don't live in a terribly centralized location. I think asdf is the "central" repos, but it seems like most of the useful items there have been created by a small handful of users.
Re:Logix: Adding macros to Python by mdakin on Monday September 10, 2007 @11:20PM (#53142)
Indeed I hope pg has a strategy to grow a Python-like library around Arc.