“It takes 10 years to study, train and specialise in order to be a M.D that prescribes radiation therapy to people. It takes 3-4 years to do a Bachelor’s degree in order to be a programmer that codes the machine that blasts peoples with radiation.” I often open my OOP course with this sentence, trying to motivate SE students to take their programming skills seriously. A couple of days ago the New-York Times published a gruesome proof why that sentence presents a real problem. Apparently, software and configuration errors in linear accelerators (the machines that blast patients with radiation) caused numerous injuries and several death cases. Now it’s official: Bad code kills.
Continue Reading »
Guy Wiener on January 28th 2010 in Software Engineering
Prolog is not a functional language - Not yet, at least. Sometimes, that’s a shame, especially when you want to use meta-predicates such as “forall” or “findall”, and use a predicate with partial arguments as the goal - As you would have done in functional programming languages.
Luckily, that specific scenario is actually possible - In SWI-Prolog, at least. The “call” meta-predicate, and its derivatives, may take a functor and extra arguments as parameters. Then, the extra arguments are concatenated to the arguments of the functor, and the resulting functor acts as a goal.
If this is all Prolog-Chinese for you, here’s an example:
Continue Reading »
Guy Wiener on December 4th 2009 in Programming
I’ve returned last week from EUC’2009. My conclusion: If programming languages were stocks, and if I were a market advisor, I would put a “strong buy” recommendation on Erlang. If you have some spare “programming language money” (that is, the time and patience to learn a new language), put it on Erlang. It would be worth your while. Here are some reasons why:
Continue Reading »
Guy Wiener on November 18th 2009 in Programming
Mayer and mine work on self-application in Erlang is going to be presented on the Erlang User Conference 2009. Here is the full teaser:
Most servers and clients in Erlang are implemented as named procedures in named modules. Similarly, processes communicate via named messages. This exposes and fixes a great deal of information about an Erlang application: The names of the modules, procedures, messages between servers and clients, etc. This talk explores how to gain anonymity through the use of anonymous higher-order procedures.
To spawn a process on a node, one must either to use a module name and a function, or to pass an anonymous procedure. In order to use a function from a module, the module file must be available on the remote node.
For a server to receive many messages, the spawned function must be recursive. Recursive functions are typically implemented in Erlang via a name in a module. Running such a server requires that the client be aware of the names of the module, function, and messages.
Functional programming languages (such as LISP, Scheme, and Erlang), permit recursion to be replaced with self-application, which means functions that are applied to themselves. This is a classical technique from functional programming. In Erlang, this technique adds flexibility, anonymity and security. Specifically, we demonstrate how to
- Spawn a fully-functional server without requiring shared modules or access to the file system.
- Have client-server groups that take the message names as arguments.
- Use random and constantly-changing message names.
See you there!
Guy Wiener on October 12th 2009 in Programming
No-one is more dangerous than the supervisor of a failed system, who abandons the system, but keeps the loot: A position of power.
I saw that quote on the 1956 anti-communist students’ rebellion memorial in Budapest. (read: Buda-pesht. There is no such city as “buda-pest”. It’s a transliteration error.)
Without mentioning names, I can think of several engineering and programming practices that can fall into this category: Mistakes that are too collosal to admit; Practices that give power to the supervisor but no merit to the practitioner.
In the spirit of Tom Gilb, any development method should by itself be subject to development. Keep that in mind next time someone declares “the ultimate programming methodology” or “the last programming language we’ll ever need”.
(Btw: COBOL has just celebrates its 50th birthday.)
Guy Wiener on September 29th 2009 in Uncategorized
“Prolog” and “Hacking” are not two terms that are usually found in close proximity. In a matter of fact, most hackers I know do not consider Prolog as a programming language. Prolog is just that thing you learn in a principles of programming languages course, that demonstrates “what are declarative languages”. Afterwards, you forget about it and go back to program in some imperative language, just as Kernighan & Ritchie intended you to do.
You couldn’t get it more wrong.
Continue Reading »
Guy Wiener on September 12th 2009 in Programming
I thought that my trustworthy Dell laptop with 2 GB of RAM will serve me throughout my Ph.D, but that was before I had to develop an Eclipse plug-in. A single instance of Eclipse Galileo modelling edition chews up 360 MB of RAM just for starters. Running another instance in debug mode doubles the weight, at least. Pile upon that a couple of UML2 documents with their fancy editors, et voila! Half of the RAM is gone.
Why is that? Even the notoriously hoggish IntelliJ IDEA 8 doesn’t take that much RAM. I don’t know for sure how comes Eclipse became the new memory hog in town, but I have a guess: It has something to do with EMF.
EMF stands for “Eclipse Modeling Framework”. It’s the underlying layer that enables all those nice property sheets and graphical editors. Basically, it adds highly-detailed reflection to Plain-Old Java Objects (POJOs) by generating a massive amount of code. This reflection is needed for auto-generating all that fancy GUI, but it requires supporting data structures - And that shows up on the system monitor.
(Btw, if you’re willing to pay the price for reflection, why not use a language that have native reflection, such as Python, and get rid of those code-generated monstrosities? Just a thought.)
No solution this time. It is a ranting post.
Guy Wiener on August 4th 2009 in Uncategorized
Meta-languages and meta-platforms are usually perceived as a complicated solution - Meta-code is a tricky thing. That’s no excuse, however, to make things even more complicated than they should be. The mental cost of thinking in meta-terms is enough: You don’t have to throw other complications in.
UML was never lightweight - A standard that was rolled out with 9 different diagrams sounds more like a committee’s compromise that something usable. When you start using UML meta-programming platforms (”Eclipse Galileo modeling” edition is shipped with a few) you find out just how ridiculously entangled it has become. The excellent Acceleo framework uses 3 different meta-languages (UML, OCL and EMF) to generate Java code that can generate other code from a UML model. Suddenly LISP’s Meta-Object Protocol or Python’s Metaclasses seems like the simple solution. Don’t get me wrong - Acceleo, comparing to other UML-based solution, is a great framework - But enough is enough. It’s difficult enough to write a meta-program in a single language. Two languages are somewhat expected too - A language and a meta-language. Piling 3 or 4 different frameworks into meta-programming is not the right solution - It’s the result of desparately trying to handle an over-complex meta-protocol.
I have some code generation program that I need to implement. Eventually, it will be an Eclipse-based plug-in… But before that, I think I’ll hack it in Python.
(Btw, there are alternatives to UML: OPM and Planguage to name a few. More to come on this)
Guy Wiener on July 12th 2009 in Uncategorized
I’m a programmer. As such, it always shock me to see something that just works. That was my feeling when I managed to run Erlang’s pool module. The setup requires some attention, but after that, it’s insultingly simple.
To run an Erlang nodes pool, you need the following:
Continue Reading »
Guy Wiener on June 11th 2009 in Programming
The following Java code is legal, believe it or not:
public enum MyEnum {
INST1() {
public void foo() {
//...
}
},
INST2...;
}
What the f…?!
Continue Reading »
Guy Wiener on June 9th 2009 in Programming