#include <iostream>
#include <string>
usingnamespace std;
constchar* A = "C++";
constchar* B = "Spanish";
int main()
{
cout << "Which is bigger, " << A << " or " << B << "?\n";
cout << A << ( (A < B) ? " > "
: (A > B) ? " > "
: " > " ) << B << endl;
return 0;
}
#include <iostream>
#include <string>
usingnamespace std;
constchar* B = "Spanish";
constchar* A = "C++";
int main()
{
cout << "Which is bigger, " << A << " or " << B << "?\n";
cout << A << ( (A < B) ? " < "
: (A > B) ? " > "
: " = " ) << B << endl;
return 0;
}
#include <iostream>
#include <stdexcept>
#include <string>
class Language {
Language(); //Implement this and you're an albatross platter.
bool vocab;
std::string naem;
std::string taipe;
unsignedlonglongint saize;
public:
constbool& vari_vocab;
const std::string& name;
const std::string& type;
constunsignedlonglongint& size;
Language(std::string name, std::string type, bool variable_vocabulary = false, unsignedlonglongint size = 0)
:
size(saize), type(taipe), name(naem), vari_vocab(vocab) {
vocab = variable_vocabulary;
taipe = type;
naem = name;
saize = size;
}
};
class problem_sir : std::exception {
public:
virtualconstchar* what() constthrow() {
return"Difficulty comparing a language with a fixed vocabulary and one with a variable vocabulary.";
}
} just_in_case;
booloperator > (Language a, Language b) {
if (a.vari_vocab && !b.vari_vocab || b.vari_vocab && !a.vari_vocab) {
throw just_in_case;
}
return a.size > b.size;
}
int main(int argc, char** argv) {
Language cpp ("C++","Programming",true,1337);
//I don't quite know how many delcarations there are in the C++ standard library. So I guessed.
Language span ("Spanish","Human",false,100000);
//There are roughly 100000 words in the Spanish language.
std::cout << "Comparing the sizes of C++ and Spanish: ";
try {
std::cout << (cpp > span ? "C++ is bigger!\n": "Spanish is bigger!\n");
}
catch (const problem_sir& problem) {
std::cerr << problem.what() << "\n";
}
return 0;
}
Comparing the sizes of C++ and Spanish: Difficulty comparing a language with a fixed vocabulary and one with a variable vocabulary.
1. Vocabulary is not a property of a language, but of someone who speaks that language (so says wikipedia)
2. You are comparing words with keywords. They are not the same. In c++ a word should be closer to http://en.wikipedia.org/wiki/Word_(mathematics)#Formal_theory (edit: though this has it's problems too).
3. At any time a natural language has a defined and countable set of valid words, which is not much less fixed than that of c++ (which is going to change soon).
I like your idea, but the implementation isn't great.
1. How else would you compare the sizes of a language?
2. I am *not* comparing words and keywords. I wrote in the comments that I didn't know how many declarations there were in the C++ standard library. Declarations, not keywords (we're talking about C++ keywords, right?).
3. I actually thought about this and I was not quite sure what to do, because it's vastly easier (IMO) to add "words" to a programming language than to a spoken language that can be readily understood by the reader. Finally, I decided on simplification.
Though I think its probably fair to say that both c++ and spanish have a variable sized vocabulary. Both have ways to introduce new words, although in spanish (or any language) words are only officially recognized as belonging to the standard dialect by convention of continued concurment of 1 or more subsets of the population that through time slowly begin to become incorporated into the spoken languages's vocabulary of the population at large, or by usage by a respected opinion head of a foreign word, or an irroneously used, or sometimes fabricated word or group of words forming a phrase that by virtue of the manner of conveyance, including but not limited to tone of voice, seriousness (or in certain situations lack thereof), and media by which the masses become aquainted to new such word or group of words forming a phrase, that owing to such usage speakers, and or readers, writers and listeners of the language are duped into adapting their own vocabulary to include the new word or phrase, whereas in spanish new words, and symbols are usually approved by committe, or as noted earlier, by #defining any arbitrary number of words that any individual so chooses.
So in a sense, to compare the size of c++ and spanish becomes equivalent to the philosophical/mathematical question relating to comparing infinite sequences where both sequences progress towards infinity, although 1 significantly faster than the other.
Although it still could be argued that #defining a new key word would only affect a 'dialect' of c++, not the language itself. However this still does not change the fact that the c++ standards committe has the power to create new key words themselves, it just means that c++ is progressing more slowly than spanish, towards infinity that is.
So both are infinitely big, but progressing at different speeds. The question remains, how long will it take spanish to catch up?
But C++ is not potentially infinitely big, since it will only name a small subset of all things that exist; specifically, it may only name things that exist and pertain to the software development process.
A natural language on the other hand should ideally name all things that exist, and will also name some things that don't exist.
1. I was merely complaining about the word you used. Maybe "lexicon" would have been a better choice. Though what wikipedia says about both seems inconsistent, so I really don't know ( if there is anything wrong with "vocabulary" )..
2. Terribly sorry about that. I didn't notice and just assumed keywords. Happens to me all the time..
Though that doesn't change my position that you are using two different meanings of "word".
3. You're no fun any more..
@Albatross
Don't worry. I know I for one enjoyed your code at least. I did find the boolean expression on line 34 a bit confusing though without nested parenthesis, so I changed it.
In trying to establish which is bigger between C++ and Spanish, you're all using C++.
Is C++ trustworthy and impartial? I don't know but at least it's honest enough not to compute an unanimously accepted result.
I can say confidently that Spanish is a larger language. Even though C++ is huge, you did not distinguish between Castilian, South-American or Central-American\Caribbian Spanish so I can only assume that you mean to include all of these dialects at once. Where as you did not say C\C++ or even the C family so you are comparing an entire language against a specific dialect, and even with all of the API's in C++ Spanish wins when comparing size.