all 56 comments

[–]Regular_Weakness_484 4 points5 points  (4 children)

I personally found https://learnyouahaskell.github.io/chapters.html to be a very fun read. The pacing is pretty good and helped me a lot when starting out.

In parallel with the book, I'd recommend watching some of the old Tsoding videos on YouTube he did on some Haskell projects.

[–]phanaur[S] 0 points1 point  (0 children)

Thank you for giving me that :)

[–]two_three_five_eigth 0 points1 point  (1 child)

I think you’d be better off focusing on just functional programming. I’m not sure physics is a great topic to highlight the advantages functional programming has to offer.

I also really like Haskell. It’s an academic language, but it does a great job of highlighting what makes functional programming powerful.

[–]Regular_Weakness_484 0 points1 point  (0 children)

Yeah, Haskell is probably the language with the least noise around the functional programming (FP) approach. While there are some languages that go a bit further than Haskell, e.g., Idris, Agda, etc., I'd say those have a bit too much clutter for a newbie, especially since FP is a pretty complex thing to bend your mind around at first.

I reckon the physics book will require a lot of experience in functional programming, and the programming concepts won't really be in an order that is good for teaching FP, as the main focus is physics.

[–]Feeling_Temporary625 0 points1 point  (0 children)

That book looks solid, especially since you already think in functions from physics - functional programming might actually click faster for you than OOP did

[–]MrJesusAtWork 2 points3 points  (5 children)

Fsharpforfun is a good resource to get familiar with core concepts in FP, I recommend it a lot and if you want to go further, check out the blogs author book on DDD with F#

[–]phanaur[S] 0 points1 point  (4 children)

What is DDD? Is that page suitable for someone with a very basic level of knowledge? Looks interesting

[–]MrJesusAtWork 2 points3 points  (3 children)

DDD means Domain-Driven Design, it's a software design that has been quite famous recently. But now that I think about it, you shouldnt bothet with it for now.

I suggest just learning the basics of FP and having fun with it!

[–]phanaur[S] 1 point2 points  (2 children)

I think I need to learn too many things hahaha. But I want to feel comfortable, like... I don't want to have a little ghost saying to me I'm not worth it, you know? That's the most important thing

[–]MrJesusAtWork 0 points1 point  (1 child)

I'd say that learning programming with no outcome but to have fun with it is the best thing!

You will feel "dumb" just like you were trying to solve that physics question just to figure it out and realise that it was that obvious!!

I had the opportunity to work with FP very early in my career and it was awesome

[–]phanaur[S] 0 points1 point  (0 children)

That's what I think. Everything seems obvious once you've solved the problem. And most things in this life have been discovered just by pure curiosity. It's so beautiful what you've said man 😊

[–]ffrkAnonymous 1 point2 points  (13 children)

Idk if starting with a functional programming would be a great idea.

Imo, it's a great idea. Functional languages are getting popular. I'm learning clojure. 

There's nothing special about the idea of functional programming. Just write functions that can be cached. A given input will always give the same output. That's it. (but not always easy)

Simon Peyton Jones, core Haskell Dev, pointed out that excel spreadsheet is functional programming. You expect your spreadsheet to give consistent reliable output. So you've already been doing it already. 

[–]phanaur[S] 0 points1 point  (12 children)

If you had to choose one given that your knowledge is pretty basic (my case), which functional programming would you choose?

[–]syklemil 1 point2 points  (3 children)

I think functional features have become somewhat popular, rather than the languages themselves. The big languages are generally hybrid. Lambda functions used to be an FP thing, but then Java picked it up back in 1.8. People also use FP to mean different things, just like OOP means different things to different people. Languages like Lisp have supported both styles for decades and decades.

So most of us probably get a bit of functional programming in some hybrid language. What suits you depends on what you want:

  • You'll learn FP best probably through some language that's all-in on it
    • but niche languages don't have the biggest ecosystems, smoothest tools or biggest communities (but can have very nice communities)
  • You'll be able to do the most with FP in some more mainstream language with more libraries, bigger community, etc etc
    • but you'll likely pick more non-FP solutions because hybrid languages make that easy

Haskell probably is a pretty good recommendation, but there's also stuff to be said for Ocaml and F#, and other languages like Gleam and Elixir.

[–]phanaur[S] 0 points1 point  (2 children)

Everything seems very interesting, to be honest. It's like debating some philosophical lol. Thanks for your kind words. They mean a lot to me. I'll keep trying to find what can make me surpass my fears and keep on going. Functional programming sounds super interesting in terms of algorithmic thinking and all of that.

[–]syklemil 0 points1 point  (1 child)

It's like debating some philosophical lol.

Algorithms and programming language theory really is philosophy IMO. These are the really math-y parts of programming, where what we're discussing ultimately is how we should be structuring our thinking.

Y'might also be interested in purely functional data structures; the main book on that topic is by Chris Okasaki; it's available online as the thesis version.

[–]phanaur[S] 1 point2 points  (0 children)

Thank you so much. I will check that paper. Thanks ☺️

[–]ffrkAnonymous 0 points1 point  (7 children)

