10 ms·
Another year of Clojure
- anuraj 14y agoIf I am writing an OS, I will still go back to C without an iota of doubt. I need to touch the metal down there.
- masklinn 14y agoYou could touch the metal in clojure, by implementing clojure on "bare metal"[0] [0] http://en.wikipedia.org/wiki/Lisp_machine http://en.wikipedia.org/wiki/Lisp_machine
- dmpk2k 14y agoIn theory. In practice, doing that (with Clojure specifically) would be a bit silly. A lot would need to change with the language to make it suitable for OS development, at which point Clojure would lose a lot of the attributes that make it Clojure.
- ehsanu1 14y agoA lot would need to change with the language to make it suitable for OS development I keep hearing this, or statements along these lines. But I never see an explanation for this. Performance? Managing memory from other processes? Bit twiddling required to create device drivers? Something else? Are these insurmountable?
- pnathan 14y agoTo write an OS, you need to have a few things: - ability to manually access memory - ability to use assembly and translate said assembly into the high-level language - ability to install interrupts You probably also want the ability to precisely constrain the amount of memory a block of code uses. I suppose there are other nice to haves as well: e.g., GC will need to be fairly controllable. I see no practical reason why a Lisp can't be used to write an OS, but that Lisp will need a few extensions from the usual modern Lisp capabilities.
- JonnieCache 14y ago>- ability to use assembly and translate said assembly into the high-level language Can you elaborate as to exactly what you mean here?
- pnathan 14y agoIn C, I can do something like this (pardon my rusty x86/intel syntax): int variable = 0xdeadbeef; __asm { ldw eax, $(variable) # load from variable int 0x3 # trip interrupt.. maybe read from a IO port or something. stw $(variable), $eax # get result, put into C variable } return variable; This allows me to express certain things to the computer that are outside the range of expressibility of the language model. What I would like to be able to do in Lisp is to execute the semantic equivalent of the above code fragment. I've considered hacking it into SBCL, but I have had higher priorities so far.
- mtrimpe 14y agoThis would be a good start. (mov :ax :ds) (push :cx)
- masklinn 14y ago> - ability to use assembly and translate said assembly into the high-level language Not at all, lisp machines used custom silicon implementing lisp in hardware, I believe even the microcode was lisp. > I suppose there are other nice to haves as well: e.g., GC will need to be fairly controllable. If you're coding the hardware to the language, parts of the GC can be hardware-supported directly. > I see no practical reason why a Lisp can't be used to write an OS Especially since it has been used to write OSes, multiple times.
- pnathan 14y agoOkay, I was making the assumption of using standard x86-style hardware. :-)
- swah 14y agoFunny how, when a language only has one implementation, we easily forget the two things aren't the same.
- deleted 14y ago[deleted]
- eragnew 14y agoThought this article had a number of good tips and insights. Much appreciated.
- deleted 14y ago[deleted]
- edwinnathaniel 14y agoThis article has a similar pattern like the other "we're trying a new language" articles. Sometimes I do wonder why people decided to use a new language for a critical/important piece of their product while learning on the go as well.
- jballanc 14y agoYou know that saying that "the moment you drive a new car off the lot, its value depreciates by half"? Well, the moment you ship a product, the cost of upgrading the underlying technology stack doubles.
- lkrubner 14y agoI feel like the writer of the above article answers part of your question when they write: "My experience is that when you tackle big problems, that go beyond simple execution but require actual strong engineers, hiring will be a problem, there's just no way around it. Choosing people that fit your development culture and see themselves fit to tackle big problems is a long process, integrating them is also time consuming. In that picture, the chosen language isn't a huge deciding factor." As to the issue of change, you go with something else when the current stack is bad and/or unable to do something you need. Colin Steele wrote about this when he decided to switch Hotelicopter to Clojure. He first wrote about how the existing PHP stack needed to be re-written: "For example, at that point, the site ran out of one ginormous subdirectory with hundreds of PHP files scattered like chunks of gorgonzola on your salad, sticking to one another with tenacious glee. There was a “lib” directory, which you think would hold much of the supporting library code, but a good fraction of that actually lived in “site”, and some in “server”. The previous programming staff had felt it good and worthwhile to roll their own half-assed MVC framework, including a barely-baked library for page caching (which broke and took the site down at regular intervals), and components for database abstraction that only worked with - wait for it - MySQL. Every single goddamn file was littered with SQL, like bacon bits on this demonic salad. There was a “log” directory, but the search logs weren’t kept there, they were in “server”. Etc., etc. It made you want to eat a gun." http://www.colinsteele.org/post/23103789647/against-the-grain-aws-clojure-startup http://www.colinsteele.org/post/23103789647/against-the-grai... There are certainly situations where the codebase calls for a complete re-write, and, as the writer says in the quote above, finding good engineers is hard, and the choice of language is a side issue compared to the difficulty of finding good engineers.
- chetan51 14y agoIf you were trying to build the world's next major operating system, would you go with Clojure as one of the core languages, specifically the one that developer-created apps are written in? And could Clojure be fast enough to power the actual OS itself too? With all the new excitement around Clojure, I'm just trying to understand the theoretical and practical limits of the language.
- runevault 14y agoPersonally not sure I would try an OS until Clojure has a compile to target like C, unless you'd try writing an OS in Java.
- ConstantineXVI 14y agoThere is this[0] that gets Clojure[Script] to C via Gambit Scheme, still doesn't seem like something to build an OS on top of. [0] https://github.com/takeoutweight/clojure-scheme https://github.com/takeoutweight/clojure-scheme
- praptak 14y ago> would you go with Clojure as one of the core languages, specifically the one that developer-created apps are written in? Only after detaching it from the JVM. Forcing all apps to run on JVM would obviously be too limiting. > And could Clojure be fast enough to power the actual OS itself too? It is definitely possible to get C-grade control over machine code with a Lisp, as evidenced by GOAL/GOOL. Not sure though if it is worth it.