Does D language have any "proprietary" baggage? [closed] - licensing

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about programming within the scope defined in the help center.
Closed 7 years ago.
Improve this question
I'm looking at D's licensing and see that the frontend is open source but the backend is not; what is the backend?
Why did GNU make gdc? Is it related to licensing?

There are different compilers with different goals. The frontend analyzes the source code, whereas the backend does the actual compilation. With the frontend being open-source, it can be used for multiple compilers.
DMD is the closed source default implementation of D. It is feature-complete, but may not be the best compiler performance-wise.
GDC uses the mature GNU compiler collection as backend. The same backend is widely used in C or C++ compilation and able of advanced optimization.
LDC targets the LLVM platform. This allows some interesting stuff like high-speed compilation, portable bytecode, and jitting.
As the frontend is shared across all compilers, one source file will parse the same way on every compiler. Compare this to C or C++ dialects.

DMD is just a reference implementation of the D compiler, just like, say, Glassfish is the reference implementation of the enterprise java application server.
DMD's backend has roots in DigitalMars C/C++ compiler. Makes sense as the original D creator is the the author of the DigitalMars C/C++ compiler, right? Walter could not legally completely open-source the backend because part of it has been made while it was in hands of Symantec...
Second, GNU did not make GDC - it was made by few enthusiasts, and hopefully will soon be merged into the GCC tree. GDC is GPL, simple as that.
LDC was also mentioned - it uses LLVM as backend.
What really matters is that D frontend is open-source. The fact that DMD's backend is not is irrelevant as there are so many alternatives. Both GCC and LLVM backends are superior to the DMD backend anyway.
If you are into compiler/interpreter design, I suggest you take a look at the SDC, MCI, and DIL projects. I think you have more information about them on http://wiki.dlang.org .

Related

Microcontroller IDE like simulink [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 2 years ago.
Improve this question
I have a query that, is there any simulation software available (like simulink in matlab) for micro controllers.
I have tested my system on simulink and generated a c code for it.Now I want to verify the code by running it on a micro controller simulator which also have such scopes etc(so i can easily verify my embedded code).
Xcos is a simulink analogous in Scilab very helpful for most who can't afford a matlab license. The Arduino library will help you making whatever project you want.
You can download it free here https://www.scilab.org/
Now I want to verify the code by running it on a micro controller simulator which also have such scopes et (so i can easily verify my embedded code)
You might consider a static program analysis approach. Tools like Frama-C or Coverity or Clang analyzer come to mind. But they are difficult to learn or use. If your code is compilable by some recent GCC-based cross-compiler, consider also developing your GCC plugin.
For some microcontrollers, you might find software emulators for them (e.g. sourceforge lists several of them). Qemu could be a possibility (but again, there is a learning curve).
See also this report....
Take into account your time (including learning efforts). You might decide that buying an arduino (or a RaspBerryPi) is cheaper than learning to use emulators for it. For example GCC is free software, but you'll need months of efforts to dive into its source code (many millions lines of code). Scilab is also free software. So is GHDL.
If you have access to the entire documentation of your micro-controller (including cycle times of every machine instruction), writing the emulator is also a possibility. Again, budget months of efforts. JIT compilation libraries such as libgccjit or libjit could be interesting to use for that. Or higher-level languages (e.g. SBCL).
Be also aware of Rice's theorem, C compilers like CompCert, and processor architectures like RISC-V or simulator frameworks like UniSIM
Notice that automatically assisted verification of C code reduce program bugs, but not software design bugs. You basically move bugs from programs to their specifications (as described by the V-model of software development). There is No Silver Bullet

What is LLVM and why is it so popular all of a sudden? [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 3 years ago.
Improve this question
In recent months, I have been seeing mentions of "LLVM" all over the place. I've looked it up, but the description of a "modern compiler infrastructure" doesn't really tell me anything. I can't find much about it, other than some mention of a c compiler that comes along with it (which doesn't seem to be any different from any other C compiler out there.)
Is there some difference between this LLVM thing and any other compiler, say, GCC? Or is it an over-hyped replacement benefiting from being newer than the competition?
There is some academic literature on the matter, I recommend the AOSA book chapter on it, written by the principal author (Chris Lattner).
LLVM is a collection of libraries built to support compiler development and related tasks. Each library supports a particular component in a typical compiler pipeline (lexing, parsing, optimizations of a particular type, machine code generation for a particular architecture, etc.). What makes it so popular is that its modular design allows its functionality to be adapted and reused very easily. This is handy when you're developing a compiler for an existing language to target a new hardware architecture (you only have to write the hardware specific components, all the lexing, parsing, machine independent optimization, etc. are handled for you), or developing a compiler for a new language (all the back end stuff is handled for you), or when you're doing something compiler adjacent (like analyzing source code, embedding a language in a larger application, etc.).
In order to support this, LLVM employs a pretty sophisticated internal representation (called the LLVM IR, creatively enough) that is basically assembly language for a theoretical hardware architecture designed to make targeting it with a compiler very easy. Most of the LLVM libraries take the IR in, operate on it, and output the modified IR, supporting the project's aim of modularity. This is in contrast to GCC, which (historically, I haven't checked recently) has a less complete IR and thus the separate phases of compilation are very tightly coupled because they have to share a lot of information.
Clang is the flagship compiler built on the LLVM framework.

