4

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

BarsMonster
  • 6,483
  • 2
  • 34
  • 47
  • 2
    Why is 'static type checking' so important? What problem are you having that's actually solved by this? Can you be specific on the problems you're having? Python is very, very strongly typed and the types are explicitly part of each object. There's no cast capability and no fuzziness about what type an object has. – S.Lott Aug 18 '10 at 12:21
  • 1
    Lack of static typing is part of Python's strength. Furthermore, the GIL is in 99% of cases the least concern. +1 otherwise, I'd love to use a language that didn't have nasty `{}` and `;` syntax, these are hardly necessary for a modern language. – Matt Joiner Aug 18 '10 at 12:23
  • @S.Lott: He did say statically typed, not strongly typed. – Matt Joiner Aug 18 '10 at 12:23
  • 1
    @Matt Joiner: What? He said both. The title says "strong". The question says "static". – S.Lott Aug 18 '10 at 12:24
  • Heading says strong typing, which c++ isn't. Body says static typed. – John La Rooy Aug 18 '10 at 12:25
  • BarsMonster, what's a **modern syntax**? If it looks like Fortran77 (no braces, lines have to be aligned or structured by meaningful whitespace)? I think, C++ is what you'd need, if there weren't the {}'s, right? – rubber boots Aug 18 '10 at 12:33
  • What do you mean by embeddable? Most of the environments where you can embed a Python interpreter can handle a JRE, so an example would be helpful. – Muhammad Alkarouri Aug 18 '10 at 12:40
  • Well, Python is 0.5M, JRE require 10+ and additional installation step. – BarsMonster Aug 18 '10 at 12:53
  • 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. – BarsMonster Aug 18 '10 at 12:58
  • Makes sense. I would suggest OCaml as per my answer below, but the platform would be a question because when you get outside of Windows/Linux/OS X, most of the languages suggested wouldn't work where C++ does. So I would suggest you mention the platform(s) in your question. – Muhammad Alkarouri Aug 18 '10 at 13:05
  • @gnibbler: why would you say C/C++ is **not** strongly typed? – rubber boots Aug 18 '10 at 13:16
  • 4
    @rubber: Because it isn't. There are many ways to bypass the type checking, mostly related to pointers, and some are very easy to accidentally run into. Compare that with certain functional languages: Standard ML is formally 100% typesafe (there are some implementations that permit unsafe operations). –  Aug 18 '10 at 13:44
  • @rubber boots: you can make casts that don't make sense that, unlike converting with `str`, `int`, and `float` in Python, don't retain the same representation. – Wayne Werner Aug 18 '10 at 13:46
  • @Wayne, @delnan; thanks for explanations. I was under the impression, C++ would count somehow as strong typed, but of course it gives you the tools to invalidate its potential strongtypedness. Thanks,
    rbo
    – rubber boots Aug 18 '10 at 14:30

5 Answers5

4

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.

John La Rooy
  • 295,403
  • 53
  • 369
  • 502
  • +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 Aug 18 '10 at 13:49
  • I cannot lock on windows, and I am not ready to rely on mono. – BarsMonster Aug 18 '10 at 15:02
4

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
  • 234
  • 2
  • 3
  • +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. –  Aug 18 '10 at 13:11
  • OCaml does have a GIL. – bfontaine Jan 16 '15 at 12:59
3

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.

rmcnew
  • 329
  • 1
  • 4
2

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
  • 4,761
  • 1
  • 26
  • 32
  • 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 Aug 18 '10 at 18:49
  • there is port project for windows http://code.google.com/p/go-windows/ – bua Aug 19 '10 at 11:17
2

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
  • 14,924
  • 5
  • 33
  • 44
  • 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 Aug 18 '10 at 13:49
  • 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 Aug 18 '10 at 14:15