DEV Community

Cover image for Peregrine Rewrite - The python-like language that's as fast as C
Ethan Olchik
Ethan Olchik

Posted on • Updated on

Peregrine Rewrite - The python-like language that's as fast as C

Hey guys!
My name is Ethan, and I'm one of 12 Peregrine developers. Some of you may already know what Peregrine is, some of you don't, but this article is going to explain the current state at where Peregrine is at.

What is Peregrine

If you know Python, you know how easy it is. However, it also comes with a big downgrade. Python is slow, and I'm pretty sure every python developer knows this by now. This is kind of annoying. That's where Peregrine comes in. Me and 12 other friends have been working on Peregrine for the past few months, starting as a hobby project. Peregine's syntax is very similar to Python's, and it gets trans-compiled to C, thus making it as fast as C.

Update on Peregrine's current status

Name

Peregrine's name has been getting more popular ever since I posted my last article, and a lot of things has been changed. The most noticeable thing that has changed is the name. A lot of people recommended a name change from Swallow, so it is now called Peregrine which we think suits the language more.

Rewrite

You probably already know this from the title - Peregrine is getting a rewrite. We are writing this in Python. The Lexer is already complete. We are going to rebuild the parser and codegen so it will be more efficient, and hopefully faster. This is all being done on a different branch.

Peregrine as a scripting language

Peregrine uses tcc as a secondary backend to allow it to be used as a scripting language. It uses vlibtcc which is a V wrapper for libtcc. It was implemented yesterday and is still at a very early stage. Some features do not work with it, so it is not recommended to use it at this stage, however it will be updated and fixed in the rewrite.

FAQ

Q: Is Peregrine a hobby project?

A: As of 9/10/2021, Peregrine is no longer a hobby project.

Q: Can I join the developer team?

A: Peregrine is not in need of new Developers at the moment, however you can always contribute to the repository.

Q: Is there a discord server?

A: Yes, you can join it by clicking here

Q: Why not contribute to Nim or Julia?

A: Peregrine has different goals than Nim and Julia. They also achieve different things in different ways.

Q: Will all python modules be compatible with Peregrine?

A: Yes, that's the plan. It will take a long time to implement as it is a difficult task, however it will be there.

Got any more questions that you would like to be answered?

You can open a new discussion that discusses your questions. You can also email saptakbhoumik@gmail.com, or join our discord server

Conclusion

Peregrine is planned to release version 0.0.1 sometime in March, so make sure to show some support by starring the repo and make sure to press on the "Watch" button so you don't miss any updates.

We would greatly appreciate any contributions, so if you find something that you can improve, open a pull-request! You can also check out our open issues. Please make sure you contribute to the rewrite branch, as we are going to replace the main branch with the rewrite.

Thanks so much for reading <3!

Discussion (23)

Collapse
schollii profile image
schollii

Please don't make the same mistake as Nim: beautiful python-like syntax, type inference etc but misses one super important capability that made Go become more popular despite lack of generics and try/except, and that's first class concurrent processing which nowadays is essential. Don't make it a library, rather provide some language constructs that build on the ideas of Go channels and even maybe address some of their limitations (there are some).

Collapse
aboominister25 profile image
Rayyan Cyclegar

Hm, isn't an eventual goal of this language compatibility with python libraries? If it is, I'm not sure how this would work, since for concurrency like this, you'd need to get rid of the GIL, which a fair bit of C python libraries depend on.

Collapse
aboominister25 profile image
Rayyan Cyclegar • Edited on

Alright, so this seems like an interesting project, and I'm excited to see where you guys get with this. Now, you've said that python is "slow". The reality is that this is relative on the application. For most tasks, python is plenty fast enough, and it's not like you can't optimize it, there's tools such as PyPy, Numba, and cython, which can provide speedups. In a lot of cases however, any speedup at all is unnecessary, since python is fast enough for a good bit of tasks. However, if you're writing something like a 3D game, or something like a kernel, python probably isn't the right choice for that. I personally have never found python to be too slow for anything I've done. That being said, I have mostly stuck to web development, where most of the slowness in your applications are restricted to network related stuff, which would be the same, no matter what language you use.

Collapse
lewiscowles1986 profile image
Lewis Cowles

People can already write better python and go through optimization to get python to "work faster".

Ultimately I doubt it's speed is your limiting factor. So why peregrine? Because it's easy to work on a new shiny and hard to fix what is there, or convince those within the community to follow suit.

Well. Done, have fun. But I wish I would see less fracturing and attempts to take from a decent, well established language.

Collapse
rechie_kho profile image
Techie Kho

Wow, my drawings appears on this website (I helped to draw the peregrine banner + logo)! I hope to contribute to code, too, but this is the first time hearing V and I only get into lower level programming like C for a month (I really like pointers!).

Collapse
ethanolchik profile image
Ethan Olchik Author

we switched to python, so hopefully more people can contribute!

Collapse
rechie_kho profile image
Techie Kho

That is great!

Collapse
salman0ansari profile image
Mohd Salman Ansari

i have been following this project since start
Good luck with devlopment.

Collapse
haarts profile image
Harm Aarts

That is not a small task! Good luck!

Collapse
saptakbhoumik profile image
SaptakBhoumik

Thanks

Collapse
rehman000 profile image
Rehman Arshad

I read the last article and I'm wishing all the devs. Best of luck. This is no easy task. I've already starred the repo, I might check it out later.

Collapse
ethanolchik profile image
Ethan Olchik Author

Thanks for the support!

Collapse
itsnikhil profile image
Nikhil Taneja

Woah that's a big commitment.. good luck Peregrine team ❤️

Collapse
ethanolchik profile image
Ethan Olchik Author

thanks!

Collapse
keetsscrimalittle1 profile image
KeetsScrimalittle

Sounds interesting. A 3 syllable name is not a big issue. Good luck

Collapse
hey_trey profile image
segreus

That is amazing that new and new languages appear, it really helps us to optimize the work process

Collapse
slidenerd profile image
slidenerd

i want your project to succeed but i think your name Peregrine is very difficult and keep a lot of people away. Can you not find a simpler name? Maybe call it kobra or something

Collapse
ethanolchik profile image
Ethan Olchik Author

Sorry but we're not planning to change the name any time soon.

Collapse
asvald profile image
Asvald

I think I've read it, not peregrine but swallow...

Collapse
ethanolchik profile image
Ethan Olchik Author

Yeah, we changed the name

Collapse
hegade profile image
s hegade

Very excited to use :)

Collapse
souksyp profile image
Souk Syp.

Written in V?? 😱

Collapse
allanjaba profile image
allan-jaba

What of swallow?