How would you implement a functional programming language? [closed] - haskell

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
In functional paradigm, a function is a primary 'control structure'. For eg., the + operator is also treated as a function and you can pass them around like any other 'objects'. I was wondering that if i had to implement a toy functional language, would i implement simple functions as true functions (i.e. translate + into a callable routine) or translate them into normal instructions that would be placed 'inline' into the translated code. But then, with the second strategy, would i be able to pass them around and apply them partially like in haskell? What are your thoughts on implementing/translating functions as a central idea in a functional language?

I can recommend the PJL book. I wrote a compiler with help from it (in 1989-90, in Prolog) and the book is a very good introduction to the subject.
It might be dated (written in 1987, 30 years ago) but it still covers the basics very well. It is, however, completely focused on lazy languages like Haskell. At the time Haskell did not exist and the book uses LML or Miranda, a predecessor language but the languages are very close.

Related

what is the relationship between safe & pure & referential transparency in functional programming? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
pure / impure: appears when we talk about the different between Haskell and lisp-family.
safe / unsafe: appears when we name functions like unsafePerformIO, unsafeCoerce.
referential transparency / referential opacity: appears when we emphasize the benefit of purely functional programming.
The difference between these words are very subtle, I find there is some post talking about them individually, but I'm still hoping there is a clear comparison between them, and I can't find such a post here yet.
I've always been fond of Amr Sabry's 1998 paper that explored a similar question with the rigor it deserved: https://www.cs.indiana.edu/~sabry/papers/purelyFunctional.ps
A sample quote:
A language is purely functional if (i) it includes every simply typed
lambda-calculus term, and (ii) its call-by-name, call-by-need, and
call-by-value implementations are equivalent modulo divergence and
errors.
While this question can generate a lot of "opinion" based answers (which I am carefully avoiding!), reading through Amr's paper can put you in the right mindset about how to think about this question; regardless whether you end up agreeing with him or not.

Is there any advantage using high-order functions (filter, map, fold) instead of pattern matching in Haskell? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
I have some code in Haskell that is using pattern matching. However, I think that I can use folds and filters. For me this would be more readable, but I want to know it there is any advantage in terms of complexity.
The main reason to use higher-order functions instead of pattern matching and manual recursion is that it makes your code more concise and way easier to read.
Once you get the hang of them, you'll find that reading source code suddenly became way easier as those functions are amongst the most popular in all of Haskell.
It's also considered a good practice, and many people appreciate that you abstract your code.

Haskell for Robotics [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I am looking up on web about Haskell and its applications. Basically i trying to learn functional programming language and i see Haskell is very famous among them. What i want to know is, is it possible to use Haskel as substitute for c in robotics? Can i use Haskell for embedded system programming and getting data from sensors, moving the motors, implementing mathematical model that is used to design the robot and its behaviour and if possible apply machine learning algorithms?
I am just starting off in this field so if the question is naive enough, please answer like you would answer any newbie.
Update: If the Question is too broad, i would like to know the specifics. Do people compile down the haskell to the embedded hardware or use haskell as a remote control in most of the cases? Which one is more approachable using haskell? What is the general way of using haskell in hardware embedded programming? If it is only used as a remote control, how to implement genetic algorithms and machine learning algorithms using haskell? I know its too broad but i would just like to know the general usage if my requirement is such.

Why would i learn erlang or haskell? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 8 years ago.
Improve this question
Why should I learn Haskell, Erlang or other concurrent languages if I am already an OCJP and can master C/C++?
People have a craze of learning Erlang, Haskell, Oz, Prolog. But is it really necessary? Does it have any scope in a programmers carreer?
The main reason to learn new programming language is not in learning just another programming language but to learn new programming paradigms, techniques and tools. Once I learned Prolog I started to write very different C code. It happen again with Perl and again with Erlang. It change way how to you will see problems and how you decompose them into manageable chunks and also way how you will implement them in readability and maintainability sense. But don't forgot learn how to write Perlish, Haskellish and Erlangish and whatever way. If you will write C like code in all those languages it will be waste of time.
Haskell is a functional programming language. I had the chance to learn few things about Haskell last year and i can say it was something new.
I think you should dive into Haskell, you'll have to use only recursive functions as there is no loops. It helped me a lot to improve my programming methods.
Give it a try and if you don't like it, just try something else.

Why use advanced compiler techniques over simple string manipulation in small compilers? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 8 years ago.
Improve this question
What advantage is using (what I understand as) advanced compiler techniques like special grammar, AST, etc over simple string manipulation for making very small programming languages? I'm interested in compiler design and don't know wether I should learn all of this compiler theory if I'm only going to make small and simple languages. I know that as I start to make bigger languages I will probably have to use parser generators and the like, but until then should I bother?
You should definitely know what an AST is and how to build one. Even if you use parser generators later on. I mean, how can you be interested in compiler design but not in grammar and syntax trees? It always pays off to learn how stuff works under the hood, rather than taking it as magic.
And seriously, parsing anything else than Whitespace or Brainf*ck is awful with string manipulation as soon as it gets more complicated...

Resources