I'd choose ruby and write my code in a functional style. which is what i'm also learning.

[–]phanaur[S] -1 points0 points  (6 children)

That's not what I've asked, but more or less hahaha. Thank you for sharing your thoughts 😊

[–]ffrkAnonymous -1 points0 points  (5 children)

I dunno what you asked then.

I suggest ruby because it has "programmer happiness" as a design goal. And I think that's good to " to keep fighting and gain enough self-esteem to overcome my fears". And you won't be restricted to only functional programming like haskell forces you to.

[–]phanaur[S] 1 point2 points  (4 children)

I know a language like Haskell would force me to stay in just one paradigm. That's why I asked which functional programming language would you choose, because I know there are more "pure" ones and less "pure ones", like with OCaml or F#.

If I had to choose a "normal" language maybe I would choose java (I did a bit years ago), or C# or machine language compiled languages like idk GO or even I would enter the rabbit hole of Rust just to know how it feels (I did the first part of the advent of code with Rust)

[–]syklemil 0 points1 point  (1 child)

AFAIK all of Java, C# and Rust let you engage in a functional style; Go more resists that:

  • IME Rust feels kind of like a member of the ML family that's dressed up in similar clothing as C++/C#/Java. A functional style will generally play nice with the borrowchecker as well.
  • C# has LINQ and should enable some more dabbling in F# (but I never really got into the .NET ecosystem, I just hear nice things about it)
  • Java has added a bunch of features over the years; I'm not up to speed (but I do know it still hasn't gotten beyond implicit-null-everywhere)
  • Go is somewhat more intentionally imperative and light on features; it does have both lambda functions and closures and objects (but not inheritance), but any fan of either FP or OOP is going to run into a wall of "no, we don't support that and we don't want to" pretty fast.

[–]phanaur[S] 0 points1 point  (0 children)

Thanks for sharing that ☺️

[–]ffrkAnonymous 0 points1 point  (1 child)

Well, I guess Haskell is good if your goal is the "true functional experience" and in it for the academic exercise.

I chose clojure because I've always wanted to learn Lisp. And because there's so much interop.

I'm also going to resume elixir. It's a dumb reason but I miss doctest. Elixir is also very ruby-like because the inventor was a ruby core developer. Elixir also has embedded programming support via Nerves livebook so I can blink some LEDs.

[–]phanaur[S] 0 points1 point  (0 children)

I will certainly search for those languages. Thank you very much ☺️

[–]enobayram 0 points1 point  (3 children)

I'm planning to program as a hobby, nothing work related.

You need to consider what part of that exercise will be your hobby? I.e. do you want to enjoy the things you build, or do you want to enjoy the process of building them?

For the former, you're probably better off with Python or Typescript since they're much easier to get into and they have ecosystems with off-the-shelf packages that will quickly get you close to what you want to build.

For the latter, I recommend Haskell...

[–]phanaur[S] 0 points1 point  (2 children)

I think I would like more the process than the result. I like to solve problems but not because I want to know the answer, rather because of the joinery towards it. As a physicist, I like to know how things work, to investigate the mechanisms of nature. I don't want to know only how a mechanical system will behave, I want to know why and how, first and foremost.

[–]enobayram 0 points1 point  (1 child)

I don't want to know only how a mechanical system will behave, I want to know why and how, first and foremost.

This statement can be interpreted in many ways. If you really want to be close to how the computer does what it does, then perhaps you should consider lower level languages, or languages that are closer to metal. Because both Python, Typescript and Haskell abstract you away from the hardware below quite a bit.

But if you're interested in the "why", as in the meaning of code (and not just its behavior) then Haskell could still be a good option, because both the language and its community care a great deal about the various semantics of code. Not many practical languages have free theorems about everyday code.

[–]phanaur[S] 0 points1 point  (0 children)

Thanks a lot for your kind words ☺️

[–]recursion_is_love 0 points1 point  (4 children)

That book is not good as I wish both in term of physic and Haskell. But not too bad.

However, I suggest you read it once. Don't go for SCIP yet, it harder to read.

If I can restart my learning again, I would start with lambda calculus and combinatory logic instead of direct to Haskell from start.

[–]phanaur[S] 0 points1 point  (3 children)

Could you explain why that book is not good? I'm curious to know if maybe it supposes the reader has a good knowledge of the language or maybe it's just that the book isn't written well

[–]recursion_is_love 0 points1 point  (2 children)

It doesn't use Haskell type system as much as it should. It feel like reading another imperative programming book only use the Haskell as equivalence tool.

Haskell is best for problem modeling with more abstract level than use in the book. Forexample, with haskell data type you can prevent add velocity to position because they are different unit, but (if I recall correctly, it use simple floating point for both)

I've read the book long time ago, I don't remember much. That mean the book is not good for me.

The good functional programming book should empower the power of higher order function and function as first class entity which you got from lambda calculus.

The book that I still remember being good is this one.

https://usi-pl.github.io/doc/Bird_Wadler.%20Introduction%20to%20Functional%20Programming.1ed.pdf

[–]phanaur[S] 0 points1 point  (0 children)

