3

I've been looking for functional language with C-like syntax and static typing. So far my choice would be Nemerle. Is there anything else/better?

EDIT:

second choice would be Lua or Go.

Any pros and cons?

Lukasz Madon
  • 1,496
  • 13
  • 22
  • I think you should specify which features you are interested in, behind static typing. – CheatEx Apr 26 '11 at 13:21
  • I will not be using it in a project (at least for now). I want to learn functional programming with the language as a platform. It has to be mature enough, running on windows. Would be great to have interactive mode. Also, not very complicated. – Lukasz Madon Apr 26 '11 at 13:32
  • 1
    The mention of lua and go here is bizarre. – Jim Balter Sep 14 '17 at 09:34

5 Answers5

9

I would say JavaScript

  • It is a functional language
  • It uses C syntax
  • It can be used on a variety of operating systems (in both client and server mode), can be embedded in a lot of platforms (.NET, Java, Qt )

    This can be useful.

DomreiRoam
  • 191
  • 1
8

In general functional languages do not have C like syntax, It comes down to the fact that functional languages do things differently than C type languages so the syntax tends to be very different (and often shorter). At least for me adopting to the new syntax has not been a big deal when picking up languages. Right now I'm spending most of my time on Erlang but also took a look at Haskell and have done scheme in the past.

Zachary K
  • 10,433
  • 2
  • 37
  • 55
  • 1
    I do think for some the syntax is wildly different and that can be scary. Although, after a day or two looking at Lisp I can say that I absolutely love the syntax. Sometimes it is better to just break out of ones comfort zone! – Jetti Apr 26 '11 at 12:59
  • yep but Lisp has very weak type system. – Lukasz Madon Apr 26 '11 at 13:12
  • True, but take say Haskell, which has a crazy strong type system, its got its own ideas on on syntax but it kind of grows on you. – Zachary K Apr 26 '11 at 13:29
  • @lukas - Like Zachary said, I'm more stating the fact that the syntax will grow on you after awhile, but only if you give it a chance. – Jetti Apr 26 '11 at 13:44
  • 3
    @lukas: Common Lisp has a strong type system. All objects are typed, and the type is determinable in detail at any time. You may be thinking that it has a dynamic, not static, type system. – David Thornley Apr 26 '11 at 13:46
  • @David I disagree. Theoreticly, type checking has nothing to do with type system. We have dynamic languages with weak typing(Lisp) and stronger(Phyton). An example: expresson + 3 "aa" works for Lisp but it is semantic error for Phyton(3 + 'aa'), because Phyton **checks** the types of this expresson. Similary with static typing(typing at compile time), but I guess such thing does not exist(language with static type system and weak type checking). – Lukasz Madon Apr 26 '11 at 14:38
  • @lukas: C has static,weak type; C++ is even weaker (and 'staticker' too). – Javier Apr 26 '11 at 14:47
  • @Javier what do you mean by weak? runtime type checking? – Lukasz Madon Apr 26 '11 at 15:10
  • @lukas: What the heck version of Lisp are you using? I specified Common Lisp, because I don't like generalizing across language families, and I'm not all that familiar with Scheme or Emacs lisp. To repeat, Common Lisp is strongly dynamically typed. – David Thornley Apr 26 '11 at 17:45
  • @lukas: no, runtime type is dynamic type. weak means that values convert from one type to another automatically. strong type means that any conversion has to be explicit. – Javier Apr 26 '11 at 17:55
5

Scala has a distinctly C like syntax, albeit with an Object-oriented layer on top which comes via Java. The language is a nice blend of functional programming in the Standard ML family with an object-oriented language whose type system is tightly built into the ML-style static type inferencer of the language.

This means that you can type inference and pattern match over objects of user-defined classes in configurable ways, while keeping the strong-typedness which the ML-family languages are known for.

That said, I'd agree with the other posters -- consider stretching yourself a little more; learn a lisp, which is to say a language which is almost without syntax, and you'll never be hung up on `which' syntax your next language has again. :-)

jimwise
  • 7,433
  • 1
  • 30
  • 32
1

Single Assignment C is the first that comes to mind.

However, I agree with the others. The syntax of functional languages can often be the interesting part! For instance, you can embed BASIC syntax inside Haskell's!

Jason Reich
  • 111
  • 4
0

For you purposes (from the second comment) you should pick a language as little similar to C as possible, IMHO. Prolog and Scheme are best match to you requirements (except C-style syntax, of cause).

Anyway, you should keep in mind that all languages in your list are general-purpose and industry-oriented. They are not intended to be used for learning.

CheatEx
  • 101
  • 2