Project Euler – Problem 1
May 28, 2012 at 3:23 pm | Posted in Programming | 2 CommentsTags: Project Euler
Recently I came across Project Euler. I always had trouble with applying problem-solving thinking to problems. Somone on IRC somwhere told me that these are the toughest problem he had ever faced in programming. I think its a good idea to test my abilities by solving these problems. Here is the first and easy one (easiest one ?):
/* Add all the natural numbers below one thousand that are multiples of 3 or 5.
* version 0.1
*/
#include <stdio.h>
#include <stdlib.h>
int main(void)
{
int i;
unsigned long s = 0;
for (i = 3; i < 1000; i += 3)
s += i;
for (i = 5; i < 1000; i += 5)
{
if(i % 3) s += i;
}
printf("%lu\n", s);
return EXIT_SUCCESS;
}
After you solve a problem and give correct answer, it shows in your registered account as solved and a link to the forum thread is also provided where you can see different kinds of solutions posted in different languages. It also shows how many people so far have solved the problem. Thats a good measure of your intelligence (if very few has solved it). Iam using C language for now to solve problems as C is the only language I know currently. I think you must go ahead and give Project Euler a try.
Copyright © 2012 Arnuld Uttre, Village – Patti, P.O – Manakpur, Tehsil – Nangal, Distt. – Ropar, Punjab (INDIA)
Verbatim copying and distribution of this entire article are permitted worldwide, without royalty, in any medium, provided this notice, and the copyright notice, are preserved.
Go Programming Language
May 25, 2012 at 12:47 pm | Posted in community, Programming | Leave a commentTags: go programming language, google go, google go comparison with C, google go comparison with Haskell, haskell vs google go
I was reading draft of new C++ standard a.k.a C++11 (you too must check out N3337.pdf) and somehow I came across Go Programming Lanaguage and on that same page I found this quote of Bruce Eckel:
The complexity of C++ (even more complexity has been added in the new C++), and the resulting impact on productivity, is no longer justified. All the hoops that the C++ programmer had to jump through in order to use a C-compatible language make no sense anymore — they’re just a waste of time and effort. Now, Go makes much more sense for the class of problems that C++ was originally intended to solve.
Now thats a pretty solid and strong statement, I got shakes reading that and it reminded me of The Case for D by Andrei Alexandrescu. Go is designed by a team consiting of our good old friends Rob Pike and Ken Thompson. It has some very good positive reviews. I still have to read the criticizm of it. As per computer language shootout results, C (using GNU’s gcc) is far faster but the code-size of Go was much less (almost 1/3rd). Next on comparison was C++ (GNU’s g++) and results were almost same. Next on my list were Lisp and ATS. checkout the results yourself down here in graphs.
I discussed this performance issue on Go language IRC channel (#go-nuts, freenode) and they gave me very logical and accurate explanation that Go is not mature yet and performance comparison is with very mature C and C++ libraries which are around for a decade or more. So I cna conclude comparison is not exactly a fair comparison. I think Go will catch up with performance issues very fast as user base is growing at electric pace. Reminds me of the times and discussion when Python’s user base was growing and they were trying to resolve all the issues they could with full hard work.
Whenever a new language comes or whenever you want to learn an already established language, I think you must look into why that language was created in first place. Does that match your why of learning ? you must be using that language for some purpose, does the design goal suit your purpose ? In my case I think Go language suits, here is the excerpt from Does the world need another programming language ?
A couple of years ago, several of us at Google became a little frustrated with the software development process, and particularly using C++ to write large server software. We found that the binaries tended to be much too big. They took too long to compile. And the language itself, which is pretty much the main system software language in the world right now, is a very old language. A lot of the ideas and changes in hardware that have come about in the last couple of decades haven’t had a chance to influence C++. So we sat down with a clean sheet of paper and tried to design a language that would solve the problems that we have: we need to build software quickly, have it run well on modern multi-core hardware and in a network environment, and be a pleasure to use.
Go has the feel of a dynamic language like Python or Ruby or JavaScript, but it has the performance and safety of a language like Java or C or C++. So you get the lightweight feel of a modern scripting dynamic language but the robustness and performance of a more old-fashioned language.
Based solely on the above criteria I think I can start using Go right away and if I don’t have enough mature libraries or some specific functionality, then ATS is always there. When companies become big they become rigid, like a stubborn spoilt son of a businessman. They refuse to change to get edge over other software corporations because the change requires a lot of effort. I think the weight of word “Google” behind Go programming language will give it an edge over that rigidity. (same thinkg with Java and .NET).





Copyright © 2012 Arnuld Uttre, Village – Patti, P.O – Manakpur, Tehsil – Nangal, Distt. – Ropar, Punjab (INDIA)
Verbatim copying and distribution of this entire article are permitted worldwide, without royalty, in any medium, provided this notice, and the copyright notice, are preserved.
one year vs four days
May 12, 2012 at 1:47 pm | Posted in Programming | Leave a commentTags: Programming, project manager, software business
At my workplace I contributed to the creation of a software while working with systems programming team. It worked fine at that time. Last year new requirements were proposed, which, from my perspective, pressed the need for a fundamental change in design. Face the fact, Corporates are rigid, hence ideas of changes in design were postponed, postponed and the postponed more. Its same story everywhere in every corporation (except few ones). Company decided not to take the risk of making new changes and added new code to the current product at that time. And that spoke trouble many months later and screams were heard followed by pressures and tensions in few months after those “many months”.
During last week I was assigned the task of rewriting one part of that software, as managers got too much frustrated with the rigidity. I was given the freedom of doing whatever I wanted to do make problems disappear in 2 days (I told them I don’t know black magic and none of my friends know Voodo). I looked at old design and new requirements and hell I did not see any match. So I rewrote several (yeah, not one) parts of that softwares, almost 80% of the code was rewritten, tested and given back in 3 days flat.
Whats so important in this ? The software which took one year to write, I rewrote 80% of code in 3 days, edited makefile and compiled the source and ran it and it did not segfault. Holy Cow… it was really black magic. Everything gave correct results while I tested it for 4th day. There was only one problem of a mutex lock was not opening. Whats the lesson ?
Experience, listening to experts in field and using methods, tools and techniques advised by those experts. No one is master in this world (especially no one becomes a master in 4 years) you have to share and learn from programmers around, provided those programmers really work hard on writing correct code. If you can’t find such programmers around you, google for usenet newsgroups, IRC channels, check comp.lang.(your language). Earlier when I contributed I was a newbie and now after 4 years I see I have developed the skill to solve problems in a fast and efficient manner. If I knew algorithms and data structures better than what I know now then I could have done much better job than 4 days or produced much more requirements-matching code. When a function is wrong then you can rewrite it. When a data-structure is wrong then you have to rewrite the data-structure and all the functions associated with it, which means 100% rewrite, which is what I did and I removed the rigidity of that software. It was pretty hard and the result was astounding.
Other lesson is to make sure your requirements are specific, not general. Instead of saying “We want to add/remove/find elements as efficient as possible”, one needs to ask “We want to add/remove/find elements based on a unique keyword.” Ask questions: Removals are more or additions ? “You want to sort the input or not and why ?”. “What exactly the input is and what exactly the output is, which requirements can match which data structure.” “Which operations are important and which are not.” “you want it to eat less memory or cpu and why” etc. etc.
This experience makes me both sad and happy. Happy because I can see specialized methods, tools and techniques of programming can save huge amounts of time. Sad because I am still far behind those methods. No wonder companies like Google/Microsoft/Facebook are ruling the world. They hire programmers who have mastered the art of these techniques/tools/methods. I still don’t know how to write a Red-Black tree using pointers. I still don’t know how to make it cpu-efficient or memory-efficient. Do we sort a red-black tree ? Saddest part is none of the interviews ask any questions of these type. All of the friends I know have never been asked any questions on algorithms/data-structures. Without them you can and will put lots of rigidity, headache in shipped code and build your future-tensions as inherent property of the software. When will you learn timesort ? (Tim Peters created timesort for use in Python Programming Language. go google immediately).
NOTE: As a business-owner/manager you must be thinking what is the business use of all these specialized techniques/methods and tools of programming ? Whats it in for me, Need I not make money ? I need to produce results as manager. Well, I am telling you since you are asking (or will ask): these are invaluable and useless, depending on your attitude. If you want your problems to be solved faster and better then use them. If you want to be better than your competitors then use them. If you don’t want to handicap yourself by solving same kind of problems for next 10 years but will really be happy to solve differet kind of business problems and make more money each year then please use them. And if you don’t want to accept that algorithms/data structures can help you then please don’t. Earth was always moving around Sun even when whole world believed it did not. I can’t help if you don’t want to listen to Joel Spolsky (I am writing in bold that he is a businessman) and Guy Steele and loads of others. In fact no one can help you then. (By the way, everyone knows Guy Steele)
Copyright © 2012 Arnuld Uttre, Village – Patti, P.O – Manakpur, Tehsil – Nangal, Distt. – Ropar, Punjab (INDIA)
Verbatim copying and distribution of this entire article are permitted worldwide, without royalty, in any medium, provided this notice, and the copyright notice, are preserved.
A Modern Systems Programming language
March 28, 2012 at 10:50 am | Posted in Hacking, Programming | Leave a commentWith more effort in the direction of finding a modern systems programming language I had email communications with several people including Eli Gottlieb, creator of decac programming language, GNU Hurd community and ATS language community. It was Eli Gottlieb who gave me the idea that unless I am doing a hobby project I should talk to Hurd people about my ideas and I am glad I did and as you have seen my letter to Hurd community already in my previous post, to find the replies, check out march 2012 archives of bug-hurd mailing list or go here
Seems like Hurd guys either did not like my idea or are nto intersted in it at all, hence I decided to not do any further debate. ATS community has given some replies here, else you can chekc out March 2012 mailing list archives from their site http://www.ats-lang.org
Eli has advised me to go through osdev.org and learn something about OS programming before I venture into writing a microkernel myself. Hongwei from ATS advised to first write a microkernel and then later see how ATS ecnodes to those principles. Wise advice and I am gonna follow. I don’t think I wil start HurdNG development anytime soon, in fact its gonna be quite late. I also need to to how decac was designed and what does it offer, then check out ATS too. While in the meantime I am checking other high level langauges like Haskell and what they offer and comparing the design-ideas to decac, ATS, C and C++ in return. Going to be a lot of work. We have quite high-level and very good programming langauges available at our disposal e.g Common Lisp, Haskell Caml etc. and good modern scripting languages and are available too (Squirrel is one of them, angel-code scripting library is another major step) but not much of mature modern systems programming languages.
Copyright © 2012 Arnuld Uttre, Village – Patti, P.O – Manakpur, Tehsil – Nangal, Distt. – Ropar, Punjab (INDIA)
Verbatim copying and distribution of this entire article are permitted worldwide, without royalty, in any medium, provided this notice, and the copyright notice, are preserved.
Must Reads – 1
March 23, 2012 at 4:59 pm | Posted in Hacking, Programming | Leave a commentI started learning programming in year 2005. After I quit my sales job in February of 2005, I purchased Red Hat Linux Bible in end of April same year. It has been 5 years since then, I learned a lot about computers and it became my passion since then, all possible because of GNU, different Newsgroups, mailing lists, forums and all the helpful people in this virtually real world. I have read many articles and books and essays and history of UNIX, Linux, GNU, BSD, Debian, and many other organizations and groups. Based on my experience I am providing here a list of articles that every computer science student, every programmer must read if he wants to truly understand what he is doing. In fact, every person who buys softwares must read some fo them to open up his mind, same way he knows about his motorcycle like what is spark plug and where it is, what air to keep in tires, if you own a car then how to learn to safely drive a car, how much useful those air-bags are, how to overtake (never to overtake from left e.g.), when is its really essentially to honk, not to talk on mobile phone while driving etc. That way no one wil be able to fool him around while buying softwares. May be after reading them a general computer user will walk on a path and come to know that Truth is really far more stranger than fiction. Ideal process would be o just read these links and google for extra depending on if you want to do computer programming or if you are not a programmer and you need something specific or just out of curiosity:
- The GNU Project
- Open Sources: Voices from the Open Source Revolution
- How To Become A Hacker
- Beating the Averages
- Perils of Java Schools
- A brief history of the Underground scene
- Master Foo and the Script Kiddie
- Teach Yourself Programming in Ten Years
- Why Functional Programming Matters
- Why Lisp
- Roots of Lisp
- Arrays and Pointers are not same
- Literate Programming
- The Arch Way
- Debian Social Contract
- Masters of Deception
- Cult of the Dead Cow
- DEF CON
- Kevin Mitnick
- The Man Who Sold the Moon
- The Art of Computer Programming
- Homesteading the Noosphere
- The Cathedral and the Bazaar
- A Comment on “Warez D00dz” Culture
- School Education and Software
- United States vs. Microsoft
- Browser Wars
- European Union Microsoft competition case
- Pirate Bay Founders Jailed
- Lisp Prgramming Language
- 12 Steps to Better Code
I guess in 1996 I tried to learn English from a book which you can find on every corner of India and it boasts to teach you English in 30 days. I tried and failed several times. Then in my graducation I tried to learn programming from a 30 days book and I failed again. So it worked out. The problem was that these 30 days, 30 weeks, 10 days, 21 days books never teach fundamentals. Most of them have many unreasonable assumptions. By reading these you can only have superficial knowledge about these subjects and 0% knowledge of basics. This is so strange but I myself wanted to write an article like Teach Yourself “Martial-Arts/Car-Repair/Large-Scale-Electric-Systems/Nuclear-Physics/Fine-Arts/somethnig-here/fill-your-favorite-words-here” in 10 Years.. AT that time I never came across anything like blog, in 1996 there was not internet at my place, therefore I never wrote the article. Later I went into different kinds of jobs and forgotten about it. When I started learning programming and started my blog I wanted to write one but then suddenly one day I came across Peter Norvig’s Teach Yourself Programming in 10 Years and I got surprised. I concluded I will not write any blog post about my experience because people will think I am copying Peter Norving and trying to imitate him. So I dropped the idea but in the meantime before internet came I shared my experience of 30 days books with my friends.
I don’t remember all the articles I have read over years. I will keep on adding them as soon as I remember.
Copyright © 2010 Arnuld Uttre, #331/type-2/sector-1, Naya Nangal, Distt. – Ropar, Punjab (INDIA) – 140126
Verbatim copying and distribution of this entire article are permitted worldwide, without royalty, in any medium, provided this notice, and the copyright notice, are preserved.
Blog at WordPress.com. | Theme: Pool by Borja Fernandez.
Entries and comments feeds.