Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Which Scripting Language?

Discussion in 'Editor & General Support' started by J Dog Hombrey, Jun 18, 2008.

  1. J Dog Hombrey

    J Dog Hombrey

    Joined:
    Jun 8, 2008
    Posts:
    8
    As the title of this topic may suggest, I am wondering which of the 3 scripting languages supported by unity I should use.

    I have no experience with any of these languages. I have a tiny bit of experience with c-script (Different to C#) and that's all.

    I'd like to use one that would be easy for someone from a non-programming background to pick up (Provided that doesn't mean less flexibility)

    Look forward to hearing from you all

    Jeff
     
  2. Marc

    Marc

    Joined:
    Oct 4, 2007
    Posts:
    499
    I prefer C# easy to use and IDEs exist that have intellisense like systems. It is an imperiative language just like JavaScript and the version unity is using so not much difference there. I just really dislike dynamic typing as Javascript contains as it can lead to some time spent debugging simple type errors. Other than that think they are fairly equal in learning curve. I have never used Boo so dunno about that.

    Guess one way is to look at some of the tutorials and see which one you find the easiest to pick up.

    Regards,
    Marc
     
  3. Omar Rojo

    Omar Rojo

    Joined:
    Jan 4, 2007
    Posts:
    494
    Use javascript:

    - easy to use
    - faster to code
    - source codes are smaller
    - no geek-language-knowledge required
    - documentation almost complete with js examples
    - simple to understand
    - automagically helps you with stuff
    - almost everybody here knows js so they can help
     
  4. StarManta

    StarManta

    Joined:
    Oct 23, 2006
    Posts:
    8,773
    Each language has its advantages. The biggest difference is this: Javascript makes it easier to write code, but much easier to write slower code.
     
  5. Dreamora

    Dreamora

    Joined:
    Apr 5, 2008
    Posts:
    26,601
    given you have C script experience, JavaScript is most likely the simplest to go as they are familiar. Unitys Javascript isn't real javascript. Only a syntax that looks alike. Its something between JavaScript, higher capable C-Script and who knows what else
     
  6. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    Have to disagree with the dynamic typing/slower code thing with Javascript. Type inference takes care of most of the dynamic typing. You can manually statically type everything if you want to be 100% sure, or you can just turn off dynamic typing entirely.

    --Eric
     
  7. HJPuhlmann

    HJPuhlmann

    Joined:
    Oct 18, 2007
    Posts:
    47
    Use c# and you get the world of .net 2.0 .....
     
  8. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    You also get that in Javascript and Boo. It's a Unity thing, not a language-specific thing.

    --Eric
     
  9. bronxbomber92

    bronxbomber92

    Joined:
    Nov 11, 2006
    Posts:
    888
    More specifically, a Mono thing :D

    But yeah, C# is probably the "hardest" to pick up of the three (but really, it's not bad). JS seems to be the forum favorite and it's rather easy to get into. I really like Boo as a language, it's great. Syntax like Python (no yucky braces to deal with, uses indentation to signify scope instead) and has some more of the advance language features C# does and Js doesn't. Only downfall of using Boo in my opinion is the lack of popularity among forum members and UT staff (seems UT likes to use JS and C# for everything).
     
  10. Dreamora

    Dreamora

    Joined:
    Apr 5, 2008
    Posts:
    26,601
    If Boos popularity has to do with its python similarity perhaps? :)
    To me its simpler to program in Ruby and LUA than in Python, I just never got warm with that language. Even Perl was better
     
  11. Marc

    Marc

    Joined:
    Oct 4, 2007
    Posts:
    499
    That kinda invalidates the point of dynamic typing... They knew it could cause problems so the made an option to disable it :roll:
     
  12. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    No, not really. It's per-script, so if you have a particular script that you want to make sure goes as fast as possible and doesn't use dynamic typing under any circumstances, then you can disable it by using "#pragma strict". Otherwise you leave it on for those occasions when dynamic typing makes things easier to program and it's not in a speed-critical script.

    --Eric
     
  13. Marc

    Marc

    Joined:
    Oct 4, 2007
    Posts:
    499
    Or just devlop a good coding style in C# and not worry about either. :p
     
  14. podperson

    podperson

    Joined:
    Jun 6, 2006
    Posts:
    1,371
    If you want to use C# IDEs, then use C#.

    JavaScript (in Unity) basically means less typing. In C# everything you do requires more typing.

    e.g.

    "using UnityEngine;"

    don't need to type this in JavaScript, it's understood.

    "public class ActivateTrigger : MonoBehaviour {"

    You name your file "ActivateTrigger.js" and this is understood (and you still need to name the file "ActivateTrigger.cs" in C#.

    Basically C# is full of useless typing that conveys ZERO INFORMATION to the compiler.

    Your class vars in JavaScript are public by default ("var fred = 3" is public) whereas you'll need to type "public int fred = 3" in C#. Note that fred is an int in JavaScript whether you type "var fred = 3" or "var fred : int = 3" Again, less typing in JavaScript).

    Oh in JavaScript you'll need to type "function" whereas in C# you might only have to type "void" or something ... so there's a possible win for C#.

    On the other hand, a major advantage of C# is that the capitalization convention of C# matches that of Unity and Mono (C# is a CamelCase language whereas JavaScript is a camelCase language). Mono feels like a natural extension of C# (because it is) whereas it's slightly alien to JavaScript.

    If you've read this far you'll have noticed that there's very little difference between the two and furthermore that's pretty much all you need to know to convert C# code to JavaScript and vice versa.
     
  15. jashan

    jashan

    Joined:
    Mar 9, 2007
    Posts:
    3,307
    ... unless you do use that C# IDE, in which case C# means significantly less typing because the IDE types almost everything for you. I might be wrong, of course: Not sure if there's something like Visual Studio for JavaScript...

    ;-)

    As an example, I just typed:

    p TAB v TAB MyNewMethod(st TAB myParam) {
    Do DOWN TAB(th TAB .g TAB);
    }

    and Visual Studio created for me:

    Code (csharp):
    1.  
    2.     public void MyNewMethod(string myParam) {
    3.         DontDestroyOnLoad(this.gameObject);
    4.     }
    5.  
    (perfectly formatted, of course - without me even thinking about how this should be formatted ;-) )

    Of course, if you use Unitron, C# is a real pain (but so is any other language, to me, including JavaScript).
     
  16. podperson

    podperson

    Joined:
    Jun 6, 2006
    Posts:
    1,371
    Less typing but ignoring typing, less meaningless detritus.

    I agree though that autocompletion for JavaScript would be nice. (Coding JavaScript in TextMate seems pretty slick, although it's not Intellisense.)

    In C# you're typing more stuff (or having it typed for you) that doesn't actually add any logic to the program. If you take one script and another script and look at all the code they have 100% in common that contributes nothing to make one script different from another script -- that's pollution.
     
  17. bronxbomber92

    bronxbomber92

    Joined:
    Nov 11, 2006
    Posts:
    888
    It may be pollution in perspective of compiling it, but often times it may the aid clarity to the code of program. I usually find C# easier to read than Javascript :)
     
  18. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    Other way around here...I find wading through the unnecessary repetition tedious and annoying, and it makes it harder for me to see at a glance what's actually happening.

    --Eric
     
  19. jeremyace

    jeremyace

    Joined:
    Oct 12, 2005
    Posts:
    1,661
    In the end, it comes down to what you work best with, how you think, how you work, and what you are actually doing.

    I love C#, and really don't like JS for several reasons, but that's just because of how I work and what I am doing.

    I do recommend, however, that people learning programming learn C# first, then move to JS if they prefer it. The reason for that, is C# forces you to design your code very well from the start and understand what's going on behind the scenes, while JS is more forgiving in that area.

    Once you get a good grasp on how things work, if you still prefer JS (or Boo) then by all means go for it.

    Just my suggestion, and like a certain programming language, it won't apply to everyone either. ;-)

    Try em all, see what you like best.

    -Jeremy
     
  20. Thomas-Lund

    Thomas-Lund

    Joined:
    Jan 18, 2008
    Posts:
    465
    Being a java developer, I started out with JS just to keep the minimal resemblance. Quickly we all went over to C# and (for me) Visual C# Express (free).

    Moving an entire game over from JS to C# didnt take more than a few days, and cant really say that I want to look back.

    Only issue that you will run in to is documentation being JS, so you constantly have to "translate".
     
  21. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    C# is a lot more like Java than Javascript is, though...should have gone with C# to begin with. ;)

    --Eric
     
  22. podperson

    podperson

    Joined:
    Jun 6, 2006
    Posts:
    1,371
    I don't see how being forced to write more stuff results in better design.

    In C# it takes more typing to declare stuff and more reading to see how stuff has been declared ... the stuff isn't more thoroughly declared, just more verbosely declared. It's like arguing that "this_is_a_public_method" is somehow more informative than "public". (OK, it probably is. Once.)

    There's absolutely nothing preventing you from writing code that's EXACTLY the same in terms of disorganization or whatever in C# as in JavaScript.

    I will agree with one thing -- Mono is more of a pain to use from JavaScript than C#. This isn't a problem with JavaScript, but it is a problem with USING JavaScript.

    (A lot of prejudice against JavaScript should actually be directed at web browsers and Internet Explorer in particular, specifically inconsistent implementations of the DOM. JavaScript is of itself a very elegant language design. I speak here as a long-time JavaScript hater. It's much like hating Java because of the AWT.)
     
  23. jashan

    jashan

    Joined:
    Mar 9, 2007
    Posts:
    3,307
    Haha - I like those discussions. It's fun, isn't it?

    In the end, it's really just a matter of personal preference. Just like some people think, opening braces need to be at the end of the line and think this is much more readable, and others think that opening braces MUST be at the start of the next line, and will tell you that this is much easier to read.

    Hm? ;-)

    Very simply because the compiler can tell you "you know what, bro, turning this object of type UltraCoolHyperObject into a float may seem cool to you, but it might simply not be the greatest idea to do that. If you are really sure you totally have to do that, maybe at least do me the favor of offering me a proper typecast, ok?"

    And, when then, some day later, you or somebody else is reading that code, you'll immediately see the conversion:

    Code (csharp):
    1. float myNumber = (float) objOfUltraCoolHyperType;
    In JS, as most people would use it, this will be:

    Code (csharp):
    1. var myNumber = objOfUltra...;
    The compiler will most likely not care, but you might have a serious issue during runtime (and runtime-errors are always much harder to fix than compilation errors).

    And: Wow, of what type was objOfUltra... now again? Hm... don't remember... but since the compiler doesn't care, why should I? ;-)

    In the end, being a fan of C# (and other primarily strongly typed languages), I'd say those languages are for people who want to avoid keeping too much stuff in their minds and instead have it all "on paper". This leaves room in my mind for other stuff I consider more important ;-)

    The problem I mainly see with JavaScript is that quite frequently, you *think* you understand the code - but in reality, you simply don't (talking about myself here, of course ;-) ). And the worst part about this: Once this happens (and you realize it), there's no one there to help you...

    That was my very first experience with programming in Unity (JavaScript, because most examples are JavaScript): I read the examples, and thought "ha, cool, easy". Then I changed something, and it was broken beyond repair. There's so much stuff implicit in the code that if you don't really know the engine and the API by heart, I don't think you can claim you really understand that stuff.

    I started being able to do stuff "on my own" once I had everything converted to C# - because then, I didn't have to *know*, I could simply read instead.


    Of course, there's some rather advanced things for which dynamic typing is really useful (which is why it was introduced for C# 3.0), but I think those are somewhat rare cases - and personally, I avoid those because it consumes more of my brain-capacity understanding those hyper-advanced concepts than simply typing out something real quick that does the same and that I'll still understand two years from now ;-)

    Sunny regards,
    Jashan

    PS: It would be interesting to compare the length of postings of people who prefer C# to the length of postings of people who prefer JavaScript. Some like it verbose, others don't ;-) ...
     
    Novack likes this.
  24. podperson

    podperson

    Joined:
    Jun 6, 2006
    Posts:
    1,371
    It will care in both JavaScript and C#. You're comparing C# to non-compiled web JavaScript. This is a "Straw Man" argument -- C# is better than something that doesn't exist.

    If JavaScript in Unity were "real" web JavaScript your complaints would be valid (although not necessarily compelling -- real JavaScript has many virtues as a result of being highly dynamic ... but it's a different productivity / performance tradeoff than Unity JavaScript).

    Final Clarification:

    In Unity JavaScript:

    var foo = SomethingExoticallyTyped; // foo is now a TYPED variable of type SomethingExoticallyTyped; foo = 17; will now generate a compile-time error.

    I would tend to write:

    var foo : SomeExoticType = SomethingExoticallyTyped // if the type of the RHS is not clear, but it's OPTIONAL.
     
  25. Joe ByDesign

    Joe ByDesign

    Joined:
    Oct 13, 2005
    Posts:
    841
    Just chiming in here not having followed this (old) and seemingly never ending topic...

    The short is (and has been repeated before); do what feels best to you.

    As for "either or" discussion, well some of us have taken to using "typed Javascript" as a convenient (though obviously JS biased) middle ground.

    Makes for very readable code with less hoop jumping, if you're adverse to that (at the cost of some language features).

    "Most of the flavour with half the fat?" :)
     
  26. Adrian

    Adrian

    Joined:
    Apr 5, 2008
    Posts:
    1,061
    Hey, I just want to add my saddening that Boo hasn't been mentioned mutch in this thread. :cry:

    For me, it combines some advanced features that C# offers with a simpler and less verbose syntax. And hey, if I already sincerely indent why shouldn't that at least benefit the compiler? :p

    Unity's languages are very similar and if you don't use some advanced OOP (e.g. shadowing) then you can pretty much interchange them and I mentally do that often with relative ease.
     
  27. Randy-Edmonds

    Randy-Edmonds

    Joined:
    Oct 10, 2005
    Posts:
    1,122
    Curious.. do you use MonoDevelop with the Boo addin?
     
  28. jashan

    jashan

    Joined:
    Mar 9, 2007
    Posts:
    3,307
    Are you sure you knew what I was talking about? Have a look at this JavaScript file. It's a valid "Unity JavaScript" file that compiles without a problem. But try executing it inside of Unity and you'll see what ugly runtime errors are (simply attach it to some random game object):

    Code (csharp):
    1.  
    2. var someConditional = true;
    3.  
    4. var whateverType;
    5.  
    6. iLikeTypos = 5;
    7.  
    8. iLikeTipos = 6;
    9.  
    10. whateverType = gameObject;
    11.  
    12. if (someConditional  iLikeTypos == 5) {
    13.     whateverType = 5;
    14. }
    15.  
    16. whateverType.transform.position.y = 3;
    17.  
    Now try to create the same nonsense in C# ;-)

    Obviously, one *can* write it in JavaScript in other ways that are more safe (as your example indicates) - but then it's also more verbose... I do enjoy freedom of expression, but you'd have to give me an example of what the freedom I had just used to create this nonsense script is useful for. Possibilities that have no use just create clutter and confusion ;-)
     
    Novack likes this.
  29. rapidrunner

    rapidrunner

    Joined:
    Jun 11, 2008
    Posts:
    944
    Seems that everyone here as good points; but i think that there are different way to see the problem, since the experience of any of us is different :)

    you know java or javascript? stick with java!

    you know C++? go for C# (i love to type more because i know what i am doing, and the security to give a void to a function, compared to returning a value is sometimes very useful when you ahve thousands of lines of code....this works for me in C++ but i never tried C#, so i assume that is the same)

    if you know python go for boo

    if you do not know anything; learn the basics of OOP and go for JS, since is easier to learn for who is new to programming (this doesn't mean less powerful, since AFAIK all the scripted languages are at the same speed level in Unity...please correct me if i am wrong)

    I would not imagine someone starting from 0 and learning C# for Unity scripting, unless he want to use something useful and pursue a career as programmer in C# or C++ development

    The other 2 scripting language are useless if you don't work with Unity; since JS is not real Js and boo is a dialect of python.

    just my 2 cents :)
     
  30. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    If you know Java, you should use C#. Javascript (both real Javascript and Unityscript) is not much like Java. C# is like Java though.

    --Eric
     
  31. Der Dude

    Der Dude

    Joined:
    Aug 7, 2006
    Posts:
    213
    I believe C# is more powerfull soley for the fact that you can make use Object Oriented Programming. Inherting from base classes, overwriting methods and implementing Interfaces can make your life _so_ much easier.
    This is not performance-wise but design-wise.

    OOP > all!
     
  32. MatthewW

    MatthewW

    Joined:
    Nov 30, 2006
    Posts:
    1,356
    You can use interfaces and inheritance with Unity's JavaScript. Unfortunately, method overriding doesn't work with ad-hoc polymorphism, which defeats much of the point...

    For the record, we use JavaScript and #pragma strict at Flashbang. Whichever works best for you is the right answer in any language debate, of course; the advice in this thread is solid.
     
  33. Thomas-Lund

    Thomas-Lund

    Joined:
    Jan 18, 2008
    Posts:
    465
    Very true.

    Also the ability to have propper Collections and such is a big plus, together with the more powerful features of a language like Java/C# (OOP wise)
     
  34. Adrian

    Adrian

    Joined:
    Apr 5, 2008
    Posts:
    1,061
    Your example is not very fair. JS tries to infer the type of variable and then statically types it. Only if you don't give any hint what type a variable should be it switches to dynamic typing.

    I.e. if you do:
    Code (csharp):
    1. var whateverType = gameObject;
    the compiler infers the type and that line is identical to:
    Code (csharp):
    1. var whateverType :GameObject = gameObject;
    Changing your example like above will then throw a compile error that int cannot be converted to GameObject.

    So in JS and Boo, if it's obvious what type a variable is at the time of it's creation (either by assigning it a value or by declaring the type), then it's statically typed just as in C#. This is also true for method return types and even works for arrays:
    Code (csharp):
    1. // This is inferred as String[]
    2. var myStringArray = ["one","two","three"];
    Currently I'm using Komodo Edit and the Python syntax highlighting for Boo. Highlighting works well but autocompletion does not.
     
  35. rapidrunner

    rapidrunner

    Joined:
    Jun 11, 2008
    Posts:
    944
    Agree with you Eric; the statement would be "if you know javascript stick with JS in Unity" .

    Der dude: the 3 script languages are compiled by the engine, that's why no matter what you use, it will work in the same way.
    Design-wise, you would not use Unity but pure C++, or C# with XNA :) I am for the well written and organized code, but in this case you are working on a framework that does a lot for you, so the design part is only related to implement your features and try to not write no-sense code that simply burn cycles.

    I agree that anyone can choose his language, but giving multiple choice would mean to support 3 different categories of users, and seems that this does not happen, so if you learn JS you will have a lot of material to work on, compared to Boo and C#
     
  36. jashan

    jashan

    Joined:
    Mar 9, 2007
    Posts:
    3,307
    I can only speak about C#, and there it's not a big issue. You have to add the stuff that's missing in JS, twist a little bit with the syntax, and there you go. So I don't mind that the examples and so on are mostly in JS because by converting them to C#, I can assure I understand what they do (which is better than just reading).

    It's a bit difficult as a beginner, as you then usually don't know what the relevant classes are (because as a Unity beginner, you naturally don't know the Unity API very well ;-) ) - but on the other hand, once you've been through that, you should have at least a good basic understanding...

    Sunny regards,
    Jashan
     
  37. Der Dude

    Der Dude

    Joined:
    Aug 7, 2006
    Posts:
    213
    Then just out of curiosity I would like to know, how I can create my own abstract type with overrideable methods and implement a self-made interface using UnityScript.

    I guess it depends on the complexity of your game logic. If you do the bread and butter kind of things, then surely there is no need for the higher OOP stuff.
    I just want to give an example where inheritance and the features that come with it, make your life easier.

    We have one script in our shooter that handles the calculation and hit detection of the shots being fired in the scene. In our game, there are different kinds of shots. Ballistic-, Pulse- and Ray- Shots are just a few of them.

    Now because they all inherit from the base class Shot which declares an abstract method DoCalcStep() (which they of course override), we do not have to keep seperate lists for all of the different types of shots.
    Additionally, functionality they all share (e.g. handling of a hit) is only written once and there is only one place to debug.
     
  38. rapidrunner

    rapidrunner

    Joined:
    Jun 11, 2008
    Posts:
    944
    Der Dude:


    I am sure that anyone can reply to this question better than me; I started to use the engine not too long ago, and the only noticeable difference that i have seen (from tiutorials and examples) is the way to do the things in the 3 srcripting language.

    Well, your concept come from OOP programming, nothing new...do one object and create other objects that inherit the parent class methods, and add what you need (or override at will); and you can do the same thing in Unity with any script; the only difference is the way that you do things.

    I am having not too many problems with C#, but i realized that multiple inheritance is not supported in JS (correct me if i am wrong); but there is no need to do MI unless you wanna program like a book :) all the things learned at the college are basically useless at work place; if i would have read the book at home would be the same thing, since at work we do so many dirty things while coding that is hard to follow any kind of common rule (except code formatting); and even if is bad, sadly that is the difference between when you develop with your friend (or a small team) and when you work in a corporate :)

    OOP is a concept, is not tied to a language, and even Visual Basic 6 can use OOP concepts even if is not a OOP language (by definition); so the choice is up to you...i choose C# and JS as alternative ^_^
     
  39. Der Dude

    Der Dude

    Joined:
    Aug 7, 2006
    Posts:
    213
    I never claimed that it was. Seeing as most (?) people in this forum learned coding through Unity, I thought an example would make my point clearer than talking in abstract terms.

    Agreed.
    Since I don't know how to do basic OOP stuff with UnityScript, I'll do my textbook-code in C# for the time being ;)
     
  40. Marc

    Marc

    Joined:
    Oct 4, 2007
    Posts:
    499
    In the true sense of the word multiple inheritance it is not supported in C# either, there are workarounds for it though, but the approach in C#, or philosophy if you will is more like Java, that a single rooted inheritance hierachy is the best way to do things and if you want to do something like multiple inheritance you should do interfaces instead.

    Edit: Heh its even in MSDN faq: http://blogs.msdn.com/csharpfaq/archive/2004/03/07/85562.aspx

    Regards,
    Marc
     
  41. rapidrunner

    rapidrunner

    Joined:
    Jun 11, 2008
    Posts:
    944
    Good to know Marc! thanks!
     
  42. Marc

    Marc

    Joined:
    Oct 4, 2007
    Posts:
    499
    Oh just to add another comment that might be usefull when deciding what langauge to use.

    Build into C# are events and delegates. Which basically gives you an event system that is simply to use. Don't think JavaScript have that build in. You can roll your own like it has been done here on the forum.

    Regards,
    Marc
     
  43. imparare

    imparare

    Joined:
    Jun 24, 2008
    Posts:
    369
    New to Unity this week and from a Windows background. Started my scripting all in C# and working thru the tutes and user guide means converting all the time. This is a positive as I can't just follow the stuff blindly, I have to think about it a lot more which for me means a better learning experience.

    Plus Marc is rapidly becoming my personal tutor - apologies Marc (I will try and post when your not around - many thanks so far though).
     
  44. Adrian

    Adrian

    Joined:
    Apr 5, 2008
    Posts:
    1,061
    JS does have limited support for delegates. You can use them with dynamic typing but I haven't found a way to declare them. Haven't tried the event system but that might work as well.

    Boo supports both delegates (callables) and events.
     
  45. podperson

    podperson

    Joined:
    Jun 6, 2006
    Posts:
    1,371
    JavaScript proper allows inheritance and overriding via _prototype as well as specializing individual objects (a given object can be given a specific copy of a method unique to that object). You can also write functions to specialize objects, which is -- I guess -- a bit like Lisp macros (I don't understand Lisp macros). Both options give you the good parts of multiple inheritance without the (many) bad parts.

    I don't know exactly how inheritance works in Unity JavaScript, but I've seen examples so I expect it does work.

    However, the root assumption here is that you need to use inheritance *all the time* or you're not doing OOP. There's a hilarious snippet in Aaron Hillgrass's Objective-C book about meeting a guy from Taligent at a trade fair and asking him to build a simple application using Taligent (regarded at the time as having the bee's knees of C++ OO libraries). He said when he left the guy was still implementing subclasses. The same app can be written in Interface Builder with no code at all (using Objective-C's dynamic features). In Objective-C (and, generally, JavaScript) you use existing classes, in C++ you subclass, and subclass, and subclass.

    It's like C++ people raving about "design patterns". Most (well, many) "design patterns" aren't necessary in languages that are more modern than C++.
     
  46. lankoski

    lankoski

    Joined:
    Apr 20, 2008
    Posts:
    148
    Well, you do not need design pattern with any language. However, they can be useful if you do not want to invent a wheel again.

    Software design patterns are only a way to present a problem and a solution to the problem.
     
  47. podperson

    podperson

    Joined:
    Jun 6, 2006
    Posts:
    1,371
    Of course, but many (C++) design patterns are simply workarounds for problems in C++.

    Here's a nice rant that includes discussion of this topic:
    http://steve.yegge.googlepages.com/singleton-considered-stupid

    And another:
    http://yosefk.com/c++fqa/index.html
     
  48. Dreamora

    Dreamora

    Joined:
    Apr 5, 2008
    Posts:
    26,601
    Well, you do.
    No design pattern = most of .NET not existant as the whole UI part is built around the observer pattern for example. (not doing it is plain stupid actually and you would end on stone age stuff ie event switching like in C-stoneage-stoneage)

    Most of the todays modern, stable and "future proof" languages base large parts of their common design around patterns (and design paradigms), some more obvious, some less obvious.

    Thats what clearly makes the difference between them and C++, which is based around "hack it as you like, you can make the code correct, readable and well structured if you want but there is nothing that even forces a base of any of those in your code"
     
  49. lankoski

    lankoski

    Joined:
    Apr 20, 2008
    Posts:
    148
    Now I do not follow.

    A pattern, I think, is a general, abstract solution to certain kind of a problem; a pattern is not implemented code. From this point of view, my above claim should solid :?
     
  50. Dreamora

    Dreamora

    Joined:
    Apr 5, 2008
    Posts:
    26,601
    What I meant is .NETs own core design in many aspects bases on well known proofen patterns and modern OO paradigms.

    To me a pattern is only a pattern if it has an abstract solution and works in reality. "Theoretical" patterns don't qualify as patterns to me, as PCs are not interested in theory but in practical solutions, but you are naturally right, that the patterns are not the implementation but the problem - solution scenario.