[Home] [Downloads] [Search] [Help/forum]

Gammon Software Solutions forum

See www.mushclient.com/spam for dealing with forum spam. Please read the MUSHclient FAQ!

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  General
. . -> [Subject]  Languages

Home  |  Users  |  Search  |  FAQ
Username:
Register forum user name
Password:
Forgotten password?
(New message)
Subject: Languages
Name:
Your forum user name.
Register forum user name
Password:
Your forum password.
Forgotten password?
Message:
Message to be posted (in English, please).
Forum codes:
Check this if your message uses 'forum codes' or templates (auto-detected for new posts).
Forum codes Templates

Save this message ...


Subject review (reverse sequence)

Pages: 1 2  

Posted by David Haley   USA  (3,881 posts)  [Biography] bio   Moderator
Date Thu 11 Nov 2004 07:45 PM (UTC)  quote  ]
Message
That's exactly the kind of stuff I'm talking about. Sure, it's nice to be able to write "cute" code for "cute code contests" or "hard to read code contests" but beyond that, the ability to write "cute" code is absolutely useless for any kind of production environment. In other words, the ability to not indent is only useful if you're not writing in a production environment where code is shared/maintained/developed/etc.

David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone

http://david.the-haleys.org
[Go to top] top

Posted by Poromenos   Greece  (1,037 posts)  [Biography] bio
Date Thu 11 Nov 2004 07:33 PM (UTC)  quote  ]
Message
You obviously wouldn't do that, since "cute" code might be very cute, but it's impossible to debug. I'm talking about this:


s::l86                      );;;l33=
e.  l87    ();   y(1)       ;}h   l31  ::l35     (v  &r){r   .l41    ((a*)  &q ,x        (q))    ;r.l41    ((a*)     &l33,x
(l33))      ;y    (1)       ;;}l31::  l31   (){  u();;      }h   l31  ::  l67  (l26   a*l36,l26  a*   l37 ){v    r;   l38
l40  ;r.    l39  (l36       ,s        ::   l54    |s       ::    l46  );   l40  .l39   (l37      ,s    :: l72    |s    ::l46
|s::l69       );c(r.        l42         ()||     l40         .l42     ()    )y   (0)      ;l35(  r);  l45  ();l63   (r,l40
                  );
             r.l47
();l40.l47();y(1);}l28 l31::l63(v&e,l38&p){f a n=0;f a z=0;f a k=0;h g=0;f l79 l66=l33;w*b=d;l48(l66){c(!k){e.l41((a*
        )&n,x(n));c(e.l60())l59;k=128;}z=n&k;k>>=1;c(z)b=b->m;t b=b->j;c(b->l34){p.l43((a* )&b->l27,x(b->l27
            ));l66--;b=d;}}}l28 l83(h l80,a*l30[]){l32 l52;l31 l65;c(l80==4){c(l76(l30[1],"\x2d\x63")==
                0&&l52.l49(l30[2]))l52.l58(l30[2],l30[3]);t c(l76(l30[1],"\x2d\x64")==0&&l65.l49(
                                   l30[2]))l65.l67(l30[2],l30[3]);}}

Vidi, Vici, Veni.
http://porocrom.poromenos.org/ Read it!
[Go to top] top

Posted by David Haley   USA  (3,881 posts)  [Biography] bio   Moderator
Date Thu 11 Nov 2004 07:03 PM (UTC)  quote  ]
Message
Trust me, if you ever have to maintain a large codebase that does something moderately useful, the last thing you will want to see is somebody being "cute" if that means you have to spend even just a few more minutes trying to figure out what they were trying to do/say. :-)

David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone

http://david.the-haleys.org
[Go to top] top

Posted by Poromenos   Greece  (1,037 posts)  [Biography] bio
Date Thu 11 Nov 2004 08:12 AM (UTC)  quote  ]
Message
Cuteness isn't very bad as long as it's optional. You still can be cute or indent and be pretty whenever appropriate. And yes, the Obfuscated C Contest has some great programs :P There's one where the entire program is written in preprocessor directives, try to find it. I still don't know how he did that :P

Vidi, Vici, Veni.
http://porocrom.poromenos.org/ Read it!
[Go to top] top

Posted by Jestre   (13 posts)  [Biography] bio
Date Thu 11 Nov 2004 05:56 AM (UTC)  quote  ]
Message
I use Python for scripting. That's what made me use Mushclient.

I must agree with Nick on Lua too. Its really nice. I also like Ruby but that isn't supported.
[Go to top] top

Posted by Nick Gammon   Australia  (18,772 posts)  [Biography] bio   Forum Administrator
Date Thu 11 Nov 2004 01:35 AM (UTC)  quote  ]
Message
Quote:

