/    Sign up×
Community /Pin to ProfileBookmark

IS programming Frustrating to you?

I am a new programmer/web developer. I have been doing this about 2 months. OMG this stuff is so frustrating. Html and css were cake. javascript is tough though! The concepts are easy enough but I cant do anything with out a reference book! i feel like nothing works for me and all my scripts are worthless. Does it get easier?

Was your first programming language tough?

is programming frustrating for you?

Until i get better i am going to be using this forum a lot. I would appreciate any help i can get on debugging my scripts. I am sure all of them will be relatively easy for whoever is reading this.

to post a comment
JavaScript

16 Comments(s)

Copy linkTweet thisAlerts:
@mrhooDec 08.2006 — Mostly we get over it.
Copy linkTweet thisAlerts:
@KorDec 08.2006 — I have noticed that a lot of javascript books/tutorials do not follow a simple OOA & OOD (Object Oriented Analysis & Object Oriented Design) rule in their pattern. They do not show [B]why, what[/B] and [B]how[/B] javascript does/works.

I simplified overview of javascript might look like that:

A web page has [B]elements[/B] (tags, textnodes, comments...). Elements have [B]attributes[/B]. Attributes have [B]values[/B]. Javascript is a language which is able to [I]create/remove[/I] elements and attributes and to [I]set/modify[/I] the attributes' values.

The changes made are [I]dynamic[/I] and [I]virtual[/I]. That means javascript works in the same session (without reloading the page) and javascript do not change "physically" the web page. That makes it a [I]client-side language[/I]. It can not write/store data. (A [I]cookie[/I] is a notable exception, but this is to be learn later)

In order to do the changes, javascript uses [B]methods[/B] via a [B]syntax[/B] based on [B]statements[/B]. Statements are nested in [B]functions[/B]. Functions are called by [B]events[/B], following a user's [B]action[/B].

So. Here's a basic analysis of how javascript works:

Suppose you have a document with a DIV tag which has a certain background color (CSS set) and you want to change it's background when clicking on a button:
<i>
</i>...
&lt;div style="width:50px;height:50px;background:#CC0000"&gt;&amp;nbsp;&lt;/div&gt;
&lt;input type="button" value="Change bgcolor"&gt;
...

1. First you have to find and to define the element (to do the reference) as an unique element of that page. To do that, javascript uses several methods, one of them is reference by [B]id[/B]. That means you must give your element an id:
<i>
</i>&lt;div id="mydiv" style="width:50px;height:50px;background:#CC0000"&gt;&amp;nbsp;&lt;/div&gt;

Now you have to set a javascript object which will represent that element. In this case, javascript uses [B]getElementById()[/B] method. But the element (as all the elements) belongs to the [B]document[/B] root, thus the complete reference looks like:
<i>
</i>&lt;script type="text/javascript"&gt;
var myElement=document.getElementById('mydiv');
&lt;/script&gt;

2. Now that we have the element, we must identify the attribute. The attribute in this case is [B]style[/B]. But style is a "dual" attribute. It is an element as well, and it has it's own attributes. We are interested in it's [B]background[/B] attribute's value, and we need to change that value via an [B]asignment[/B]:
<i>
</i>&lt;script type="text/javascript"&gt;
var myElement=document.getElementById('mydiv');
myElement.style.background='#00FF00';
&lt;/script&gt;

3. Now we must insert all these in a function and find the javascript event which will call the function. In this case, the event is [B]onclick[/B]. And here's the final code:
<i>
</i>&lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"&gt;
&lt;html&gt;
&lt;head&gt;
&lt;title&gt;Untitled Document&lt;/title&gt;
&lt;meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"&gt;
&lt;meta http-equiv="Content-Style-Type" content="text/css"&gt;
&lt;meta http-equiv="Content-Script-Type" content="text/javascript"&gt;
&lt;script type="text/javascript"&gt;
function myFunction(){
var myElement=document.getElementById('mydiv');
myElement.style.background='#00FF00';
}
&lt;/script&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;div id="mydiv" style="width:50px;height:50px;background:#CC0000"&gt;&amp;nbsp;&lt;/div&gt;
&lt;input type="button" value="Change bgcolor" onclick="myFunction()"&gt;
&lt;/body&gt;
&lt;/html&gt;


