Better programming in the python ecosystem.
Table of Contents
1 A better python
I am not entirely happy with python, but there is so many benefits in using python, if only there was a way to use python with all the benefits but not having to deal with some of the downsides.
credit: hy-lang
1.1 Introducing Hy
Oh wait but there is, it is called hy. Now if you are not a "crazy lisp user" you might not be all that hot on the idea of writing parentheses around all your code all the time, but there is a few benefits to this, also it is not more parens really they are just placed differently.
(print "Hello, World!")
Only the parens are different between these two.
print("Hello, World!")
it is the same characters, just the paren changed place in hy, now this is a simple example. There are some benefits from this one is the fact that more functional style code is possible in hy, which is not possible in python directly.
1.2 Differences
So there is a few small differences that you need to know.
1.2.1 Tuples
1.2.2 List
1.2.3 Set
1.3 Hy adds stuff to python
So since hy is a lisp that runs on python there are things in hy that python does not have by itself.
1.3.1 macro
This can be very useful if you want to do some heavy compilation, but ideally if you could just do it at compile time and then never again that would be very nice, this is exactly what macros do, oh and allow you to crazy things like adding new language features, well to some extent at least.
The only thing you should be aware about with macros is that if you do not have a value at compile time it cannot be a macro.
(defmacro m [] (setv x (** 2 20)) x)
If you run this twice, it will take some time once, but then the second time it is compiled into the program and returns much much faster.
If this has whetted your appettite for a better way to write python there is additional documentation https://docs.hylang.org/en/stable/tutorial.html
Or if you think I am crazy for suggestion this you can always tell me in the comments, however if this is in any way useful, I appreciate votes.
Leave Better programming in the python ecosystem. to:
Read more #hive-169321 posts
Best Posts From iobates
We have not curated any of iobates's posts yet. But you can encourage our curation team to review posts by visiting them regularly and by referring other readers. Because we give priority to frequently read content.
More Posts From iobates
- Bitcoin vs CBDC
- A quick Tactic from a game.
- Ads making a site useless
- Having Started my fitness training I was a bit sore for a few days.
- Carnivore diet 27 August 2024
- Carnivore 26 August
- Hiring practice at IBM will destroy the company.
- Carnivore 25 august
- Carnivore 24th August 2024
- Carnivore 23 August 2024
- Carnivore diary for 22nd of August 2024. Some benefits from the diet as well.
- Carnivore Diary 21st Aug
- Carnivore Diary 20th of August 2024
- A gem from a blindfold game
- Chess problem, from a game
- Tracking pill use, a simple CLI tool
- update to the unpacker, delete the archives when unpacking completes; it works but I think it has a few bugs.
- AI: Hype-train, is it finally over ?
- A Small Program to extract Archives
- Blindfold game analysis