Found in 3 comments on Hacker News
Iwan-Zotow · 2019-01-24 · Original thread
It is not about distaste, though idea about keeping and carrying 1 around is a recipe for bugs. It is all about composability.

Could you make proper monoid out of Julia ranges? What would be a unit in that monoid? Could you tell me how empty range looks in Julia (in Python/C++ it looks trivial)?

> Python cannot even index lists by ranges (or other lists)

sure, Python has deficiencies as well.

C++ STL iterators/ranges are made in the same way, and for a good reason - composability first. It described very well in Alex Stepanov book (https://www.amazon.com/Mathematics-Generic-Programming-Alexa...), as well as how it helps when we move to parallel algorithms (http://stepanovpapers.com/p5-austern.pdf).

It is even more explicit in upcoming Ranges library in C++20

Suncho · 2018-04-11 · Original thread
Yes! Alexander Stepanov is fantastic. He's the designer of the Standard Template Library (STL) for C++, which is C++'s core library of generic algorithms. It's part of the standard libary.

If you can understand how to use the STL properly, you're well on your way to becoming a profiicent C++ programmer.

His books are fantastic too.

Elements of Programming:

https://www.amazon.com/Elements-Programming-Alexander-Stepan...

and From Mathematics to Generic Programming:

https://www.amazon.com/Mathematics-Generic-Programming-Alexa...

If you prefer video lectures, his second book is based off his lecture series Four (three) Algorithmic Journeys:

https://www.youtube.com/playlist?list=PLHxtyCq_WDLV5N5zUCBCD...

https://www.youtube.com/playlist?list=PLHxtyCq_WDLW0NqZCcrrQ...

https://www.youtube.com/playlist?list=PLHxtyCq_WDLXrHwcaay14...

https://www.youtube.com/playlist?list=PLHxtyCq_WDLVQPzEm3igP...

It's a combination of history and math/algorithms and programming (using C++). If you're just looking for a straight intro to C++ course this isn't it. But it's a ton of fun and the generic programming/STL mindset is very powerful.

Programming Conversations is another great lecture series by Alexander Stepanov:

https://www.youtube.com/playlist?list=PLHxtyCq_WDLXFAEA-lYoR...

I would also recommend searching YouTube for videos by Sean Parent. This one in particular is very enlightening:

https://www.youtube.com/watch?v=qH6sSOr-yk8

Sean Parent is very good at getting you in the STL mindset and showing off the expressive power of using the standard STL algorithms in your code. Except in the simplest cases, you should try to use them instead of writing your own loops.

Here are some random tips if you're coming from C or Java:

"new" is not the way to create objects in C++. new and delete should almost never be used by serious programmers in C++. Never use new and delete (or malloc and free). If you want a dynamically-allocated array, use the standard vector.

It's much easier to write C++ than it is to read it. This is because you can always write using a simple clear subset of C++ that you understand. Try to pick a style that you think as many people as possible will understand. Programming languages are for humans to read. I try to write code that I think C programmers can read.

Edit -- Another tip:

Exception safety isn't about C++'s exception-handling language feature. Exceptions still happen in C. There's just not a language feature that directly expresses them.

Writing exception-safe code is nearly impossible in C. RAII and C++'s built-in exceptions make it possible. If you're careful to always use RAII by default, you can get the basic exception safety guarantee automatically without thinking about it. And you can get the strong exception safety guarantee whenever you need it.

Good luck!

rickhanlonii · 2015-06-04 · Original thread
Every good programmer should know? At least abstract Algebra.

The thing about advanced maths is that it forces you to think about abstractions in ways that not even programming forces you to think. You can get pretty far programming without much abstraction, but you can't understand the mathematical fact that any group of order four is either cyclic or isomorphic to the Klein-four group[1] without thinking in a really abstract way. The more you study these abstractions in advanced maths, the better you get at thinking in an abstraction-first way.

A great book that just came out this year explains this really well by taking you from a basic algorithm to an abstract implementation, explaining the maths along the way (from multiplication to abstract algebra and number theory). It's titled From Mathematics to Generic Programming and I recommend it to anyone who wants to understand more of what I mean[2].

--

[1]: http://math.stackexchange.com/questions/165341/any-group-of-...

[2]: http://www.amazon.com/Mathematics-Generic-Programming-Alexan...

Fresh book recommendations delivered straight to your inbox every Thursday.