It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
I have been programming for a few years now and have seen the name Bison in passing, but never bothered to ask why it is or why it might be needed. How can Bison effect how I program, can it make my C/C++ code faster?
Bison is a parser generator. It takes it's input in something similar to Backus-Naur notation and outputs code to parse input according to that grammar. It lets you write a parser more easily than you would otherwise. Instead of having to do everything manually, you only have to specify the rules of your grammar and what you want to happen when it matches one of the rules.
GNU Bison is the only Bison related to programming I know of. It won't make your code faster, and it's possible that you won't ever need it in your life. However, learning some compiler theory, or even writing a simple compiler yourself, is a terrific learning experience that does affect the way you program, the way you think about computer programming, and a lot of things like that. If you enjoy formal languages and automata, you'll enjoy compiler theory; if you dislike theory in general, it's probably not for you. If you're interested, there are lots of questions about starting books on Stackoverflow.
Oh and, once in a while a programmer does need some more complicated parsing work and suchlike, and it's a huge boon to know about parser generators, instead of writing everything by hand, following a naive approach.
Related
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
Scala's Macros and C++ templates both provide access to compile time meta-programming. Could you elaborate on similarities and differences? Are they equal in terms of expressiveness?
One important difference between them is that Scala macros are written in Scala, whereas C++ templates are their own programming language, which is completely unlike C++. C++ is an imperative object-oriented strict impure language, C++ templates are a declarative hybrid logic/functional non-strict pure language, which was never intended to be used as a full-fledged programming language, and thus lacks many of the features necessary for programming in the large.
They both provide compile time metaprogramming and both are turing complete, but that's about all they have in common. I am no expert on C++, but as far as I know, the fact that C++ templates are turing complete is rarely exploited and using them for actual programming is hard. Often, templates are just used to provide parametric polymorphism (aka generics), whereas Scala macros are written in Scala and can use the full power of the language at compile time.
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
Clojure/ClojureScript does not have reader macros. I personaly think it is a huge loss as I'm specifially interested in hacking with the syntax. Is there way to develop websites using a lisp with reader macros?
Common Lisp has Parenscript, that allows you to generate JavaScript from Lisp syntax, and be able to use reader macros.
You can also hook it with slime-proxy and swank-js to have a fully interactive experience.
You might be interested in sweet.js. It's essentially JavaScript with a powerful macro system that does much, if not all, of what reader macros can do. Now, it's not actually a Lisp, but JavaScript was partially inspired by Scheme, and sweet.js's macro system is intended to be the natural extension of the Scheme macro system to a language with non-S-expression-based syntax.
The big caveat is that sweet.js is super-new. It doesn't even have version numbers yet. So it's more something to keep an eye on than something to use for production code just yet.
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
I'm looking at the possibility of building a system where when a query hits the server, we turn the query into c++ code, compile it as shared object and the run the code.
The time for compilation itself needs to be small for it to be worthwhile. My code can generate the corresponding c++ code but if I have to write it out on disk and then invoke gcc to get a .so file and then run it, it does not seem to be worth it.
Are there ways in which I can get a small snippet of code to compile and be ready as a share object fast (can have a significant start up time before the queries arrive). If such a tool has a permissive license thats a further plus.
Edit: I have a very restrictive query language that the users can use so the security threat is not relevant. My own code translates the query into c++ code. The answer mentioning clang is perfect.
Running Clang in JIT mode should provide the speed you need, and example can be found here, safety on the other hand is something else...
Ch also had a JIT added, and seeing as its an interpreter, it might provided an easier sandboxed/controlled environment.
In addition to Necrolis answer, there's also specialized C++ parser Cling. Might come in handy.
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 11 years ago.
I've read a lot of good things written about design patterns but am yet to actually look at things in detail. To me, design patterns is just a fancy name for data structures and algorithms. Before I invest any time in more reading, I'd like to see some good examples of design patterns working in real life.
What good examples of design patterns can I find in well-known open source projects?
C++ preferred.
Update: I see the close votes and downvotes. These were expected. If there is an alternative post with answers to my question, please lead me to it. At least leave a reason as to why this post doesn't belong here.
It appears you did not invest enough time into design patterns to truly grasp what they are. I encourage you to read more, because design patterns are not a fancy name for data structures and algorithms; there is barely any link between algorithms and design patterns. Design patterns are "recipes" that help you organize classes and their relationships in a way that makes them easier to reuse.
As for examples, no need to look very far: the STL collection iterators are implementations of the iterator pattern.
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 11 years ago.
Do you know a good encryption algorithm that isn't too difficult to implement in c++ (but neither too easy)?
Look at this wonderful comics on AES. It explains the cryptographic background of the algorithm and you can practice by writing a high-performance implementation of one in different languages.
I think RSA is good as well as pretty much straightforward to implement. You might want to look into it. Another one I would be suggesting which is also straightforward is DES.
Rivest, Shamir and Adleman (RSA)
Data Encryption Standard (DES)
If you're just looking for something to code up for the learning experience, I've always liked the Advanced Encryption Standard. The actual standard document at NIST provides all the detail you need to write and test your code.
I like RC5 for its simplicity. Much easier to implement than e.g. AES, and while not quite as strong, it is still a good cypher.