Hello and welcome to CertForums.co.uk, here we host free active certification forums with links to the best free resources for Microsoft's MCSA MCSE MCDBA Cisco's CCNA CCDA and CCNP, and CompTIA's A+ Network+ i-NET+ and Security+ certifications in the UK. If you wish to post or use other advanced features you will need to register first. Registration is absolutely free and takes only a few minutes to complete so sign up today!

If you have any problems with the registration process or your account login, please contact support

Go Back   CertForums > Off Topic Forums > The Lounge - Off Topic
Home Forums Register Search Today's Posts Mark Forums Read

Good book

Post New ThreadReply
 
Thread Tools Display Modes
  #1  
Old 15-May-2008, 05:38 PM
Tinus1959's Avatar
Tinus1959 Tinus1959 is offline
Lifetime Member
Posts: 1,328
Points: 1083 Tinus1959 has over 1000 pointsTinus1959 has over 1000 pointsTinus1959 has over 1000 pointsTinus1959 has over 1000 pointsTinus1959 has over 1000 pointsTinus1959 has over 1000 pointsTinus1959 has over 1000 pointsTinus1959 has over 1000 points
Power: 26
None
Join Date: 11 Apr 2007
Location: The Netherlands
Age: 48
Certifications: See my signature
WIP: MCSD, MCAD, CCNA, CCNP
Good book

At the moment I'm reading the first two parts of the series "write great code". This should be on the list of every programmer. After reading you understand what is going on IN the computer and why things get slowed down.

One example:
I want to fill a two dimentional array whit the product of the indeces. So I declare the array and start filling with a two level loop.

For n = 0 to 1023 do
For m = 0 to 1023 do
a[m,n] = m*n
next m
next n

Compare this to:

For n = 0 to 1023 do
For m = 0 to 1023 do
a[n,m] = m*n
next m
next n

It might be hard to believe, but one code is much faster than the other.

Why is this?
I'll give the explanation next week.


MCP (NT 3.51) MCSE (NT 4.0, 2000, 2003) MCSA (2000, 2003), MCT (since 1999), Vista, Exchange 2007, A+, Network+, Security+, CEH.

Last edited by Tinus1959 : 15-May-2008 at 05:39 PM.
 
Reply With Quote
  #2  
Old 15-May-2008, 06:08 PM
dmarsh26's Avatar
dmarsh26 dmarsh26 is offline
Longterm Member
Posts: 885
Points: 1591 dmarsh26 has over 1500 pointsdmarsh26 has over 1500 pointsdmarsh26 has over 1500 pointsdmarsh26 has over 1500 pointsdmarsh26 has over 1500 pointsdmarsh26 has over 1500 pointsdmarsh26 has over 1500 pointsdmarsh26 has over 1500 pointsdmarsh26 has over 1500 pointsdmarsh26 has over 1500 pointsdmarsh26 has over 1500 points
Power: 26
None
Join Date: 24 May 2007
Location: Hampshire
Age: 33
Certifications: One or two...
WIP: Girlfriend+
Multidimensional arrays are still constructed out of a large block of contiguous memory, ie in effect they are a one dimensional array, anyone who has programmed assembler, C or has used overlays in FORTRAN, or has reverse engineered code will know this.

To index into the second dimension you must offset by the size of the second dimension, effectively paging the array. For arrays of non trivial size linear access of the array will be faster because it will result in less paging of virtual memory.

One part of code will sweep memory in a linear fashion, the other will jump to the same position in each 'page', resulting is a vast amount of jumping around.

The multiplication despite the change in the operands will be a constant time operation for each iteration.
The two pieces of code are not equivalent as they will store the results in a different order in memory.

This is why people say you should learn assembler or C and why embedded and games programmers are respected more than other programmers. You need to understand the machine and the back end of your compiler or you JVM and your OS, all of it.

Programmers used to create whole worlds in 64k, assembly lang programmers would chose op codes to save one cpu cycle, you should at least understand the performance characteristics of you chosen algorithms and their implementation.


Last edited by dmarsh26 : 15-May-2008 at 07:02 PM.
 
Reply With Quote
  #3  
Old 15-May-2008, 06:36 PM
Tinus1959's Avatar
Tinus1959 Tinus1959 is offline
Lifetime Member
Posts: 1,328
Points: 1083 Tinus1959 has over 1000 pointsTinus1959 has over 1000 pointsTinus1959 has over 1000 pointsTinus1959 has over 1000 pointsTinus1959 has over 1000 pointsTinus1959 has over 1000 pointsTinus1959 has over 1000 pointsTinus1959 has over 1000 points
Power: 26
None
Join Date: 11 Apr 2007
Location: The Netherlands
Age: 48
Certifications: See my signature
WIP: MCSD, MCAD, CCNA, CCNP
Spot on! Very good.


MCP (NT 3.51) MCSE (NT 4.0, 2000, 2003) MCSA (2000, 2003), MCT (since 1999), Vista, Exchange 2007, A+, Network+, Security+, CEH.
 
Reply With Quote
Post New ThreadReply Spread this thread: Submit this thread to digg Submit this thread to del.icio.us


Go Back   CertForums > Off Topic Forums > The Lounge - Off Topic


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
just started reading the M Meyers a+ book ezzzy A+ 22 31-Mar-2008 11:26 AM
Great Apache security book ffreeloader The Lounge - Off Topic 3 13-Mar-2008 03:37 PM
Security Power Tools tripwire45 Reviews 1 03-Mar-2008 11:19 PM
Illustrated Guide to Astronomical Wonders tripwire45 Reviews 0 30-Dec-2007 10:12 PM
Remote assistance frustration: MS press book simply doesn't help csh Server Exams 4 17-Oct-2007 04:27 PM


All times are GMT. The time now is 07:14 AM.

Powered by vBulletin® Version 3.6.10
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
CertForums.co.uk (C) copyright 2003-2007 All Rights Reserved. Content published on CertForums.co.uk requires permission for reprint.
Hosted by Lunarpages