HNHacker News
TopNewBestAskShowJobs

gilch

79 karma · joined August 31, 2017

submissionscomments
gilch··on Ask HN: How to start learning about investments?
The search term is "paper trade". Many online brokers offer this. It's good to know the mechanics of how to create and submit orders before you try it with real money. You can also find apps for that which aren't tied to a broker.

You don't have to wait a full year if you use a "backtest", which works on historical data. There's software for that as well. Beware of future knowledge overfitting to noise though.

Ultimately, it's best to analyze the historical data directly first, to prove the edge was there, before running a backtest.

Training your intuition is a bad strategy. Markets are more random than you think they are, and this is becoming more true over time as markets become more efficient. You need a system.

gilch··on Ask HN: How to start learning about investments?
Whatever you do, don't jump out at the bottom! You have to hold on and ride it out. However, it is prudent to reduce exposure a bit when volatility is too high. See "Kelly Criterion" for how to calculate this. Inverse volatility weighting is usually sensible for this reason.

You can guard against left tail risk with insurance. See the VXTH index and the SWAN ETF for good strategies here. Don't buy too much insurance, or you can't make money.

You can also think of your future salary as a kind of bond in your portfolio that you can't sell. Seen in that light, the optimal balance is probably using some leverage, even if that means risking a total wipeout early on in your career.

gilch··on Ask HN: How to start learning about investments?
I don't know tax laws in other countries, sorry. Some of them have similar tax-sheltered retirement accounts though.

The 15-30% is if you're being very aggressive (but not reckless) with leverage. You wouldn't get that much in Wealthfront's default portfolio, or a target-date mutual fund, for example. That's also on average over time; some years will return much more than 30%, and some will lose money, and, of course, past performance can't guarantee future results. Broad market conditions could shift enough to invalidate any strategy. But you can do better than index funds. Compare PSLDX to SPY over the same period: https://www.portfoliovisualizer.com/backtest-portfolio?s=y&t...

Notice that they both had ~50% drawdowns, bottoming around 2009, but PSLDX was not that much worse, and grew faster afterwards. SPY also had a slightly worse worst year. PSLDX had significantly more volatility, but the returns more than made up for it, giving it a better Sharpe ratio than SPY. So not only are the absolute risks comparable, but the higher Sharpe means that if you leverage PSLDX down to SPY's volatility (by keeping a 17% cash balance), the drawdown was smaller and the return is still higher than SPY at ~15% instead of ~11%.

gilch··on Ask HN: How to start learning about investments?
There are a lot of junk resources that just want to sell you things and are a waste of time. It takes a certain level of expertise just to find competent teachers. But I'll try to briefly summarize what I wish I had known when I started.

~80% of this game is showing up. (Pareto Principle.) Wealthfront, Betterment, or a target-date mutual fund is way better for growth than a bank account. Start there if you don't have a better idea.

If you want to be more aggressive, averaging 15-30% growth per year is not unrealistic. E.g. PSLDX alone has averaged 17.39% since inception in 2007, but it also had a 50% drawdown in that time. Some years are better, some worse. But that's one fund. You can do even better than this if you know what you are doing (e.g. https://www.portfoliovisualizer.com/backtest-portfolio?s=y&t...). See also, Nassim Taleb’s Barbell.

To play this game well, you need an edge. See Expected Returns (https://www.goodreads.com/book/show/10982323-expected-return...), a classic. The easy edge is "risk premium", but there are others. Edges are not that secret. Search https://ssrn.com for more ideas. When analyzing, beware that any monkey can optimize a backtest. The idea is to find a persistent edge, not overfit to past noise.

You also need risk management so you don't lose money too fast. You have to tolerate some volatility, but control risks. You can lose money by

1. oversizing bets (see "Kelly Criterion", also borrowing costs),

2. trading too frequently (bid-ask spread, commissions, fees, especially for mutual funds),

3. being on the wrong side of an actual edge, usually by buying too much insurance / fighting the risk premium,

4. and paying taxes and penalties (retirement accounts, beware insider trading, etc.).

If you can limit these, the remaining market noise is as likely to work for you as against you. It washes out. See my LessWrong series for more detail, starting with https://www.lesswrong.com/posts/rPe6b7MCxaK8ZzYdC/you-need-m... Also, stop-loss orders suck; puts are better.

At 15-30%, you can double your money every four years or so. Paying the 10% penalty for early withdrawal from a traditional IRA is worth it for tax-free growth if you can compound for even a few years, so put as much in as you possibly can as soon as you possibly can. You can and should contribute some directly, but most will come from rolling a 401(k). The annual limit there is currently $58k if under age 50 and your plan allows after-tax contributions. If retiring early, don't contribute to Roth (you don't get to keep as much up front), but do convert to them after you stop earning and are in a lower bracket. I can't know your exact financial situation, please talk to a professional about this stuff.

