modeling - Is UML a programming language?

ID : 274525

viewed : 42

Tags : umlmodelingmodel-driven-developmentuml

Top 5 Answer for modeling - Is UML a programming language?

vote vote


I'm going to go against the general trend and share an experience that shows what UML can do today, and what some future version of UML (or another modeling approach) could be.

First a bit of history.

Way back when, people programmed computers in assembly (not going ALL the way back here). Then along came higher level languages like C and Basic. Programmers that were very good in assembly argued that you can't fully express everything the processor is capable of doing (in an optimized manner) in a higher level language. In fact, they were right. Some things were much less optimal from a memory and performance perspective in higher level languages because you could not fully control the instructions issued to the processor.

The thing is, higher level languages provided a much more abstract form of expression. So, they caught on and after a while, people didn't really care that you could not fully control every aspect of the processor because the developers were so much more productive (Moore's Law also helped).

Similar rounds happened with object oriented languages, and again with managed languages. Each time, a higher level of abstraction became available and eventually won out because it was more efficient to use as a developer. In fact, generally inefficiencies in the higher levels of expression disappear as compilers become better and optimization techniques improve.

Model driven development is a higher level of expression. You cannot fully represent any code you could write in, say, C# or Java. Especially not out of the box. However, it is possible to generate a very substantial portion of an application directly from a UML model.

I led the UML-based code generation effort for several rather large projects. In many cases, we could generate 30% to 60% of the entire source code of the (real life, enterprise-class) applications. And that's just with a small team writing generators for a particular domain. Eventually, an entire industry will be behind tools to generate more and more of real-life application from models.

That is the next step in the natural evolution we have seen in our industry time and time again, ever since the first assembly codes abstracted opcodes (there was probably something before that, but that was before my time).

vote vote


Short answer: no. Some UML modeling tools can generate Java, C++, and code in other programming languages. However, what it generates are usually interfaces and class relationships. These tools generate stubs for which the implementation still needs to be provided, so human intervention is necessary.

vote vote


There are some tools to convert UML modeling diagrams to into code - specifically, UML state diagrams. For example, I used a tool called "Rhapsody" (from I-Logix) back in 2000 that would convert a UML diagram to C++. It was cool because the tool could run the state machine directly, and could also run code on a remote machine (in this case, a board running vxworks).

But generally speaking, UML is best used as a modeling tool. Use it to model your system and provide diagrams for your design papers, or whatever. Then use that knowledge to develop your system in an organized manner.

vote vote


In theory? Yes - you could use a gajillion state machine diagrams and specify everything in painstaking detail, then connect the state machine diagrams to methods in your class diagram and run some horribly complicated tool to generate all of this.

But this isn't something you'd want to do. You won't be getting any more freedom in the way you express yourself, because you have to use the right kind of syntax so that the tool will understand everything you write. Not only that, but you'd be able to write the actual code yourself in far less time than it would take you to make all of those diagrams - and the only thing it gives you is that the code is a carbon copy of the spec (because the spec generates the code). That may be a good thing, but since you have no actual code, that also means that debugging means debugging the diagrams - and that is almost surely going to be near impossible.

vote vote


UML can model a state machine. Thus, it can represent a Turing machine. A compiler with enough sophistication can read this representation and create a binary (executable) representation of the Turing machine.

So, my answer is yes.


Since my answer seems to be disagreeable to some... let me clarify that this "compiler with enough sophistication" is completely imaginary and probably far in the future... but it seems from the other answers, there are some programs that can generate some boilerplate code or even generate and run a whole program.

I think that proves that UML (or some subset of it) qualifies as a programming language, but probably not a good one.

Top 3 video Explaining modeling - Is UML a programming language?