HNHacker News
TopNewBestAskShowJobs

artagnon

1,571 karma · joined March 2, 2009

https://artagnon.com https://github.com/artagnon
submissionscomments
artagnon··on Ask HN: Good C++ code bases to read?
Here are a couple of expertly-written C++17/C++20 repositories:

https://github.com/hanickadot/compile-time-regular-expressio...

https://github.com/nlohmann/json

If you've not written C++ code before, it can take a while to catch up with the latest developments in C++23. Start with C, and learn these, in approximately the specified order:

1. lvalue references.

2. Constructors, destructors, and inheritance.

3. Annotations such as const and noexcept on members.

4. Simple type templates, and value templates.

5. constexpr, std::move, and rvalue references.

6. Type traits and std::enable_if.

7. Concepts.

Once you learn the core language features, learning the various data structures/algorithms in `std` should just be a matter of looking them up in cppreference, and using them over and over again.

Good luck.

artagnon··on Free Linear Algebra textbook
True. Examples are necessary for both motivation, and for showing how the formalisms work, at this level. One good undergraduate textbook that has plenty of examples is Dummit & Foote. However, that doesn't mean that you don't define anything properly, and solely use examples to show how to crunch certain computations. The student is then stuck with a bunch of patterns in their heads, with little mathematical understanding.
artagnon··on Free Linear Algebra textbook
Interesting approach. He starts off with vector spaces, after providing some intuition, and uses it to drive the rest of the book. He defines matrices in terms of linear maps, and talks about operations on vector spaces, with small sections dedicated to the corresponding matrix computations. There's no hand-waving or lack of rigor.

Overall, a fine textbook.

artagnon··on Free Linear Algebra textbook
I'm not too fond of the example-driven approach. The student will certainly be able to multiply simple matrices and compute determinants in some simple cases, but will not be able to answer fundamental questions like "what can I put in a matrix?", or "what is a vector field?" (the author gives 10 "rules" with no structure, so it's impossible for the student to memorize them). The author throws around `R` everywhere, but all his examples use `Z`. For a book on linear _algebra_, there is very little algebraic rigor in the book.

The standard textbook for learning linear algebra at the undergraduate level is Hoffman and Kunz, which is far better.

In short, this is a poor textbook.

artagnon··on Ask HN: Is there a website specialized in mathematics courses?
See the other reply on the thread: https://news.ycombinator.com/item?id=24900707
artagnon··on Ask HN: Is there a website specialized in mathematics courses?
I started in late 2016. Initially, it was just during the weekends. I was a regular at the local coffee shop near my place in Boston: I'd go in with my iPad and some sheets of paper, spend 4~5 hours studying, while constantly consuming coffee. Then, I found a friend who had done a Bachelors in math, and we'd visit the local community college 3~4 times a week, and discuss general math and GRE problems on the blackboard for a couple of hours after work: it was a lot of fun.

In mid-2017, I moved to California and spent ~2 hours a day studying by myself, while maintaining a day job writing Haskell and Coq. Then, in late-2019, I quit my job and moved to India to study mathematics full-time (read: 4~6 hours every single day). I started meeting a professor at the local university once a week to discuss my solutions to problems in Miles Reid. We worked through Reid together. I also audited a course in algebraic topology at the university, simultaneously.

In mid-2019, I moved to Paris to continue studying part-time (1~2 hours a day) while working on a Coq project. After some shuffles, I found a professor I really liked, and we started working together. He wrote me the primary recommendation for the Masters program.

I hope the elaboration was more useful than two numbers.

artagnon··on Ask HN: Is there a website specialized in mathematics courses?
Motivation and direction are important when starting out. I decided pretty early on that I wanted to be an algebraist, but would have to build some mathematical maturity before I could get there, so I had a rather shallow goal in the beginning: to be able to solve the previous years' math GRE papers. Off the top of my head, these were some of the books that I worked through:

1. Spivak's Calculus.

2. Johnstone's Notes on Set Theory and Logic.

3. Gamelin's Complex Analysis.

4. Hoffman & Kunz' Linear Algebra.

5. Dummit & Foote's Abstract Algebra; just the group theory.

6. Munkres' Topology; just the general topology.

Once I was happy with my preparation, I strived for a deeper understanding of Group Theory. I bumbled through Herstein, but didn't understand it very well. Then, I stumbled upon Artin's book, and worked through it using the outline provided on the MIT OCW course page, and I could confidently solve most of the exercises.

For category theory, the top resources that I would recommend are:

