C++ and real languages

This is a discussion on C++ and real languages within the C++ Programming forums, part of the General Programming Boards category; Originally Posted by anon Code: #define weil while ... Actually "weil" means "because", you want "während". I knew someone once, ...

  1. #31
    Technical Lead QuantumPete's Avatar
    Join Date
    Aug 2007
    Location
    London, UK
    Posts
    894
    Quote Originally Posted by anon View Post
    Code:
    #define weil while 
    ...
    Actually "weil" means "because", you want "während".
    I knew someone once, who developed his own preprocessor that would replace his german keywords with the english equivalent. But to be honest those 20 or so frequently-used keywords aren't that hard to learn.

    QuantumPete
    "No-one else has reported this problem, you're either crazy or a liar" - Dogbert Technical Support
    "Have you tried turning it off and on again?" - The IT Crowd

  2. #32
    and the hat of sweating
    Join Date
    Aug 2007
    Location
    Toronto, ON
    Posts
    3,545
    Quote Originally Posted by Stonehambey View Post
    Personally I don't think it makes any difference. The language is C++ (or whatever). Go up to an English speaking person who isn't a programmer and ask them what the 'for' or 'virtual' keywords are for and he wouldn't be able to tell you. The fact that he speaks English doesn't give him any kind of advantage here. Ultimately, learning a few English keywords is trivial when trying to learn how the language works and how to program in general.

    Comments are slightly different, I imagine you would write these with your target audience in mind. If the majority of those can use English, then it's only logical to write your comments in English.
    Oh I would definitely disagree with that.
    Since I'm fluent in English, when I see a function that I've never seen before, I can usually make a pretty accurate guess as to what it does just from the name. If functions looked more like this:
    Code:
    fdfasd( "%d fdsjkjlkjsf %s!", ruios, vbios );
    tjkeio( ruios++ );
    iowmdiflw::fuivmwi fsjis( vbios );
    ...
    Then I'd probably just give up and go work at McDonalds.

  3. #33
    Registered User
    Join Date
    Oct 2001
    Posts
    2,129
    Quote Originally Posted by anon View Post
    And of course, if you really want to (feature on TDWTF yourself), it should be very simple to localize all the keywords (it is undefined behaviour, though):

    Code:
    #define wenn if 
    #define für for
    #define weil while 
    ...
    Probably won't work for standard libraries, but perhaps you could create wrappers for everything?
    Why would it be UB?

  4. #34
    The larch
    Join Date
    May 2006
    Posts
    3,573
    I was probably wrong, I though about redefining keywords (such as #define private public) which this is not.
    I might be wrong.

    Thank you, anon. You sure know how to recognize different types of trees from quite a long way away.
    Quoted more than 1000 times (I hope).

  5. #35
    Registered User
    Join Date
    Jun 2008
    Posts
    266
    cpjust I love your idea. If I could I would totally abolish English and replace it with an improved version of that but of course it's not that simple. I also guess I wasn't the first person to thing of a new language. Just because something has been stadard for some time (english) doesn't mean that it shouldn't be replaced(e.g. Windows).
    Last edited by lruc; 09-04-2008 at 01:13 PM.

  6. #36
    Banned master5001's Avatar
    Join Date
    Aug 2001
    Location
    Visalia, CA, USA
    Posts
    3,685
    I notice that MSVC 2008 accepts pretty much any char in variable names. It is not very portable, but on the other hand, when you are moving an equation directly from paper to code, it can be very clear as to what is going on.

  7. #37
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,173
    AFAIK, the standard only allows english chars a-z and numbers, not any other chars in variables. It's a shame, says I.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.
    For information on how to enable C++11 on your compiler, look here.
    よく聞くがいい!私は天才だからね! ^_^

  8. #38
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,892
    Not quite. The standard guarantees that these work (plus the underscore). However, it says that it is implementation-defined whether, and which, other characters are allowed in variable names.

    Thus, any code that goes outside the guaranteed range is not portable, but not necessarily invalid either.
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

  9. #39
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,173
    Well, that pretty much guarantees that the use of any non-english character and numbers in variable names is undefined, as many other things.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.
    For information on how to enable C++11 on your compiler, look here.
    よく聞くがいい!私は天才だからね! ^_^

  10. #40
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,892
    Not undefined. You either get a compiler error, or it works.
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

  11. #41
    Registered User Stonehambey's Avatar
    Join Date
    Jan 2008
    Location
    Kent, UK
    Posts
    118
    Quote Originally Posted by cpjust View Post
    Oh I would definitely disagree with that.
    Since I'm fluent in English, when I see a function that I've never seen before, I can usually make a pretty accurate guess as to what it does just from the name. If functions looked more like this:
    Code:
    fdfasd( "%d fdsjkjlkjsf %s!", ruios, vbios );
    tjkeio( ruios++ );
    iowmdiflw::fuivmwi fsjis( vbios );
    ...
    Then I'd probably just give up and go work at McDonalds.
    Fair enough, I didn't really consider stuff like the STL and pre-existing functions, in which case a knowledge of English would give you an advatage

  12. #42
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,892
    The standard C library being an exception
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

  13. #43
    Banned master5001's Avatar
    Join Date
    Aug 2001
    Location
    Visalia, CA, USA
    Posts
    3,685
    I prefer to only use irregular characters for personal applications that I only plan on compiling for my benefit. As I mentioned, its nice to have code that looks like:

    Example:
    Code:
    ∆t = +(t[0] - t[1]);
    ө = atan(∆t) + 1;
    But these sorts of lines of code don't translate well across all compilers. However, if you are taking something from paper and applying it directly to your program, this makes life so much cleaner.

Page 3 of 3 FirstFirst 123
Popular pages Recent additions subscribe to a feed

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21