Live data from Hacker News

SPy: An interpreter and compiler for a fast statically typed variant of Python

antocuni.eu

91–100 of 133 posts

Re: SPy: An interpreter and compiler for a fast statically typed variant of Python

#91
post #41
post #39

Earlier quoted context omitted.

> A type is a contract, not a hint! In Python it is a hint.

Exactly. That was their worst mistake ever

I agree. I use Beartype to get runtime type checks, but it shouldn’t be necessary. Some support for type checking, whether at byte compile time or runtime, should land upstream.

Re: SPy: An interpreter and compiler for a fast statically typed variant of Python

#92
post #45

It's weird, but the pain of moving to a whole new language seems less than the pain of using one of these language subsets. I guess it might be because of "loss aversion": we dislike losing something we have more the value we put on gaining it. In a new language each newly added feature is a gain, but in a language subset you're always encountering things you would have in the full language. So no matter how good the…

One of the standard architectures for complex applications is to put together a scripting language and an systems programming language. You can either look at the scripting language as primary with the systems language used for performance or hardware interfacing or you can look at the systems language being primary and the scripting being used around the edges. The model of having a closely related scripting and sys…

Yes, there are quite many real-world cases of this architecure. But, wouldn't it be better it the same language (more or less) can be used for both? I don't think such a language exists currently, but I think it would be a nice goal.

Re: SPy: An interpreter and compiler for a fast statically typed variant of Python

#93

While obviously this would need CPython to SPy `import` support for it to displace CPython for me, it seems like you can `import` SPy to CPython, which makes it an attractive solution for implementing fast libraries where Rust is perhaps too heavy duty.

Seems correct. See point.spy in the playground here: https://spylang.github.io/spy/

# - the unsafe module allows C-level direct memory access to pointers and unsafe arrays

# - @struct maps directly to C structs

# - most users will never have to deal with this directly: using the unsafe` module is the equivalent of writing C extensions or using Cython

Re: SPy: An interpreter and compiler for a fast statically typed variant of Python

#94

Earlier quoted context omitted.

You can have that today with Nim.

There don't seem to be great web frameworks like Flask, Django, or FastAPI for Nim.

"Great" smells very subjective. I went to https://forum.nim-lang.org/ . Put "flask" in the search box. Second hit (https://forum.nim-lang.org/search?q=flask) is this: https://forum.nim-lang.org/t/11032 . That mentions not one but 2 projects (https://github.com/HapticX/happyx & https://github.com/planety/prologue).

If either/both are not "great enough" in some particulars you want, why not raise a github issue? (Or even better look into adding said particulars yourself? This is really the main way Python grew its ecosystem.)

Re: SPy: An interpreter and compiler for a fast statically typed variant of Python

#95
post #60

Earlier quoted context omitted.

There is a compiler detailed in the page on the link; > 3. We have a compiler for deployment and performance. The interpreter and the compiler are guaranteed to produce the exact same results at runtime.

Where is it? Would love to compare the approach to py2many.

https://github.com/spylang/spy

Re: SPy: An interpreter and compiler for a fast statically typed variant of Python

#96

Earlier quoted context omitted.

One of the standard architectures for complex applications is to put together a scripting language and an systems programming language. You can either look at the scripting language as primary with the systems language used for performance or hardware interfacing or you can look at the systems language being primary and the scripting being used around the edges. The model of having a closely related scripting and sys…

Yes, there are quite many real-world cases of this architecure. But, wouldn't it be better it the same language (more or less) can be used for both? I don't think such a language exists currently, but I think it would be a nice goal.

Oxcaml, of course.

Re: SPy: An interpreter and compiler for a fast statically typed variant of Python

#97
As a prospective user the first thing I look for is lists, list comprehension, list slices, string methods, zip, zip*, tuple destructuring, generators, dicts and sets. These data structures, their syntax, and associated methods are what make Python a joy to use. They are what make it possible to solve a puzzle in a one-liner.

The examples in the playground are neat but I don’t see any of the Python bread and butter usage. I see C with Python syntax.

I’d like to see Python syntax solving a problem in a pythonic way, albeit with type annotations. And then I’d like to see the compiled version run 30x-100x faster. Is that ultimately the promise of this project?

Re: SPy: An interpreter and compiler for a fast statically typed variant of Python

#98

Earlier quoted context omitted.

Yes, there are quite many real-world cases of this architecure. But, wouldn't it be better it the same language (more or less) can be used for both? I don't think such a language exists currently, but I think it would be a nice goal.

Oxcaml, of course.

Interesting, I was not aware of OxCaml. (If this is what you mean.) It does seem to tick a few boxes actually. For my taste, the syntax is not as concise / clean as Python, and for me, it is "too functional". It shares with Python (and many high-level languages) the tracing garbage collection, but maybe that is the price to pay for an easy-to-use memory safe language.

In my view, a "better" language would be a simple language as concise as Python, but fully typed (via type inference); memory safe, but without the need of tracing GC. I think memory management should be a mix of Swift and Rust (that is, a mix of reference counting and single ownership with borrowing, where need for speed).

Re: SPy: An interpreter and compiler for a fast statically typed variant of Python

#99
post #45

It's weird, but the pain of moving to a whole new language seems less than the pain of using one of these language subsets. I guess it might be because of "loss aversion": we dislike losing something we have more the value we put on gaining it. In a new language each newly added feature is a gain, but in a language subset you're always encountering things you would have in the full language. So no matter how good the…

The author seems to speak to that here: > SPy does something different: on one hand, it removes the dynamic features which make Python "slow", but on the other hand it introduces new features which make it possible to implement and use the same pythonic patterns which we like. The author seems unusually focused on explaining his new way, which may help it feel more like a new language with a coherent philosophy and u…

Not unlike how Crystal isn't really "compiled Ruby" but rather its own language that just looks and feels similar to Ruby.

Re: SPy: An interpreter and compiler for a fast statically typed variant of Python

#100

I like the idea of a compiled language that takes the look and ethos of Python (or at least the "looks like pseudocode, but runs"-ethos) I don't think the article gives much of an impression on how SPy is on that front.

I believe that Python is as popular and widely used as it is because it's old enough to have an expansive ecosystem of libraries. It's easy enough to implement one in pure Python and possible to optimize it later (Pydantic is a great recent-ish example, switching to a Rust core for 2.0). That same combination of Python + (choose a compiled language) makes it quite difficult for any new language to tap into the main s…

Python is popular because of it's expansive ecosystem of libraries, which only exist because the language is duck typed. If it was statically typed, the expansive ecosystem of libraries wouldn't exist.

There is a factor of 3x difference in dev speed between the two typing systems.

Post reply on HN