gilch··on Why Lisp? (2015)
Hissp is a Lisp clone in Python, with a tiny escape hatch to fully utilize the Python parts. https://github.com/gilch/hissp
gilch··on Why Lisp? (2015)
If you're already familiar with Python libraries, check out Hissp (https://github.com/gilch/hissp), which compiles to Python expressions.
gilch··on The Myth of a Superhuman AI
Pretty sure this is sarcasm, as in, the lies are so transparent they're humorous, and this was on purpose.

For those who didn't notice, nuclear plants have, in fact, melted down, more than once. Biosafety level 4 labs have, in fact, had leaks of pathogens before, more than once. An agent AI will tend to develop a survival instinct by default, even if we don't give it one, because it is a convergent instrumental goal. Thus, it would be motivated to not simply let you yank it, would fight you if you tried, and may even take preemptive precautions.

gilch··on Show HN: Lisp implementation in modern Java, Go, C#, TypeScript, Python
Hissp: https://github.com/gilch/hissp
gilch··on How the Python import system works
Hylang also does this. Macropy too.
gilch··on Julia and the Reincarnation of Lisp (2020)
Here's a Lisp in Python: https://github.com/gilch/hissp
gilch··on Thriving in a Crowded and Changing World: C++ 2006–2020 [pdf]
I'd add an array language like APL or J to that list. Idris is worth mentioning, but maybe Curry+Coq cover that space. Maybe Icon too.

Concepts, Techniques, and Models of Computer Programming [1] with Mozart/Oz covers a lot of ground by itself.

[1] https://www.goodreads.com/book/show/772585.Concepts_Techniqu...

gilch··on Show HN: I made a Lisp that transpiles to Python expressions
I made a quickstart for it in the style of Learn X in Y Minutes. See the docs.
gilch··on Parentheses Are Just Typechecking
Red and Rebol have prefix notation and no parentheses to delimit the arguments. That means you have to know the arity of each function to understand how to build the parse tree. This is apparently not as hard as it sounds, because natural languages work the same way, although they can be ambiguous, at least if you're familiar with all the functions.
gilch··on Joplin – an open source note taking and to-do application with synchronization
How do the UI and features compare to Evernote?
gilch··on Hy: A dialect of Lisp that's embedded in Python
Hy's loop/recur had a serious bug last I checked: https://github.com/hylang/hy/issues/1465

But see the @loop decorator from Drython for how to do this in Python: https://github.com/gilch/drython/blob/eb1773c14060e31e2544f5...

gilch··on Hy: A dialect of Lisp that's embedded in Python
There even a mal in Hy! https://github.com/kanaka/mal/tree/master/impls/hy
gilch··on Hy: A dialect of Lisp that's embedded in Python
What about a Lissp-Hebigo pair? https://github.com/gilch/hissp#hebigo