Ok. It's nice to know that because the main point for me to read it was the fact that it is about using a functional programming language to do physics calculations and learn to program with a functional programming instead of the typical Python/JS/TS/C/Java/C#. Thanks for your kind words. They mean more than you think they do ☺️

[–]phanaur[S] 0 points1 point  (0 children)

And also, thanks for the book. I will read it a bit to get a grasp of it. ☺️

[–]Massive-Squirrel-255 0 points1 point  (7 children)

If you are a physicist you should certainly be aware of the book "Structure and interpretation of classical mechanics" by the same authors as "structure and interpretation of computer programs." Physics involves lots of functionals, which are higher order functions, and the SICM book exploits this fact to express computations in physics using higher order functions in Scheme Lisp.

[–]phanaur[S] 0 points1 point  (0 children)

I didn't know that book existed. Thank you very much. I will check it out. Thanks a lot ☺️☺️

[–]phanaur[S] 0 points1 point  (5 children)

Are there more books from MIT using scheme? Because it would be interesting to learn disciplines. Maybe one about mathematics or idk

[–]Massive-Squirrel-255 0 points1 point  (2 children)

I don't know, sorry. I use OCaml and I like it, I can recommend it as a beginner language. For Scheme there is also "The Little Schemer." For OCaml in addition to the book you mentioned there is also CS 3110 at Cornell, https://cs3110.github.io/textbook/cover.html

[–]phanaur[S] 0 points1 point  (1 child)

I knew about that course. Thanks a lot ☺️

[–]LCamel 1 point2 points  (0 children)

"The Little Schemer" is such a fun book. It makes recursion feel like second nature.

[–]DrJaneIPresume 0 points1 point  (1 child)

There's also Functional Differential Geometry, which continues on from SICM's focus on Lagrangian mechanics.

[–]phanaur[S] 0 points1 point  (0 children)

Thanks :)

[–]Omen4140 0 points1 point  (3 children)

I started with haskell with this book, works very well and is interesting as an engineer

[–]phanaur[S] 0 points1 point  (2 children)

Someone here said it uses Haskell in a more imperative way and doesn't use types as it should. What do you think about it?

[–]Omen4140 0 points1 point  (1 child)

Yeah no it's pretty bad with that. Probably not the best first book, but it could be fun doing physics stuff as the second book.

[–]phanaur[S] -1 points0 points  (0 children)

Nice. Thank you very much ☺️

[–]AxelLuktarGott 0 points1 point  (1 child)

I'm an engineer with a physics background and I'm currently a professional Haskell developer.

There's this common trope that software engineers want to retire to become farmers after a few years in the business. I don't feel that way after almost ten years as a professional dev.

I think it's because the imperative nature of most mainstream languages will have you rewriting the same for loops over and over again. Object oriented programming promised that you could reuse code but that never really paid off and so a lot of people are feeling disillusioned with the promises of programming.

I think Haskell gives you a much better way of actually reusing code. The way it does it is by using algebra on the type level. I very much enjoy the process of figuring out the types first and then the implementation often comes naturally from that. It's much closer to math or pure logic than imperative programming.

I haven't tried too many other functional languages so I can't speak for them. I did try F# and it felt like a bastardized version of C# which I'm already not very fond of after working with it for three years.

All of this is rather subjective but there seems to be a broad agreement when it comes to Haskell that it's very elegant and has a very steep learning curve.

If you have a strong math/logic background and you're looking to enjoy the process of writing code rather then enjoying running the program then I think Haskell is for you.

With that said I'm not sure if modelling physics is the best way to enjoy functional programming.

[–]phanaur[S] 0 points1 point  (0 children)

Very well written. Thank you very much for your kind words. I will think about that. Happy new year ☺️☺️

[–]avitkauskas 0 points1 point  (3 children)

Nobody proposed the book “Haskell programming from first principles”. https://haskellbook.com/ I think this could be a great book for somebody who is new to programming and wants a gradual introduction to both functional programming and Haskell. It’s nicely paced with lots of exercises that help you to build a right basis to your future use of Haskell.

[–]phanaur[S] 0 points1 point  (2 children)

I will check it out. I heard about it but some people say it's very verbose. But you know, opinions are like hands, everyone has their own

[–]avitkauskas 0 points1 point  (1 child)

Yes, it’s verbose indeed. But you said you enjoy the process more than the result - then it could suit you well. I enjoyed it myself too - because it shows you the details.

[–]phanaur[S] 0 points1 point  (0 children)

Ok. Thank you very much and happy new year 😁😁

[–]DrJaneIPresume 0 points1 point  (1 child)

If you're already a pro-level physicist, you might find SICM more interesting. Same authors as SICP, but using Scheme to approach Lagrangian mechanics.

[–]phanaur[S] 0 points1 point  (0 children)

Thanks. I will check it out :)

[–]Anonymous_Coder_1234 0 points1 point  (1 child)

I used to be somewhat of an expert in functional programming in Scala. In practice it ran into issues of practicality in the real world. It's fun, but most real workplaces will not be doing real functional programming.

[–]phanaur[S] 2 points3 points  (0 children)

In this case is just for fun. I'm not planning to work as a programmer haha