SitePoint Sponsor

User Tag List

Page 2 of 2 FirstFirst 12
Results 26 to 38 of 38
  1. #26
    SitePoint Enthusiast
    Join Date
    Apr 2007
    Posts
    70
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Michael Morris View Post
    I wouldn't recommend Javascript as a first language because of it uses prototypical inheritance instead of classical inheritance. That is, the way object oriented programming works in javascript can throw you for a real curve ball. Scope is also very tricky in all dialects of EMCA. While these are advanced issues, they are front and center in javascript whereas in PHP they are less pronounced - and PHP uses classical inheritance like most languages.

    Another reason not to take on the javascript bear first is how intimately tied it is to the DOM model. You can't readily learn javascript until you have a concrete grasp of HTML and CSS.

    That said, when the time comes to pick it up it won't be too hard. As with PHP it's a member of the Algol family of languages (C and it's variants and Java also fall in this family). This means the basic syntax of code and control structures remains unchanged between languages for the most part (PHP being the odd man out by using the '\', '->' and '::' operators where other languages use the '.' operator.
    Javascript's scoping issues are not that different in declaration visually than that of python which is for all intents and purposes one of the most popular programming languages in the world. In fact it is pretty easy to adopt conventions to avoid scoping issues that make it easy to go from one language to another. Here is an example of something you might see a java dev or python dev write in javascript.

    Code JavaScript:
    var object = {
     
    aVariable: "",
    aHiddenVariable: "",
     
    init: function() {
        var self = this;
     
        self.aVariable = self.doSomething('idTag');
        self.aHiddenVariable = self.doSomething(self, another-'idTag');
    },
     
    doSomthing: function(self, id) {
        id = self.doSomePrivateThing(id);
     
        return document.getElementByID(id);
    },
     
    doSomePrivateThing: function(something) {
        return "prefixSomeText" + something;
    },
     
    doAnotherThingMoreCheeky: function(elementID, hiddenNode, normalNode) {
        var tag = "#" + elementID;
     
        $(tag).bind('keyup', function() {
        if(typeof hiddenNode != "null") {
            hiddenNode.value = this.value;
        }
        normalNode.value = this.value;
     
        return;
    });
    }
     
    }
     
    object.init();
    object.doAnotherThingMoreCheeky('idTag', object.aHiddenVariable, object.aVariable);

    That isn't too convoluted at all. Defining self as this in the init and passing it arround makes it easy not to get into conflicts inside jquery functions where this is the dom element you are working on.

    It doesn't look too, too different than python.

    Code Python:
    class object:
        __init__(self):
            self.aVariable = ""
            self.aHiddenVariable = ""
     
        def doSomething(self, something):
            return self.aMethodCall(something)    
     
        def doSomethingMoreCheeky(self, somethingA, somethingB):
            if(self.aVariable != null):
                aHiddenVariable = somethingA
            aVariable = somethingB
            return
     
        def aMethodCall(self, something):
            return //do some logic here

    The syntax of C vs python whitespace indentation are different but passing self around (basically catching the instance) isn't that dirty. I think people complaining in the javascript world might just think Java, .NET and PHP simply are 'right' and 'clean' while javascript and python are 'dirty'.

    Of course python passes the instance to a method and you need to recieve it. You could easily use "this" or "that" or "lalalacandyland" to assign the instance a name. Javascript's scoping issues are quite different and you could easily just use the native "this" or even use the object name since it is at a global as soon as you assign.

    But that is neither here nor there. The fact remains that looking at the two's sources, following established conventions, will not be too far off in regards to scoping issues at first glance. Some people only do self when they need to scope and that is ok too... javascript has implicit fascets but another person coming in behind you might not be a) a js developer and b) get cought up in this.hell

    But meh... it doesn't stop you from learning programming. You just don't learn very many design patterns in javascript or ECMAScript which is hopefully the goal of any programmer because it allows you to interact with other developers and make reusable, extensible components.

  2. #27
    SitePoint Member rhart's Avatar
    Join Date
    Apr 2011
    Location
    Ohio
    Posts
    4
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I would suggest you start with C++. That is what I started with and it really gives you a good foundation for learning any other language. Once you have the fundamentals down, you will find that's it really not that hard to pick up other languages.
    Browse thousands of new and updated iPhone and iPad gaming apps. http://www.appharvester.com

  3. #28
    Keeper of the SFL StarLion's Avatar
    Join Date
    Feb 2006
    Location
    Atlanta, GA, USA
    Posts
    3,747
    Mentioned
    65 Post(s)
    Tagged
    0 Thread(s)
    Well the best way to learn, I find personally, is to try and do something.

    You got a collection of baseball cards? Why not learn how to create a webpage for showing off the cards you have.

    You play a sport? A webpage about your favorite team.

    Pick something you -enjoy-, and make a project out of it.
    Take some time before you even look at a piece of PHP, and plan things out.
    Make a drawing of what you want each page of your site to do, and which page links to what. (I have a whiteboard that I use for brainstorming. Easy to erase when you change your mind - and every programmer does!)

    If you really want to force yourself into a programming mind, take one page, and think through the logic of it. Let's take an example.

    If I made a page about... my sport's team's record this year. What would I want to do.

    Well i'd have the header.
    Then in the content section, I want to show the schedule. Maybe a table view.
    And in that table view, a Win or Loss column.
    But I want it to stand out a bit. So if the team won that game, I want the W to be blue. If they lost, I want the L to be red.
    Oh, and at the bottom, I want to show a display with the Win/Loss numbers.

    Now you've got a page plan - start trying to create it. If you run into something you dont know how to do, my first step would be to (pardon the acronymical swear) RTFM. Type into your browser: php.net/thingyourtryingtodo. Not sure how an if works? php.net/if . Want an array definition? php.net/array .

    If that doesnt work, come back here, and ask for help. Be specific; be ready to show your code (Make an effort yourself, even if it's pseudocode), and dont forget to obfuscate any passwords.

  4. #29
    SitePoint Guru bronze trophy TheRaptor's Avatar
    Join Date
    Jul 2011
    Location
    New York
    Posts
    710
    Mentioned
    40 Post(s)
    Tagged
    0 Thread(s)
    I started with PHP back when I was learning to program, and I tried to learn the syntax without actually understanding the basic theory behind it. I learned the syntax well but I didn't know how to implement it. Once I understood the theory, it was much easier for me to grasp the syntax and it made more sense.

    After you've learned the basics, go with a C based language. They make a good starting point as they are strict and not as loose as other languages are.

  5. #30
    I solve practical problems. bronze trophy
    Michael Morris's Avatar
    Join Date
    Jan 2008
    Location
    Knoxville TN
    Posts
    2,011
    Mentioned
    57 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by iackay View Post
    Javascript's scoping issues are not that different in declaration visually than that of python which is for all intents and purposes one of the most popular programming languages in the world. In fact it is pretty easy to adopt conventions to avoid scoping issues that make it easy to go from one language to another. Here is an example of something you might see a java dev or python dev write in javascript.
    And? Last time I checked this isn't the python forum. Most popular programming languages in the world? For each python job I see 10 C++ and 20 PHP jobs so, erm, no. It's a niche language at best.

    My point isn't changed by your argument - rather reinforced. How javascript handles scope is different from most other ALGOL languages and this will be a stumbling block at first. It also different from most of the major languages (which python emphatically is NOT a major language - I would be surprised if it's market share exceeded 10%).

    You also didn't address my main reason for not recommending Javascript as a starting language - it's deployment of prototypical inheritance - a trait that is almost unique to it (I think SmallTalk is the only other language that uses that model). Classical object oriented inheritance is hard enough to learn without dealing without trying to learn prototypical inheritance at the same time.

    (That said, prototypical inheritance is a lot more powerful and can even emulate classical inheritance, but grasping it takes a bit).

  6. #31
    Non-Member bronze trophy
    Join Date
    Nov 2009
    Location
    Keene, NH
    Posts
    3,760
    Mentioned
    23 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by TheRaptor View Post
    C based language. They make a good starting point as they are strict and not as loose as other languages are.
    Bwahahaaa... oh man, you slay me. "C" and "strict/not loose" in the same sentence??? HAHAHA... Oh man, what a riot.

    Your kidding, right?

    Sorry, "Wirth" fan here, to me C is so sloppy and loose it's no wonder 90% of the stuff written in it is buggy as all hell.

  7. #32
    SitePoint Guru bronze trophy TheRaptor's Avatar
    Join Date
    Jul 2011
    Location
    New York
    Posts
    710
    Mentioned
    40 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by deathshadow60 View Post
    Bwahahaaa... oh man, you slay me. "C" and "strict/not loose" in the same sentence??? HAHAHA... Oh man, what a riot.

    Your kidding, right?

    Sorry, "Wirth" fan here, to me C is so sloppy and loose it's no wonder 90% of the stuff written in it is buggy as all hell.
    I guess I opened a can of worms here . IMHO C# and C++ are very good starting points as they teach you good solid techniques and overall the basics of how to program. And for the most part C is a strongly-typed language

    Also just FYI, alot of the scripting languages we have today are based off C .

  8. #33
    SitePoint Enthusiast
    Join Date
    Apr 2007
    Posts
    70
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Michael Morris View Post
    And? Last time I checked this isn't the python forum. Most popular programming languages in the world? For each python job I see 10 C++ and 20 PHP jobs so, erm, no. It's a niche language at best.

    My point isn't changed by your argument - rather reinforced. How javascript handles scope is different from most other ALGOL languages and this will be a stumbling block at first. It also different from most of the major languages (which python emphatically is NOT a major language - I would be surprised if it's market share exceeded 10%).
    You are absolutely mad if you think Python isn't a major language. How on earth could you ever, ever come up with some sort of idea? Python is behind nearly most new administration scripts in Unixland, dependency management program and virtual machine automation today.

    You also didn't address my main reason for not recommending Javascript as a starting language - it's deployment of prototypical inheritance - a trait that is almost unique to it (I think SmallTalk is the only other language that uses that model). Classical object oriented inheritance is hard enough to learn without dealing without trying to learn prototypical inheritance at the same time.

    (That said, prototypical inheritance is a lot more powerful and can even emulate classical inheritance, but grasping it takes a bit).
    I wasn't addressing prototypal inheritance because I wasn't intending to. I was commenting on your comment about javascript's scoping issue. Prototypal inheritance ... who cares. Only people who hate javascript even talk about it. The same way only people who complain about assigning this to something else in js complain about it being dirty and a hastle.

    But get real if you think Python is a second class language you are insane.

    EVE Online
    TRAC
    Django
    Pythons
    Twisted Python
    Bazzar
    Hg ( Mecurial )
    BitBucket Hg hoster
    Anaconda - Fedora Installer
    YUM - RPM management
    Industrial Light and Magic use Python in their 3D modeling tools
    BitTorrent - which alone blows your comment out of the water...
    DropBox
    Ubuntu Software Center

    and the list goes on.

    Sorry but you are just plain wrong.

  9. #34
    Non-Member bronze trophy
    Join Date
    Nov 2009
    Location
    Keene, NH
    Posts
    3,760
    Mentioned
    23 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by iackay View Post
    How on earth could you ever, ever come up with some sort of idea?
    There's this attitude that if it's not your favorite pet language, it doesn't exist and nobody actually uses it.

  10. #35
    SitePoint Enthusiast
    Join Date
    Apr 2007
    Posts
    70
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by deathshadow60 View Post
    There's this attitude that if it's not your favorite pet language, it doesn't exist and nobody actually uses it.
    indeed.

    I mean half of amazon runs on python... facebook... again python... I guess those are niche cases though in his eyes.

  11. #36
    Non-Member bronze trophy
    Join Date
    Nov 2009
    Location
    Keene, NH
    Posts
    3,760
    Mentioned
    23 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by iackay View Post
    I mean half of amazon runs on python... facebook... again python... I guess those are niche cases though in his eyes.
    See my list for Pascal -- "Outdated fossil" indeed.

    It's ok to not like the language (I think python, ruby and anything with "ASP" in the name is total trash) -- but to say it's outdated, irrelevant, or any other disparagement about it's popularity is just asinine. (says the guy who goes "wait, people still use coldfusion?!?" -- we're all guilty of it at some point!)

    Oh, and on the subject of prototypal inheritance -- it's different, but not so different it should be a deal-breaker compared to classical constructors. That's such a minor nit-pick given how every C syntax language basically has objects shoe-horned into them "any old way". I've yet to see one that had objects make anywhere near as much sense as they do in Smalltalk, Oberon or Object Pascal (or should I call OP by it's real name -- SIMULA). Hell, even Lua does it better than most C syntax languages... but then I'd sooner program ALGOL than deal with C syntax languages; just for some unfathomable reason the needlessly cryptic C syntax has become the industry norm and what you're EXPECTED to work with in most cases. It's why as much as I dislike python or ruby, at least they're trying to shake things up a bit syntactically.

    The old adage, just because it's popular doesn't make it any good -- See Wordpress, Dreamweaver, phpBB...

    My main problem with prototypal is destructors end up broken due to the lack of true pointers -- to go hand in hand with the lack of true pointers (one of PHP's shortcomings) making doing the USEFUL stuff with objects (like linked lists, btree's) painful at best, impossible at worst. "instancing" has to be one of the WORST concepts added to programming languages -- I say destroy something, I want it gone NOW! null all reference pointers! Not the "Oh something is still pointing at it somewhere so we can't do that, so we'll just decrement the reference count instead" idiocy.

  12. #37
    SitePoint Enthusiast
    Join Date
    Apr 2007
    Posts
    70
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Languages are just tools. Whether it is cobol, coldfusion or C++ the only downside to a language is usually human errors when designing software and opinions people pick up when they hit a mental limitation they cannot overcome without understanding the foundation of the language they are using.

    It is like the OOP guys bashing C, or overlooking it for something more 'modern' OOP language, when C is very capable of writing OOP code. You might not get polymorphism but that is not in itself inclusive of OOP.

    You by all means can write OOP code in C. An easy way to get methods in structs is to just have to pass pointers to your struct in a function. Otherwise, under the hood a C++ struct compiles down similarly to a standard C struct written to do what I stated above.

    The biggest difference you will find compilation wise is that the size of a struct with an extra variable will be bigger than the C++ struct that doesn't need the extra variable for its method.

    Meh, languages are tools. As long as there is a compiler for your target platform and your code is written well then who cares who uses what :shrugs:

  13. #38
    I solve practical problems. bronze trophy
    Michael Morris's Avatar
    Join Date
    Jan 2008
    Location
    Knoxville TN
    Posts
    2,011
    Mentioned
    57 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by iackay View Post
    indeed.

    I mean half of amazon runs on python... facebook... again python... I guess those are niche cases though in his eyes.
    Facebook is on PHP.

    Look at job listings. For every python job there are dozens for C, PHP and Java. So yes, niche language.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •