Tao of the MachineProgramming, Python, my projects, card games, books, music, Zoids, bettas, manga, cool stuff, and whatever comes to mind. |
Front page Last 10 archives 2003-09-06 2003-09-13 2003-09-20 2003-09-27 2003-10-04 2003-10-11 2003-10-18 2003-10-25 2003-11-01 2003-11-08 Category archives bettas books CCGs Charm esoterica Firedrop games general ideas internet Kaa linkstuffs Lisp manga music Mygale Nederland nostalgia programming Python SGI switch Wax Zoids :: Search All posts ...by category ...by date ![]() :: About me :: Oasis Digital :: Resume :: GeoURL :: RSS :: Atom ![]() ![]() |
Nowak's ObservationIf the code isn't elegant, it's probably wrong. (Which implies that most of my code is ready for a major overhaul, by the way...)
Posted by Hans
"presuming you're using a language that allows for elegant programming"
Nowak on 2003-11-21 01:04:11
{link}
Categories: programming Snarls of defianceTime for another depressed rant... after a few weeks of negotiations with people who were supposedly looking for a Python/Zope programmer, they have now decided to look at a different product. In C#, of all languages. The number of job opportunities involving C#/.NET is steadily growing. However, I don't exactly like C# or .NET. I really don't know why people use this "new" technology at all. Granted, I am not an expert, but what I've seen so far from it is not promising. It's slow, eats a lot of memory, it's difficult to use, and uses crippled languages. On top of that, there's hardly anything new about it; it's just Microsoft's answer to Java. Of course, I secretly do know why people use it -- because Microsoft touts it as the technology of the future, and that's enough for hordes of people to start using it. And if tomorrow Microsoft comes with a new technology called "Flapdoodle", those same hordes will start using that. It doesn't matter if it's any good, it doesn't matter if there are better products out there; it's enough that it has "Microsoft" on it, so managers will get a warm fuzzy feeling and can rely on the fact that they have a vast pool of programmers at their disposal. Some people think that a Microsoft product is necessarily bad. Or even that a popular product is necessarily bad. I am not one of those people. But I mean, hell, just *look* at C#/.NET. It's not good, and it doesn't introduce anything new, but it's backed by a large company, so people use it, and nobody cares if the clock is set back 5 or 10 years. The same is true for Java, really. And, just like all games absolutely have to be 3D these days, all business apps absolutely have to be web-based. Whether a web application is appropriate for the problem at hand is irrelevant; it's just "what we do" these days, and alternatives are seldom considered. I don't know what it is with programming these days, but I certainly don't like it anymore. Like the industrial revolution made workers disposable, the current developments make programmers disposable. I haven't been around for that long, but I remember that you had to be smart and creative to be a decent programmer. I'm not saying that those days are all gone now, but the new "technologies" certainly aren't rewarding this type of developer. Rather, they are rewarding conformists, making cookie-cutter programs in languages that won't let you do what you want, often written for people who want to know as little as possible about computers. There are voices that claim that dynamic languages will be big in 5-10 years. I hope they're right, but currently it's still very hard to get a job like that, especially around here, a rural area where people don't even know what a computer is. Sometimes I think I should give up trying to get a programming job or even a computer-related job. I might as well go back to accountancy, there's about as much creativity there as in today's industrial programming. The bottom line is, that programming isn't fun anymore. Sure, I can have fun with Python or Lisp or other dynamic languages, and at the same time get things done, fast, producing readable, reusable, maintainable, elegant code. Cool for those late-night hacking sessions, and maybe to get some whuffie. It won't land me a job though. Some people may be of the opinion that I should just put up or shut up. If Java, C++ and .NET are in high demand, then use that, and get a job. If you want to use an "exotic" language, then don't complain if you don't find anything. Fair enough... but... I didn't enter software development for the money. I am not a corporate drone who will use whatever excuse of a language/tool people will throw at him. I started programming at age 12, because it was fun and creative. Later I was able to get paid for it. But I still think programming should generally be fun and creative. If not, then I might as well go flip burgers, or go back to an accounting office (which bored me to tears, literally). Is there a way to "fix" the industry? Will software become like a manufactured product, with little or no creativity involved? Is it worth doing your own thing, because you are convinced it's the right thing to do, even if it goes against popular opinion? I still believe so... but the uphill battle becomes a bit difficult if you cannot pay your bills anymore. *breathes* Fun with the Dutch language(via Ned Batchelder) Joho the Blog: The Dream Comes True. This post talks about "English" words with 4 consecutive vowels. (I say "English" because apparently it has to borrow heavily from other languages: sequoia, hawaiian, etc.) Although Dutch and English are closely related, the way they create new words is very different. In English, you often just put them one after another: "computer" and "screen" make "computer screen". Dutch, on the other hand, glues words together: "auto" + "verkoper" => "autoverkoper" (car salesman). In that respect, it is more like German. One peculiarity is that there really is no limit to the length of the words you can make this way. A far-fetched, but not unrealistic example would be:
Nobody actually uses that word in real life, but it *is* real, and so is the organization that it describes. I used to work for one... Also note that Dutch often glues words together with an -s- in the middle. That's why it's uitkeringsinstantie, rather than uitkeringinstantie. Other combinations do not grow this -s-. There are virtually no rules for this, which adds to the language being difficult to learn. (To foreigners, *and* to the Dutch themselves...) As for strings of consecutive vowels, Dutch has a few nice words, like papegaaieëieren (parrot eggs) and koeieuier (a cow's udder). However, with the introduction of the Nieuwe Spelling in 1995, it seems that these aren't valid anymore. (Yes, one of the favorite pastimes of the Dutch is to change the spelling around every N years, to make things extra confusing.) The Nieuwe Spelling didn't affect the long words with consecutive consonants, though: the infamous angstschreeuw (cry of fear) is still valid, and so is slechtstschrijvend (worst-writing? writing the worst?). But if you think this is bad, there are languages (like Slovenian and Serbo-Croatian) that have words with no vowels at all. Dutch is really no match for them... Short manga descriptions (1)This category is long overdue, so without further ado, short descriptions of 10 mangas. Most/all of these mangas can be found on the Net, if you know where to look. 1. Midori No Hibi: Tough guy cannot get a girlfriend. An unknown power turns his right hand (!) into one. This is a bit of a... complication. 2. Anima: In a fantasy world, some people have traits of certain animals... birds, bats, fish, bears, for example. These people are called +anima (yes, with the "+" in front of it) and are welcomed by some, persecuted by others. 3. Chobits: (Licensed in the US) In a maybe not-so future world, the so-called persocons are very popular. These are robots that look and act very much like humans (mostly girls), and can be used as servants, data banks, etc. A lonely guy wants one, cannot afford it, but then finds a forsaken persocon in the trash. (How could it be otherwise?) It turns out that this is not a regular persocon... 4. Bokko: In ancient China, there was a clan of great fighters and strategists. Over time, the clan becomes corrupt. One man, Kakuri, leaves for this reason, and goes on to defend a city against a vast army. ... Quite an interesting manga, but not for the weak of stomach. 5. Break Shot: There are many mangas about sports, and this one focuses on billiards. Not extremely interesting; high school boy is a natural talent and wins some tournaments, etc. The billiard techniques don't seem very realistic either. 6. Detective Conan: A very talented young detective is turned into a little boy because of some strange potion. In spite of being little, he doesn't give up his detective work, determined to find the guys who gave him the potion, and to somehow return to his previous state. Of course, a 7-year-old isn't quite believable as an investigator, so he lives with his former girlfriend (who doesn't know his identity) and her father, who also happens to be a detective (although much less talented). So he goes on to solve many cases, almost all of which are credited to the lesser detective. This is one of those strange mangas that seem childish, aimed at children, but that have a considerable amount of blood and gore. 7. Full Metal Alchemist: In a strange world, magic and technology go hand in hand. There are "alchemists", who can conjure things, turn part of themselves into metal, etc. Mildly interesting. 8. Hunter x Hunter: A bit similar to #6, in that it seems childish, but has lots of gore in some places. 1) A kid wants to be a "hunter", the meaning of which isn't really explained, but it's a kind of special agent. Candidates have to do a gruesome test; after the test, there are some quests, among which is "Greed Island", a computer game that you can enter physically. 9. A Record of Lodoss War: D&D-style fantasy done by mangaka. Not bad. 10. Kirara: A girl dies in a car accident on the way to her wedding. Her ghost comes back, but somehow ends up in the past -- her husband-to-be is in junior high, and, to complicate matters, so is she (or rather, a younger version of her). 1) len(x) vs x.__len__()This seemingly simple problem had me stumped for a little while. Let's say you have a class that functions as a wrapper around another object. Something like: class P: def __init__(self, obj): self.obj = obj Now, is there a simple way to delegate all 1) method calls to an instance of P, to the object it wraps? (Simple, as opposed to defining all these methods yourself.) Including magic methods? Certainly. The solution is: class P: def __init__(self, x): self.obj = x def __getattr__(self, name): return getattr(self.obj, name) p = P("hello") print p.__len__() # 5 print p.__getitem__(0) # h print len(p) # 5, again print p[0] # he q = P([1, 2, 3]) q.append(4) print q # [1, 2, 3, 4] I have known the class P(object): Try it, and watch the behavior change. Sure, After looking around a bit in the c.l.py archives, it seems that for new-style classes, By the way, this version of def __getattr__(self, name): print "__getattr__:", name return getattr(self.obj, name) The script then generates this output: __getattr__: __len__ 5 __getattr__: __getitem__ h __getattr__: __len__ 5 __getattr__: __getslice__ he __getattr__: append __getattr__: __str__ [1, 2, 3, 4] 1) The lisping snakeThe time has come to look at integration of Python code with the Lisp interpreter. It's far from complete, but this time seems as good as any. The main problem is the difference in types. The Lisp interpreter currently uses several special objects: LispInteger, Pair, LispSpecialAtom (for Let's look at some (hypothetical, for the moment) example code. (setq os (py-import 'os)) (funcall (py-getattr os 'path 'join) "foo" "bar") => "foo\bar" Two conversion problems occur here: once when we call os.path.join, because the LispStrings "foo" and "bar" need to be converted to Python strings; and once when Lisp gets the return value back, in this case a Python string that needs to be converted to a LispString. This is all fairly simple. But now consider: (setq f (funcall (py-builtin open) "myfile.txt" "r")) (setq poplib (py-import 'poplib)) (setq pop (funcall (py-getattr poplib 'POP3) "host")) The Lisp interpreter now has several objects: a file object, a module, and a POP3 instance. How to represent these in Lisp? I wonder if it's best to use a thin wrapper class, call it PythonObject. PythonObjects can then be manipulated by selected "py-" functions. (For example, a file object wouldn't have dedicated Lisp functions to deal with it, but you would be able to use its methods and Python functions through the py- interface.) This would work, but we would still need an extra step or two to convert numbers and strings and such. Thoughts welcome. -- Generated by Firedrop2. |