Specific Domain Language Examples:

  • Awk:
    • process text files
    • unix/linux command line tool
    • used in conjunction with others
      • e.g. grep
  • VHDL:
    • VHSIC hardware description language
    • design and simulate hardware/circuits
    • can test virtually before building
  • HTML:
    • mark-up for web pages
  • Maple/Mathematica/Matlab:
    • mathematical computation
    • include visualization e.g. plotting
    • often used via interpreter
  • SQL
    • relational database management
    • several dialects
  • R / S
    • statistical computing languages
    • often via interpreter
    • R includes graphics and visualization
  • latex:
    • markup language for generating text documents
    • not WYSIWYG => little more work to learn
    • high quality publication
    • easy to change layout style

Using DSLs

  • use them on their own
  • or, with other languages
    • many have bindings to other programming languages
  • ODBC(windows)-JDBC(java)
    • bridge using SQL inside Java
  • Advantage: use a DSL where it is strong
  • Disadvantage:
    • code can got very complicated
    • can be hard to understand
    • easy to introduce security holes
      • pass strings poorly can lead to an injection attack
  • can use them in conjunction with other languages and/or applications
    • latex => temp
    • PDFLatex => pdf
    • PDF Viewers to view
  • Fragile
    • might not be portable between environments
    • each application could change separately
  • blurry line between DSLs and libraries
    • inference engine (library) vs Prolog
    • sometimes you have the choice: both are available.
  • Libraries are often easier to use
    • flexibility & power of a general purpose language
    • specific functionality of library
    • easier to set up projects and compile
  • At some point, a separate DSL makes more sense (e.g. SQL).

Mix Language Programming

  • some languages are great for developments
  • some languages are very fast in terms of processing
  • working in one language, but you want to use a library available in another language
  • interprocess communication
    • sockets, network calls, message passing
    • this can be slow and messy
  • compilers can sometimes compile different languages to object code then link them together
  • multi-threading <- requires that all can run in the same execution environment/VM
    • SWIG: simplified wrapper and interface generator
    • allows access to C/C++ libraries from Python, Java, Ruby, Perl, etc.
  1. Write everything in dev-friendly language such as Java or Python (only worry about big O)
  2. If slow => use a profiler -> will tell which code is slow
  3. Optimize that part of slow code
  4. Rewrite that part in C and call it using SWIG
  5. test it
  6. If the slow functions are pure function => try parallelize it.
  7. Look at clustering tools if necessary