Hacker Newsnew | past | comments | ask | show | jobs | submit | gilch's commentslogin

C macros are just a text preprocessor. You could run the C preprocessor on a text file and have the result be Python code. Comments might be a little tricky, but it's doable. Or you can run a text file through a general-purpose one like m4.

For sum types we have enums, and for product types we have tuples (or namedtuples or dataclasses). Sugar could be done with decorators or metaclasses.

For Lisp macros, there's macropy and Hissp.

https://www.gnu.org/software/m4/

https://threeofwands.com/algebraic-data-types-in-python/

https://github.com/lihaoyi/macropy

https://github.com/gilch/hissp


C preprocessing is token-based. The input is decomposed into preprocessor tokens, sequences of which are then manipulated.

There are issues with using stand-alone implementations of C preprocessing like GNU cpp with languages that deviate from C in their token syntax.


> I loved Lisp, but none of the lisps have anything like Python's ecology.

Try Hissp (https://github.com/gilch). Lisp programming and Python's ecosystem.


No commits for a year? https://lolg.it/amber/amber Is it dead?


I think so. SqueakJS fills the space Amber used to occupy.


Is Squeak itself still an actively developed project? I hear much more about Pharo.


While it's slowed down in recent years, it's still active. Re: Pharo, that's just because they market it hard and don't give much (any?) credit back to Squeak which is what it was forked from. (and still shares more DNA with Squeak than the Pharo folks like to admit)


i would like to learn pharoh, but I can't seem to understand how to get started. It looks like one of those tools you need a video to understand.


You can start with the Pharo MOOC: https://mooc.pharo.org/

There's a tutorial to get the very basics of Smalltalk/Pharo called ProfStef. Here's an online version: https://amber-lang.net/learn.html

It has a built-in version on Pharo images as well.


Have you seen you have this track in Exercism?

https://exercism.org/tracks/pharo-smalltalk

And this if you want to feel not alone in the first steps:

https://www.youtube.com/watch?v=YQ-kAQWMMTQ


Thank you! Getting into it this new week.


When you start it, you get a first start wizard that allows you to start a tutorial


Glamorous toolkit docs/examples are a useful pharo intro.


It's actively developed. Pharo started as a fork of Squeak.


Squeak is certainly slow, but Cuis is moving at a good clip.


Python is great for API discovery. `dir()` and `help()` are builtins. Use the REPL.


Sadly, hard disagree. I programmed Clojure professionally for ~2 years, and its REPL is significantly better than Python's. Despite that, nothing compares to "dot" autocomplete and being certain that a method can take a certain object type. Like, I could type dir/help and then the token in question then parse the output with my eyes, remove the help/dir and type in what I wanted... or I can hit dot and scroll the available methods/properties. It's not even close.


That is the right answer. While some comparisons have been written already, they're somewhat out of date. Hissp could use a new writeup. Let me know if I can answer any questions about Hissp, and when your blog post is ready :) You can reach me at the Hissp community chat channel on Gitter's Matrix: https://gitter.im/hissp-lang/community -- share your Hissp experience or get support.


As the Hissp author/maintainer, I'd be interested in hearing about your take on Hissp's practicality (or lack thereof) in more detail.


Not accurate as worded. Python caches module imports in `sys.modules`, so all imports get the same one. A `reload()` will reuse the same dict object that was being used as the module's namespace, so everything with a reference to the module object will see the same namespace and get the updates.


What? Yes you can. I do it all the time.

    import code; code.interact(local=vars(foo))
where `foo` is the module object you want to set as current. This launches a subREPL in that module's namespace. (EOF kills the subREPL and returns to main.)

Python has a debugger in the standard library that can also do post-mortem inspections.


You might be interested in Hissp, a Lisp with access to the breadth of libraries available to Python. https://github.com/gilch/hissp


> I would certainly take Python's huge ecosystem over Lisp's metaprogramming.

You can have both with Hissp. https://github.com/gilch/hissp


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: