Which is bigger?

Pages: 1234
@Duoas:
I've modified your code so it works.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#include <iostream>
#include <string>
using namespace std;

const char* A = "C++";
const char* B = "Spanish";

int main()
  {
  cout << "Which is bigger, " << A << " or " << B << "?\n";
  cout << A << ( (A < B) ? " > "
               : (A > B) ? " > "
               :           " > " ) << B << endl;
  return 0;
  }
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#include <iostream>
#include <string>
using namespace std;

const char* B = "Spanish";
const char* A = "C++";

int main()
  {
  cout << "Which is bigger, " << A << " or " << B << "?\n";
  cout << A << ( (A < B) ? " < "
               : (A > B) ? " > "
               :           " = " ) << B << endl;
  return 0;
  }

[edit] @wtf [/edit]
Aww, but you took the randomness out of it...
Last edited on
I think we have a winner

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#include <iostream>

using namespace std;

int main()
{
     int spanishSize = sizeof("Spanish");
     int cppSize = sizeof("C++");

     cout<<"The bigger language is: ";

     if(spanishSize > cppSize)
     {
          cout<<"Spanish";
     }
     else if(spanishSize == cppSize)
     {
          cout<<"It's a tie!";
     }
     else
     {
          cout<<"C++";
     }

     cout<<endl;

     return 0;
}
But that seems rather judgemental. Perhaps they should size themselves:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#include <iostream>
#include <string>
using namespace std;

void size( const string& s )
  {
  cout << "Size of " << s << " is " << s.size() << "\n";
  }

int main()
  {
  size( "Spanish" );
  size( "C++" );
  return 0;
  }

:->
You're all doing it wrong. :P

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#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;
    unsigned long long int saize;
public:
    const bool& vari_vocab;
    const std::string& name;
    const std::string& type;
    const unsigned long long int& size;
    Language(std::string name, std::string type, bool variable_vocabulary = false, unsigned long long int 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:
    virtual const char* what() const throw() {
        return "Difficulty comparing a language with a fixed vocabulary and one with a variable vocabulary.";
    }
} just_in_case;

bool operator > (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.


EDIT: -Albatross (dangit)
Last edited on
Objection.

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.
Last edited on
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.

-Albatross
Last edited on
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..

The way I would have done it is closer to
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#include <iostream>

struct NaturalLanguage{};

struct FormalLanguage{};

int main() {
   NaturalLanguage Spanish;
   FormalLanguage Cplusplus;

   std::cout << "Which is bigger, Spanish or C++ ?\n"
      "Spanish" << ( Spanish < Cplusplus ? " < " :
                     Spanish > Cplusplus ? " > " : 
                                           " = " ) << "C++";
}
Which, of course, does not compile.

My point is that of all the problems that arise when you do this comparison, you picked the least significant one..
1. Oh, okay. I understand, and now I myself am not sure. :)

2. It's sort-of hard when the languages (even though they *are* languages) are so different, though... somehow they don't fit too poorly in my mind.

3. Now look, if anybody else pinches my phrase, I'll throw them under a Caml.

-Albatross

Okay, maybe I did pick one of the smaller problems. 'Twas fun, though.
Last edited on
@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.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#include <iostream>
#include <stdexcept>
#include <string>

using namespace std;

class Language {
    Language(); //Implement this and you're an albatross platter.
    bool vocab;
    std::string naem;
    std::string taipe;
    unsigned long long int saize;
public:
    const bool& vari_vocab;
    const std::string& name;
    const std::string& type;
    const unsigned long long int& size;
    Language(std::string name, std::string type, bool variable_vocabulary = false, unsigned long long int 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:
    virtual const char* what() const throw() {exit(22);
        return "Difficulty comparing a language with a fixed vocabulary and one with a variable vocabulary.";
    }
} just_in_case;

bool operator > (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 span ("Spanish","Human",false,100000);
    //There are roughly 100000 words in the Spanish language.
    Language cpp ("C++","Programming",true,1337);
    //I don't quite know how many delcarations there are in the C++ standard library. So I guessed.
    std::cout << "Comparing the sizes of C++ and Spanish: ";
    try {
        std::cout << ( (span > cpp) ? ( (&span > &cpp) ? ("\n" + cpp.name + " > " + span.name) : ("\n" + span.name + " > " + cpp.name ) ) : ("\n" + span.name + " > " + cpp.name ) ) << endl;
    }
    catch (const problem_sir& problem) {
        std::cerr << problem.what() << "\n";
    }
    return 0;
}
That way it'll throw an exception even if both languages have a variable/static lexicon/vocabulary.

...And oh my, what did you do to line 50?

-Albatross
Last edited on
I changed the couting from string literals to string variables in keeping with the fashion of using variable names.
a.vari_vocab && !b.vari_vocab || b.vari_vocab && !a.vari_vocab
is
a.vari_vocab ^ b.vari_vocab
or even simply
a.vari_vocab != b.vari_vocab
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.
Hey, I started with C++ and Spanish. :-P
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.
I did not specify which dialect of spanish so you assume I mean them all?
I did not specify which subset of c++ so you assume I mean only c++?
Pages: 1234