?

Log in

No account? Create an account
Set::Symbolic -- the rewrite - brad's life [entries|archive|friends|userinfo]
Brad Fitzpatrick

[ website | bradfitz.com ]
[ userinfo | livejournal userinfo ]
[ archive | journal archive ]

Set::Symbolic -- the rewrite [May. 2nd, 2007|06:14 pm]
Brad Fitzpatrick
[Tags|]

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?
LinkReply

Comments:
[User Picture]From: teferi
2007-05-03 01:27 am (UTC)
I would so have used this last year when I was doing some finite topology that involved manipulating power sets.
(Reply) (Thread)
[User Picture]From: brad
2007-05-03 01:29 am (UTC)
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.
(Reply) (Parent) (Thread)
From: lakme
2007-05-03 01:35 am (UTC)
Will you come join oldskoollj and visit with some of your original LJ users? :) I think you would like that.
(Reply) (Thread)
[User Picture]From: taral
2007-05-03 04:48 am (UTC)
Guh. You want to write that in perl? Sounds very *very* FP to me.
(Reply) (Thread)
[User Picture]From: brad
2007-05-03 05:41 am (UTC)
Perl can be very FP, if you want it to be. Look at the guts of DJabberd, for instance.
(Reply) (Parent) (Thread)
[User Picture]From: ciphergoth
2007-05-03 08:17 am (UTC)
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?
(Reply) (Parent) (Thread)
[User Picture]From: brad
2007-05-03 08:32 am (UTC)
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*
(Reply) (Parent) (Thread)
[User Picture]From: schernyshev
2007-05-03 07:47 pm (UTC)
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.
(Reply) (Parent) (Thread)
[User Picture]From: brad
2007-05-03 08:41 pm (UTC)
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.

(Reply) (Parent) (Thread)
[User Picture]From: taral
2007-05-03 11:56 pm (UTC)
I write stuff in all sorts of languages. I call it the "right tool for the job" philosophy.
(Reply) (Parent) (Thread)
[User Picture]From: schernyshev
2007-05-04 04:12 am (UTC)
(Reply) (Parent) (Thread)
[User Picture]From: blech
2007-05-03 05:42 am (UTC)
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.
(Reply) (Parent) (Thread)
[User Picture]From: taral
2007-05-03 11:54 pm (UTC)
How's the performance of FP style in perl? Many languages have the features, but fall down on the performance.
(Reply) (Parent) (Thread)
[User Picture]From: robbat2
2007-05-03 05:31 am (UTC)
dodging the original question, I have a pure bash implementation of that set stuff that I wrote for an app...
(Reply) (Thread)
[User Picture]From: brad
2007-05-03 05:41 am (UTC)
Gross. :)
(Reply) (Parent) (Thread)
[User Picture]From: 2shortplanks
2007-05-03 10:36 am (UTC)
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.
(Reply) (Thread)
[User Picture]From: joshrotenberg
2007-05-03 04:06 pm (UTC)
"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.
(Reply) (Thread)
[User Picture]From: xlerb
2007-05-03 10:31 pm (UTC)
DBD::SQLite?
(Reply) (Thread)
[User Picture]From: brad
2007-05-03 10:42 pm (UTC)
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.
(Reply) (Parent) (Thread)
[User Picture]From: sodabrew
2007-05-05 03:20 am (UTC)
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?
(Reply) (Parent) (Thread)