Art of Writing Small Code by Sumit misra

  • 258 views
Uploaded on

“Knowing when not to code” is possibly the most important skill of a programmer to learn. In practice, more code is almost always bad: it trashes the CPU cache, hogs the memory bus, uses up more CPU …

“Knowing when not to code” is possibly the most important skill of a programmer to learn. In practice, more code is almost always bad: it trashes the CPU cache, hogs the memory bus, uses up more CPU cycles, makes a security audit of the code harder, is harder to follow and maintain, and - last but not least - more code needs more documentation. The art of writing small code is to define a lot, not a LOT.

More in: Technology , Education
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
    Be the first to like this
No Downloads

Views

Total Views
258
On Slideshare
0
From Embeds
0
Number of Embeds
0

Actions

Shares
Downloads
4
Comments
0
Likes
0

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide
  • Stopwatch programHTML/JavaScript: 20 linesWindows 7 Phone : 25 linesJava AWT: 43 linesWindows C++: 120 lines

Transcript

  • 1. Art of Writing Small Code Sumit Misra General Manager RS Software (India) Limited
  • 2. Code is developed to address a Problem Space Problem SpaceLearning by knowledge sharing
  • 3. Code maps the Problem Plane to a Solution PlaneHigher the Solution Plane in abstraction – smaller would thecode be Code Solution Plane Problem Plane Learning by knowledge sharing
  • 4. MASHUP CODE Abstraction LARGE GRAIN CODE ASSEMBLY CODE SCRIPTS << GRAIN >> ASSEMBLY CODE SMALL GRAIN Problem PlaneLearning by knowledge sharing
  • 5. Partitioning the Problem 1 2 space such that the solution planes are consistent IS 3 4 The prelude to the Problem SpaceLearning by knowledge sharing
  • 6. Large Code Base Small Code Base Problem Plane 1 2 3 4 1 2 3 4Learning by knowledge sharing
  • 7. Worlds smallest TETRIS program - one line of BBC BASIC, 256 bytes in all written by Olly Betts 0MODE9:OFF:GCOL-9:CLG:REPEATs=s+VPOS:PRINTCHR$30s:REPEATSYS6,135TOi,p,d:PRINTTAB (p=0)CHR$9;:IFPOS=22VDU3100;VPOS,21;6667;:UNTIL0ELSEUNTILVPOS=25:v=ABSRNDMOD7:VD U31:COLOUR3:REPEATm=9-INKEY(INKEYTRUEOR6)MOD3:FORr=TRUETO1:t=rANDSGNt:IFt=rCOLOU Rv-15:VDUrEORm:i+=m=7AND9-6*r:IF0ELSEFORn=0TO11:d=nDIV3OR2EORd:VDUd:IF1<<(n+i)MO D12AND&C2590ECDIV8^vAND975t+=POINT(p*POS,31-VPOS<<5):IFrVDUp,8:IF0ELSENEXT,:VDU2 0:UNTILt*LOGm:UNTILVPOS=3:Z Is this the type of small code we want to write ?Learning by knowledge sharing
  • 8. High Meta Language (Haxe/Neko) Web Programming Language (Dart – Google) Distributed / Meta Program / Reflection Abstraction Internet / RAD Internet / Web Object Oriented Structured Programs Low 1950 1960 1970 1980 1990 2000 2010 >>Learning by knowledge sharing
  • 9. Problem Plane is Expanding Web Services Solution Plane Internet Web Services Web ServicesLearning by knowledge sharing
  • 10. Mobile Service LOCATION Web Services EMAIL Smart Internet / Mobile User Experience Web / Cloud APPLICATION GPS CODE Gyro-meter (HTML5) Magnetometer SOC IAL Pyrometer NETWORK Light Sensor Face Detector Fingerprint Det … more …Learning by knowledge sharing
  • 11. Source: online.wsj.comLearning by knowledge sharing
  • 12. Stop Watch program 20 lines HTML/Java Script 25 linesUser Experience Windows 7 Phone 43 lines Java / AWT 120 lines Windows / C++Learning by knowledge sharing
  • 13. SMALL CODE would need BETTER DESIGN and GOOD KNOWLEDGE of the available frameworks and services “ Im sorry for the long letter, my dear, but I did not have time to make it short. “ – Winston ChurchillLearning by knowledge sharing
  • 14. Thank you sumit@rssoftware.co.inLearning by knowledge sharing