TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Ask HN: Where did you first come across functional programming?

14 pointsby curious16almost 2 years ago
What were your realisations after learning functional programming?<p>Were you a proficient programmer before that?

14 comments

dserbanalmost 2 years ago
Haskell course at university. Had fun doing all the exercises in the curriculum, and couldn&#x27;t stop. Explored on my own how to implement in Haskell the more advanced programming patterns that weren&#x27;t covered in the course. Had fun with lazily evaluated infinite lists where you evaluate the second element of the lazy list that was passed as an argument, and at the end of the same lower order function you return the lazy list but with its head chopped off, to have the algorithm run in constant space.<p>I have come to regard lazily evaluated infinite lists as a must-have before you can call something a functional programming language.<p>In trying to build more complex systems, I noticed that you really have to know what you&#x27;re doing with Haskell, otherwise you end up with leaks that are very difficult to trace back.<p>What really solidified FP for me was taking an elective category theory for computer scientists course.<p>Today I&#x27;m building stuff in Scala, which is the closest you can get to being able to pay the bills while doing principled FP.
jjicealmost 2 years ago
University (like a lot of CS students I&#x27;d assume). I always saw it as an academic thing and didn&#x27;t give it much use until my compiler course. My professor for the course maintains a somewhat well known SML compiler and our course was writing a very formal functional programming language in SML. A lot of the power starting falling into place at that point. ADTs especially were eye opening.<p>I don&#x27;t write in pure FP languages now, but I do use the concepts I learned all the time, especially as their fantastic concepts are leaking into other languages, like Rust.<p>I don&#x27;t think pure FP languages will ever be real industry winners, but I think they&#x27;re great experiment and research grounds for features that the broader community eventually adopts, which is such an important thing for improving the expressibility of our code.
Leftiumalmost 2 years ago
FP didn&#x27;t really start to &quot;click&quot; until I found &quot;Functional Core, Imperative Shell&quot;[1] last year (2022). The HN comments from that thread were very helpful, too.<p>I didn&#x27;t really grok FP until 2022, but I learned Scheme as early as 1999 for programming 101 (comp sci degree). We used the SICP textbook; looking back it seems SICP used an FP language to teach programming, but didn&#x27;t explore some important FP concepts like Option&#x2F;Either (a.k.a. Monads. Perhaps our class just didn&#x27;t cover that part of the book?)<p>Between 1999 and 2022, I dabbled in FP because I heard good things about it. But I think many FP practitioners could improve their marketing&#x2F;teaching skills. Most FP texts seem to dive into mathematical jargon (monads, functors, etc) without even explaining why knowing these would be useful.<p>So I&#x27;m writing a series of articles on FP. The first one is on why FP is worth learning: &quot;More Performant, Testable Code with Functional Programming. (FP language optional!)&quot;[2]<p>The next article will be a curated list of articles&#x2F;videos that I feel explain FP better than most; the ones I wish I had found way back when starting to dabble in FP.<p>Also there&#x27;s an argument many of FP&#x27;s useful features have been copied by more imperative languages[3]. So people may be unwittingly doing FP even if they aren&#x27;t using an FP language. For example, anonymous first class functions have been added to C++ and even Excel. JS has always had anonymous first class functions.<p>[1]: <a href="https:&#x2F;&#x2F;hw.leftium.com&#x2F;#&#x2F;item&#x2F;18043058" rel="nofollow">https:&#x2F;&#x2F;hw.leftium.com&#x2F;#&#x2F;item&#x2F;18043058</a><p>[2]: <a href="https:&#x2F;&#x2F;blog.leftium.com&#x2F;2023&#x2F;04&#x2F;more-performant-testable-code-with_28.html" rel="nofollow">https:&#x2F;&#x2F;blog.leftium.com&#x2F;2023&#x2F;04&#x2F;more-performant-testable-co...</a><p>[3]: <a href="https:&#x2F;&#x2F;youtu.be&#x2F;QyJZzq0v7Z4" rel="nofollow">https:&#x2F;&#x2F;youtu.be&#x2F;QyJZzq0v7Z4</a>
revskillalmost 2 years ago
OOP programmer lives inside the GoF design pattern and the result is AbstractSingletonFactoryBeanProxyAdapter class you love !<p>Nowdays, my programm is mostly the composition of some functions. Want inheritance and polymorphism ? Just use object composition and multi dispatch functions.<p>The way to go forward is abandon any of `class` keyword.<p>Protected, public, private is a lie and also a trap. It didn&#x27;t prove anything.<p>Your encapsulation rule is inside your interfaces, not inside your class keyword.<p>Now you can say: But OOP served me well, i can get shit done fast !<p>Absolutely, any tools can serve you enough. The issue is, once you use the bad tools, you get into a rabbit hole to slow down everything else eventually.
评论 #36149835 未加载
47thpresidentalmost 2 years ago
I&#x27;ve came across Haskell in my computer science class at High school&#x2F;Sixth Form. It&#x27;s in the AQA Computer Science specification [1] and you are expected to know the basic concepts of functional programming as well as interpret code in the written exam.<p>[1] <a href="https:&#x2F;&#x2F;www.aqa.org.uk&#x2F;subjects&#x2F;computer-science-and-it&#x2F;as-and-a-level&#x2F;computer-science-7516-7517&#x2F;subject-content-a-level&#x2F;fundamentals-of-functional-programming" rel="nofollow">https:&#x2F;&#x2F;www.aqa.org.uk&#x2F;subjects&#x2F;computer-science-and-it&#x2F;as-a...</a>
jdale27almost 2 years ago
My first programming course was CS 61A at Berkeley, taught with the textbook Structure and Interpretation of Computer Programs. I had tinkered around a bit with other languages before that, but hadn&#x27;t got seriously into programming until that time. I consider myself very fortunate not to have been previously indoctrinated into imperative &#x2F; stateful programming.
评论 #36148254 未加载
jobhdezalmost 2 years ago
The first programming language I learned was Scheme - I read the little schemer by Felleisen but my second book was what really taught me to program. This second book was structure and Interpretation of computer programs. I’ve been using lisp ever since. Scheme is a a beautiful language but I’m a Common Lisp guy now a days
pjacotgalmost 2 years ago
Haskell course in 3rd year at university in the year 2000. It was only 5 weeks and I didn&#x27;t fully appreciate it at the time. I did maths for a few years after that and only returned to programming later and rediscovered functional programming as it started becoming popular again. I haven&#x27;t programmed in a functional language professionally but ideas from functional programming have changed the way I write code.
kazinatoralmost 2 years ago
My first exposure to functional concepts was, doh, mathematics! Functions are maps, not procedures that flip bits. There recursive definitions and such. Inductive proofs. The activity of doing derivation: you leave the old formula as is, and produce a new one from it by applying rules, which you should recognize as a kind of function.<p>Some of this stuff, you play with in &quot;Blub&quot; imperative languages. If you write a recursive factorial or fibonacci in Pascal, that&#x27;s functional programming. Just not with higher order functions.<p>The C preprocessor is an example of functional calculation. (Though macros can be undefined and redefined, mainly they are just defined and called, and perform substitutions without clobbering anything.)<p>Unix pipelines : don&#x27;t clobber anything other than the file being created or replaced at the end.<p>Parsing a grammar with Yacc and building a tree: basically functional. The imperative bits going on are hidden under the hood. $$ = make_node($1, $3) is an assignment, but it&#x27;s boiler-plate; you don&#x27;t think of it as assignment, but yielding the semantic value of the rule, which is constructed from the pattern-matched $1 and $3 pieces.<p>All those things teach you that it&#x27;s useful and good to calculate a new value from an existing one, while leaving the original alone.<p>There is a lot of functional programming in the middle of imperative programming. E.g. constructing a balanced binary tree might not be functional (it can be, but often isn&#x27;t in Algol-like languages), the queries on that structure are conductive to functional programming. Queries don&#x27;t mutate the structure, and if recursion is used, don&#x27;t mutate traversal variables.<p>A binary search of an array can be coded functionally via recursion.<p>Here is a functional version of strchr in C:<p><pre><code> const char *strchr(const char *str, int ch) { return (*str == 0) ? 0 : *str == ch ? str : strchr(str + 1, ch); } </code></pre> Lisp was something that clicked almost instantly. I came to that armed with a lot of experience and understanding, and was well-versed in recursion, plus all around systems programming as an experienced developer. The idea that, say, a tree could be recursively defined as a null value, or else a node with two children, was nothing new. Or that a recursive function could search that.
GianFabienalmost 2 years ago
Lisp at university several decades ago.<p>Although I don&#x27;t use it in my daily work, I still tinker with Scheme and SBCL from time to time.
rsrsrs86almost 2 years ago
I heard about LISP in 2014. Back then I worked in finance and it looked so similar to spreadsheets.
richardjam73almost 2 years ago
Long ago I wanted to make a specific script for Gimp which needed to be written in Scheme. I didn&#x27;t know anything about FP at the time and didn&#x27;t really understand why things were done the way they were.<p>Over a decade later I decided to learn F# and now it makes sense.
austin-cheneyalmost 2 years ago
As a self taught developer functional programming is my original programming style. I never understood why anybody would choose OOP unless a language forced it on you. To me OOP is more complex and requires so much more decoration and ritual.
maxrfalmost 2 years ago
jvm - scala, took martin odersky&#x27;s course - was &#x27;fun&#x27;