Welcome to Scribd, the world's digital library. Read, publish, and share books and documents. See more
Download
Standard view
Full view
of .
Look up keyword
Like this
1Activity
0 of .
Results for:
No results containing your search query
P. 1
JforC20071003

JforC20071003

Ratings: (0)|Views: 15|Likes:
Published by shabunc

More info:

Published by: shabunc on Sep 08, 2011
Copyright:Attribution Non-commercial

Availability:

Read on Scribd mobile: iPhone, iPad and Android.
download as PDF, TXT or read online from Scribd
See more
See less

09/08/2011

pdf

text

original

 
 
J
For C Programmers
Henry Rich
2007/09/29 (J6.02)
Copyright © 2004, 2006 Henry H. Rich. All rights reserved.Send comments to HenryHRich@nc.rr.com
 
 ii
Foreword
You are an experienced C programmer who has heard about J, and you think you'dlike to see what it's all about. Congratulations! You have made a decision that willchange your programming life, if only you see it through. The purpose of this book is tohelp you do that.It won't be easy, and it certainly won't be what you're expecting. You've learnedlanguages before, and you know the drill: find out how variables are declared, learn thesyntax for conditionals and loops, learn how to call a function, get a couple of examplesto edit, and you're a coder. Fuggeddaboutit! In J, there are no declarations, seldom willyou see a loop, and conditionals often go incognito. As for coding from examples, well,most of our examples are only a couple of lines of code—you won't get much momentumfrom that! You're just going to have to grit your teeth and learn a completely new way towrite programs.Why should you bother? To begin with, for the productivity. J programs are usuallya fifth to a tenth as long as corresponding C programs, and along with that economy of expression comes coding speed. Next, for the programming environment: J is aninterpreted language, so your programs will never crash, you can modify code while it'srunning, you don't have to deal with makefiles and linking, and you can test your codesimply by entering it at the keyboard and seeing what it does.If you stick with it, J won't just help the way you code, it'll help the way you think. Cis a computer language; it lets you control the things the computer does. J is a languageof computation: it lets you describe what needs to be done without getting bogged downin details (but in those details, the efficiency of its algorithms is extraordinary). BecauseJ expressions deal with large blocks of data, you will stop thinking of individual numbersand start thinking at a larger scale. Confronted with a problem, you will immediately break it down into pieces of the proper size and express the solution in J—and if you canexpress the problem, you have a J program, and your problem is solved.Unfortunately, it seems to be the case that the more experience you have as a C programmer, the less likely you are to switch to J. This may not be because prolongedexposure to C code limits your vision and contracts the scope of your thinking to the sizeof a 32-bit word—though studies to check that are still under way and it might be wisefor you to stop before it's too late—but because the better you are at C, the more you haveto lose by switching to J. You have developed a number of coding habits: for example,how to manage loops to avoid errors at extreme cases; how to manage pointerseffectively; how to use type-checking to avoid errors. None of that will be applicable toJ. J
will
take advantage of your skill in grasping the essence of a problem—indeed, itwill develop that skill considerably by making it easier for you to express what yougrasp—but you will go through a period during which it will seem like it takes forever toget things done.During that period, please remember that to justify your choice of J, you don't have to be as expert in J as you were in C; you only have to be more productive in J than you
 
 iiiwere in C. That might well happen within a month. After you have fully learned J, itwill usually be your first choice for describing a program.Becoming a J programmer doesn't mean you'll have to give up C completely; everylanguage has its place. In the cases where you want to write code in C (either to use alibrary you have in C or to write a DLL for a function that is inefficiently computed in J),you will find interfacing J to DLLs to be simple and effective.This book's goal is to explain rudimentary J using language familiar to a C programmer. After you finish reading it, you should do yourself the honor of carefullyreading the J Dictionary, in which you can learn the full language, one of the greatcreations in computer science and mathematics.
Acknowledgements
I am obliged to the reviewers who commented on earlier versions: Terrence Brannon,Michel Dumontier, Ken Iverson, Fraser Jackson, June Kim, David Ness, Richard Payne,John Randall, Ewart Shaw, and Keith Smillie. Brian Schott, Nicholas Spies, and NormanThomson exchanged emails with me at length to smooth over rough spots. David Steeleconducted a painstaking review of several early drafts and suggested many changes greatand small. Björn Helgason translated the text into Icelandic, finding a number of errorsalong the way. Markus Schmidt-Gröttrup has translated the text into German. RicSherlock reformatted the Reference Card into a thing of beauty.
 
Kip Murray's 'review' became more of a dismantling, cleaning, and reassemblyoperation in which large sections of prose were rewritten as he pointed out to me their essential meaninglessness; the reader should be as grateful to him as I am.Without the patient explanations of my early teachers in J, Raul Miller and Martin Neitzel, I would have given up on J. I hope that this book pays to others the debt I owe tothem.My current happy career as a J programmer would not have been possible without thework of the staff at Jsoftware, Inc., who created J. For the patriarch, the late Ken Iverson,I am unworthy to express admiration: I have only awe. I hope his achievement eases thelives of programmers for generations to come. To the rest, both Iversons and non-Iversons, I give my thanks.The implementation of the J interpreter has required diverse skills: architecturalvision, careful selection of algorithms, cold-eyed project management to select featuresfor implementation, robust and efficient coding, performance optimization, and expertisein numerical analysis. Most improbably, all these talents have resided in one man, Roger Hui
il miglior fabbro
. J gives us all a way to have a little of Roger's code in our own.We should aspire no higher.
Change History
2002/6/18: Add chapters on mathematics in J, and section on Symbols; minor changes towording; bring text up to J Release 5.012002/8/16: Minor additions; added section on aliasing; added chapter on sockets

You're Reading a Free Preview

Download
scribd
/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->