Lambdascript – A new pure functional language built on top of Python
github.com
github.com
Many of these Python built languages seem to flip it around and build on the weaknesses of Python and not build on Python's strengths.
http://www.oilshell.org/blog/2016/11/30.html
update here: http://www.oilshell.org/blog/2017/01/06.html
I'm not claiming my experience generalizes... if you have a lot of Java-like code you can probably use mypy. Bizarrely, some people do actually have a lot of Java-like Python code.
From what I've seen, literate programming is great in theory and worse than useless in practice. It's so far away from reality. I have had the misfortune of working on a FunnelWeb codebase, and it was one of the most incomprehensible codebases I've ever seen.
Preprocessing the code is an awful step in any language. Somehow, the "not documentation" still goes out of date. There are several other problems, explained at [0] better than I can in a comment.
Specifically about this project: While I enjoy writing blogs in markdown because of its constraints, reStructuredText (reST) is more powerful/expressive (by design). Because you can easily express semantics/relationships, the resulting links in the generated documentation make the "web" of source code easier to navigate - something Knuth was trying to do with literate programming.
Literate programming goes in the opposite direction, and I don't think that's necessarily good, though it has it's use cases. I think data science with Jupyter notebooks are a great display of when it's good (and that's likely the best / most used form of literate programming out there), because in data science a lot of what you need to justify is the "why" a calculation is done the way it's done. Pretty graphs inline are just a bonus.
For ordinary code though? Comments are a fallback for complicated bits, but I feel like they shouldn't be the norm. I want people to write code that doesn't need hand holding just to understand.
If your end goal is to produce some kind of largely static artifact then literate programming is fine. For everyday code where you iterate and refactor all the time, literate techniques have all the downsides of prolific comments.
I've found it really useful for a big Django project, when I add some functionality, the definition of the models, views, dependencies and URL references are all adjacent in a nicely indicated section and subsections. Navigating around it in a PDF reader has been more pleasent than scrolling up and down code, and hunting for the appropriate file, as I would often find myself doing in Eclipse.
I'm also able to put output of the tests into the doc, and a full set of installation instructions from a fresh machine, and usage instructions, in the same doc with pointers to the appropriate code chunk.
Much of this can be achieved in various other ways. But the actual result is that I've been much happier in my last few literate projects, than I was in the ones before that.
Finally, I've also noticed that I don't have the encroaching feeling of my current project getting a bit big and unwieldy even though this is easily the most complicated thing I've ever done.
But according to Knuth, literate programming is about more than online code, it also includes the whole web-o'-macros thing.
> I'm also able to put output of the tests into the doc, and a full set of installation instructions from a fresh machine, and usage instructions, in the same doc with pointers to the appropriate code chunk.
Python has ways of doing this, and all of this just feels like overloading a document. Repos exist for this, and work fine keeping everything together.
https://github.com/jameysharp/corrode/blob/master/src/Langua...
[0] https://stackoverflow.com/questions/16869050/is-literate-pro...
Funny you ask this, I ran across a @raganwald post mentioning a great example of ^literate programming^ (mixing code and documentation), "Literate CoffeeScript" [0]. You can read about how CoffeeScript does this at http://coffeescript.org
[0] blog post: http://raganwald.com/2013/03/27/literate-coffeescript.coffee...
[1] raw text: https://raw.githubusercontent.com/raganwald/raganwald.github...
If it's just for comment, that's some impressive work. The compiler is fairly short and is a good demo of how you can do this sort of thing surprisingly quickly if you know what you are doing.
If you intend this as something a lot of people will use, then I'd express very serious concerns about building this on top of Python. Python is one of the slowest languages there is [1]. Putting a mismatching paradigm on top of it is going to cost you some sort of multiplicative slowdown, which could very easily be in the 5x range and could even be in the 20x-50x range. Expect another penalty in memory consumption for what is again already a bit of a memory-using language. It's not long before you've got a language on your hands that is 200-500x slower than C, and perhaps more to the point, 100x slower than Haskell itself. This will make trying to convince anyone else to use it an uphill battle, because while performance isn't everything (Python is perfectly suitable for many uses, of course), insufficient performance is a critical blocker for using it for some project, and performance this bad will be "insufficient performance" for a lot of projects.
Let me be clear that I am NOT pointing this out as a "criticism" of the project. If you are doing this to learn or share some fun stuff, this is irrelevant to you, and let me re-emphasize that you're off to what looks like a good start! I mean this in the spirit of warning you about what may be your biggest problem, depending on your unspecified goals, so you can make good engineering decisions about what to look out for and what to tackle.
One possible solution you could consider is rather than targeting Python AST, which I think your code is doing?, you might consider targeting the bytecode directly. While you're still going to experience a certain amount of paradigm mismatch, you might find this cuts perhaps a 2x out of the multiplicative slowdown stack, gives you more options that Python directly does, and especially in the case of PyPy, may give you the option of examining what bytecode constructs PyPy is better able to optimize and give you some wiggle room in what you emit that you can exploit.
Even if this is just a learning project you may also find you learn useful things by doing this; "emitting bytecode" is a popular option nowadays, with things like LLVM. From emitting bytecode for Python you may even find it not to be too big a leap to emit native code with LLVM, too. A language that automatically works natively when code is implemented in pure lambdascript but transparently interacts with Python would start turning some heads. It's not hard to imagine potentially getting some speedups over Python. Though that's a tougher bar to clear; you've got a typesystem to think about at that point. The code is currently so small and agile it's a good time to start looking at these issues.
[1]: I no longer believe "languages don't have speeds, only implementations do". After many years of trying to speed up the many dynamic scripting languages and generally hitting a wall around 10x-20x slower than C across the board, I now consider the burden of proof that languages do not at least set lower bounds on performance to be on someone who can produce a truly fast-as-C dynamic language interpreter/compiler. (Obligatory LuaJIT callout as the closest to date.)
It seems the submitter is also the author of that project, so I guess this is just a forgotten "Show HN:" prefix in the title.
Now, sticking to that language for a final version would be more concerning, but even that ain't really a dealbreaker; lots of "slow" languages are perfectly capable of interfacing with "fast" languages through some kind of FFI (or, at the very least/worst, IPC over some kind of pipe or socket or what have you). Gradually writing faster implementations as you run into bottlenecks is a perfectly common and reasonable development approach.
Neither do I. That's why I conditionalized that point on the intent of the poster, who as of this writing has not replied to any of these comments.
I wish people would be more clear about their intentions. I have no problem with any of them, ranging from idly showing off something they did for discussion to "I intend professionals to drop everything and use this exclusively", but the feedback appropriate to the various cases along that range are very different. I don't want to blast a student for not creating something that Google can base their next 10 years on, but I don't want to provide someone trying to win over professionals with feedback about their capitalization of identifiers.
But kudos for adding tail recursion to a pythonic language. At last.
- Lambdascript runs on Python3.x
- Grumpy runs on Python2.7
I can only hope I guess ...
I think there are some much better ideas surfacing soon.
E.g. the best parts of OOP were the ideas of data encapsulation, of modularity, of interfaces separate from implementations. These live on, whether you use method dispatch and inheritance or not.