HNHacker News
TopNewBestAskShowJobs

gilch

79 karma · joined August 31, 2017

submissionscomments
gilch··on Lisp.py
Also check out Hissp: https://github.com/gilch/hissp
gilch··on Vala Programming Language
There are a number of those. See https://www.reddit.com/r/whitespaceLisp for a more complete list.
gilch··on Why Hy?
I'm not suggesting anyone stop writing tests. Rather I was referring to tools like Cider, which provide intellisense-like features by analyzing runtime state without static analysis: https://docs.cider.mx/cider/usage/misc_features.html#find-re...
gilch··on Why Hy?
In that case, would the Hissp README https://github.com/gilch/hissp#readme be an appropriate introductory article in your view? It opens with some small examples and concludes with some design philosophy.
gilch··on Why Hy?
Here's another way to do it:

  >>> def foo():
  ...     import __main__
  ...     a = __main__.a
  ...     print(a)
  ...
  >>> foo()
  1
gilch··on Why Hy?
The Hy page had way too much syntax, but the Hissp Quick Start didn't have enough? Or not soon enough? One does have to understand the little pieces to make sense of the big ones. You want something in between? Can you point to an example at the right level?

Ctrl+F and try skipping to ";;;; The Basic Macros" section on that quick start page. Is that about the right level?

For many of the "popular" languages, a simple cheat sheet showing the equivalent control structures in a common language might be enough for a typical programmer to get a handle on it quickly. But Lisp is not an Algol-family language. It's different enough that such a document would fail to convey what makes it interesting. There's an inferential gap that must be bridged first, and it's difficult to do that quickly; a programmer mistakenly [expecting a short inferential distance][1] may not have the patience to "get it".

[1]: https://www.lesswrong.com/posts/HLqWn5LASfhhArZ7w/expecting-...

gilch··on Why Hy?
Python expressions are accessible in [Hissp][1]. In [readerless mode][2], you're writing in Python anyway, so it's trivial. In [Lissp][3], you can inject Python code strings with `.#`. In [Hebigo][4], you just put parentheses around the whole thing.

[1]: https://github.com/gilch/hissp

[2]: https://hissp.readthedocs.io/en/v0.3.0/tutorial.html#hello-w...

[3]: https://hissp.readthedocs.io/en/v0.3.0/tutorial.html

[4]: https://github.com/gilch/hebigo#bracketed-expressions

