Posts filed under 'programming'
Recently, I stumbled on the Io programming language. It’s a cool language, primarily because of its elegant simplicity. In fact, the entire website of the author is quite interesting and similarly elegant through simplicity, as his quotes page suggest not entirely by accident.
Although I cannot find the web links that brought me from one to the other, reading about this language made me read briefly about an older language under the same name, Io, of which the only main presence is a reference to it in Raphael A. Finkel (1995), Advanced Programming Language Design, which turns out to be a freely available book with really very interesting content. So, the last few days I have been reading the first couple of chapters from this book.
Stumbling from one interesting site about language to another, I just now stumbled on this description of the Q-BAL programming language. A language designed purely for fun, not for any practical use, but it’s pretty cool, again due to its simplicity, but also because of its twist of thinking in terms of queues instead of stacks.
All this is obviously distracting me from more urgent work / research, but it is pretty interesting reading. So many programming languages in the end look so similar, either object-oriented or imperative with very little variations, that it is refreshing to read more about how functional language work or what kind of other variations one can think of.
May 30th, 2008
Based on this post in Andrew Gelman’s blog, which I read religiously, I wrote a little R template for the bootstrap procedure. Well, the template is simple, but the cool thing is that it tells you when it is finished, so you can stop going back and forth to the R window to check whether it’s done. This one is fast, but for a long, slow procedure, that’s pretty cool. Alas, only works on a Mac (and perhaps Linux?).
x <- rnorm(100,3,2)
bs <- NULL
for (i in 1:1000)
{
bs.sample <- sample(x, length(x), replace=T)
bs[i] <- mean(bs.sample)
}
system(sprintf("say The bootstrap has finished. The result is a mean of %4.2f, with standard error %4.2f. You can access the result with the b s variable.", mean(bs), sd(bs)))
October 28th, 2007
R already has a function called ls(), which simply lists the names of all objects in the current environment, and ls.str(), which does so with a lot more information. I wanted one that looks a little more similar to ls -l in a Unix environment, so here’s a start:
my.ls <- function(envir = as.environment(-1)) {
names <- .Internal(ls(envir, all.names=T))
for (item in names) {
l1 <- length(get(item))
l2 <- ""
if (!is.null(dim(get(item)))) {
l1 <- dim(get(item))[1]
l2 <- sprintf("%10d", dim(get(item))[2])
}
cat(sprintf("%-30s %-10s %-10s %10d %10sn",
item, class(get(item)), mode(get(item)), l1, l2))
}
}
April 29th, 2007
I quite like this little page by Peter Norvig on how to become a good programmer. One quote I like: “Learn at least a half dozen programming languages. Include one language that supports class abstractions (like Java or C++), one that supports functional abstraction (like Lisp or ML), one that supports syntactic abstraction (like Lisp), one that supports declarative specifications (like Prolog or C++ templates), one that supports coroutines (like Icon or Scheme), and one that supports parallelism (like Sisal).” But he has generally interesting comments.
January 4th, 2007
Because of a project I am planning with a friend of mine, I have been spending a little bit of time studying Ruby on Rails in more detail. So far, I’m quite impressed. Ruby on Rails is a scripting language similar to PHP or ASP, but it also handles a lot more behind the scenes than any of those languages do. With only very few lines of code you can set up a page to list items in a database, edit them, delete them, etc. By just creating a table in a database and one command you can tell the system to create the scaffolding of an entire application. You of course end up rewriting most of the scaffolding to customize the page to your requirements, but it makes it incredibly easy to test parts of the site, since all is working at least in a preliminary sense within no-time. It’s like a scripting language on top of a game engine - the whole engine for the website is there, you just need to script the particular use you want to make of it.
I’m reading The Pragmatic Programmers - Agile Web Development with Rails now, which shows how to develop a basic shopping cart application, while demonstrating all kinds of good programming practice: separating layout from code; testing habits; etc. Really quite nice and quick to read. After this, I should be able to develop a website using Ruby on Rails in no-time.
December 23rd, 2006
Finally finished reading The Practice of Programming. This presentation by one of the coauthors is kind of interesting / funny, about the good, bad, and ugly of Unix, one billion seconds after its creation. It is particularly interesting to read after the last chapter of their book.
Another interesting presentation by the same author describes how innovation is stiffled by Unix’s ubiquitousness. Quite interesting as well.
October 27th, 2006
Still reading Kernighan & Pike, The Practice of Programming, which I like a lot, and made me more curious about who this Kernighan guy is. So I checked his website, followed some links, and get more and more interesting information, way too much for me to actually read today. So here’s just a few links so as not to lose them:
- Brian Kernighan’s homepage, with a few links about the books, some source code, etc.
- Paper by Dennis Ritchie on the history of the C language
- Martin Richards’ homepage, a professor in computer science at Cambridge, who has links about some of C’s ancestors, and who seems to have modern applications with really old programming languages, including on a small Linux-driven gaming device. Definitely want to spend some more time studying this site sometime!
- User’s Reference to B, one of C’s prime ancestors
- The Programming Language B
- A very old C Reference Manual
- An old C Tutorial by Kernighan; this and the above are mostly incorporated in their The C Programming Language
- A technical note on calling sequences in C
- Presentation by Ritchie about ‘five little languages and how they grew’, on Bliss, Pascal, Algol 68, BCPL, C
- A proposal for variable-size arrays by Ritchie that was not implemented in the C standard
October 23rd, 2006
After seeing my boss’ hand in bandage due to using the computer too much, I’m wondering whether it would be possible to develop a VoiceIDE, an IDE based entirely on voice commands. The programming language itself would probably have to be adjusted to be easy to pronounce. E.g. try to say a regular expression out loud! Kaya might actually be well on the right track, with largely text-based commands instead of too many () and []. But it should be possible to improve on that.
It would involve:
- Building a good GUI;
- Developing a new language incl compiler and debugger;
- Using speech to text and text to speech modules;
- Building a nice programming interface that automates wherever possible.
Using voice commands requires a lot of differences with regular IDEs, like commands to quickly move around your code, interfaces to select variable names, etc.
If developing a new language, it would be nice to have a language that is elegant and safe, like Kaya, but that creates code close to C speed. So it should still be fairly close to computer language and allow for a lot of flexibility, like pointers. All added safety comes at a cost of less flexibility, though, so this requires a lot of thinking.
Another idea I had was to perhaps rewrite the Kaya compiler in C. Try to make it run much faster than the current compiler and in the process write out the documentation, since that is still practically absent. But I should first have a really close second look at Kaya whether it is really worth investing any time in.
October 20th, 2006
Not much new to tell. Have been reading a few chapter thus far in Kernighan & Pike, The Practice of Programming, which is a very good introduction to, well, programming. Very basic concepts, most of which I already knew, but very well laid out and good to sharpen my skills. I’m anxious to spend some time doing their exercises, but without a computer at home that will have to wait, I suppose.
Their somewhat silly example of a random text generator made me think about how to implement some code that reads the news and then runs some kind of factor analysis to group articles. So that might well be my next coding project - something different from online games (just read an extensive blog which convincingly argues how dangerous those games can be) and even kind of related to my studies.
Also discovered that Neoware is going to sell a thin client laptop. This means a laptop without harddisk, so that the prime use is through networking, including remote desktops and SSH. Cool idea, were it not that it does not actually lead to a cheaper laptop - they still charge $800.
October 19th, 2006
In relation to a query by an client, I had to look up a bit of information about memory management. There is a very interesting page on Unix and C/C++ Runtime Memory Management (I read up to here) and Micah Altman gave an interesting presentation on the subject.
Earlier today I have to go to the library in the applied sciences faculty and there were several seemingly very cool books. One was by Bill Blunden, Virtual Machine Design and Implementation in C/C++, about the design of the HEC virtual machine. Seems intruiging, although a lot of plain code instead of text. Another book was called Computer Arithmetic, by Parhami, about the real nitty-gritty details of the algorithms and circuit designs used for processors to do arithmetic.
Last night I looked at some presentations about Ruby on Rails. It’s intruiging - about three lines of code to have a complete online form linked to a database etc. It just basically automates an enormous amount of coding between the SQL database and the webpage to maintain it. Useful for many applications, I think, but not really for online game design. It feels like giving up a little bit too much control, though, but that’s just a feeling
.
I also spent a tiny bit more time on Kaya, trying to see how the webprog library works. It’s badly documented and the tutorial is outdated, but the source code of the library is simple enough to figure out what to do. I miss syntax highlighting in Emacs, though! The webprog part makes it quite easy to write proper webpages in Kaya code without being too much bugged down by HTML syntax, which is nice. Here’s the tiny sample program I tried:
webprog webhello;
import Webprog;
import HTMLDocument;
HTMLDocument webmain()
{
doc = HTMLDocument::new(HTML4Strict, "Test webpage");
blog = addDivision(doc.body, "My blog", "blog");
return doc;
}
Which, after very slow compiling, produces:
Content-type: text/html; charset=UTF-8
My blog
In other words, I did not have to worry about any HTML syntax, and I can determine all layout issues with CSS by simply using the
Maybe I really should consider working on an Emacs environment for Kaya and a GeSHi language file to make the above sourcecode look nice!
October 12th, 2006
Previous Posts