what compiler should I use as case study for self studying compiler principles techniques [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 7 years ago.
Improve this question
I decided to start studying compiler theory but the problem is that I want a compiler for any language in order to track each of
lexical analyzer output.
syntax tree.
intermediate representation.
code generation.
I dont care for optimization right now
I am aware of some questions similar to mine about clang and gcc and I understand that both of them make lexical and syntax analysing on the fly
I just want any compiler in any language as long as the compiler itself is written in C and run on ubuntu x64
I am not sure you have the right approach, if you are willing to learn about compilation techniques for C specifically. And C is not the best language to write a compiler in (if you start from scratch, Ocaml is better suited for that task). BTW, recent Clang/LLVM or GCC are coded in C++ (no more in C).
The C language now sort-of requires optimization, as I explained here, so skipping the optimization part is not very useful. Be aware that optimization passes form the majority and the most difficult part of real-world compilers.
The lexing and parsing parts of compiler are now well understood. And there are several code generator tools for them (yacc or bison, lex or flex, ANTLR...). For several pragmatical reasons, real compilers like GCC don't use these tools.
You could look into tinycc, nwcc, or 8cc if you want to look inside non-optimizing toy C compilers.
You could also look into the intermediate representations of real compiler, e.g. GIMPLE for GCC (BTW, try to compile with gcc -fdump-tree-all -O2 -c some simple C code with a few loops; you'll be surprized by the hundreds of dump files showing the many internal compiler representations from many passes). You'll learn a lot by customizing GCC with MELT, and the MELT documentation page contains several very useful references. This answer should also help and contains or references some pictures of GCC.
disclaimer: I am the main author of MELT
PS. There are very good reasons to bootstrap compilers. So a compiler for a language other than C is unlikely to be coded in C (it is often coded for that language itself), since C is not a good programming language to write a compiler from scratch.
PPS. If you only know C -and no other programming languages-, I would suggest to learn some other programming language (e.g. Scheme with SICP, Ocaml, or Haskell or Scala or Clojure or Common Lisp) before diving into compilers! Read also something about Programming Language Pragmatics. If you know a bit of Scheme or Lisp, Queinnec's book Lisp In Small Pieces will teach you a big lot.
There are many, many places to start from to explore this territory. Many languages include a compilation capability or aspect such as Lisp and Forth.
To learn about a C compiler, there is a book about the LCC compiler which includes the source code for the compiler. There are also repositories of old C compilers at The Unix History Society archive (tuhs.org).
Still another angle you could take is to examine the language False (an ancestor of the more famous Brainfuck) which is designed to be implemented with very little code.
Another angle, which connects to your interest in complexity theory, is to learn about the Chomsky Hierarchy of languages and the associated abstract machines which can parse them. This will teach you why Lex and Yacc are separate tools and what each is good for (and how to do it yourself and not need them at all).
I am actually on the very same quest myself. I'm currently reading the old 1979 book Anatomy of Lisp which contains compiler code in, of course, Lisp. But this is ok, because I already have my own homebrewed lisp interpreter to execute it with.
The Tiger language has been designed by prof. Andrew Appel exactly on purpose to illustrate, step-by-step, a full compiler construct process.
You can google for 'tiger language' and read some online resource, there are also some questions/answers here on SO, but the better choice would be to get a copy of the book for the language you prefer, and implement the parts you're most interested into.

Any C compiler with C output? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 7 years ago.
Improve this question
We all know that C compilers spit out assembly.
However I am doing research where my tool only accepts a narrow subset of ANSI C.
Is there any C-to-C translators out there that can inline functions or flatten struct's, but writes out C code?
Any other tool that could simplify C code, let me hear them.
LLVM supports something like this.
If you do not require the resulting C code to be particularily readable, you could use your regular compiler to produce a binary executable, and then use a decompiler to produce C code from the binary. The decompiler will most likely not be able to "deinline" the functions that the compiler inlined. Not sure about the structs, though, but if you compile without debugging symbols and use a not-too-sophisticated decompiler, it might not detect the structs at all.
Clang can translate its AST back to C as far as I can understand from various sources on the Internet.
The old MIT project C2C (was on FTP for some time) and the newer Cilk give you the possibility to run the C->AST->C process.
Cilk and Cilk++ are actively maintained. They include a very good ANSI C parser.
Our DMS Software Reengineering Toolkit and its C Front End can do this.
DMS provides generic machinery for parsing, building ASTs, symbol tables, generally analyzing ASTs, and specific analyzers for control/dataflow/points-to/value range, as well as transforming ASTs aribtrarily either procedurally or using patterns, and regeneration of source text including comments. DMS's ability to process multiple compilation units at the same time allow for global analzyers and transformations that affect multiple compilation units simultaneously.
DMS's C Front end specializes all this for C (it has front ends for a variety of other langauges). It handles variety of dialects, including ANSI, GCC 3/4, MS Visual C and Green Hills C; it can be customized for other dialects as needed.
DMS has been used for a variety of C analysis/transformation projects, including analyzing a 26 million line software system.
An interesting application of DMS is to instrument C source to catch pointer errors when they occur (rather than suffering a long-delayed crash); see our CheckPointer tool. This tool reads the source code, inserts extra code to check each pointer access, and then writes out the results.
In the process of doing this, it normalizes the C code to a simplified subset to get rid of lots of special cases. This normalization may be pretty close to the kind of thing OP wants to do.

Using LGPL library in a commercial Java application [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about programming within the scope defined in the help center.
Closed 7 years ago.
Improve this question
I have a commercial Java application which I will be distributing.
I want to use an LGPL'd java library.
I wont be modifying the library.
Does the LGPL license of that library have any impact on my application's license?
Yes, it does to a certain degree. You are e.g required to allow people to upgrade the LGPL'd library without your help. I suggest reading through the whole license yourself, as you're legally obligated to adhere to it's clauses. Know what you oblige yourself to, don't just take other people's words for it :)
As far as I understand the LGPL, no, you can distribute it however you like. You will only be linking to the library, not creating a derivative work, and the LGPL doesn't restrict linking.
There is no impact on your application. LGPL license allows inclusion in commercial application as long as the terms of the license are fulfilled (LGPL license text in the distribution, indication of the use of the library, etc).
My guess is that as long as your linking is dynamic (i.e. dynamic loading of the .dll/.so/.a/.class/whatever file at runtime), you're OK. If you statically compile your code to include the library, you're at risk of violating the license, depending on how your code is structured.
If it's Java, however, you can not link statically - it's an impossibility of the platform.

Resources