gilch··on Why Hy?
Static analysis becomes less important in a language with a REPL and dynamic reloading. Analyze the code by running it and inspecting the results.
gilch··on Why Hy?
Python has pre-emptive threading too! The GIL makes it all but useless for CPU-bound tasks, but it works fine for IO. Keep your health-check tasks in a non-IO thread and communicate with queues.
gilch··on Why Hy?
Even indenting properly goes a long way:

    (/ (+ (- b)
          (sqrt (- (* b b)
                   (* 4 (* a c))))
       (* 2 a))
The trick is that a trail of any number of `)`'s should also end the line. Like any language, it takes some getting used to, but I find this tree structure perfectly readable now.

Sure for the four-function calculator operations, operator precedence levels are a reasonable notation, but when you can define your own functions, and your programming language now needs a dozen precedence levels, it becomes hard to read. Lisp is completely unambiguous.

gilch··on Why Hy?
Hissp is an alternative approach. Unlike Hy, which compiles to Python AST, Hissp compiles to Python, so it doesn't break with every Python release.

Its read language (Lissp) doesn't have an Emacs mode (yet), but its syntax is so close to traditional Lisps that lisp-mode pretty much works. No completions either. There is Lily https://github.com/mjobuda/damascus-tools/tree/main/lily, which proved Jedi works on Lissp, but it's never quite worked right.

Hissp leans more Lispy than Pythonic compared to Hy, but still prioritizes interop, so the object model is still Python's.

gilch··on Why Hy?
Not Intellisense, but there is jedhy: https://github.com/ekaschalk/jedhy which can do completions. Last Hy version verified working for: Hy 0.16.0
gilch··on Why Hy?
It works if you disambiguate your namespaces:

    >>> a = 1
    >>> def foo():
    ...     a = globals()['a']
    ...     print(a)
    ...
    >>> foo()
    1
Still yuck?
gilch··on Why Hy?
You can still use `global` though.
gilch··on Why Hy?
Would you prefer something like this? https://hissp.readthedocs.io/en/v0.3.0/lissp_quickstart.html
gilch··on Why Hy?
Equivalent in Common Lisp:

    * (let ((a 1))
        (defun foo ()
          (setq a 2))
        (foo)
        (print a))
    
    2
    2
gilch··on Why Hy?
I wonder if Hissp would be more to your taste? https://github.com/gilch/hissp
gilch··on Why Hy?
Have you tried Hissp yet?
gilch··on Why Hy?
No closures? Hasn't it always had them?
gilch··on A trick to have arbitrary infix operators in Python
You only need the parens when the arity can vary. It doesn't have to be binary. Red and REBOL are prefix languages like Lisp, but without the parentheses, and their calls can have more than 2 arguments. You do have to know the arity of each function to make a parse tree, so the arity of any given function is fixed.
gilch··on 5% of 666 Python repos had comma typo bugs (inc V8, TensorFlow and PyTorch)
You might like [Hissp's][1] import system. It does compile down to Python.

[1]: https://github.com/gilch/hissp

gilch··on ASK HN: What should a Python developer learn next?
Read the [Hissp][1] tutorials (find the docs). It shouldn't take a Python dev too long. It will deepen your Python knowledge and give you a gentler introduction to the world of Lisp because it uses the familiar Python vocabulary with Lispy syntax and then introduces macros. After that intro, and given your JS experience, you should be able to pick up ClojureScript without too much trouble.

[1]: https://github.com/gilch/hissp

gilch··on Land of Lisp (2010)
I think LoL is too CL-specific. If you know both languages first, you can pretty much translate, but since they'd be trying to learn Lisp in the first place, this is a bad idea.

On the other hand, [Hissp][1] has a pretty good tutorial for anyone coming from a Python background.

[1]: https://github.com/gilch/hissp

gilch··on PyTorch: Where we are headed and why it looks a lot like Julia (but not exactly)
See also, Hissp: https://github.com/gilch/hissp
gilch··on Coconut: Simple, elegant, Pythonic functional programming
That's really not true either. The lambda parameters are locals [a]. A let-binding is just a lambda that you call immediately. You can use defaults so the value doesn't have to appear as an argument [b]. Also, Python has assignment expressions now [c], and comprehensions are expressions which can have their own locals [d].

    >>> (lambda a, b=2:
    ...   print(a, a, b, b, c:=3, c, *[[d,d] for d in [4]][0])
    ... )(1)
    1 1 2 2 3 3 4 4
That's four different ways to get locals with no statements.
gilch··on Ask HN: Tips for more energy during day?
Cacao. Theobromine is a stimulant, but has milder side effects than caffeine. YMMV.
gilch··on Coconut: Simple, elegant, Pythonic functional programming
And Hissp.
gilch··on Coconut: Simple, elegant, Pythonic functional programming
Where is the "no multi-line lambdas" myth coming from? I see this one a lot and its wrong. Python's lambdas can have as many lines as you want.

Did you mean to say that lambda expressions can't contain statements? But no Python expressions can! But functional programming is all done with expressions anyway, to the point where functional languages don't even have statements, so what's the problem?

gilch··on Differences with other Lisps
Hy actually compiles directly to Python AST, not to Python. For a Lisp that compiles to Python, see Hissp: https://github.com/gilch/hissp
gilch··on Ask HN: How to start learning about investments?
Nassim Taleb’s Barbell strategy has really changed my thinking on this. In a nutshell, you put 85-90% of your portfolio in super conservative low-risk investments that at least beat inflation, 10-15% in aggressive speculation with very high potential payoffs (like WSB short squeezes), and nothing in the middle!

Why? Black Swans. Taleb says:

"If you know that you are vulnerable to prediction errors, and accept that most risk measures are flawed, then your strategy is to be as hyper-conservative and hyper-aggressive as you can be, instead of being mildly aggressive or conservative."

The "moderate middle" isn't as safe as you think it is, thus, it's not compensating you enough for the risk. The conservative side of the barbell will protect you from a negative black swan, and the aggressive side will expose you to positive ones.

← PreviousPage 3 of 5Next →