1. Mileweski's Category Theory for Programmers, the video lecture series. As is always the case with video lectures, this one can help motivate a Haskell programmer uninitiated in category theory.

2. Goldblatt's Topoi. It's fairly dated, but teaches category theory well, via its application to topoi.

3. MacLane's CatWork. I'm not especially fond of this one, but it's necessary to work through it.

The most important thing to understand when learning category theory is that it cannot be learnt in a vacuum: the subject is entirely vacuous, and you need to use it in other mathematical disciplines to give it meaning.

Good luck.

artagnon··on Ask HN: Is there a website specialized in mathematics courses?
I've self-taught myself undergraduate-level Mathematics, and am currently enrolled in an advanced Masters program specialized in higher category theory at Université de Paris. Here are some thoughts:

First, the amount I learnt on a day-to-day basis from self-studying in my free time pales in comparison to the amount I learnt from a structured course ending with an exam, in which you have to commit to studying 2~4 hours of math every single day.

Second, classroom lectures mainly act as a structured table-of-contents for working through various textbooks. The problem sheets they distribute in the tutorials are very helpful, as is the discussion of problems that some students might have got stuck in.

Graduate-level math textbooks are fantastic, and the authors have poured 10+ years of their lives writing them. No online course with cute interactive video can substitute them. Having said that, there are some video lectures that can act as good motivation for studying a subject. For instance, Wildberger's lectures on algebraic topology (find them on YouTube) are a great starting point for the subject.

You first have to decide on what you want to learn, by looking through various fields, and narrow your scope. Mathematics is a huge discipline, and you have to decide what you like, and work through the prerequisites in a disciplined manner.

I cannot emphasize the importance of working through exercises enough. All mathematics textbooks have exercises at the end of each section, a subset of which you must work through.

Having said all this, you might find the following site interesting: it contains a lot of unpolished notes from studying various math textbooks, but it requires a lot more work to be useful to a larger audience. Look through it, and pick something you like. On request, I might find the time to add some material.

https://artagnon.com

artagnon··on Mood and cognition after low LSD doses: A placebo controlled dose-effect study
Depression and anxiety are independent. It's possible to be depressed and anxious, depressed and non-anxious, anxious and manic, and manic with no anxiety.

I wouldn't recommend LSD to people with anxiety, as raises anxiety. I would _mildly_ recommend it to people who suffer with depression, but have a low level of anxiety. And yes: it does help break out of rumination cycles, and weaken old neural connections.

You make it sound like negative thoughts are the _cause_ of depression. This is not the case, although they are correlated: when you're depressed, you tend to have negative thoughts, which can drive you deeper into that very depression.

What I would recommend strongly to people with depression is a prescription anti-depressant (it can take a long time working with a good psychiatrist to find one). Possibly light smoking as well, if the person is otherwise healthy.

There is no silver bullet here. Certain people have certain imbalances in neural chemistry, and small doses of the right prescription drug can help correct that. For chronic symptoms, people have to be on the drug for a lifetime; for others, a few years.

artagnon··on Show HN: Elsa – A QuickJS wrapper written in Go
Ofcourse; Deno is V8-based, which is a lot more full-featured than quickjs. Perhaps this is a more informative benchmark: https://bellard.org/quickjs/bench.html
artagnon··on Show HN: Elsa – A QuickJS wrapper written in Go
It's a simple command-line application that dispatches to the quickjs runtime. The headline is somewhat misleading.
artagnon··on Show HN: Clayoven – a minimalist website generator for math, code, and articles
Unfortunately, KaTeX can't do commutative diagrams, while MathJaX has an xypic.js extension, which can.
artagnon··on Self-Taught Mathematician; an Impossibility?
Let's just say that there was very little emphasis on Math in my Physics Masters, which in itself was very poorly taught, and leave it at that.
artagnon··on Self-Taught Mathematician; an Impossibility?
I will concede that I have some friends who are Mathematicians who could provide me _some_ feedback. Besides, I did end up contacting a few serious Mathematicians at various points to get feedback on my exercises -- it was just at extraordinarily low levels, compared to coding.
artagnon··on Self-Taught Mathematician; an Impossibility?
I agree that it's necessary to do exercises in order to understand the subject, but I disagree that you need to have them checked by someone else -- in many cases, you should be check it for yourself, honestly.

Beyond the junior undergraduate level, computation-style problems go away, and you're just left with exercises that ask you to prove a certain something. It takes a long time to build up a sufficient degree of rigor, but it happens eventually -- I did go get some of my proofs checked by serious Mathematicians at some point, and it turned out that my intuition wasn't far behind.

