8 ms·
Atomo, the programmer's programmable programming language
- apl 16y ago0 fib = 1 1 fib = 1 (n: Integer) fib := (n - 2) fib + (n - 1) fib Reading the first line as "For zero, 'fib' is 1" is surprisingly intuitive. Not sure if this translates to something like x = Object clone though. Maybe some conventions shouldn't be touched?
- steveklabnik 16y agohttp://en.wikipedia.org/wiki/Pattern_matching http://en.wikipedia.org/wiki/Pattern_matching
- apl 16y agoSure, but I'm surprised by the "reversed" notation. Wouldn't it be fib 0 = 1 in Haskell? I just felt that this order works well for pattern matching functions, but not as well in other contexts. No CS background here, by the way; maybe I'm just missing your point.
- vito 16y agoBoth of those uses of = above are actually pretty consistent, given how Atomo's scoping and dispatch system works. When you said "for 0, fib is 1," you could just as easily say "for the current scope object, x is Object clone." This is exactly how it works. Method dispatch is 100% pattern-matching, and Atomo's scopes are 100% message dispatch, combined with delegation. When you say "0 fib = 1", the method is inserted on Integer. When you send a message to an Integer, you're sending (pseudocode) `Single "fib" (Integer 0)`. The methods on Integer pattern-match on that, in this case with `PSingle "fib" (PMatch (Integer 0))`. If that pattern fails, it moves on to "1 fib = ...", and finally to the least-precise "(n: Integer) fib := ...". Not sure if that answers your question, but I thought I'd expand on it a bit.
- steveklabnik 16y agoIt would be. My bad, I thought you were talking about the concept not the order of things. I'm not sure how I feel about it, to be honest. But I do love me some pattern matching...
- deleted 16y ago[deleted]
- swannodette 16y agoThis looks really cool and reminds me a lot of Io. Speaking of Io, this make me curious about the performance of Atomo. Io while an amazing experiment in expressivity has terrible performance. Does Atomo similarly prioritize expressivity to the detriment of reasonable performance?
- vito 16y agoRight now, my priority with Atomo is consistency in the design and simplicity in the implementation. It's acting as an incubator for a ton of interesting language features at the moment (both for myself and for Slate), so I haven't made optimization a priority yet as major parts of it are constantly changing. For example, the version on Hackage has a traditional exception system, while the latest darcs changes have replaced that entirely with a condition/restart system written in Atomo. I'd call it "fast enough," but it's no speed demon. It's pretty early on; I just started planning Atomo's design this June. There's almost certainly some low-hanging fruit when it comes to optimization, and it is something I've been keeping a close eye on for a while now. It's only been getting faster, and in my testing of GHC 7 I saw pretty substantial performance boosts for free. And that's the nice thing. It's built on a fantastic platform, which you can drop into very easily whenever you want with a nice DSL. Glad you like it, though. I completely understand the caution when it comes to performance of such a high-level language.
- swannodette 16y agoSounds reasonable. So is it possible to mix Haskell in with Atomo to get to the metal so speak? Do you have any examples of this?
- vito 16y agoYes; all of Atomo's kernel is defined using this Haskell DSL. For example, here's Atomo's ports system: http://darcsden.com/alex/atomo/browse/src/Atomo/Kernel/Ports.hs http://darcsden.com/alex/atomo/browse/src/Atomo/Kernel/Ports... I've also written a few wrappers for Haskell libraries over at http://darcsden.com/alex http://darcsden.com/alex - see http, json, and command. Basically, you define your methods in Haskell, and call them from Atomo; these methods can be defined as an expression (=:::), a value (=::), or some arbitrary VM action to be executed to yield a value (=:). (Admittedly those operators have gotten a bit silly.) The definitions use QuasiQuotes for the method pattern, and can use them for expressions as well, though that's not encouraged (operator precedence and macros make it a tricky thing to do at compile time). They look a bit noisy - [$p|x foo: y|] but that'll be fixed come GHC 7, where that pesky $ is removed.
- ivanmantova 16y agoJust when I thought I wouldn't be surprised by a new language anytime soon. Getting the source right now to see what's inside.
- jashkenas 16y agoMany bits of Atomo are written in Atomo, including Eco (the package manager), the REPL, and so on... http://darcsden.com/alex/atomo/browse/prelude/ http://darcsden.com/alex/atomo/browse/prelude/
- sliverstorm 16y agoAre there any languages out there that are, or virtually are, written entirely in themselves?
- steveklabnik 16y agoBoth Ruby and Python have interpreters implemented in themselves. http://rubini.us/ http://rubini.us/ http://codespeak.net/pypy/dist/pypy/doc/ http://codespeak.net/pypy/dist/pypy/doc/
- DavidSJ 16y agoSqueak, for example, has its VM quite literally written in a subset of itself called Slang, which translates to C: http://ftp.squeak.org/docs/OOPSLA.Squeak.html http://ftp.squeak.org/docs/OOPSLA.Squeak.html Also, most Lisps (especially Scheme) have a relatively small core written in C for bootstrapping, and the rest of the language is written in itself.
- scott_s 16y agoThe Jikes RVM (Research Virtual Machine) uses a similar approach: http://jikesrvm.org/ http://jikesrvm.org/ Most of the implementation is written in Java, but there's a small core written in C that bootstraps the VM.
- jashkenas 16y agoI was interested in Atomo-in-Atomo, because I'm working on CoffeeScript, a language that is written in itself: http://jashkenas.github.com/coffee-script/documentation/docs/grammar.html http://jashkenas.github.com/coffee-script/documentation/docs...
- ash 16y agoHere's what I needed to do to install and run Atomo under (latest) Ubuntu: $ sudo apt-get install haskell-platform libghc6-terminfo-dev $ cabal update $ cabal install atomo $ ~/.cabal/bin/atomo > 1 + 1 2
- vito 16y agoHackage has been down all day; I've uploaded a new version (0.2.1) just now which has the new condition/restart system, new REPL, and other goodies. Should be just a "cabal update; cabal install atomo" away! :)
- russellallen 16y agoVery cool - you mention Slate, are you in contact with Brian Rice? Because if not you should be.
- vito 16y agoYep! He's in #atomo, and I'm in #slate; there's a ton of back-and-forth.
- gregschlom 16y agoLooks cool, but what are the use cases for Atomo? Would be nice if there was a section "Why Atomo", on the website. More specifically, what prompted the creation of Atomo? Is it only for fun/personal research? Is it a school project? Is there a business problem that Atomo is solving? (I'm just curious, this is not a "do we need another programing language?" criticism. I always wanted to write my own programming language for fun :)
- jhrobert 16y agoI love the "Particule" concept, a nice extension of atoms (and a much nicer name than "tuple"). Where is it coming from? Without going into Prolog, now that you have some pattern matching, maybe you could have some notion of success/failure, like in Icon, this is very expressive. http://en.wikipedia.org/wiki/Icon_(programming_language) http://en.wikipedia.org/wiki/Icon_(programming_language)
- draegtun 16y agoLike others have already mentioned it does (at first glance) seem have a passing resemblance to Io (http://iolanguage.com http://iolanguage.com). Here is the Greeter example in Io: Greeter := Object clone Greeter new := method (n, Greeter clone do (name ::= nil) setName(n) ) Greeter sayHi := method ( (name .. ": Hi!") println ) Greeter new("Alex") sayHi Very close. However even though I've tried to make it look identical you can see the differences poking through. And reading through the Atomo docs there are (naturally) other divergences. I would say that Atomo is probably more closer to Ioke (http://Ioke.org http://Ioke.org) than Io. The philosophy behind Io is to keep it small & simple. Whereas Ioke is Io + extra syntax, literals, etc baked in. Worth keeping an eye on Atomo... as is Io & Ioke. For reference here are the other examples in Io: File with("out-file") open do ( write("hello, world!\n") ) fib := method (n, if (n == 0, return 1) if (n == 1, return 1) fib(n - 2) + fib(n - 1) ) list(1, 2, 3) sum Range 0 to(5) map(* 2)