Live data from Hacker News

I thought I understood recursion

functional.christmas

111–120 of 124 posts

Re: I thought I understood recursion

#111
post #100

Depending on the particular language and platform, it can be quite dangerous to use recursion in production software due to the risk of a stack overflow. To be safe you have to first determine analytically that this can never happen. For algorithms that manipulate tree data structures it's often safer to avoid real recursion and instead sort of simulate recursion using a list or stack data structure allocated on the…

Tbf most code doesn't encounter trees deep enough to generate a stack overflow.

It's more of a concern with things like mutual recursion (multiplying your frame depth at each step, instead of just +1) or if your recursion depth is based on unbounded user input (eg iterating over an AST, or this code snippet)

Re: I thought I understood recursion

#112
post #51
post #32

Earlier quoted context omitted.

That has not been my experience. In a C# shop, if you want to do something not-C#, best is to switch employers. I don't say that placing such high value just into what tool you use is smart; but changing tools in a company is often a total no-go.

Yes totally that. I have been told many times in the last 20 years that the only thing that gets used comes from Microsoft. Literally the same shops end up with several piles of unmaintained crap which is either "not invented here" stuff, abandoned microsoft frameworks and all the staff have left to go find another job because it's not shiny any more. Also a bad outcome.

A NIH attitude is kinda the the opposite of what I meant. Choosing the right job for the tool, would mean that all the wrong jobs should be outsourced.

Re: I thought I understood recursion

#113
post #98

Earlier quoted context omitted.

Lets extend this analogy to books: all books are just letters and words writen on a page. And some pictures too. It doesn’t matter how a book is written as long as it produces letters, words and paragraphs and pictures. It doesn’t sound right, does it?

That's not a fair extension of the analogy. An equivalent analogy would be that you can use any text editor or word processor to write a book.

A more fair and understandable analogy is to compare it with natural language, which is just made up of simple sounds chained together.

Re: I thought I understood recursion

#114

Earlier quoted context omitted.

I'm not sure that holds up. Real people working at real companies are writing real code in Haskell every day. I found several job postings in London that advertised Haskell as a requirement / nice to have. Haskell is also taught and used extensively at my alma matter, and is in fact the first language you will be introduced to at a CS/SE degree. How is that in any way, shape, or form comparable to Brainfuck?!

When was the last time you installed and/or ran a Haskell program? If the answer is more recent then "never", then what was it? It's possible that Haskell is like COBOL in that it's used in industry but not at all by the community. But I'm not sure how I would characterize it, then. Does industry use count as "practical"? I honestly don't know. Anyway, examples would be nice.

And what is "the community"?

Haskell indeed has less penetration than something more popular like JavaScript.

But the Haskell language is not easy to use if you're a script-kiddy. Most "easy" languages can have some form of copy-paste reuse, and a lot of "the community", it would seem, just append together useful snippets to get their programs done (and whether they have a deep understanding or not is not needed).

This isn't true for Haskell. It's actually quite hard to just "copy/paste" Haskell without out knowing the underlying concepts. I wager that the reason there seems to be less.of a community in Haskell is due to this property.

Re: I thought I understood recursion

#116

"It is rather an attempt to get my head around functional programming, and to me Haskell doesn’t seem to have any practical application beyond that." Cardano/ADA's core Ouroboros protocol was entirely written, with formal proofs, in Haskell. It is by far the most serious attempt at proof of stake in the crypto industry. I think what you're really saying is, you won't find many jobs out there w/Haskell as a requiremen…

>You just have to look harder to see where it's being used. This is where advocacy slips over the line into a kind of blind faith evangelism -- with an added pinch of pedantry peculiar to our field. I will state without proof that every language ever invented is currently being used for something practical somewhere. E.g. someone has a useful shell utility they wrote in Brainfuck that they run every day and that they…

Haskell is significantly less popular than some other languages, but it has a non-trivial amount of people using it in serious applications in industry (e.g., a large part of Facebook’s spam filtering system is written in Haskell [1]), as well as for some reasonably popular open source projects like Pandoc. Furthermore, Haskell has a rich ecosystem of open source libraries on Hackage.

How does this not qualify it as a language with practical applications? Frankly, your comment comes across as being based upon hearsay, instead of actual experience with the language and its community. You’re right that Haskell is not as popular as more mainstream languages, but that does not make it similar to Brainfuck.

[1] https://engineering.fb.com/security/fighting-spam-with-haske...

Re: I thought I understood recursion

#117
post #65
post #7

> My background is in OO programming, mostly using C#. C# being the versatile language it is, I have had the perception that whatever you do in other programming languages, you can with a little more code and hassle achieve in C# as well. If need be, I can program C# using a functional paradigm. And, of course I use recursion all the time. I know all there is to know about recursion. IME there are two kinds of progra…

I have mixed feeling on this. I see what you are saying but I have also seen plenty of Python code written by what are clearly Java developers. And Framework collectors who have learned learn the very basics of Django before they moved onto something new - and hence written a load of overcomplicated crap that could have been done a lot cleaner if they had learned the framework in more depth. Learning some things in d…

i think these are different things.

Yours is concerned with code quality and maintainability, both generally benefit from idiomatic programming style which people new to the language rarely have. And you're 100% right.

BUT the parent post was talking about ideologies "the one true language" vs "hey, i can make this work anywhere"

the latter camp affects you in that many of them don't have the discipline or patience to really ingest the new language before spewing out code that "works" but sucks for maintainers.

Re: I thought I understood recursion

#118
post #85

Earlier quoted context omitted.

Don't know if you're serious, but for the most devs, the job is chosen for, not by, you

Isn't that a slave mindset? You weren't born prebound to a specific job. Most devs (heck, most workers in any industry), can try and look for appropriate jobs.

"appropriate jobs"

most devs have "appropriate jobs" for their skillset. It doesn't follow that the tooling chosen by others before you at that job is "appropriate" or that the language is "appropriate" or that you have any choice in the matter. Most of us don't. Most of us work within the constraints provided. Some of us work to remove or change those constraints.

getting an "appropriate job" rarely addresses these problems and even more rarely makes it evident that they exist before you take the "appropriate job"

Re: I thought I understood recursion

#119
post #25
post #10

Earlier quoted context omitted.

It's not obvious to me why choosing the right tool for the job is better than choosing the right job for the tool.

Might it be easier to switch tools than jobs for most people?

raaaarely.

you generally have an established codebase of tens of thousands of lines of code that the business is based on... usually with little to no test coverage. Creating a parallel version of the code in the new language would take ages and be filled with errors because the lack of tests proving the behavior in the old one means you rarely know if you new version is "correct" or not ... and then you end up with annoyed customers but... all of that is moot because you can't get management to sign off on using so many resources for so long to do a thing that customers will never see and can't be marketed.

Re: I thought I understood recursion

#120
post #112
post #51

Earlier quoted context omitted.

Yes totally that. I have been told many times in the last 20 years that the only thing that gets used comes from Microsoft. Literally the same shops end up with several piles of unmaintained crap which is either "not invented here" stuff, abandoned microsoft frameworks and all the staff have left to go find another job because it's not shiny any more. Also a bad outcome.

A NIH attitude is kinda the the opposite of what I meant. Choosing the right job for the tool, would mean that all the wrong jobs should be outsourced.

> Choosing the right job for the tool, would mean that all the wrong jobs should be outsourced.

outsourcing that is just "kicking the can down the road" some poor developer is still left dealing with the same problem. It doesn't change anything other than who has to do the thing you don't want to / don't think is right.

Post reply on HN