320 likes | 348 Views
Parrot in the Real World. Dan Sugalski dan@sidhe.org. A Presentation in two parts. Part 1 - The practical project Part 2 - The ramifications. Yarde Metals. Metals wholesaling company $200M+ year 400K+ items/year 400+ employees 6 branches. Metaltraq.
E N D
Parrot in the Real World Dan Sugalski dan@sidhe.org
A Presentation in two parts • Part 1 - The practical project • Part 2 - The ramifications
Yarde Metals • Metals wholesaling company • $200M+ year • 400K+ items/year • 400+ employees • 6 branches
Metaltraq • Whole company run on a package called Metaltraq • Handles sales, shipping, tracking, invoicing--pretty much everything • We have the source, all 460K lines of it • Unfortunately it’s in DecisionPlus
System Setup • Whole company runs on a single server • All terminal-based access • ISAM database, one index per data file • Only access to data through DecisionPlus
Reports Screens DecisionPlus Language Basic Architecture Engine Database Screen
The Problems • The underlying database engine has size issues • Integrated database is all ISAM • DecisonPlus, as a language, is nasty • Stuck on SCO Unix as a platform
The size issues • Each data file has a maximum size limit • Our most active only holds about 17 months of data • That was 18 months a while back • Good for the company, bad for MIS
ISAM. Ick • The only access to the data is via DecisionPlus • One index per table • Serious performance issues if you don’t use that index • Any data queries need MIS help
DecisionPlus • Antique 4GL • Slightly more primitive than Parrot’s assembly language • No subroutines, just labels, goto, and gosub • No blocks, just continued lines • Limits on the length of a single line • No lexicals. Or, really, globals • Phenomenally primitive array access
Two language versions • Forms, with screen interface • Reports, with looping, totalling, and cross-reference file support • Two versions of the same language, subtly different
SCO Unix as our platform • Need anything more be said?
The Original Plan • Move database to Postgres • Compile all programs into Perl • Dump original source • Do all new work in Perl
It was a good plan… So, of course it was doomed to failure Sort of
Transition to Postgres worked • We play trigger games to simulate ISAM behaviour • Auto-generate the “ISAM key” • DB thunking layer knows how to use this info • Nightly transfer gives us an up-to-date data warehouse • Already in production use
Destination: Perl… not so good • DecisionPlus is really primitive • No subroutines or functions, just labels you can goto and gosub to • No lexical variables either • Or, technically, any variables at all • The generated perl was horrible
Perl really isn’t a target language • Working around the scoping issues was… interesting • The resulting code looked like machine-generated code and wasn’t really editable • It was so non-perl that working with it would’ve really hurt • Performance penalties with no win
The New Plan • Target Parrot instead • We had the parser • We had a working compiler • Parrot was working fine
Balancing the Issues • Parrot gave us multi-language capabilities • Most of which were theoretical • Engine was fast • But… untested • So we did the sensible thing--a test run
The Test • Get a simple screen running • Jan 9th deadline • Made it with hours to spare
Pretty big test • Working DB access library • Working screen access library • 70% of the language
What we have • 6K lines of PIR code in support libraries and class libraries • ~660 line DecisionPlus Parse::RecDescent grammar • 5K line compiler in perl • Full interface to Postgres & ncurses • No C code at all
Project Status • Currently in-house beta • August general beta • Looking for a September or October rollout • Still got some things to thump, but they’re almost all compiler and runtime things • One big parrot bug
What this did for Parrot • Didn’t alter the design, though it did change the timetable some • Multimethod dispatch • Objects • Dynamic bytecode loading • Stress-tested Parrot a lot
The Ramifications • Really nice target for many languages • Generating code is really, really easy • Interfacing’s simple • Dynaloading’s handy
Nice target • Parrot maps well to procedural languages • Object and MMD systems makes custom data types simple • Surprisingly stable
Easy code generation • AST->PIR translation is trivial • Parrot hides a lot of the tricky stuff • Calling Conventions • Register coloring • Instruction set maps nicely to most languages
C interfacing’s dead-easy • No C code needed • All with Parrot’s NCI interface • For a 2 hour hack it’s stood up really well
Dynamic loading games work • Parrot’s built-in compilation system’s easy to use • Loading bytecode, assembly, or PIR work the same way • Bit limited with compilers right now, alas
End conclusions • Compilers really aren’t tough • Parrot’s a nice target for compilers • Our cross-language features do work as we’d hoped • Moving a 4GL to Parrot is reasonably (potentially easily) doable