Something is wrong with programming syntax
I never understood all this interest in DSL (domain specific languages). I’ve seen beautiful code done in a DSL-way (whatever it means) in all kind of languges from C to Lisp for ages.
I suppose the emergence of Ruby and the renewed interest in Smalltalk and lisp-based languages like Clojure made DSL an interesting topic for blog posts.
But I must admit that maybe we need to explain what DSL means… or why a good API design is always needed, because:
// describe the optimization problem
LinearObjectiveFunction f = new LinearObjectiveFunction(new double[] {-2,1}, -5);
Collection constraints = new ArrayList();
constraints.add(new LinearConstraint(new double[] {1,2}, Relationship.LEQ, 6));
constraints.add(new LinearConstraint(new double[] {3,2}, Relationship.LEQ, 12));
constraints.add(new LinearConstraint(new double[] {0,1}, Relationship.GEQ, 0));
// create and run the solver
RealPointValuePair solution = new SimplexSolver().optimize(f, constraints, GoalType.MINIMIZE, false);
// get the solution
double x = solution.getPoint()[0];
double y = solution.getPoint()[1];
double min = solution.getValue();
About this entry
You’re currently reading “Something is wrong with programming syntax,” an entry on rogersm.net
- Published:
- 07.08.09 / 10am
- Category:
- programming
3 Comments
Jump to comment form | comments rss [?] | trackback uri [?]