All you have to do now is to learn the javascript [B]methods, events[/B] and [B]syntax[/B].

I hope it helps.
Copy linkTweet thisAlerts:
@UltimaterDec 08.2006 — JavaScript is just as easy as drinking coffee for me. It's such an easy language that accomplishes so much with such little effort that one can relax while programming it over a Java-flavored coffee. I personally think JavaScript easier than all the other programming languages and not just because JavaScript is my mother programming language (first one I learned). Debugging JavaScript is a breeze and it is very forgiving (e.g. optional semicolons). Although JavaScript has very limited power, I personally think JavaScript's Object-Oriented implementation very structured so I can understand code at a glance. Sadly I cannot force others to write clean code... The biggest challenge JavaScript faces is browser compatibility and accessibility (users with it disabled).
Copy linkTweet thisAlerts:
@sickofitall_ukDec 08.2006 — I am finding it extremely frustrating.

Thing the biggest reason for this is examples I am looking at don't always explain exactly what is going on and why at points throughout the code.

I've got the feeling I'm never going to get above cutting and pasting at this rate!
Copy linkTweet thisAlerts:
@KorDec 08.2006 — I am finding it extremely frustrating.

Thing the biggest reason for this is examples I am looking at don't always explain exactly what is going on and why at points throughout the code.

I've got the feeling I'm never going to get above cutting and pasting at this rate![/QUOTE]

Don't lose your temper. I guess all of us, in our impatience, have started with copy/paste. We all had the feeling that something happens and we didn't see the deep and essential mechanism. It's like a foreign language. At the beginning you think you will die without a dictionary. One day you discover that you can actually read a newspaper written in that language for free... :-)
Copy linkTweet thisAlerts:
@CharlesDec 08.2006 — Actually, I find it rather soothing. And I'm always consulting a reference. The hard part, though, is trainning you head to work with language in a uniquely in-human way. But the focused concentration required can be a nice meditation. The jokes about "nerdvana" are just a little close to the truth. But it takes struggle to get there.

The first language that I played around with was Fortran but the first one that I really learned was Pascal. Pascal was written by Nicholas Wirth to be a training language and at that it excells. I highly suggest that you learn it well and then leave it.

Go to your public library and get a hold of [i]JavaScript : The Definitive Guide[/i] by David Flanagan. Read that through, cover to cover, several times. And then keep it on your desk for a reference.

The next thing that you need to do is to take your time and play with the language. Never be satisfied with something that works. Keep revising it to make it shorter. Lets say you start with something like [font=monospace]if (flag == true)[/font]. I see that all the time from newbies. Learn to ask yourself What happens if I shorten that to [font=monospace]if (flag)[/font]. And find out if you can shorten [font=monospace]if (string != '')[/font] to [font=monospace]if (string)[/font]. And you will have taught yourself something about how JavaScript Booleans work.

And it's hard to explain why, but I do believe that learning Perl will greatly help your JavaScript.
Copy linkTweet thisAlerts:
@howlieboy69authorDec 08.2006 — Hey thanks for the great replies.

Was your first language tough?

I just want someone to tell me "It will get easier, in a couple months you

ll be somewhat of a pro" because Ive read over 1500 pages in a month and it is still tough for me to get my own functions to connect with the DOM.
Copy linkTweet thisAlerts:
@sickofitall_ukDec 08.2006 — I did a bit of c years ago but that's it!

