Simon Willison’s Weblog

Subscribe

Items tagged programming in Oct, 2010

Filters: Year: 2010 × Month: Oct × programming × Sorted by date


Why does Python load imported modules separately for different files, unlike C or PHP? Isn’t that inefficient in terms of memory usage?

It doesn’t—you’re misunderstanding how Python’s module system works. If two different places have “import os” in them, the os module is only imported and executed once—it’s cached in the sys.modules dictionary so you can see it happen if you want to. The key thing to understand is that “import os” attaches the os module to the “os” symbol within the current file’s scope, loading it only if it hasn’t been loaded already.

[... 104 words]

What is the best way to maintain a API wrapper class across multiple languages?

1. Use JSON for your API. That takes away a lot of the necessity for an API wrapper, since it means you’re automatically returning native data types (hashes, lists, strings etc) for most programming languages.

[... 175 words]

What are the main weaknesses of Ruby as a programming language?

Ruby still has a cultural tendency towards monkey-patching, aka action-at-a-distance. There are plenty of gems which modify existing classes—sometimes in ways that can break working code.

[... 45 words]

What companies are using Node.js in production in Texas?

There’s a list on this page: https://github.com/joyent/node/w...

[... 23 words]

Is there a way to learn Ruby in one hour?

Not unless you already know a bunch of other languages and are well versed in programming language theory. Even then, that might be long enough to get your head around Ruby syntax and semantics but it will still take weeks or months of study to get truly comfortable with the language idioms.

[... 76 words]

Why do so few companies use the Dojo Toolkit?

Dojo is fantastic software, but it does a lot more than the other libraries and consequently has a much higher learning curve. It’s advanced features may serve as something of a disadvantage for achieving more widespread adoption—most developers don’t need the more advanced abstractions provided by Dojo when they start their projects, and by the time they DO need that stuff they’ve already written a ton of code using another library!

[... 88 words]

What company had the first API?

They weren’t the first to have an API, but Flickr were the first consumer web site that really pushed the concept in my opinion. They originally promoted it as “you can always get your data back if you want to”, but they then greatly benefited from the ecosystem that grew up around it.

[... 65 words]

What is a painless way for a non-Unix programmer to get started learning Unix or GNU/Linux?

I’d suggest getting yourself an Ubuntu virtual machine running on your own laptop—VirtualBox is free, so that’s a good starting point. That way you can play with Linux all you like without fear of breaking anything, since you can always delete the image or roll back to a snapshot.

[... 73 words]

Is it important for modern programmers to know how to use Unix? Why?

I’d say yes. If you do any kind of server-side development, Linux/Unix etc UNIX (links to: /topic/Unix), etc., is where most of the exciting innovation is happening. Tools like HadoopApache Hadoop (links to: /topic/Apache-Hadoop), RedisRedis (links to: /topic/Redis), MongoDBMongoDB (links to: /topic/MongoDB), nginxnginx (links to: /topic/nginx), git etc Git (links to: /topic/Git-version-control-1), etc., all come from a Unix UNIX culture, and not knowing your way around a command line makes it much harder to get to grips with them.

[... 110 words]