As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
Would it be possible to structure a language in such a way that it can be written in itself? Could you write a c compiler in c, or a python interpreter in python? And if not, could the source then be re-written in itself? If so, would you have to use any components of another language (ie run compiled c in a python script)? Have there been any examples of this in actuality?
The key word you are looking for is self-hosting.
Other programs that are typically self-hosting include kernels,
assemblers, shells and revision control software.
Programming languages which have been self-hosted include Ada, BASIC,
C, CoffeeScript, F#, FASM, Forth, Haskell, Java, Lisp, Modula-2,
OCaml, Oberon, Pascal, Python, Scala, Smalltalk, and Vala.
One more compiler not on the list that I have worked with is Mercury.
And the related term Self-interpreter.
There are some languages that have a particularly nice and elegant
self-interpreter, such as Lisp or Prolog.
Yes
Is gcc C compiler written in C itself?
It just requires predecessor. At some point someone wrote a compiler without a compiler in asm.
I would assume.
Yes, one approach is to write a metacircular interpreter, which has the advantage that it is very easy to understand or write a simple one. Probably the most well-known textbook example of this is chapter 4 of Structure and Interpretation of Computer Programs, which explores implementing a subset of Scheme in itself. Although if you'd like to learn about interpreters and programming languages in general, I think PLAI is a better place to start.
For a production language, you often want more than a simple interpreter, but you can still bootstrap the implementation at some point. For a recent example, the Rust compiler is written in itself.
Related
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 9 years ago.
I apologize that this isn't a technical question, but as a programming student, I find it difficult at times to remember various arguments (especially in BASH scripting), so my question to the pros is, do you use references and "cheat sheets" or is it all from memory?
We don't memorise as in memorising the multiplication table. We memorise as in playing a musical instrument: kept using it.
We memorize only one command, man and bookmark only one URL, The Portable Operating System Interface (POSIX) which provides the cheat sheets for shell and kernel programming alike. We learn C only from one book, Kernighan, Ritchie: The C Programming Language and Unix/Network programming only with W.Richard Stevens' books.
Everything else is expendable :-)
Well I guess there is no real way to memorize things, you need to really have an understanding of the commands. To be honest a lot of people still may need to look in the "man" for particular commands to find all their options. The first step is feeling comfortable with bash and the commands and having a general appreciation of how bash commands generally work.
Then there is good old fashioned repeated use which will get you more familiar with the commands and then it will become second nature. So I guess the answer is to get a general appreciation and keep learning and applying what you learn on a regular basis.
I personally have a cheat sheet of commands that i use on my setup.
The more you code the less you will need to look something up. Google is your friend.
Firstly, try focus on remembering concepts and not variables or function names.
Secondly, using cheatsheets and references is a good choice for beginner, you can even print it and put nearby.
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 9 years ago.
Recently I started looking at functional languages to make some algorithmic parts of my application more reliable. Of course I bumped into Haskell. But it prepared too many surprises for me with its laziness. Sometimes simple things become very and very slow.
So I'm wondering is there a language I can use to write small algorithms in functional style but without unnecessary laziness which causes more problems then helps.
The program should be compiled into Win32/64 native code (preferably dll) and have comparable performance with C++.
OCaml is probably the closest to Haskell, but it's strict and impure. It's a successor to ML.
OCaml, ML, and Haskell can all be compiled to machine code on any common platform.
In my experience, though, laziness is usually a great feature once you get a sense for how it works.
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 11 years ago.
Is anyone knowledgeable on programming language implementation of algorithmic trading?
I am going to propose a research project on functional programming and algorithmic trading.
My proposal is here: http://pastebin.com/wcigd5tk
Any comments would be very appreciated.
What do you think the future of functional languages in the financial field is? I see many job postings that ask for experience in java and C++, and i dont understand why.
Jane Street is very well known for using OCaml for their trading software. Here you can find some reasons why they decided to use functional languages rather than imperative ones. They also have a blog describing several specific solutions to problems they encountered during development.
C++ is the most popular in that field.
java , python ,haskall ,c# are all runners up
haskall and c# are functional with haskell being purely functional
eventually the field will move to a more "modern language" like c# or haskall but right now c++ has so much support the libraries are already made and its implementation is the easiest .
For Trading application, it usually has Real time, multithread, low latency, high availability to consider too. I was working in a company developing a trading application using both(mixed) C++ and Java as it fit with the behaviour of the application.
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 11 years ago.
I was wondering is it worthwhile learning a language like Erlang. I am looking at learning a new language and the following questions are on my mind :
Will learning functional programming help me/improve as a programmer?
Industry Usage of Erlang/ projects using erlang ?
Any real future in learning erlang from a career point of view?
Possible advantages/disadvantages of erlang over python/PHP/ etc
Thanks,
Vicky
Coming from Scheme here so I can't speak much for Erlang. But as Scheme is functional as well, let me try to convince you.
Will learning functional programming help you as a programmer?
Absolutely. I've heard a lot of reasons for this, some I can attest to, others not (yet). Actually, in my opinion, it's moot trying to convince people that functional programming is worth learning at all, especially when there's a lot of press about Python/PHP/Java(Script)/etc. They have to be convinced for themselves, when they learn it.
As for me, Scheme allowed me to appreciate recursion more. Sure you rarely use recursion in other languages due to limited stack space but as a lot of algorithms are described recursively (albeit implemented iteratively, that is, using loop constructs), implementing them recursively should give you a better appreciation for them.
Industry use of Erlang?
Pass. Though I recommend looking around at Commercial Uses of Functional Programming.
Learning Erlang for a career?
I'm not the person to ask so I can't elaborate but I've heard that FP proved to be very useful in parallel computing. Talk about the future!
Advantages over Python/PHP/etc?
It's functional so it is a good practice for mathematical thinking about algorithms, which is not very apparent (at least for me) when you code in a procedural language. Also, look at the results of Programming Language Benchmarks. It seems that functional languages are faster than those you mentioned (LISP, Haskell, Erlang). Python goes after Erlang but Erlang sure is faster by around half of Python's time! And look at Erlang HiPE: 10.22 seconds! (I'm looking at x64 Ubuntu Intel Q6600 quad-core---parallel processing gave them a leg-up?)
TL;DR Go ahead and learn it. You'll thank me, I'm telling you ;D
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 12 years ago.
In the past LISP was the only powerful functional programming language, as far as I understand. Now there are lots, why do people still use LISP with its weird syntax? Is there a unique killer-feature of a kind?
First, Lisp in general and Common Lisp in particular is more "multi-paradigm" than "functional". From here on, I will mostly discuss Common Lisp (CL).
There isn't "one killer feature", though. CL is a programmable programming language, making it easy to do meta-programming. That is, you can usually do "meta-level" things directly in the language instead of having to reach for a pre-processor that does textual transformation into your base language.
CL also has a very powerful object subsystem (CLOS), that has, so far, supported anything I've wanted to do with class hierarchies and/or methods.
As far as the syntax goes, I guess it's a bit different from the more classic syntax of the "Algol family" languages, but it's no more and possibly less weird than APL.
There is a unique killer-feature. It's called a macro-system. With macros you can expand your language and it makes it really easy to make great DSLs. This kind of thing would be hard (and not that nice) to implement with Scala, Erlang or Haskell.
The syntax or the lack of it is what lot of lispers really like because it brings a great uniformity which is something that is lacking in a lot of languages. For a standard C or Java programmer the Erlang or Haskell syntax is weird too so what's worse about syntax other that it looks weird.
Another question you should answer is why are the other languages better then Lisp, what feature is Lisp missing?
But it's of course the case that many modern languages learn a lot from Lisp and there are many more languages that can be used for the same problem.
Don't forget that Lisp is not one language there are diffrent kind of Lisp dialects. Scheme, Common Lisp or Clojure and all have diffrent focuses.
So the question what language to use can only be answered by trying them every has something pretty special about them. Erlang with the Actors, Haskell and Scala have these crazy typesystems, Lisps have awesome macro-systems .....