Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"

Re^2: sourcefilter with complete parser?

by Laurent_R (Abbot)
on Dec 11, 2013 at 23:13 UTC ( #1066744=note: print w/replies, xml ) Need Help??

in reply to Re: sourcefilter with complete parser?
in thread sourcefilter with complete parser?


Rolf, to start with, I should say that I have never done anything with source filters and that I barely know what it is all about (having read just a couple of articles on the subject). So my answer might be off-topic, sorry for that if it is.

I just want to say that I have had an experience similar to Roboticus, although certainly much less extensive. We have a major application (35 million customers, many thousands of programs) running under VMS. We were studying the possibility of migrating it to Unix/Oracle (because support for VMS is likely to end within a few years, perhaps before 2020). The main language used for this application (especially for all the functional parts and the database access part) runs under both VMS and Unix, so that most of the work would be recompilation of the sources and any adaptations needed, large project, but it looks feasible. But probably a quarter to a third of the programs are scripts are written in DCL, which is a VMS scripting language, more or less the equivalent of shell script under Unix. These are used to launch multiple processes in parallel, to synchronize processes, transfer, copy or sort files, etc. The immense majority of these DCL scripts would have to be translated into shell script (or even possibly Perl script in some cases).

I participated to a "phase-0" pilot proof-of-concept automatic DCL2shell translating effort, and we were able to produce automatically shell equivalent of our DCL programs within a few weeks. But we knew that we had selected relatively easy cases. Therefore, a second phase (still proof-of-concept) was launched to get into the more complicated things. I was not directly involved in this second phase, so that I can only say what was reported to me: once you get into the more gory details, it gets really very complicated. There are a number of things that just can't be processed automatically and need complete refactoring. And that was only phase 2 of proof of concept study.

The cost of the project, if it were to be launched, was estimated to be in the order of 15 to 20 million euros. A very big amount, indeed, but probably much less than migrating to a completely different system (that would probably cost 3 to 5 times as much). We have some extra time before deciding to go for it or not, but at least we have an idea on how difficult and costly it would be.

My point was just to broadly confirm the general idea of Roboticus's post: translating 80% of the code is relatively easy, the next 15% are getting really hairy, and the last 5% might take more time than all the rest together.

OK, I am not talking about a simple program, but about a very complex application with thousands of programs. What you are trying to do might be simpler (hopefully it is), but it is definitely not a simple task.

  • Comment on Re^2: sourcefilter with complete parser?

Replies are listed 'Best First'.
Re^3: sourcefilter with complete parser?
by LanX (Chancellor) on Dec 12, 2013 at 00:50 UTC
    Thanks, even if you replied to the wrong person. =)

    Please let me point out that 100% translation is always possible if you don't care about performance.

    The most brutal force (if this word exists) is done by emulating the CPU of a processor supporting the language.

    I'm not interested to emulate or translate more than 80% of a language even if it might be quite easy with some LISP dialects were most of the complicated constructs are just implemented in some core stuff.

    Let me give you an example: there is a very subtle difference how JS and Perl numify strings.

    Frankly I don't care to support software which relies on such differences. It even throws warnings.

    DB<116> use warnings;0+"2" => 2 DB<117> 0+"ss2" => 0 DB<118> 0+"3ss2" => 3 DB<119> use warnings;0+"3ss2" Argument "3ss2" isn't numeric in addition

    >>> a="ss2"; 0+parseInt(a) NaN >>> a="3ss2"; 0+parseInt(a) 3

    Of course it's possible to wrap every variable in numeric context with a function which numifies the Perl way.

    Such a code would be incredibly slow.

    But only supporting the "normal" scalar case were strings are to be treated like numbers is far faster.

    Just substract zero:

    >>> a="2"; 0+a "02" >>> a="2"; 0+a-0 2

    My theory is that it's pretty feasible to create a new language which is a subset of Perl5 or Perl6 and creates acceptable JS.

    "Acceptable" doesn't mean 100% compatible. Neither different versions of Perl nor JS are ever 100% compatible.

    perlito is already quite good at this.

    Cheers Rolf

    ( addicted to the Perl Programming Language)

      My theory is that it's pretty feasible to create a new language which is a subset of Perl5 or Perl6 and creates acceptable JS.

      Have you considered helping Pawel Murias, Jimmy Zhuo, Reini Urban, Zaki Mughal, Tokuhiro Matsuno et al progress the JS backend for NQP? Note that while that project's main goal is to compile Rakudo Perl 6 to JS (which is why the repo is called rakudo-js), the interim goal is to compile the much simpler NQP to JS and (based on comments by pmurias) the project is quite close to achieving this lesser goal.

      Achieving this lesser goal would mean a few things potentially relevant to your quest:

      • There'd be a Perlish lang (NQP -- not quite a small subset of P6) that targets JS (in addition to PIR/Parrot, Java/JVM, and MoarVM).
      • There'd be a Perlish toolkit (also called NQP) for easily creating langs, dialects, and compilers that automatically target JS (and NQP's other backends).
      • Anything you did to improve JS codegen would be leveraged by all langs/compilers in the NQP ecosystem (NQP itself, P6, phpish, rubyish, yourlang, et al).

        I'm was considering now...

        But B::Deparse has my priority and each time I looked into perlito it resulted into mail dialogs with Flavio.

        I need a projects which keep me entertained and B::Deparse is fun ... and last time I talked to Reini in Kiev he wasn't too fond about porting to JS.

        But you might help me with your expertise:

        Do you know any Perl6 on Perl5 implementation?

        Or at least a P6-parser in P5 and/or a consistent language specification?


        Or s/Perl6/NQP/ for last three questions.

        Cheers Rolf

        ( addicted to the Perl Programming Language)

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1066744]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (10)
As of 2016-10-21 21:03 GMT
Find Nodes?
    Voting Booth?
    How many different varieties (color, size, etc) of socks do you have in your sock drawer?

    Results (290 votes). Check out past polls.