Set::Symbolic -- the rewrite |
[May. 2nd, 2007|06:14 pm]
Brad Fitzpatrick
|
About a year ago or so I wrote some code on a laptop while on a trip, then destroyed my laptop hard drive somehow before the trip was over, so I was unable to get it checked into version control anywhere.
I never got around to rewriting it because it was too depressing, and it was only for a fun project/feature anyway ... nothing critical.
Well, I started rewriting it... at least the docs:Set::Symbolic - base class for sets which can be operated on symbolically
Set::Symbolic lets you define and work with sets which be manipulated and operated on symbolically. For instance, you can do operations like union, intersection, removal, etc of large or abstract sets without actually evaluating or loading their contents. When finally wanting to know the contents of a expression involving a lot of sets, Set::Symbolic will figure out the best execution plan (order of evaluation) and/or symbolic reductions to minimize loading cost of constituent sets, using hints provided by the sets themselves (which may not even know their exact size or contents). That's as far as I've gotten. I don't think anything exists on CPAN to do this? I looked around again just now but couldn't find anything. Anybody know? |
|
|
Comments: |
I would so have used this last year when I was doing some finite topology that involved manipulating power sets.
![[User Picture]](https://l-userpic.livejournal.com/54541970/2) | From: brad 2007-05-03 01:29 am (UTC)
| (Link)
|
I would've loved it too! :(
We'll see if I finish it again this time... I don't really need it for anything at the moment.
Will you come join oldskoollj and visit with some of your original LJ users? :) I think you would like that.
Guh. You want to write that in perl? Sounds very *very* FP to me.
![[User Picture]](https://l-userpic.livejournal.com/54541970/2) | From: brad 2007-05-03 05:41 am (UTC)
| (Link)
|
Perl can be very FP, if you want it to be. Look at the guts of DJabberd, for instance.
Of all the languages out there, what is it keeps you stuck on Perl? I made a deliberate effort to stop programming in Perl and switch to doing everything in Python. Is it simply because you have so much Perl code now that switching to a new language would be a lot less useful?
![[User Picture]](https://l-userpic.livejournal.com/54541970/2) | From: brad 2007-05-03 08:32 am (UTC)
| (Link)
|
The only problem with Perl is that it has a reputation for being unreadable, because a lot of sysadmins who aren't programmers also write Perl. Perl can be beautiful.
I've tried to write Python and tried to write Ruby, but both frustrate me in little to severe ways, and aren't enough better than Perl to warrant a switch. Python's the closest to being compatible to me, but its anonymous function declarations blow... way too verbose. Don't even get me started on all the things I hate about Ruby.
Yes, Perl has its ugly quirks too, but I know them all, and their history. So basically I hate everything, and I hate that they're not all compatible. I'm really hoping Parrot becomes a reality one day, or something like Microsoft's DCLR (CLR layer for dynamic languages). Whatever. I just want to share libraries between languages.
Perl 6 looks good, and I might even start using it soon here, given that Pugs will compile it to Perl 5, JavaScript, etc.
*shrug*
Can't agree more - can count time when I wanted to switch to something new just because perl is not considered cool and it's hard to find people who will write in it but I can't - Perl is very hard to quit. I tried Python and Ruby - no luck. I'm not even mentioning freaking PHP which seems to be the most popular tool but sucks beyond belief.
Funny enough, I like JavaScript even more then Python and Ruby, especially after all classes by Douglas Crockford and his JSLint and JSMin.
![[User Picture]](https://l-userpic.livejournal.com/54541970/2) | From: brad 2007-05-03 08:41 pm (UTC)
| (Link)
|
Yeah, I like JavaScript a lot. I just don't like the lack of block scoping. I always have to make an anonymous function inline and immediately call it if I want a new scope that, say, closures can capture variables in... especially inside loops... for (var i=0; i<100; i+=) {
(function(){
// real loop body here.
})();
} Kinda lame. But fixed in JS 2.0.
I write stuff in all sorts of languages. I call it the "right tool for the job" philosophy.
Who says you can't do functional programming in Perl? "With lexical scope and anonymous closures, you have pure untyped λ-calculus" says mjd, and he's cleverer than I am, so I'm inclined to believe him.
How's the performance of FP style in perl? Many languages have the features, but fall down on the performance.
dodging the original question, I have a pure bash implementation of that set stuff that I wrote for an app...
![[User Picture]](https://l-userpic.livejournal.com/54541970/2) | From: brad 2007-05-03 05:41 am (UTC)
| (Link)
|
Gross. :)
Closest thing I can think of off the top of my head is Quantum::Superpostions, which has an overloaded scalar that simultaneously represents all members of the set it represents...
I don't think it does the smart execution plan things though.
"Set::Symbolic lets you define and work with sets which be manipulated and operated on symbolically."
I think you are missing a 'can' in there.
![[User Picture]](https://l-userpic.livejournal.com/54541970/2) | From: brad 2007-05-03 10:42 pm (UTC)
| (Link)
|
Uh... Except, not at all. SQLite works with concrete sets. You put data into it, then select from it. It doesn't let you work with abstract sets which aren't necessarily backed by data.
An upside of concrete sets is that you can figure out that an O(n) algorithm is faster than an O(1) algorithm if you can count the set and discover it to be extremely small.
My best understanding of not doing this is basically just always pick the best algorithm, and forget about trying to optimize the fixed overhead out. Yeah? | |