(I'm telling you, Nick. Don't play with it [Python] or you will never use VB script again.)


Well, I have been playing with Lua recently, and am rather impressed with that. However I haven't found a COM interface for it yet, so if that were to be added to MUSHclient it would be a bigger undertaking.

As for what Poremenos was talking about, there are competitions for who can write the most obscure C, obviously not for any sort of production environment.

See this site: http://www.ioccc.org/

Here is an example:


#include <stdio.h>
int l;int main(int o,char **O,
int I){char c,*D=O[1];if(o>0){
for(l=0;D[l              ];D[l
++]-=10){D   [l++]-=120;D[l]-=
110;while   (!main(0,O,l))D[l]
+=   20;   putchar((D[l]+1032)
/20   )   ;}putchar(10);}else{
c=o+     (D[I]+82)%10-(I>l/2)*
(D[I-l+I]+72)/10-9;D[I]+=I<0?0
:!(o=main(c/10,O,I-1))*((c+999
)%10-(D[I]+92)%10);}return o;}

Operation

Compile normally and run with one argument, an integer with 2n digits.

Program will return the integer part of its square root (n-digits).

For example,

       > gcc -o cheong cheong.c
       > cheong 1234567890
       35136
       > cheong 0200000000000000000000000000
       14142135623730
       >


- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by David Haley   USA  (3,881 posts)  [Biography] bio   Moderator
Date Wed 10 Nov 2004 10:55 PM (UTC)  quote  ]
Message
It's not a C vs. VB argument. What you're talking about - the ASCII art - is "cute". When one writes code for real, one does not write "cute" code. There are tons of reasons, for instance cute code is extremely difficult to maintain. If you were a programmer and turned in code that wasn't indented according to the company style guides, people would be very unhappy with you. If you're a student in a programming class and don't turn in indented code, your grader will be very unhappy with you. If you're just submitting random code to your peers, they'll be unhappy with you if it's not indented.

'Cute' code certainly has its purposes, e.g., well, when you're trying to be cute. :) But when you're trying to write a program that does something useful and that you plan on maintaining, expanding and debugging, 'cute' good is a Very Bad Idea no matter what language it's in.

David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone

http://david.the-haleys.org
[Go to top] top

Posted by Poromenos   Greece  (1,037 posts)  [Biography] bio
Date Wed 10 Nov 2004 10:13 PM (UTC)  quote  ]
Message
Did you forget to add the code tags to that? I don't see the spaces. Also, I agree with the special syntax (I enjoy the looks on people's faces when they see my database program spelled out as large "Poromenos" ASCII art :), but you can't do that in VB either, and if you have a language whose line endings are \n you might as well take it a step further and enforce indentation, since it is very ugly to see unindented code. So, essentially, the argument is a C-style vs VB-style one, and not at all about enforcing indentation.

Vidi, Vici, Veni.
http://porocrom.poromenos.org/ Read it!
[Go to top] top

Posted by Shadowfyr   USA  (1,774 posts)  [Biography] bio
Date Wed 10 Nov 2004 04:29 PM (UTC)  quote  ]

Amended on Wed 10 Nov 2004 11:16 PM (UTC) by Shadowfyr

Message
That entirely depends on the language Poromenos. With VBScript it is a tad easier, but with something more C like, such as the POVRay SDL, you can do it several dozen ways:

sphere{<0,0,0>,1 pigment{color rgbt <1,1,1,1>}}

sphere {<0,0,0>,1
  pigment{
    color rgbt <1,1,1,1>
  }
}

sphere
  {<0,0,0>,1
  pigment
  {
    color rgbt <1,1,1,1>
  }
}

And so on... I generally use two spaces and the second format, but others might use three spaces, tabs, or any number of different points of indention. However, if the SDL 'required' you to indent as part of the language, you wouldn't get 3D signitures or one line shortest code contests entries like:

background{rgb<.5.7,1>}global_settings{radiosity{error_bound.5count 99}ambient_light#local _=function{pattern{agate turbulence 1octaves 9}}0}isosurface{function{(y+.07-_(x+9,y,z)*.115)/20}accuracy 1e-5pigment{rgb 1}}light_source{5<8,4,2>}

You can see the result of this as the second one down at this site:

http://astronomy.swin.edu.au/~pbourke/povray/scc3/final/

Yeah, that is a bit of a silly reason to not use indention, but the point is, the option exists. ;)

main {
__if (Schrodinger_Cat is Alive or version >= "XP"){
____if version = "Vista" then Performance /= Number_of_Cores;
____call Functional_Code();}
__else
____call Crash_Windows();}
[Go to top] top

