Thread Closed 
 
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
FAQ: Why Erlang?
03-22-2015, 07:28 AM (This post was last modified: 03-22-2015 07:28 AM by micheus.)
Post: #1
Exclamation FAQ: Why Erlang?
Not to be lost - from the original thread in the old forum by bjorng.


Why is Wings implemented in Erlang and not in C or C++?

I did not know that Wings would be so popular that other people would want to help developing it or trying to write importers for the Wings file format. I just wanted a decent 3D modeler for my own use.

I started implementing Wings because it was not possible buy Nendo at the time (in 2001). I wanted to do some 3D modeling and I had played around with the Nendo demo and liked it. I realized that implementing multiple Undo would be trivial in a functional language (Nendo had one level of Undo).

C/C++ was out from the start. I wanted a language with automatic memory handling so that I didn't have to worry about allocating/freeing memory myself, and I didn't want to spend a lot of time in low-level debugging to find pointer errors and memory leaks (I do enough of that in my day work, so I didn't want to do that in my spare time too).

My idea for implementing multiple Undos would not work in Java, so Java was also out.

Since I know Erlang very well (since I work with Erlang's run-time system and Erlang compiler in my day work), Erlang was the natural choice.

Other possible choices would have been Scheme or Lisp, but I don't know those languages nearly as well as I know Erlang. (Although Scheme and Lisp can be used in a functional style, they can be used in an imperative style as well; the mix of imperative and functional style (properly used) could have had advantages. A disadvantage with Lisp/Scheme is that there is no pattern matching.) An interesting language if I had started today would be Haskell.


Will Wings ever be re-implemented in C or C++ (or some other language)?

I have no intention of doing that.

But feel free to start your own Wings-rewriting project.


What are the strengths of Erlang?

Concurrency and support for Symmetric Multi Processing (i.e. using all processor cores in modern computers). But Wings doesn't use that at all (yet).

Another strength is pattern matching. Instead of complicated ifs with ANDs and ORs, you write a pattern for what you want to mach out. That makes Erlang good for implementing complex 3D modeling commands (and for implementing complicated telecom protocols and web servers).

That Erlang is functional. A functional program is easier to test.

Memory handling: It is easy to create dynamic data structures containing many small objects. In C/C++ you would typically have to use write custom memory allocators to achieve acceptable performance (or used fixed arrays, but then there will be limits for the user).

Dynamic typing. You don't have to declare any types; type errors will generate an exception at run-time. Since exceptions can be caught, it is possible to recover from most bugs (i.e. the user doesn't usually lose his work even if there is a bug).


What are the weaknesses of Erlang?

Erlang can't match C in raw performance. (Erlang programs are not compiled to native code, but to the instruction set for a virtual machine.) For instance, the '+' operator in Erlang can operate on both integers of unlimited length and floats, and the types of the operands are only known in run-time (but the compiler does some optimizations for floats). But working in Erlang, I can usually implement a new feature quickly (and have it working without bugs), and then spend some time optimizing the performance it it is not fast enough (perhaps using a more complicated but more efficient algorithm that would be difficult/time consuming to implement correctly in C). Working in C, there is much more work go get something working at all, and then there can be subtle memory problems that you don't find out until later.

Dynamic typing (yes, it is listed as a strength too). Most type errors will only be found at run-time. But there is a tool called Dialyzer that can analyze an entire Erlang application and find type mismatches.

My Wings3D Collection at G+
Thread Closed 


Forum Jump:


User(s) browsing this thread: 1 Guest(s)