Similarities and differences between Scala macros and C++ templates [closed] - c++

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.

Related

How to make a simple embeddable scripting language for C++? [closed]

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 9 years ago.
I'm building a game engine and can't quite find a scripting language that does what I want, and is embeddable into C++. Therefor, the natural solution is to build my own.
I know the basics about Flex, Bison, peg/leg, and a little about VMs. Can I use this knowledge to build a small scripting language for a game engine? How would I implement an embedded language? I'm not really sure where to start off building such a small language.
A common scripting language for use with C++ is Lua. You can implement it with Luabind or another binding, there are plenty (and there are even tutorials to write your own).
Another option is to use Python with Boost.

Lisp with reader macros that targets the browser? [closed]

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.

What is Bison and why is it useful? [closed]

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.

difference between c++9(g++ 4.3.2) and c++ 4.0.0-8 [closed]

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 12 years ago.
what is the difference between C++(g++ 4.3.2) and C++ 4.0.0-8 and the best compilers for these.
What you are referring to appear to be version numbers of compilers available on your (unnamed) platform.
C++ proper has no such version numbers. Instead, C++ is defined by ISO standards, generally referred to by their year of ratification. So far we have:
C++-98: The initial standard defining the basic language, including templates, the so- called Standard Template Library, iostreams, etc.
C++-2003: The first revision of the standard, making minor corrections and clarifications to C++-98.
C++-TR1(2005): A (non-normative) technical report suggesting several new additions to the standard library in the std::tr1 namespace. Notably includes boost-developed smart pointers, hash tables (std::tr1::unordered_set, etc.) and other capabilities. These additions are expected to be officially incorporated in the upcoming C++-0x standard.
C++-0x (aka C++-2011): A major extension of the language with functional constructs such as lambda and automatic type determination, as well as significant new library content mostly from boost.
The version numbers you mentioned appear to be release numbers from one or two particular compilers. Generally those versions don't map directly to the C++ standards, but instead to differing (hopefully improving) levels of conformance with particular ISO standards and perhaps optimization capabilities.

c++ like languages [closed]

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 12 years ago.
I think C++ is one of the best known programming languages of all time, especially for low level programming stuff, but what other languages are a bit like C++ in means of capabilities?
edit: I want compiled, low level programming languages. Not languages like java.
edit: What I meant with c++ like language is this: A compiled, low level language, suitable for high performance applications, it doesn't have to be oop, but it should have similar capabilities as C++ (e.g. OS programming). I hope this makes my question more clear.
http://en.wikipedia.org/wiki/D_%28programming_language%29