Can anyone recommend any particular books on the subject? Learning off the web is ok but it can get a bit confusing as different people suggest different ways of going about a problem (which is good but it's difficult to figure out the best way for any particular situation).
Copy linkTweet thisAlerts:
@KorDec 08.2006 — The single way you can solve a particular situation is to rise over that particular situation, find a pattern, go to a general situation, get the solve and climb down to the particular. This is what Object Oriented Analysis (OOA) is made for.

Let's back to my example. The "particular situation" is : I need to change the background color of a DIV. If you remain in the "particular", you may simply build two documents, one with a red colored DIV, and one with a green colored DIV, and use a link on the red colored to open the green colored.

But when you perform a OOA, you will be able to find a better way (or several different ways) to do that. All you have to do is to consider a document as a [I]system[/I] composed of objects (elements). As I said, the objects have attributes(properties) and properties have values. Objects/attributes/values can be created/removed/changed using methods.

In OOA (and OOD - Object Oriented Design) everything can be considered as an [I]object[/I]. Even an attribute can be seen as an object.

Now coming back, to solve a particular situation you have to model a [I]general problem domain[/I], not a particular one. It is not useful to change the background's color of a particular DIV, you must find a way to change the background's color of all the DIV's. That is not enough, so go further and think to change the background's color of all the tags (if they accept background as native attribute). And further, to change any property's value of any object on the document.

Go from particular to general, find a solution as general as possible, then go back to the particular and apply it. In my example previous background example, if you need to change 2 or more DIV's bgcolor, you may think that you must use 2 or more functions. Of course you may. But if you try to overpass the "particular" way of thinking, you will discover that you may use a single function, nomatter how many div's you have, by passing the id and the color's value as parameters to the function:
<i>
</i>&lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"&gt;
&lt;html&gt;
&lt;head&gt;
&lt;title&gt;Untitled Document&lt;/title&gt;
&lt;meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"&gt;
&lt;meta http-equiv="Content-Style-Type" content="text/css"&gt;
&lt;meta http-equiv="Content-Script-Type" content="text/javascript"&gt;
&lt;script type="text/javascript"&gt;
function myFunction(id,col){
var myElement=document.getElementById(id);
myElement.style.background=col;
}
&lt;/script&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;div id="mydiv1" style="width:50px;height:50px;background:#CC0000"&gt;&amp;nbsp;&lt;/div&gt;
&lt;input type="button" value="Change bgcolor" onclick="myFunction('mydiv1','#00FF00')"&gt;
&lt;br&gt;&lt;br&gt;
&lt;div id="mydiv2" style="width:50px;height:50px;background:#0000CC"&gt;&amp;nbsp;&lt;/div&gt;
&lt;input type="button" value="Change bgcolor" onclick="myFunction('mydiv2','#FF00FF')"&gt;
&lt;/body&gt;
&lt;/html&gt;

And still there are possibilities to find a more general solution. Think global, and you will be able to solve local.
Copy linkTweet thisAlerts:
@baseiberDec 08.2006 — My first programming language (Java 1.4) was tuff but I loved it. It was frustrating at times but that made finding the solutions more rewarding.

The big thing about programming or web development is that you need to keep up with what's going on. I know a lot of programmers who were great at C, Cobol, or VB. Unfortunately they had trouble finding jobs when the companies they worked for had lay offs or went out of business.
Copy linkTweet thisAlerts:
@mjdamatoDec 08.2006 — IMHO, the difficult part for most people is not the programming itself. It is the logic. Anyone can set a value, create a loop, create a function, etc.

But, the real difficulty is in determining where to create a loop, a function or where to set a variable. Some "best practices" can be taught. For example, if you need a boolean variable (on/off), you should almost never (with few exceptions) actually set a string as "on" or "off" - instead use true & false. But, "real" logic is not something I believe can be taught.

I know a lot of good web designers that can do programming, and I know a lot of good programmers that can do design. But a good programmer who is also a good designer is a very rare breed. basically the difference between right-brained and left-brained people.
Copy linkTweet thisAlerts:
@Typhoon101Dec 08.2006 — While there may be many good books on the topic available, it is difficult, if not impossible to read a book and then expect to understand everything. A large amount of the stuff learnt will be forgotten.

To quote Homer Simpson "Every time i learn something new, it pushes old stuff out of my brain".

Rather than trying to learn JavaScript and then trying to do something with it, i find it best to have a specific problem and learn what is needed to solve that. You will find that over time a larger portion of the learnt stuff is used repetitively and so you will retain the knowledge.

To directly answer your question, JavaScript WAS my first language and yes i did find it very tough to start with, only copying and pasting code and getting annoyed when it was conflicting with other code on my page. now i write my own. It will get better. Beware though, don't think you will become a pro in two months. It will take time.

This forum is an excellent source of information for specific problems. There are many very talented programmers who are willing to help and answer your questions.
Copy linkTweet thisAlerts:
@semi-sentientDec 08.2006 — IMHO, the difficult part for most people is not the programming itself. It is the logic. Anyone can set a value, create a loop, create a function, etc.

But, the real difficulty is in determining where to create a loop, a function or where to set a variable. Some "best practices" can be taught. For example, if you need a boolean variable (on/off), you should almost never (with few exceptions) actually set a string as "on" or "off" - instead use true & false. But, "real" logic is not something I believe can be taught.

I know a lot of good web designers that can do programming, and I know a lot of good programmers that can do design. But a good programmer who is also a good designer is a very rare breed. basically the difference between right-brained and left-brained people.[/QUOTE]


Agreed completely. When I first got into programming I hated it and decided to get a degree in networking instead. It seemed like a daunting task to have to learn all these different languages, but as I started doing more and more scripting, which lead to actual programming, I realized that learning how to program was the difficult part, not learning the languages.

For the OP, two months is nothing. It takes quite a while to develop a "coder" mentality. You have to keep working on it, and write as much code as possible, regardless of the language. You won't see the real benefits until you actually start writing meaningful code, as opposed to school assignments.
Copy linkTweet thisAlerts:
@Tweak4Dec 08.2006 — My first languages were Basic and Pilot, but that was just goofing around when I was a kid. My first "actual" programming experience was in college, where I had a lot of VB6, with a couple semesters of C++ and COBOL. I picked up html and javascript in my free time, and when I graduated, I got a lot deeper into JS for my job, and now equally deep in C#.

As stated above, once you get a grip on one language, additional ones will come with significantly less effort- you already know most of the concepts, its just a matter of learning syntax, and any "quirks" that exist in one language but not another.

Don't feel bad about having to go to a reference book- that's why they're there. I have about 7 different language books on my shelf at work, and at any given time, 2 or 3 are lying open on my desk.

The more you code, the less you'll need to look up, but you'll still need to go find things on occasion...

And for what its worth, I used RikComery's approach to learn several languages. I run though all the training material we have, and then say "I wonder if I can write a program that will do _________". Then you find what you need to make that work... It's definitely slow, but it's a solid way to learn a lot of the basics in a language.
Copy linkTweet thisAlerts:
@felgallDec 08.2006 — My first programming language (Fortran) was hard because I was learning it from a book and didn't have access to a computer to try any of my programs out. It was a real relief several years later when I finally got access to the mainframe computers at the university to find out that the programs that I had written only required minoer bug fixes in order to work. Learning additional languages such as BASIC, Pascal, Cobol, and PL/1 were a lot easier and after learning those adding new languages became fairly trivial until I decided to find out about Object oriented languages. Learning the OO concepts was hard and took me a while but applying them in a language that supports that structuring once you understand the concepts is easy. I lost track of how many programming languages I know some time back in the 80s, learnt a lot more since then.
Copy linkTweet thisAlerts:
@howlieboy69authorDec 09.2006 — Gold...Gold your givn' me.

seriously, thanks alot
×

Success!

Help @howlieboy69 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.22,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...