artagnon··on Self-Taught Mathematician; an Impossibility?
Actually, the view that Mathematics was "discovered" and not "invented" is quite popular among Mathematicians. There is an area of research called the Foundations of Mathematics, which investigates this question.

It's untrue that Mathematics does not undergo any refactoring -- in fact, it does: even in a field as new as Algebraic Geometry, the "classical" textbooks which build up the subject using ideals and varieties are very different from the modern ones which start from Scheme Theory.

Moreover, Category Theory shows that there is a beautiful underlying structure in all fields that can be extracted out into a new field. For example, the concept of adjunctions existed much before Category Theory was invented -- CT came along and showed that similar structures exist in Algebraic Topology, Algebraic Geometry, Differential Geometry, and other fields.

artagnon··on It’s time to kill the web app
Every generation of programmers _does_ learn from previous work, and every new platform starts from scratch learning the lessons, and incrementally evolves. A Hello World GUI on Windows 95 will require calling into a complex and undecipherable Win32 API; a Hello World on the web needs one simple line. Platforms do get frozen over time (like the Linux kernel), and people use it to build useful things with low effort. The Linux kernel is a result of incremental evolution: Linus proudly says that it's not designed.

There are severe shortcomings in all platforms that have aged. Why does power management in Linux suck so hard? Why can't we have networked filesystems by default (NFS is quite bad btw)? Until somewhat recently (~7 years), audio on Linux was a disaster: "Linux was never designed to do low-latency audio, or even handle multiple audio streams (anyone remember upmixing in PulseAudio?)". What the hell are UNIX sockets? Is there no modern way for desktop applications to talk to each other? (DBus was recently merged into the kernel). Why doesn't it have a native display engine? (X11?)

Today, it's more fashionable to criticize the web, since majority of the industry programmers endure it. Sure, there are some "simple" things that are just "not possible" with the web (everyone's pet peeve: centering). Yes, you lose functionality of a desktop application, but that's the whole point of a new platform: make what people really need easy, at the cost of other functionality. For an example, see how Emacs has been turned into a web app, in the form of Atom? You don't have to write hundreds of lines of arcane elisp, but you also don't get many features. Atom is a distillation of editor features that people really want.

I don't understand the criticism of transpiling everything to Js; you do, after all, compile all desktop applications to x86 assembly anyway. x86 assembly is another awful standard: it has evolved into ugliness (ARM offers some hope). Every platform was designed to start out with, and evolved into ugliness as it aged. We already have a rethink of part of the system: wasm looks quite promising, and you'll soon be able to write your Idris to run in a web browser.

artagnon··on A Review of Perl 6
It's nice to dream up a language with the perfect semantics; in reality, all programming languages make compromises because they are limited by current compiler technology. Ruby is on one extreme end of the spectrum, making little compromises on beauty, but we all know how slow it is.

Go is on the other end of the spectrum; they have tuned their syntax to be fast to parse, and have stuck to implementing existing compiler technology. If your semantics are very far removed from how computers work, you need a very advanced compiler like GHC.

It sounds like Perl6 is somewhat centrist in its approach, and has innovated quite a bit; I think it will be possible to almost match Perl5's speed with reasonable effort. The interpreter might do well on small examples, but the VM will dominate in very large ones. Many compilers are tiered in that they use an interpreter for cold code, and spend the effort to generate code and JIT hot code.

artagnon··on Ask HN: How do you create productive habits?
Maintain a healthy balance in life. Read fiction, listen to podcasts, go on long walks, chat about non-technical things over coffee/lunch everyday. Oh, and get ample sleep. Beyond that, it's creature comforts around your desk: a good coffee machine, a sitting+standing desk, good natural lighting, a whiteboard, a scratchpad, a relatively new iMac.

Habits are easy to create when it's convenient to have them. That's mostly what I'm pitching.