Hissp takes a different approach than Hy. Where Hy has to use shims to pretend statements are expressions, Hissp just targets the expression subset in the first place. (Actually a somewhat smaller subset than that if you're not injecting any raw Python: literals, lambdas, identifiers, and calls.)

gilch··on Hy: A dialect of Lisp that's embedded in Python
See JetBrains MPS: https://www.jetbrains.com/mps/

The "Projectional Editor" might be the kind of thing you're talking about. The meta language is stored as syntax trees rather than text and can be rendered in different ways.

gilch··on Hy: A dialect of Lisp that's embedded in Python
See hy2py: https://docs.hylang.org/en/master/language/cli.html#hy2py
gilch··on Hy: A dialect of Lisp that's embedded in Python
That capability is in the standard library now: https://docs.python.org/3/library/ast.html?highlight=unparse...
gilch··on Hy: A dialect of Lisp that's embedded in Python
Not sure how close Hebigo gets to that idea: https://github.com/gilch/hissp#hebigo
gilch··on Hy: A dialect of Lisp that's embedded in Python
What else does it need to be a Lisp?
gilch··on Hy: A dialect of Lisp that's embedded in Python
Yes, but you have to (require) it: https://docs.hylang.org/en/master/api.html#module-hy.contrib...
gilch··on Hy: A dialect of Lisp that's embedded in Python
See Hebigo's Python-like approach: https://github.com/gilch/hissp#hebigo
gilch··on Hy: A dialect of Lisp that's embedded in Python
Hy does have a let macro now, but you have to (require) it before it works: https://docs.hylang.org/en/master/api.html#module-hy.contrib...
gilch··on Python vs Common Lisp, workflow and ecosystem (2019)
And Hissp, a Lisp which compiles to Python expressions.
gilch··on Go+: Go designed for data science
No, Python's lambdas can have as many lines of code as you please. They are not limited to one line.

I'm not sure where this myth comes from, but I see it a lot. Maybe some people think that "lines of code" == "statements", but these are not remotely the same thing, even if they happen to coincide in simple cases.

Python's lambdas are limited to one expression in the implied return statement, but not allowing multiple statements in lambdas is no real limitation when programming in the functional style, as the true functional languages have no statements to speak of, only expressions, and their lambdas work exactly the same way Python's does. A single expression is all that a functional programming language's lambda needs.

Multiline lambdas are considered poor style in Python ("Why not use a `def`?" they'd say.), so you may not see them much, but they do work. The Hissp compiler, for example, relies on this feature. (I am the author of Hissp BTW.)

gilch··on Hissp
You mean without marking all the atoms as "object"? Clojure is written in Java and is dynamically typed. I experimented with statically typed linked-lists in Saccharin https://github.com/gilch/saccharin but ran into the limitations of Java's type system at the time. I couldn't figure out how to do certain list operations without losing the types.
gilch··on Hissp – A Lisp-Flavored Python
From the Hissp FAQ: https://hissp.readthedocs.io/en/v0.2.0/faq.html#i-got-here-f...

They’re both Lisps that can import Python, but Hissp has a very different approach and philosophy.

I was also a major contributor to the open-source Hy project. Hy is obviously a much older project than Hissp with more contributors and more time to develop. While my experience with Hy informs my design of Hissp, Hissp is not a fork of Hy’s source code, but a completely new project with a fundamentally different architecture.

The biggest difference is that Hy compiles to Python abstract syntax trees (or “AST”, an intermediate stage in the compilation of Python code to Python bytecode). In contrast, Lissp works more like ClojureScript: the Lissp language uses Hissp as its AST stage instead, and compiles that to Python code, which Python then compiles normally. Hy compiles to a moving target—Python’s AST API is not stable. This helps to make Hissp’s compiler simpler than Hy’s.

Hy has an intermediate layer of Hy model objects it uses to represent code, although it tries to convert them automatically, this can make it even more confusing. E.g. (type '42) is <class 'hy.models.HyInteger'> in Hy, but <class 'int'> in Lissp.

Except for tuples, which represent invocations, and strings, which represent raw Python (and module literals/qualifiers), Hissp’s representation for Python objects are simply the objects. Hissp will at least attempt to compile in anything, even if it has no literal representation in Python code, by falling back to pickle, if necessary. Hy will just crash if you insert anything it can’t model.

This means that Hissp has a much higher degree of homoiconicity than Hy.

Hissp code is made of ordinary Python tuples that serve the same role as linked lists in other Lisps, or Hy’s model objects. Using these directly in Python (“readerless mode”) is much more natural than writing code using Hy’s model objects, although using the Lissp (or Hebigo) language reader makes writing these tuples even easier than doing it directly in Python.

Hissp is designed to be more modular than Hy. It supports two different readers (Lissp and Hebigo) with the potential for more. These compile different languages that represent the same underlying Hissp trees. The separate Hebigo language is indentation-based, like Python, while the included Lissp reader uses the traditional S-expressions.

Hy code requires the hy package as a dependency. You need Hy’s import hooks just to load Hy code. But Hissp only requires hissp to compile the code to Python. Once that’s done, the output has no dependencies other than Python itself. (Unless you import some other package, of course.) This may make Hissp more suitable for integration into other projects where Hy would not be a good fit due to its overhead.

Hy’s compiler has a special form for every Python statement and operator and has to do a lot of work to create the illusion that its statement special forms behave like expressions. This complicates the compiler a great deal, and doesn’t even work right in some cases, but allows Hy to retain a very Python-like feel. The unparsed AST also looks like pretty readable Python. Not quite what a human would write, but a good starting point if you wanted to translate a Hy project back to Python.

But after writing Drython, I realized that the expression subset of Python is sufficient for a compilation target. There is no need to do the extra work to make statements act like expressions if you only compile to expressions to begin with. It turns out that Hissp only required two special forms: quote and lambda. (And you could almost implement lambda via a text macro.) This makes Hissp’s compiler much simpler than Hy’s, and makes full code-walking macros much easier to implement, because once all the macros are expanded, there aren’t that many special cases to deal with. But, the lack of statements makes it feel a bit more like Scheme and a bit less like Python. And, of course, the expression-only output, while a direct and sensible translation once you understand Hissp, is completely unpythonic.

Another major difference is Hissp’s module literals and qualified symbols, which allows macros to easily import their requirements from other modules. Macro dependencies are much harder to work with in Hy. Lissp’s template quote automatically qualifies symbols like Clojure does. Hy can’t do that.

Hy passes Python keyword arguments using HyKeywords, while Lissp passes them using symbols, so print(1, 2, 3, sep=",", end="!\n") in Python would be (print 1 2 3 :sep "," :end "!\n") in Hy and (print 1 2 3 : sep "," end #"!\n") in Lissp.

Hissp’s lambda special form parallels this call syntax for defining parameters, with : as the separator; :? as a placeholder; :* and :** to parallel unpacking; plus :/ for positional-only, based on Python’s syntax. Hy’s syntax on the other hand, has to use special symbols &optional, &rest, &kwonly, and &kwargs, based on Common Lisp’s approach to distinguish its parameter types, in addition to the #* and #** it uses for unpacking. It can’t do positional-only parameters at all yet.

gilch··on Show HN: Hissp. It's Python with a Lissp
Hissp, with its bundled reader Lissp, is a Lisp dialect that compiles to Python. It's fully interoperable with Python, because it compiles to Python. And it has macros!

The docs include tutorials, if you want to try it out.

It came up briefly on HN before: https://news.ycombinator.com/item?id=20605660 (I was also a major contributor to Hy.)

I had to code in Java for school, but after discovering Python, it seemed tediously verbose. Having read the two-volume Java textbook for one of my courses, I felt I knew Java pretty well, and experimented with how far I could bend the language to make it work more like Python (the result was Saccharin).

My interest in what make programming languages different eventually led me to Lisp. I studied Common Lisp a bit and I learned to write macros in Clojure, which seemed like a good language to study after Java, due to the interop.

I love Python and think it's an awesome language and ecosystem, but it's still a Blub. So I experimented with how far I could bend the language to make it work more like Lisp (the result was Drython).

Around the same time I had discovered that Clojure had other implementations, like ClojureScript, including one on Python that was never finished. When looking for a maintained version, I discovered Hy, which satisfied me for a time, but as I began using it, I ran into a lot of problems.

Being the language hacker I am, I started contributing, but as I learned more about how Hy (and Lisp) worked, I eventually became frustrated with its fundamental architecture, and decided I might be able to do better by starting over and applying what I learned from Drython.

The result was Hissp.

I've been working on it on and off for over a year now. I got a basic prototype out fairly quickly, but making something new reliable is harder. Writing tests, thorough documentation, and an alternative reader designed for a language resembling Python (Hebigo) exposed a lot of flaws. The docs took the longest. I also needed to implemented a doc tester and syntax highlighter, which are in the git repo, but not the package.

I feel like Hissp is finally coming together. I just released version 0.2.0 on PyPI today.

← PreviousPage 4 of 5Next →