Programming languages that compile to native code and have the batteries included - programming-languages

What are the programming languages that compile to native code and which have provided a comprehensive library with them?
Libraries that includes functionality such as Networking, File IO, RegEx, Database, Graphics, Multimedia, Win32 API bindings, File compression, etc.

I'll assume everyone has thought of C and C++.
Haskell is the obvious one here. In particular, if you want batteries included, you want the Haskell Platform.
OCaml fits this category, as well.
Go is a new player that has (most of) the feature you asked.
The D programming language with it's standard library Phobos.
Some Lisp dialects include a native compiler, like Common Lisp with its SBCL, CCL or ECL (to C) compilers.
Rust is a system programming language but doesn't include batteries but has crates ― to avoid stale standard library modules

Delphi meets all those requirements. This is a development environment based on the Object Pascal language.

Is Objective-C with Cocoa/CocoaTouch an acceptable answer?
You can use this pair for programming applications running on devices with restrictive constraints on batteries (laptops and mobile phones).

Swift by Apple, but now Open Source, compiles to native code and is available for OS X and Linux.
Batteries are completely included for Mac OS X and iOS through Apple's extensive libraries/APIs, and support for OS independence is on the way with the development of core libraries.

Hmmm. The funny thing is, most OSes have native APIs for all that stuff. So all you really need is a language that can link in OS calls. Pretty much any compiled language worth its salt will do that.

I am currently working with Qt.
http://doc.trolltech.com/4.5/index.html
Edit: a Nitpick..
A programming 'language' is a grammar and set of semantics and syntax. It contains NONE of the things you are asking about. What you want to know about is API's, not languages.

Related

What does it mean by a 'systems language'?

The Go talk 2009 pdf has a comment to explain why they came up with the go language :
No new major systems language in a decade.
What's the meaning of systems language?
Is it a language that is supposed to run on target system by generating native binary?
Is it a language that can build operating system on its own?
I can see C#/Java is `not' a systems language, and C/C++ is.
It's a rough, informal distinction, but the idea is that there are "application programming languages," targeted at programmers who develop shrinkwrapped business applications, and "systems programming languages," targeted at programmers who program tools for other programmers (compilers, etc.) and low-level software such as OS kernels, device drivers, etc.
In short, most (recently-invented, anyway) languages are designed to make it easier to develop user-facing software for dealing with some non-computing domain---finance, engineering, etc. Systems programming languages are those, such as C, FORTH, Go, etc. which are intended or at least suitable for programming in the domain of computing.
These often, but do not always, feature compilation to native code, loose type systems which permit extensive "punning," and unmanaged memory access through pointers or an equivalent construct.
Look here? Sorry if this comes off as sorta a throw away link, but really this should be all you need. Unless you are asking for something else more specific.
A reason C# is definitely not a systems language is its dependency on .NET.

How to go about making your own programming language? [duplicate]

