Art of Writing Small Code by Sumit misra

492 views

Published 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 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.

Published in: Technology, Education
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
492
On SlideShare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
5
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide
  • Stopwatch programHTML/JavaScript: 20 linesWindows 7 Phone : 25 linesJava AWT: 43 linesWindows C++: 120 lines
  • Art of Writing Small Code by Sumit misra

    1. 1. Art of Writing Small Code Sumit Misra General Manager RS Software (India) Limited
    2. 2. Code is developed to address a Problem Space Problem SpaceLearning by knowledge sharing
    3. 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. 4. MASHUP CODE Abstraction LARGE GRAIN CODE ASSEMBLY CODE SCRIPTS << GRAIN >> ASSEMBLY CODE SMALL GRAIN Problem PlaneLearning by knowledge sharing
    5. 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. 6. Large Code Base Small Code Base Problem Plane 1 2 3 4 1 2 3 4Learning by knowledge sharing
    7. 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. 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. 9. Problem Plane is Expanding Web Services Solution Plane Internet Web Services Web ServicesLearning by knowledge sharing
    10. 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. 11. Source: online.wsj.comLearning by knowledge sharing
    12. 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. 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. 14. Thank you sumit@rssoftware.co.inLearning by knowledge sharing

    ×