by piemonkey · 10y ago · 0 comments
I am very intrigued by Lia [0] as an example for how languages can be embedded inside of one another for useful effects. See Will Crichton's great blog post for more [1].
However, I am wondering why Python and PHP were chosen. I can't think of a compelling use for having both languages simultaneously. They are both dynamic scripting languages with similar design objectives.
[0] https://github.com/willcrichton/lia [1] http://notes.willcrichton.net/the-coming-age-of-the-polyglot...
> Depending on how one chooses to classify programming languages, Python and PHP can appear similar—most obviously, both are dynamically typed. From our perspective, however, there are a number of tricky differences: PHP has multiple global namespaces which can span multiple files, whereas Python uses one global namespace per file (semantic friction); most of PHP’s core data-structures are immutable, whereas many of Python’s are mutable (semantic and performance friction); and PHP’s sole collection data type is a mapping, whereas Python separates the notion of mappings from that of sequences (semantic and performance friction). As this may suggest, this combination of languages presents a number of design and implementation challenges which have no obvious precedent. We show that PyHyp’s solutions to these challenges allow interesting case studies to be implemented.
- R has lazy evaluation semantics (with caveats), and Python is eagerly evaluated. The ggplot library in Python recently posted to HN sheds some light on these issues.
- R has like 2 or 3 class systems; Python has a C++-like class system (without static typing, but gaining it in Python 3)
- They differ in semantics with respect to closures (Python 3 changed things a bit)
- R's built-in types are all vectorized, but that might be a good thing, so you can use Python semantics for scalars and R semantics for vectors/data frames/matrices, etc ?
- Python has decorators, generators, coroutines, etc.
I tend to write my Python and R in a pretty small common subset, but yeah they are in fact quite different.