This question already has answers here:
Closed 12 years ago.
Possible Duplicate:
Learning to write a compiler
I looked around trying to find out more about programming language development, but couldn't find a whole lot online. I have found some tutorial videos, but not much for text guides, FAQs, advice etc. I am really curious about how to build my own programming language. It brings me to SO to ask:
How can you go about making your own programming language?
I would like to build a very basic language. I don't plan on having a very good language, nor do I think it will be used by anyone. I simply want to make my own language to learn more about operating systems, programming, and become better at everything.
Where does one start? Building the syntax? Building a compiler? What skills are needed? A lot of assembly and understanding of the operating system? What languages are most compilers and languages built in? I assume C.
I'd say that before you begin you might want to take a look at the Dragon Book and/or Programming Language Pragmatics. That will ground you in the theory of programming languages. The books cover compilation, and interpretation, and will enable you to build all the tools that would be needed to make a basic programming language.
I don't know how much assembly language you know, but unless you're rather comfortable with some dialect of assembly language programming I'd advise you against trying to write a compiler that compiles down to assembly code, as it's quite a bit of a challenge. You mentioned earlier that you're familiar wtih both C and C++, so perhaps you can write a compiler that compiles down to C or C++ and then use gcc/g++ or any other C/C++ compiler to convert the code to a native executable. This is what the Vala programming language does (it converts Vala syntax to C code that uses the GObject library).
As for what you can use to write the compiler, you have a lot of options. You could write it by hand in C or C++, or in order to simplify development you could use a higher level language so that you can focus on the writing of the compiler more than the memory allocations and the such that are needed for working with strings in C.
You could simply generate the grammars and have Flex and Bison generate the parser and lexical analyser. This is really useful as it allows you to do iterative development to quickly work on getting a working compiler.
Another option you have is to use ANTLR to generate your parser, the advantage to this is that you get lots of target languages that ANTLR can compile to. I've never used this but I've heard a lot about it.
Furthermore if you'd like a better grounding on the models that are used so frequently in programming language compiler/scanner/parser construction you should get a book on the Models of Computation. I'd recommend Introduction to the Theory of Computation.
You also seem to show an interest in gaining an understanding of operating systems. This I would say is something that is separate from Programming Language Design, and should be pursued separately. The book Principles of Modern Operating Systems is a pretty good starting place for learning about that. You could start with small projects like creating a shell, or writing a programme that emulates the ls command, and then go into more low level things, depending on how through you are with the system calls in C.
I hope that helps you.
EDIT: I've learnt a lot since I write this answer. I was taking the online course on programming languages that Brown University was offering when I saw this answer featured there. The professor very rightly points out that this answer talks a lot about parsers but is light on just about everything else. I'd really suggest going through the course videos and exercises if you'd like to get a better idea on how to create a programming language.
It entirely depends on what your programming language is going to be like.
Do you definitely want it to be compiled? There are interpreted languages as well... or you could implement compilation at execution time
What do you want the target platform to be? Some options:
Native code (which architectures and operating systems?)
JVM
Regular .NET
.NET using the Dynamic Language Runtime (like IronRuby/IronPython)
Parrot
Personally I would strongly consider targeting the JVM or .NET, just because then you get a lot of "safety" for free, as well as a huge set of libraries your language can use. (Obviously with native code there are plenty of libraries too, but I suspect that getting the interoperability between them right may be trickier.)
I see no reason why you'd particularly want to write a compiler (or other part of the system) in C, especially if it's only for educational purposes (so you don't need a 100-million-lines-a-second compiler). What language are you personally most productive in?
Take a look at ANTLR. It is an awesome compiler-compiler the stuff you use to build a parser for a language.
Building a language is basically about defining a grammar and adding production rules to this grammar. Doing that by hand is not trivial, but a good compiler-compiler will help you a lot.
You might also want to have a look at the classic "Dragon Book" (a book about compilers that features a knight slaying a dragon on the front page). (Google it).
Building domain specific languages is a useful skill to master. Domain specific languages is typically not full featured programming language, but typically business rules formulated in a custom made language tailor made for the project. Have a look at that topic too.
There are various tutorials online such as Write Yourself a Scheme in 48 hrs.
One place to start tho' might be with an "embedded domain specific language" (EDSL). This is a language that actually runs within the environment of another, but you have created keywords, operators, etc particularly suited to the subject (domain) that you want to work in.

Is there a high level language with an interpreter, dynamic compiler and static compiler(e.g. like the c++ compiler) along with a multimedia library?

The interpreter and dynamic compiler would be for testing/prototyping and when im done testing i use the static compiler.
Java has all of these - the stock Sun JVM has both an interpreter and dynamic compiler, and the GNU Compiler for Java (GCJ) can statically compile to machine code.
There are many.
One such language is Objective Caml. Let's check it against your requirements:
High-level language: Caml supports functional, object-oriented, and imperative styles of programming.
Interpreter: The ocaml system is a read-evaluate-print loop.
dynamic compiler: On platforms that support dynamic loading, ocamlrun can link dynamically with C shared libraries (DLLs).
static compiler: Available through the -linkall flag in the compiler.
Multimedia: There are libraries for 2-d graphics, 3-d graphics, audio, and video.
The bigger question is finding the best tool for your job. Many languages meet those requirements, but the most used languages have the best documentation and the most tested bindings to libraries. If you're going to use a language like Caml, there should be some overriding benefit to that language that can't be found in other languages.
Good luck!
The best option for you depends on the kind of your application. If it is a real-time program, then just stay with C++ (or ever with C) because no high-level language like Ruby/Perl/Python will beat them in this domain. But if the complexity of your future program is high enough, the best option I see in Python + PyOpenGL (for graphics) +PyOpenAL (for sound) and PyODE (for real-time physics). Actually, Python's VM is fast enough but you can also (with some efforts) compile it into a platform-dependent optimized code.
Alternatively you can use PyGame for 2D graphics and a way comfortable sound/music management.

Programming languages with python-like syntax but native code generation

Can anyone point to programming language which has python-like syntax, but from the very beginning was designed to generate native code? I'm aware of Boo only, but it uses .net, not native code generation. Well, if nothing else than python-like languages which generate .net/java bytecode are fine too.
Cython might do -- the C code it generates is for Python extensions, but the whole thing can be packaged up and you'll be running native code throughout (after the 'import';-).
I must admit that I don't quite understand your question, for two reasons:
You are asking for a language with native code generation, but native code generation has nothing to do with the language, it is a trait of the implementation. Every language can have an implementation with native code generation. Several Python implementations have native code generation. There are C compilers that compile to JVM bytecode, CIL bytecode or even ECMAScript sourcecode. There are even C interpreters. There are also compilers that compile Java sourcecode or JVM bytecode to native code.
Why do you care about the syntax? It is probably the least important factor about choosing a programming language.
Anyway, Nim is a programming language which has an implementation which supports native code generation (or more precisely an implementation which supports C source code generation) and whose syntax is a hybrid between Wirthian style (by the looks of it the most important influences are Oberon and Delphi) and Python.
However, the fact that it has Pythonic syntax isn't going to help you at all if you don't like European style language design or Wirthian style OOP.
Also found today Delight applying Python syntax on a D back-end.
And Converge too.
Check out Cobra
It is strongly influenced by Python, C#, Eiffel, Objective-C and other programming languages. It supports both static and dynamic typing. It has first class support for unit tests and contracts. Cobra provides both rapid development and performance in the same language.
shedskin compiles Python to C++
From shedskin project page
Shed Skin is an experimental compiler,
that can translate pure, but
implicitly statically typed Python
programs into optimized C++. It can
generate stand-alone programs or
extension modules that can be imported
and used in larger Python programs.
Genie which is part of the gnome project: http://live.gnome.org/Genie
I think it's exactly what you're looking for.
If you are happy with something that compiles down to Java bytecode you could have a look at Jython. Quoting from their FAQ:
JPython is an implementation of the Python programming language which is designed to run on the Java(tm) Platform. It consists of a compiler to compile Python source code down to Java bytecodes which can run directly on a JVM, a set of support libraries which are used by the compiled Java bytecodes, and extra support to make it trivial to use Java packages from within JPython.
I've not actually used it yet but am considering it on some projects where I have to integrate with existing an Java codebase.
HTH
PyPy is a project to re-implement Python in Python. One of it's goals is to allow the use of multiple back-ends, including C. So you can take a pure Python program, convert it to C and compile it to native code. It is still a work in progress, so probably not suitable for production code.
You can find all of the previously mentioned languages, plus some more, here: http://wiki.python.org/moin/PythonImplementations
Nim is a statically typed compiled systems programming language. It combines successful concepts from mature languages like Python, Ada and Modula.
https://nim-lang.org/
You can also investigate IronPython - a python inplementation on the .NET framework
You can try Genie. It's the same like Vala, but with Python-like syntax. If you want to develop apps for Linux with GTK, and you want to compile it to native app, Vala or Genie is really good choice.

Programming language with native code support, No framework (I write the framework)

I'm looking for a programming language. It should be an easy language to learn, and should have a Garbage Collector. It should be a basic language with features like basic types (integer, boolean), arrays and etc, and I should write the framework.
It is for a game editor I want to write. The editor's designer will write the code of the UI in this programming language. The framework will be a 2D graphics and audio framework, and in the future it'll be 3D too.
I thought about the new Go language, but it doesn't have much support and theres no binding to OpenGL and etc.
Any ideas?
Thanks.
The obvious two are [C](http://en.wikipedia.org/wiki/C_(programming_language)) or C++. However, [D](http://en.wikipedia.org/wiki/D_(programming_language)) is closer to Java and C# given that it has a garbage collector in the standard, as well as an alternative standard library that is fairly closer to Java than the C++ standard library. The downside with D is that they tools are not as mature as C++ or C and the community isn't as large.
The obvious solution though it to look down the list of compiled languages on wikipedia and see which you like the look of.
Well, that's a fairly broad question and without more specific requirements it is difficult to give a focused answer, but it sounds like C (or C++) would fit the bill for you. The languages you described all owe their syntax to C. C will compile to native code. C is basic language in that there is not much to learn beyond the basic syntax and it has all the basic primitives that you require.
Now that you've added the requirement of a garbage collected language, I suppose that you could try Go, but that language is not mature and there's always a risk there.
If you don't want to manage memory all by yourself like C or C++, you can try the new Go language. It compiles to native code (albeit for Linux and MacOSX only for now) and comes with a basic framework that can be easily replaced with your own framework.
It has a very active user base, so IMO it is possible to mature quickly.
You may want to look at Lua.
Lua is a relatively tiny language which manages to be capable and universal with just a few concepts. The BNF specification for the whole language fits easily on one page. It has numbers, booleans, tables and functions, and surprisingly that's all the datatypes it needs. It can even work in an object-oriented fashion.
There's a compiler, Luac, that compiles Lua to bytecode.
Lua is already being used as a UI programming language for games. Addons for World of Warcraft and a few other games are programmed in Lua. I believe Lua is a very good fit for this kind of task.
You want OpenGL? OK... http://luagl.wikidot.com/ is an OpenGL library for Lua.
Since we don't know what you want to do, I don't know what are the chances we success. Therefor, what about a language where you have to set the probability of your statement to fail :
Meet GOTO++.
Don't say "thanks you", it's on me.
Enjoy a challenge?
Try go.
Here's a tech talk by rob pike, and here is a discussion group: http://groups.google.com/group/golang-nuts/topics
.
C++ is Great, it's not scripting lang, so you don't even need a scripting host.

Resources