Posted by Poromenos   Greece  (1,037 posts)  [Biography] bio
Date Wed 10 Nov 2004 08:08 AM (UTC)  quote  ]
Message
That's VB only, in VBScript you get an error if you declare something as a type. By the way, Shadowfyr, I'm curious to see how you indent, could you paste a sample? :p

Vidi, Vici, Veni.
http://porocrom.poromenos.org/ Read it!
[Go to top] top

Posted by Flannel   USA  (1,230 posts)  [Biography] bio
Date Wed 10 Nov 2004 08:08 AM (UTC)  quote  ]
Message
He's talking about VBScript.
And we're talking about ALL the issues with using getvariable and adding stuff to it, and getting funky results.
Or trying and compare things with conditionals.

And yes, VBScript does have casting, it's probably the single most thing we have people 'fix'. Well, that and loops in code.

But thats just it. We have to fix it. Even though you JUST set something as a number, and now youre trying to do something with it, the engine MIGHT think that it's a string and then choose one of a few ways to deal with the 'type mismatch'.

~Flannel

Messiah of Rose
Eternity's Trials.

Clones are people two.
[Go to top] top

Posted by David Haley   USA  (3,881 posts)  [Biography] bio   Moderator
Date Wed 10 Nov 2004 06:55 AM (UTC)  quote  ]
Message
Huh? VB definitely has the ability for a strict type system. 'Dim I as Integer' means that I is an integer, and if you try to assign a string to it, it will either give you a type mismatch or it will try to convert. More likely, a type mismatch. If you declare something as a string, and try to assign an int to it, it'll convert, I think - it definitely will if you use the concatenate operator.

There's no way to 'have your cake and eat it do'. Variants are a very powerful system - Perl uses them as does PHP. If you're communicating arbitrary information across application borders, you need to have *some* way of representing an arbitrary type. C uses void*, which is basically a variant in the sense that you cast it.

But VB most certainly has type casting so that you can convert variants to specific types. I believe the function in vb6 is called CInt to convert to ints, CString to convert to string, etc. The thing is that most of the time these conversions are done implicitly, but you can use them to do explicit conversions.

David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone

http://david.the-haleys.org
[Go to top] top

Posted by Shadowfyr   USA  (1,774 posts)  [Biography] bio
Date Wed 10 Nov 2004 04:32 AM (UTC)  quote  ]
Message
Yes. VB defintely has a major problem with variants. The problem is not so much that it uses them, but that it doesn't allow for more strict definitions. All COM programs use variants to talk to each other. Most languages convert to and from them to the more specific types at either end. MS decided to over simplify matters by making VB 'only' use them and nothing else. Usually this is not a problem, but some times it causes real annoyances.

main {
__if (Schrodinger_Cat is Alive or version >= "XP"){
____if version = "Vista" then Performance /= Number_of_Cores;
____call Functional_Code();}
__else
____call Crash_Windows();}
[Go to top] top

Posted by Flannel   USA  (1,230 posts)  [Biography] bio
Date Wed 10 Nov 2004 03:27 AM (UTC)  quote  ]
Message
Should not.
Can not.
Different things.

Anyway, did we all wake up on the wrong side of the keyboard today or something?

Theyre languages, they each have their strengths and shortcomings, which is why MC has a few for us to choose from.

Lets steer this back to a constructive discussion, to help new people figure out what language they might want to use.

I think the obvious 'newbie' script language is VBscript, since a lot of people grew up with BASIC in some form or another, and even more have been introduced it with a lot of other things.
It's reasonably forgiving with syntax. The only drawback is Variants, and the problems they have.
You can 'easily' incorperate COM objects (since its designed to work well with Windows), and its on most (if not all) windows boxes.

~Flannel

Messiah of Rose
Eternity's Trials.

Clones are people two.
[Go to top] top

Posted by David Haley   USA  (3,881 posts)  [Biography] bio   Moderator
Date Wed 10 Nov 2004 02:54 AM (UTC)  quote  ]
Message
Well, ok, then just say so and don't start blasting it with 'anachronism' etc. :-)

David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone

http://david.the-haleys.org
[Go to top] top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


5,073 views.

This is page 1, subject is 2 pages long: 1 2  [Next page]

[Reply to this subject]  Reply to this subject   [New subject]  Start a new subject   [Refresh] Refresh page

Go to topic:           Search the forum


[Go to top] top

[Home]

Written by Nick Gammon - 5K

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( http://www.gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Internet Contents Rating Association (ICRA) - 2K]    [Web site powered by FutureQuest.Net]