Video: Input/output and persistence

Programming is all about input and output, but what that means has changed over the years. You go back a few decades and the idea was simple. The only programs we used were what were called batch programs. You started the program like it was a food processor. You'd be giving a file of data for input, you'd let the program process all of it and spit out the results to another file or even directly to the printer, and then the program stopped. You did not interact with the program as it was running. The closest thing to this for most people now is a few command line programs or the occasional utility like doing a full virus scan of a hard drive.

This course provides the core knowledge to begin programming in any language. Simon Allardice uses JavaScript to explore the core syntax of a programming language, and shows how to write and execute your first application and understand what's going on under the hood. The course covers creating small programs to explore conditions, loops, variables, and expressions; working with different kinds of data and seeing how they affect memory; writing modular code; and how to debug, all using different approaches to constructing software applications.

Finally, the course compares how code is written in several different languages, the libraries and frameworks that have grown around them, and the reasons to choose each one.

Input/output and persistence

Programming is all about input and output, but what that means has changed over the years.You go back a few decades and the idea was simple.The only programs we used were what were called batch programs.You started the program like it was a food processor. You'd be giving a file ofdata for input, you'd let the program process all of it and spit out the resultsto another file or even directly to the printer, and then the program stopped.You did not interact with the program as it was running.The closest thing to this for most people now is a few command line programs orthe occasional utility like doing a full virus scan of a hard drive.

Things which are designed to run and finish as fast as possible, but instead theshift is to programs that run with graphical user interfaces.Things like a web browser that don't just start and run all the way through andstop as quickly as possible, but they are programs that stay up.We can interact with these continuously and unpredictably over hours oreven days or even weeks.And with these input and output is a bit vague.Well, yes, a mouse-click is input, something typed in a webpage is input, andchanging an image on the screen is output.

But that doesn't really feel the same as saving and loading files, becausesometimes we still want to be able to save documents to the hard drive or loadfiles from the hard drive or save information to the web.So describing just everything as input and output becomes a little generic.So when we talk about really saving information, running a program that thensaves information to our documents folder or saves to a database or saves tothe web or saves to a cloud,and I mean data that outlives the currently running program, meaning that wecould close the program and that data would still be on the drive or in thedatabase or in the cloud, then we use the term persistence. And we also refer tothis as saving the state of a program. Because without deciding to persist,our data it all just disappears.

All the variables we've worked with so far are just stored in the computer'svolatile memory in RAM while the program is running and when we close theprogram everything is gone unless you plan otherwise.But here's the issue. Different programming languages support persistence indifferent ways and JavaScript not very much at all.There are no words in JavaScript to save a file to the Documents folder. You can't do it.Now that's by intention. JavaScript was designed to be embedded in webpages.You just don't want all the webpages you've ever viewed being able to save filesdirectly to your hard drive.

So for security those words were never built in to the JavaScript language.Now languages that are more geared to desktop development or mobile developmentor even mainframe development do have built-in ability to write code to saveor load files to the hard drive.They often have a variety of different words to do this and we'll talk about afew of these features shortly, but first let's take a look at what JavaScriptdoes like to do for input and output if it can't load and save files.

Find answers to the most frequently asked questions about Foundations of Programming: Fundamentals .

Here are the FAQs that matched your search "" :

Expand all | Collapse all

please wait ...

Q: Using TextEdit with Mac OS 10.9 Mavericks?

A: If you're using the built-in TextEdit program in Mavericks to write your first examples and your code doesn't seem to be working, here's one reason why: by default, "smart quotes" are now turned on in TextEdit Preferences.

This is where TextEdit will automatically change pairs of double quotes to "smart quotes" - where the opening and closing quote are different, like a 66 and 99.

While this is fine for human eyes, programming languages don't want this - when writing code, they need to be the plain, generic straight-up-and-down quotes.

So make sure that in TextEdit > Preferences, that "Smart quotes" are unchecked.

Important! Whenever you make a change to TextEdit preferences, make sure to then completely quit out of the program (Command-Q or using TextEdit > Quit TextEdit) and then re-open it, as changes won't take effect on documents you already have open.

However, we're not finished - just because you've changed the preferences, it does **not** change any *existing* smart quotes back to "regular" quotes - it just doesn't add new ones - so make sure to go through your files for any time you wrote quotes and TextEdit may have changed them to smart quotes - look in both the JavaScript, and your HTML too, and compare to the downloadable exercise files if necessary.

If that sounds like a bit of a chore, I recommend just downloading a code editor like Sublime Text (www.sublimetext.com) or TextMate (www.macromates.com) and using that instead of TextEdit - it's only a matter of time before you'd move away from TextEdit anyway - we only used it in the course because it was built-in and a quick way to get started, but it's now become more of a inconvenience than it was before.

Sorry, there are no matches for your search "" —to search again, type in another word or phrase and click search.

Learn by watching, listening, and doing, Exercise files are the same files the author uses in the course, so you can download them and follow along Premium memberships include access to all exercise files in the library.

Already a member ?

Learn by watching, listening, and doing! Exercise files are the same files the author uses in the course, so you can download them and follow along. Exercise files are available with all Premium memberships.
Learn more

Upgrade to our Annual Premium Membership today and get even more value from your lynda.com subscription:

“In a way, I feel like you are rooting for me. Like you are really invested in my experience, and want me to get as much out of these courses as possible this is the best place to start on your journey to learning new material.”— Nadine H.

Thanks for signing up.

We’ll send you a confirmation email shortly.

Sign up and receive emails about lynda.com and our online training library:

new course releases

newsletter

general communications

special notices

Here’s our privacy policy with more details about how we handle your information.

Keep up with news, tips, and latest courses with emails from lynda.com.

Sign up and receive emails about lynda.com and our online training library:

new course releases

newsletter

general communications

special notices

Here’s our privacy policy with more details about how we handle your information.