TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

The Nit Programming Language

61 pointsby colundover 10 years ago

18 comments

caissyover 10 years ago
A few of the main contributors are good friends of mine, so this post might be biased.<p>One of the nicest part of Nit in my opinion is their foreign function interface (FFI). It currently supports C and Java out of the box, and Objective-C and C++ are being worked on. I had the chance to work with the FFI a few years ago when it was still a student&#x27;s master project, and I really had a blast with it. Some librairies such as libcurl[1], curses[2] and sdl[3] were implemented with this FFI.<p>Another great part of this language is a project being worked on by the same guy that built the FFI, and it&#x27;s a cross-compiler for mobile applications called Gammit[4]. You write your app in Nit and compile to Java and Objective-C natively for Android and iOS application. The iOS part isn&#x27;t ready yet, but the Android one is quite advanced with a few great examples such as a small Minecraft clone working with Google Cardboard and having multiplayer functionality.<p>[1] <a href="https://github.com/privat/nit/tree/master/lib/curl" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;privat&#x2F;nit&#x2F;tree&#x2F;master&#x2F;lib&#x2F;curl</a><p>[2] <a href="https://github.com/privat/nit/tree/master/lib/curses" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;privat&#x2F;nit&#x2F;tree&#x2F;master&#x2F;lib&#x2F;curses</a><p>[3] <a href="https://github.com/privat/nit/tree/master/lib/sdl2" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;privat&#x2F;nit&#x2F;tree&#x2F;master&#x2F;lib&#x2F;sdl2</a><p>[4] <a href="https://github.com/xymus/nit/tree/gammit" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;xymus&#x2F;nit&#x2F;tree&#x2F;gammit</a>
评论 #8857181 未加载
Profpatschover 10 years ago
Here are my thoughts after quickly glancing over the „features“:<p>1. No formatting rules and verbose „end“<p>I thought that by now it was universally accepted that having clear rules is a good idea, see Python and golang)<p>2. OO with inheritance<p>3. multiple at that<p>4. Dynamic classes&#x2F;objects<p>5. Methods <i>inside</i> the classes<p>All of these make reasoning about effects very hard&#x2F;impossible; Interfaces in golang, Multimethods in Clojure, Typeclasses in Haskell, CLOS in CL all provide a better solution to that.<p>6. Imperative<p>7. No functional elements (no functions, only methods)<p>Both mean inherently stateful, which in turn complicates reasoning<p>8. redef &amp; super<p>It’s dangerous to have behaviour of single methods spread all over your codebase.<p>9. nullable<p>Looks like an interesting idea to eliminate the class of NPE runtime errors, yet it’s a special language (and syntax!) construct. It therefore does not arise out of the type system, but is explicitely built into the type system, so it doesn’t scale. See Haskell’s Maybe type on how to eleminate NPE’s with a small, trivial type that is no more special than any other.<p>Take it or leave it, these are the things I learned in my study of programming languages. I might be wrong, I might be right, but these are the things that came up as bad design most often in different languages. &#x2F;me out
评论 #8856741 未加载
评论 #8857364 未加载
评论 #8857403 未加载
评论 #8857612 未加载
评论 #8857589 未加载
评论 #8857151 未加载
评论 #8857176 未加载
评论 #8856963 未加载
kailuowangover 10 years ago
I would appreciate if the home page provides the real incentive behind inventing this language. &quot;a robust statically typed programming language where structure is not a pain&quot; is a bit vague and not a unique thing that hasn&#x27;t been achieved by other existing languages.<p>My current hunch is something like &quot;let&#x27;s have a static typed language with Ruby syntax,&quot; but I am really not sure.
评论 #8856714 未加载
评论 #8857258 未加载
评论 #8856702 未加载
drhodesover 10 years ago
Examples? Found some.<p><a href="https://github.com/privat/nit/tree/master/examples" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;privat&#x2F;nit&#x2F;tree&#x2F;master&#x2F;examples</a>
Tobuover 10 years ago
<a href="http://nitlanguage.org/manual/genericity/" rel="nofollow">http:&#x2F;&#x2F;nitlanguage.org&#x2F;manual&#x2F;genericity&#x2F;</a><p>&gt; Unlike many object-oriented languages, generic classes in Nit yield a kind of sub-typing. For example, Pair[Int] is a subtype of Pair[Object].<p>Sounds completely broken. What if Pair[E] is contravariant on E?<p><pre><code> class Pair[E] fun contains(E): Bool fun clamp(E): Bool end </code></pre> &gt; <a href="http://nitlanguage.org/refinement/" rel="nofollow">http:&#x2F;&#x2F;nitlanguage.org&#x2F;refinement&#x2F;</a> (redefining any method)<p>That&#x27;s spooky action at a distance. It breaks modularity, could cause packaging hell.
评论 #8857499 未加载
评论 #8857641 未加载
yoanizerover 10 years ago
It is going to take a lot to convince me that the world needs yet another statically typed OO programming language that looks just like any other.
shinta42over 10 years ago
too many languages to learn...<p>elixir, nim, golang, clojure, haskell, elm, rust......there is no end...
评论 #8856877 未加载
评论 #8858053 未加载
评论 #8856733 未加载
asteriteover 10 years ago
Looks nice. Some ideas are very similar to those of Crystal ( <a href="http://crystal-lang.org" rel="nofollow">http:&#x2F;&#x2F;crystal-lang.org</a> ) like the automatic type flow. But it seems not to support union types and types are required everywhere (which some might like).
评论 #8856691 未加载
dogpaover 10 years ago
I like that I can start hacking right away after reading the &#x27;not a manual&#x27; once.<p>I don&#x27;t like the &#x27;do&#x27; - it&#x27;s either redundant or inconsistent. Why does &#x27;while&#x27; get a &#x27;do&#x27; but &#x27;if&#x27; doesn&#x27;t?<p>Or the &#x27;end&#x27;, especially as it could be a &#x27;while-end&#x27; or an &#x27;if-end&#x27;.<p>And &#x27;isa&#x27; (what was wrong with &#x27;is&#x27;)? Blech!<p>I like that &#x27;var&#x27; is an attribute and the &#x27;fun&#x27; is a method.<p>Android support is intriguing.<p>Maybe this seems like small things and I don&#x27;t know about what the rest of you are talking about. &#x27;contravariant&#x27;? huh?<p>But it looks cool to me and I don&#x27;t think you can ever have too many cool things.
评论 #8857613 未加载
rurbanover 10 years ago
<p><pre><code> for i in [0..width[ do for j in [0..height[ do if foo(i, j) then break label outer_loop # The &#x27;break&#x27; breaks the &#x27;for i&#x27; loop end end label outer_loop </code></pre> ouch. I see why mathematicians would like that, but programmers are surely annoyed by the open range &quot;[&quot;. And if the target are mathematicians, they surely dont like the verbose do end blocks, instead of {}.<p>the for loop could be then<p><pre><code> ∀ x in [0..height[: if foo(i, j): break outer_loop. </code></pre> just odd syntax choices.
nickknwover 10 years ago
Glad to see another language that has chosen to avoid NullPointerExceptions. Some of you might take issue with the way it is implemented (special syntax vs general type), but IMO it is still much better than having NPEs.
gnuvinceover 10 years ago
I was in a class last year, and one of the grad students was working on Nit and gave us a presentation of the language. It was extremely interesting and seemed quite well designed.
评论 #8857125 未加载
zak_mc_krackenover 10 years ago
The documentation in one big PDF:<p><a href="http://nitlanguage.org/manual/nitreference.pdf" rel="nofollow">http:&#x2F;&#x2F;nitlanguage.org&#x2F;manual&#x2F;nitreference.pdf</a>
kornakiewiczover 10 years ago
Altough I like the idea of writing yourself own language for learning purposes and fun, I don&#x27;t think it&#x27;s anyhow better than available toolbox.
msraviover 10 years ago
Anyone knows what the language&#x27;s performance is like? I couldn&#x27;t find any benchmarks...
评论 #8856615 未加载
VMGover 10 years ago
seeing &amp;lt; and &amp;gt; html escapes here: <a href="http://nitlanguage.org/refinement/" rel="nofollow">http:&#x2F;&#x2F;nitlanguage.org&#x2F;refinement&#x2F;</a>
pekkover 10 years ago
The sales pitch makes it sound like I can have the Java experience without the JVM, with junk like multiple inheritance, using syntax from ALGOL.<p>Where is the &quot;fun&quot; and &quot;painless&quot; and &quot;bug-free&quot; going to come from?
ameliusover 10 years ago
I stopped reading at &quot;object oriented&quot;.
评论 #8857410 未加载
评论 #8857648 未加载