Structural Diagrams for C - c

I am trying to read and understand the source of an existing C project. I keep feeling like it would be great to draw a UML Class Diagram for it to help me understand the high level relationships better, but of course - there are no classes to model.
Is there a formal diagram system that is used to model module relationships in a non-OO language? One that would be on a similar level of abstraction to a UML Class Diagram.

One alternative is to use Doxygen to map your function tree.

The OO paradigm is not a property of programming language and it's very possible to make OO implementation in C (just hard and not very intuitive). The OO design (in UML or any other modeling language) is not bound to a specific language.
Now let's get back to your question. There are many tools available for non-OO design. You can find a nice summary here and choose what fits you best.

Try FMC ( http://www.fmc-modeling.org/home) and "Apache Modelling Project" (Apache HTTP Sever modeled using FMC: http://www.fmc-modeling.org/projects/apache) as a starting point and guideline.

Related

How is abstraction realised in a system?

Some say abstraction is achieved through abstract class, while others say it is achieved through encapsulation. I am confused, would someone advise?
'Abstraction' is a very vague word covering many.many ideas in programming (and system design)
abstract classes are a very concrete mechanism in some languages.
encapsulation is a common object oriented design pattern used in some languages
Are these 2 models used for abstraction, yes. Are they the only ones, no.

Programming Paradigm Beginner

easy theory question.
I have a couple years experience with PHP and Javascript, trying to branch out into other languages and to connect my experience with some theory.
Have been reading about programing paradigms like imperative, functional, object-oriented, etc. Is there any reason, within a particular program, to commit to one paradigm or another? I can think of reasons to mix, say, object oriented statements with functional statements, but then yo read about like, whole languages that 'belong' to a paradigm (like Lisp and functional programming, for example)
Is there any reason or advantage to commit to a particular paradigm, or is it okay to just roll with what works?
Most software today is built using Object Oriented Programming, because this paradigm makes it easy to organize large amounts of code. With that said, the more paradigms you know, the better.
One particular paradigm of interest is functional. While pure functional programming isn't used very often in industry programming, a lot of the ideas are currently spilling over to Object Oriented languages like Java and C# (like the concept of first class functions, and avoiding mutation). Once you learn new paradigms, it'll change (and often improve) the way you program in other, more common or popular programming paradigms.

Using UML for C programming

I'm developing an embedded software based on standard specification.
The software is big and I need a design of my software before start coding.
the UML is an object-oriented language and could be a solution but I don't know how to use it for C softwares.
are there any document which help to use UML for C programming ?
or are there another design language for c softwares ?
Well we use Enterprise Architect to model our embedded software although we stop short of generating the code. EA can generate C code as well although we use C++ code because it feels more natural combined with UML. You can try it out and see if it fits your needs, it is not unforgivingly expensive either. It can also reverse engineer your C code so that may be a help.
Yes, you can, mostly because of two reasons:
You can actually do Object Oriented Programming with C (although it is tedious and not completely advisable), there a few books on the subject that you can read.
You can still use class diagrams to model data structures and static methods. But UML is not just about class diagrams: you also have state diagrams, interaction diagrams, use case diagrams... And they are useful for structured programming too.
I am not an expert for embedded software but have you look to https://www.polarsys.org/ ?
"PolarSys is an Eclipse Industry Working Group created by large industry players and by tools providers to collaborate on the creation and support of Open Source tools for the development of embedded systems."
It is a platform based on Eclipse dedicated to embedded software.
It use Papyrus for UML/SysML modeling and implement MARTE profil.
"Papyrus is the PolarSys solution for SysML and UML modeling. It relies on the underlying Eclipse platform and on other Polarsys and Eclipse-based offerings to fulfill lifecycle integration needs, such as a C/C++ "
I have two products in mind that could help you:
LieberLieber Software Embedded Extension, which is based on EA and gives you an idea about UML and C or
Eclipse Papyrus, which supports UML and SysML

Modelling C Programs

I have done some research on this question and most answers are a few years old or suggest just using text.
I need to model some C code I have developed for an embedded system. It is not massively complex but there are a great number of functions and UML does not appear to cover it as this is working on the pretense that the language to be modeled is object orientated.
Whilst I have read that it isn't far fetched to modify this and still use it to try and model C I wondered what thoughts people had on this or if anyone had any suggestions for how I could professionally document or model my code?
You should take a look at the Gtk documentation and the GTK-Doc tool:
http://www.gtk.org/documentation.html
It is a big API and it is pure C.

How to pick a language for Artificial Intelligence programming? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 6 years ago.
Improve this question
What is the best programming language for artificial intelligence purposes?
Mind that using suggested language I must be able to employ any AI technique (or at least most of them).
All the cool bearded gurus in what's left of AI research use Lisp :)
There are two big camps: Common Lisp and Scheme. They have different syntax, etc. Lots of good stuff written for both.
Java is a very popular all-purpose language but a lot of the interesting stuff in AI / Functional Programming, such as passing closures as first-order objects, is clumsy to do in Java.
My personal preference would be to stay away from Windowsy languages like C# and F#. Cool people develop under Unix. Or Linux if they're cool but poor.
Some cool but weird people program in Haskell. A reasonably modern FP language with good performance. I tried it once, it made my brain hurt; but you might be smarter than I am.
UPDATE: Answers to Steve's questions.
I wouldn't be the one paying for a Unix variant; that's what corporations and research institutes do. The idea is, you want to be doing AI research for an outfit that sinks millions into their hardware and doesn't balk at paying a few thousand for an operating system. That's the kind of outfit likely to have good food in the cafeteria and/or pay well for doing fun work. But I'm certainly not knocking Linux.
F# may be cool but I see a whole raft of issues getting it to run on Linux or any other Unix (that's what I meant by "windowsy"), and I don't want to work under Windows (that's what I meant by "personal preference").
To elaborate on the "windowsy" theme: You mention that F# is an OCaml variant. From my own admittedly brief research, it seems that F# is missing functors, OCaml-style objects, polymorphic variants and the camlp4 preprocessor. A functional language without functors? Really? If one were disposed to not like Microsoft, as I admittedly am, one could conclude that they had gone ahead and crowbarred a perfectly good functional language, OCaml, into something they could get to run in their CLR so they could claim to "have" a functional language. Finally, because I don't suspect, I know that Microsoft always prioritizes market dominance over product quality, I don't plan to touch F#. But this is my personal preference, and clearly identified as such, while we're really more concerned with making a good recommendation for mary.ja45 .
I have better reasons to recommend Lisp over F# and even OCaml and Haskell. These are mostly based on the historic preponderance of Lisp over any other language in the AI field.
The bulk of AI literature is based on programs written in Lisp or Prolog. If nothing else, good knowledge of Lisp would allow a student to understand the sample programs. My personal favorite AI megaproject, Cyc, has runtimes in your choice of Common Lisp or C.
In the TIOBE index of programming language (as seen and used in industry), Lisp takes 15th place while Haskell takes 43rd and F# and OCaml place below 50th. Presence on the market correlates with employment opportunities, naturally.
That said, it's quite possible that a number of the younger "AI interesting" languages are poised to skyrocket. If some major research institute published some groundbreaking, defining-the-field research in, say, Scala, you'd see Scala's popularity advance sharply in the research community and, with some lag, in industry.
I (obviously) can't comment on F#'s other qualities but you're as welcome to make recommendations as I was.
Python seems to be used a lot in the general scientific community. It has a lot of libraries available and it's easy to learn.
I'll throw Scala into the pot.
it's usable for functional programming
it can be made as fast as Java
it's a modern language with lot's of nice aspects
Java seems to be a bit popular in AI, too and so you can use all those Java libraries from Scala
I've solved all exercises from a basic AI course in Scala. It worked really well.
If by "all of AI" you also mean machine learning, which I guess, Matlab, R and Python+Scipy should definately be mentioned.
I personally use Clojure for AI programming, and have found it to be a great all-rounder AI language.
Reasons:
It's a Lisp, and Lisps have historically been very strong the the AI field
It's a homoiconic language with powerful macros, so great for code generation and genetic programming. This is a surprisingly useful property for AI programming (and possibly explains some of the success of Lisp in general in this space)
It runs on the JVM and can easily access all the Java libraries for number crunching (Weka, Colt, etc.).
It's good for rapid interactive development - it's very dynamic and you can do pretty much everything interactively in a running Clojure REPL. No need for recompiling etc.
It matters probably whether the programming environment is academic or not, but for most non-academic AI application development I would recommend sticking with a mainstream language like Java or C++. One needs to be able to interface readily with other COTS or open-source software packages, and this can sometimes be difficult or impossible in more "exotic" languages. For academic work this may be a less critical issue.
Additionally, performance can be important for many applications, and mainstream languages generally have the most heavily-optimized compilers, e.g., C++ or Java.
It is true that functional programming languages like LISP, Scheme, etc have specialized features that may make it easier to implement particular AI methods, but I do not believe this to be true for AI-related programming as a whole, e.g., quantitative machine learning methods usually don't require a functional language. If you need access to both functional constructs and general software packages, there are some tools for LISP to help with this, and the recently-developed Clojure is a LISP-variant that runs on the JVM and can access Java libraries. Also, Groovy is another JVM-based language that includes support for closures.
Lastly, some programmers like paradigm flexibility and/or fast prototyping for AI projects. Ruby and Python both see some AI-related usage for this reason as multi-paradigm languages that can also be used for scripting.
Like most things in programming, the best answer for which language to use in AI development will ultimately depend on the needs of your projects.
It really depends on what kind of problem you are looking at. Also, how "deep" you want to go into AI stuff. If you want to learn from the basics and just implement theoretical AI stuff, go with a higher level language-- as in functional programming (and proven in AI) like lisp, or prolog. If you know what problem set you are dealing with and want efficient, go with something like Java, C++ and use a toolkit to do the stuff.
Since you mention Machine Learning look into Weka Toolkit in Java for some of these stuff.
Pick the programming language with AI techniques the same way you pick a language for any other project:
What is the problem you are trying to
solve?
Is there good support available for
the language?
What are the customers requirements?
I would recommend Prolog as a very good programming language used to implement AI systems.
There is no "best" language. Each one has its merits. When I studied AI, mostly we worked with lisp and prolog, but I've been most productive in AI with Java/C# and F# has a lot to offer.
How about a framework written in Java, supporting "High Level Logic" and agent style communication.
http://highlevellogic.blogspot.com/2010/11/when-will-we-have-artificial.html
It also depends on the size of your dataset. For web-scale datasets you may want to use Map-Reduce and that implies Hadoop. Hadoop is in Java -- but you could use any language (Python, etc.) for your Map-Reduce functions.
There is also a java framework called weka, developped by the university of waikato. I don't know wether it anwsers your question, but it may help.
Quoting wikipedia: «Weka supports several standard data mining tasks, more specifically, data preprocessing, clustering, classification, regression, visualization» and more.

Resources