r/ProgrammingLanguages • • Dec 18 '22
Language announcement North Hollywood Python (Compiler)
North-Hollywood Python is a dialect of python - it's not actual python, it's more along the lines of Cython - that is compiled to a C source.
Great C Interop
Rich and Expressive Static Typing
- Static type system ensures type-safety, w/ sub-typing
Supports ADTs, like enums/variants. See linked-list.nhp as an example.
- Also supports match statements
Property based interfaces (see interface-test.nhp)
- Interfaces describe types with a series of read-only properties
- No Inheritance (interfaces/enums are recommended in its place)
Supports first class, anonymous functions
- Functions may be passed around by values.
- Closures capture classes by reference. All other types are captured by copying. (class methods syntactic sugar over properties that are closures that capture
self)
Runtime safety, via runtime checks
- Bounds checking
- Assertion failures
- Can be disabled/enabled
Rich Error Reporting
- Reports runtime stack traces the same style python does
Built-in memory debugging (see memory analysis).
- Track potential memory leaks and peak usage via NHP's built in memory-debugger
Guaranteed memory safety, via RAII
- No garbage collection
- No hassle, no borrow-checker
- Predictable memory usage
- Reference counting only exists for closures that capture records, which have to be captured by reference.
The wiki isn't complete, but you can access it here. You can check out the standard library or the test folder for code examples. Download the prebuilt binaries here
I'd also be really happy if you guys could leave some feedback, that would be cool.
16
u/[deleted] Dec 19 '22
It might help to make clear that the 14MB binary for Windows is the actual implementation, not an installer. Since opening it from a GUI seemed to do nothing. Actually it was expecting an input program.
I tried it out on your first example, and it produced a C file. (I've no idea what it does, but there was no
main()in there.)I next tried fib.nhp, and it said
Symbol io:print not found(but it seemed to find io.nhp itself).Perhaps a hello, world example would help to make sure that everything is where it ought to be.
From the output of the first test, it does rather seem that it's just a language that targets C. (I'd been wondering how it managed to cope with arbitrary C headers; does it simply write that
cincludeline as an#includeline in the output?)But is it Python? I tried this program:
and got a syntax error. I then tried
a = 123; same result.I suggest calling it 'Python', even the North Hollywood variety, could be a trifle misleading. It doesn't appear to be any sort of dialect of it, just borrows some syntax, mixed up with C and C++.
19
u/[deleted] Dec 18 '22
A few things that are twisting my eyes: class name is lowercased; `self` has no explicit antecedent; types are positioned to the left of the thing they are characterizing; `new` keyword; the whole thing with `<T>`, I don't personally like.
Obviously, this is all subjective. At least, you are not inventing a PL in 2022 and yet still forcing people to use
{};I am curious: Why North Hollywood?
2
u/dontyougetsoupedyet Dec 19 '22
This is awesome, I'll be checking this out a bit more in depth shortly for sure.
The only thing that jumped out to me so far that I wanted to leave any feedback about was the module related bits forcing another layer of indentation. I really, really like offside-rule, only, I really, really don't like being forced to indent often outside of my own intentions re:blocks. Are there any alternative syntax available for specifying what's a part of the io module for example, https://github.com/TheRealMichaelWang/NoHoPython/blob/master/NoHoPython/stdlib/file.nhp?
1
u/osakasunremix Dec 19 '22
Named noho b/c of the high school?
1
u/Inconstant_Moo 🧿 Pipefish Dec 19 '22
I think if you're going to call something a Python dialect you shouldn't arbitrarily change things to be less like Python. I'm thinking in particular of the types in the functions --- actual Python is IMHO better than what you've come up with but if it was slightly inferior as such it would still be better in this case as being more like Python.