artagnon··on The Case Against Climate Change, by Former Greenpeace President
Even without looking it up, I can say with certainty that his arguments have been debunked. Nobody should believe that 97% of scientists are wrong, or be trapped in an echo chamber.
artagnon··on The Case Against Climate Change, by Former Greenpeace President
These are good talking points when you want to debate climate change; it is necessary to gather scientific evidence to back each of these points. Everyone knows that 97% of scientists believe in climate change, 84% in an anthropogenic version; that's not news, but I didn't know what to research earlier.
artagnon··on A Medical Mystery of the Best Kind: Major Diseases Are in Decline
Our genes are somehow improving in quality (survival longevity, quality of life, IQ), and this effect is cascading over generations. I don't know if it can be explained using pure epigenetics, and natural evolution is certainly too slow to explain this, so there might be mutagens in our everyday environment that directly modify the DNA sequence. We recognize cigarette smoke, heavy metals as mutagens, but are there more subtle mutagens that lead to better DNA?
artagnon··on Show HN: Rhine – A typed Elixir-inspired language on LLVM
Nope, sorry. And that was kind of the point I was making: in over a year, I've only been able to do the most foundational work in C++. It'll need another 2~3 years to feature optimizations like that.
artagnon··on Show HN: Rhine – A typed Elixir-inspired language on LLVM
Thank you. I actually made a lot of design mistakes in both rhine-ml and rhine, which is why I shelved them as "learning projects". I do fully intend to write a solid compiler for a well-designed language in the future. I have to make my mistakes first.

So, for the curious, the big mistake in rhine-ml is making it untyped: it generates terrible LLVM IR that executes super-slowly. I could try and optimize it, or go the types route. I chose types, and I don't believe in the optional-typing escape hatch.

The big mistake in rhine is that I wrote it in C++. It'll be a decade before it can lift its own weight, and OCaml is a great language to build a compiler in.

artagnon··on Show HN: Rhine – A typed Elixir-inspired language on LLVM
I needed a title. I could have said Elixir-inspired or Crystal-inspired, but few people know about Crystal. Although it's only minimally inspired by Elixir, I decided to go with that title.

By the way, I've mentioned Crystal towards the end of the README.

artagnon··on Show HN: Rhine – A typed Elixir-inspired language on LLVM
Yes, I'd implemented the syntax with the intention of doing currying, but haven't gotten around to doing that yet. If you want to do any "partial application", you need to write a lambda, and explicitly pass its function pointer now. The next step is to automatically generate the lambda.
artagnon··on Show HN: Rhine – A typed Elixir-inspired language on LLVM
Thanks for the feedback. The ~ is a substitute for :, which is used in other languages for optional type annotations. You're right about removing ~ altogether, Go style. ~Function(Int -> Int -> Int) is a function which takes two integers, and returns one. I've mixed in some Haskell syntax there. And yes, return type is inferred.

There are two reasons for there not being explanations in the README:

1. I foolishly thought it would be obvious.

2. I wanted to focus on the implementation, not the language itself.

In any case, I've added them now, thanks.

artagnon··on A Tour of Acme (2012)
It's interesting to me that shell integration is becoming a harder problem with editors these days. Emacs has a multi-term which kind-of works (there were many packages before this that didn't work), Vim does not have a package that can present a prompt (afaik), and Atom finally has a near-perfect terminal in the form of the term3 package.

What Atom considers bare minimum is stuff that Acme doesn't even think about: syntax-highlighting, auto-indentation, and auto-complete.

artagnon··on Streams
Very coherent piece on a familiar concept.

I think of spikes as ways to sustain streams. They're also the quick route to making bad decisions. It's encouraging to see your investments jump in value every now and then, but if you sell a stock that's doing badly when you could have waited until it bounced back, you're making a bad decision. Another instance: you're steadily learning machine learning, and the motivation starts to drop; you post your little project on HN, and it makes the front page for a day; you suddenly feel better about learning it. In this case, the spike is a sneak peek into the future: you'll have a decent following if you really push yourself to learn.

artagnon··on Check-in before code review is an antipattern
Git has some serious disadvantages when compared to a centralized VCS like Perforce. It just can't handle anything more than 10~15 million lines of code (this is the size of linux.git).

In a way, Perforce is a cute middle ground. It has "pending changelists" that ReviewBoard or Phabricator can slurp up and present to reviewers. You can easily give another person your changes by "shelving" them. Mutable history is only really a "feature" in tiny projects; in massive ones, immutability simplifies life greatly and restores peace of mind. In many ways, the way Perforce handles conflicts is nicer: it doesn't pollute the actual files with conflict markers, and has an option to resolve conflicts in a nice 3-pane UI. Although it does get merges wrong every now and then.

Non-linear history is considered an "anti-feature" by many, and the LLVM community runs a primary SVN server; users submit via git-svn.

Having cheap and lightweight branching is what leads to merge headaches. In fact, (from one Tech Talk), I believe that Google runs a single branch to evade merge problems altogether.

I think git's greatest asset is the excellent local development experience. You can muck around as much as you like, making local branches/commits as checkpoints, and squash them in to submit a final patch. The command-line UI is fantastic, and everything is snappy (provided you have a small checkout). I think having a single linear "trunk" on the server-side is a good idea.

← PreviousPage 2 of 7Next →