hmemcpy / milewski-ctfp-pdf

Bartosz Milewski's 'Category Theory for Programmers' unofficial PDF and LaTeX source
https://bartoszmilewski.com/2014/10/28/category-theory-for-programmers-the-preface/
Other
10.91k stars 581 forks source link

I'm new to Functional Programming and need a quick advice #186

Closed mateusmlo closed 5 years ago

mateusmlo commented 5 years ago

So I've been into programming in general for a little more than a year only and started to study FP seriously this year, but...in the wrong language maybe? I'm aiming to become a web developer, so most of my studies have the basic HTML/CSS/JS structures, which means I'm studying FP concepts applied to JS (which is multi-paradigm but doesn't work all that well with none, I'm aware), using libraries such as Ramda and Crocks. I've been studying from various sources like the excelent Professor Frisby's Mostly Adequate Guide to FP which covers a good bit of theory, as well as a few other books, but I want to dive deeper into the maths and theories behind it all. I still get headaches trying to read HM-type signatures. Well my worry is: since the book is not translated to JavaScript, I might feel lost when trying to apply my knowledge when coding websites with it. Any advices? 😟

BartoszMilewski commented 5 years ago

I know that some people are trying to implement category theory in JavaScript, but I think learning TypeScript is a better option.

mseri commented 5 years ago

I second that, and if you want to get more deeply into web development in a haskell-like language there is also the PureScript option. Keep it mind that, differently from TypeScript, it has a much higher learning curve and is a separate language from JavaScript.

mateusmlo commented 5 years ago

First of all, thanks for replying and providing some good insights already! You guys are great! And yeah I've looked up a few things about PureScript and Elm, they really did pick my interest, mostly because both are written in Haskell and compile to JS. What I'm most concerned though is the use of such languages with widely requested frameworks such as Vue and React (which I'll do my research on) and if they will get me employed beucase oh god most requirements are about JS and do not include languages that compile to it :sweat: Maybe I'll give TypeScript a try but I'm honestly not that interested in it since it's not purely functional.

mseri commented 5 years ago

Especially I f you want to interact with react and other mainstream JavaScript libraries I think TypeScript, or OCaml/ReasonML, are better choices. you can always restrict your use to the functional part of the language, and in all cases you will benefit from a nice ML type system

alfonso1003 commented 5 years ago

Since you say you want to be a web developer and you have only a year's experience, I'd suggest you stick with learning ES6 and be familiar enough with old school Javascript (the kind with var and scope problems) so you can work with it whenever you see it. ES6 has a lot of cool functional aspects and redux is fun to use also once you get FP. You can also mix in functional packages like underscore.js and immutability-helper if you want to be a functional subversive in vanilla Javascript land.

At home, learn Haskell or Scala or Erlang or whatever, and gain a proper understanding of functional programming in a context outside of web development. Once you do that, you'll have an easier time making sense of functional web development when you get back to it.

About Typescript, you'll gain familiarity with that should you ever get thrown into an Angular project. You'll even see coffeescript, jQuery, and others out in the wild depending on where you land and whatever 5-year-old legacy (ancient in Javascript years) project you get put on. You're a pro now, so whatever flavor of Javascript gets thrown at you at the job, you can handle!

You've only been at this a year, so get your bearings straight and learn Javascript fundamentals before you get too fancy. Gain a thorough understanding of the old paradigm before you attempt to break it. Furthermore, you'll find it easier finding jobs knowing ES6/React/Vue these days than if you went out looking for Elm/functional JS jobs. I've received hundreds of emails from recruiters over the past few years, and only once has anybody mentioned Elm. You'll find it much easier learning functional programming on your own time while you're working, clothed, fed, warm, and housed.

Once you gain a thorough understanding of Javascript, then don't let it get to you so that you become like this guy: https://medium.com/@richardeng/what-if-javascript-wins-c9eaec9e5275 He raises a lot of good points and it is kind of terrifying, but that's not anything I, a lowly code monkey, can control. On top of his concerns, add on top your preference for functional programming and it's enough to make anybody go nuts. It's just a job though, right? I'll code something in BASIC if they paid me to. Why not? I'll learn Haskell at home in the meantime.

Finally, read this cynical article: https://www.kalzumeus.com/2011/10/28/dont-call-yourself-a-programmer/

The whole thing is a good read, but this part specifically applies to your situation:

Want to get trained on Ruby at a .NET shop? Implement a one-off project in Ruby. Bam, you are now a professional Ruby programmer β€” you coded Ruby and you took money for it. (You laugh? I did this at a Java shop. The one-off Ruby project made the company $30,000. My boss was, predictably, quite happy and never even asked what produced the deliverable.)

The point being, once you've been out there long enough, make an Elm project at your company, and boom. You're now a professional functional Javascript developer. It'll be easier to carve out your own niche (functional programming) once you have clout, which is generally built by first learning the current dominant coding paradigms (procedural, object-oriented).

β€œLearn the rules like a pro, so you can break them like an artist.” ― Pablo Picasso

Anyway, that's my friendly opinionated rant. Please feel free to disagree, but I hope you'll consider the points.

BartoszMilewski commented 5 years ago

Patrick McKenzie's post reads like Machiavelli, but it's so true!

mateusmlo commented 5 years ago

Thank you all for the awesome insights! After reading the comments and links, I've decided to become a better programmer before I dwelve into the deep waters of computer science and mathematical paradigms, although it's very interesting, it could put me way off track and create more difficulties at such a time where I'm so new to this world of 1s and 0s. Closing issue!