views:

186

answers:

6

Are there any languages which feature static type checking like in C++ with modern syntax like in Python, and does not have GIL?

I belive, Python 3 with ability to explicitly declare type of each variable would be 'almost there', but GIL makes me sad.

Java is nice, but I need something more 'embedable' without bulky JRE.

Update: Anything .NET-related or non-open source is a no-go.

Update2: I need explicit+strong typing to write safer code in the expense of development speed. GIL is important as the code is going to be quite computing extensive and will run on multicore servers, so it has to effectively use multiple CPU.

Update3: Target platform is Linux(Debian) on x86

+2  A: 

I think GO would fit your requirements.

This is my personal feeling but go code looks very similar to python code.

It still has classic compile approach but google will develop some interpreter certainly.

From google site:

Go is a general-purpose language designed with systems programming in mind. It is strongly typed and garbage-collected and has explicit support for concurrent programming. Programs are constructed from packages, whose properties allow efficient management of dependencies. The existing implementations use a traditional compile/link model to generate executable binaries.

bua
GO is experimental, it might be killed just like Google Wave. Also, it lack WIndows support which is essencial as development is mainly on windows platform.
BarsMonster
there is port project for windows http://code.google.com/p/go-windows/
bua
+4  A: 

Boo

Boo is an object oriented, statically typed programming language that seeks to make use of the Common Language Infrastructure's support for Unicode, internationalization and web applications, while using a Python-inspired syntax and a special focus on language and compiler extensibility. Some features of note include type inference, generators, multimethods, optional duck typing, macros, true closures, currying, and first-class functions. Boo has been actively developed since 2003.

cython

Cython is a language that makes writing C extensions for the Python language as easy as Python itself. Cython is based on the well-known Pyrex, but supports more cutting edge functionality and optimizations.

The Cython language is very close to the Python language, but Cython additionally supports calling C functions and declaring C types on variables and class attributes. This allows the compiler to generate very efficient C code from Cython code.

gnibbler
+1 I also wanted to recommend Boo. It looks like Python and has incredibly many features, including extensible syntax. It uses a VM though, and it is ".NET", but it is free software.
Eike
I cannot lock on windows, and I am not ready to rely on mono.
BarsMonster
+7  A: 

Apologies for the format of the answer which evolved with the question. The short answer is OCaml. I will rewrite this answer to have a better order if any other addition is needed.

Edit 3: With a platform Linux/x86, a computationally intensive operation would be similar to the work done in High Performance Computing, for example machine learning. Here is a discussion about programming languages for machine learning. OCaml is highly regarded there.

The more important thing would be to utilise optimised versions of libraries such as Blas/Lapack, or to write in a good programming language and profile then rewrite the critical parts as C. I have done this with Python/Numpy with critical sections written in Cython or even pure C. It is also doable with OCaml/C. Interestingly, most of the HPC tends to lean towards C rather than C++, with some work also in Fortran.

I would add that OCaml has a much more optimising compiler than Go at the moment, as the Go compiler is still in flux: the common compiler 6g is not much optimised, and the more efficient gccgo is lagging in development and much less tested.

Edit 2: Given that your question cites C++ and static/strong typing and no VM, I would say your main options are: OCaml and Go, with D being a not fully open source language that is both community friendly and has large portions open. I still advocate OCaml as your best option.

OCaml has a longer history than Go and a bigger community. The language is also more stable than Go which is still at the startup phase. Still, Go might be better if the syntax being C-like is more important to you.

Original Answer:

This may or may not fit your requirements, but I would say OCaml or F#. They are very similar, but F# is a Microsoft language hosted on .Net originally based on OCaml.

OCaml/F# is strongly typed, with type inference. So you can omit explicit type definitions that can be inferred, or you may have them explicit. They also don't have GIL.

The reason that they may fall short is if you reject insufficiently C like (joke) languages are not modern syntax. Also, F# may not make you happy if you don't want to depend on a virtual machine, though this is more than compensated by the availability of libraries compared to OCaml.

Edit: The edited question excludes .Net and similar environments hence F# is no longer viable. My answer still stands regarding OCaml, though people coming from a Python background will feel the lack of a nice and complete library.

Muhammad Alkarouri
Sorry, I updated a question, I don't think I cannot accept vendor lock-in here.
BarsMonster
I didn't sayed 'no VM' :-)If VM is not deadly slow, it's totally ok.
BarsMonster
@BarsMonster: sorry. I meant no portable VM (like .Net). Or bulky, like the JRE. I guess benign VMs like Python and Lua were not the thing I had in mind.
Muhammad Alkarouri
+2  A: 

Anything in the ML family might work for you. Ocaml is a great place to start, but it does have a stop-the-world GC last I looked. Haskell is famous as a lab for innovative concurrency models. Python's comprehensions came from Haskell, where they'rr a convenient syntax for some very fundamental ideas. And Erlang is strongly dynamcally typed, fun to write in, and does concurrency better than anybody else.

Brian Sniffen
+1 for ML/Haskell, if concurrency is so important you better use a functional language. And their type systems are as static/strong as it gets, but at the same time extremely expressive.
delnan
+2  A: 

After reading your updated spec:

I need explicit+strong typing to write safer code in the expense of development speed. GIL is important as the code is going to be quite computing extensive and will run on multicore servers, so it has to effectively use multiple CPU

What exactly does "computing extensive" mean? What problem domain? What do others who work in this problem domain use? If you are serious with this specification, you can't do much other things than using C++ in connection with well-tested libraries for multithreading and numerical computing.

my $0.02

rbo

rubber boots
This is a client-server application with 1000s of clients, where I am going to have some portion of business-logic code shared between client and server. This all should be updatable on-the-fly. Performance is critical mainly on the server side. I cannot deliver and/or update on-the-fly C++ binaries or build them from source on clients. But delivering updated bytecode module and replacing it on-the-fly is what I need.
BarsMonster
Python with multiprocessing? You shouldn't be doing heavy I/O in a single process anyway, there are bottlenecks in the OS which you can't account for by threading in userspace.
Matt Joiner
+1  A: 

Ada is a strongly-typed, compiled language with a modern, easy-to-read syntax and proven reliability for multicore computing. Ada was designed for use in large, critical, real-time systems where software MUST work at all costs.

"Ada supports run-time checks to protect against access to unallocated memory, buffer overflow errors, off-by-one errors, array access errors, and other detectable bugs. These checks can be disabled in the interest of runtime efficiency, but can often be compiled efficiently. It also includes facilities to help program verification. For these reasons, Ada is widely used in critical systems, where any anomaly might lead to very serious consequences, i.e., accidental death or injury. Examples of systems where Ada is used include avionics, weapon systems (including thermonuclear weapons), and spacecraft." (quote from Wikipedia article linked above).

Ada is freely available as part of GCC / GNAT and should be an easy "apt-get install" on Debian. You can also find up-to-date compilers and libraries (both community-supported GPL-licensed and commercially-supported packages) at http://libre.adacore.com/libre/

Ada can compile to Java bytecode for use in a JVM or compile to binary for bare-metal or embedded use.

thesuperbigfrog