9 ms·
Functorio
- shaunxcode 5y agoWhen I play factorio I am thinking about the conveyer belts as CSP channels and the grabber arms and factories as processes. Nothing to say the processes aren’t functions of course.
- schappim 5y agoFrom 9 months ago: https://news.ycombinator.com/item?id=26157969 https://news.ycombinator.com/item?id=26157969
- nodivbyzero 5y agoHere is the another interesting discussion about `Game Oriented Assembly Lisp` https://news.ycombinator.com/item?id=2090554 https://news.ycombinator.com/item?id=2090554
- switchbak 5y agoTangentially related: I would love a brilliant game dev to replace my hierarchical folder view with a recursive / graphical overview that lets me see the summarized structure/relations of an application (or set of services?). Seems like leveraging our spatial system to communicate locality and purpose while hiding the innards would be very beneficial. I don't think you'd need to go full-on graphical programming language to achieve it either.
- BlueTemplar 5y agoLike LabView ?
- deleted 5y ago[deleted]
- Zababa 5y agoI wonder what the OOP version of that would look like. Trivially, you can imagine that an assembling machine is an object to which you can send a message CopperPlate, and that will reply with CopperWire, CopperWire. I've been thinking about factories like you see in "How it's made" and how you can imagine the machines in terms of functions with an input and an output, object to which you pass something and receive something back, or even "ingredient flow" where the focus is on the product and the different steps and not the transformations.
- Barrin92 5y agoThe line between functional and object oriented actually gets very blurry when you take OO in its traditional sense, i.e. if you accept message passing between objects as the defining feature. if the object becomes a pure blackbox and all you care about is what it sends and receives then this is hard to distinguish from the functional thinking, because even functions at their core usually have an imperative implementation, they just hide it away. Erlang has been brought up in the thread and it's a good example of this because people use it as an example of both functional programming and maybe the closest thing to Alan Kay's original ideas about OO.
- i_hate_pigeons 5y agoif you take mutation of state out of the object, and we leave aside all the category theory part of fp then is more a matter of where functions are defined/how they organised
- 8note 5y agoOop's defining feature is having hidden state behind those interfaces. Pure functions do not have that
- Mikeb85 5y agoMonads are the little black boxes of state that send and receive messages. According to wikipedia, "a monad is defined as a functor with additional structure". Not unlike an object.
- epolanski 5y agoMonads don’t receive nor send anything. Arrays are a type that admits a monad instance, what do they send and receive?
- hprotagonist 5y agodef x(input): tmp=input * 5 return str(tmp) hey, hidden state!
- zz865 5y agoNice blog post, but: > You might have heard people say that functional programming is more academic, and real engineering is done in imperative style. Real Engineering is done in imperative style. There are very very few projects done in pure functional style. Sure it can be possible, there are always a few FP projects sprinkled around eg Spark has done great. But FP really is a niche specialty. It makes me think it just isn't the right tool for the job.
- 9wzYQbTYsAIc 5y agoIncluding the rest of the paragraph: > I’m going to show you that real engineering is functional, and I’m going to illustrate it using a computer game that is designed by engineers for engineers.
- klelatti 5y agoErlang is a functional language and was originally written to power telecoms systems. I think that very much counts as Real Engineering.
- wpietri 5y agoFor sure. Right tools for the job. Indeed, I'd say that a lot of the software development I do isn't Real Engineering. And that's fine! I have a lot of respect for the people who make 50-story skyscrapers. But a lot of the time what people need is a modest one-story apartment, a redone kitchen, a backyard doghouse. Or a movie set that just looks like an apartment.
- pjmlp 5y agoDigital circuits are full of FP, and that is real engineering.
- deleted 5y ago[deleted]
- carlmr 5y agoA lot of data engineering (pandas dataframes) is functional. GPU/shader programming is very functional. SQL queries are often quite functional.
- remram 5y agoI would say Factorio is all about routing & layout. The functions are handed to you.
- FPGAhacker 5y agoIt’s about supply chain management Routing and layout are tools you use in that management, but don’t mistake the tool for the problem it solves.
- tikhonj 5y agoSeems pretty similar to functional programming in that respect. When I write code in languages like Haskell, I tend to focus the most on two things: 1. The conceptual organization of the code (≈ layout) 2. The interfaces between components (≈ routing) Static types and functional programming naturally lean into this: types provide a first-class way to sketch out layout and interfaces in code without needing to implement the code in full detail. I'm drawn to static types less because of correctness or preventing bugs—although I can't complain about that!—and more because they give me a quick, high-level sub-language to sketch out and iterate on the design of my code. Those same types then act as guideposts for how the codebase fits together, making it easier for me to understand projects written by others or revisit code I wrote but don't remember well myself.
- User23 5y agoNow I want to see the Verilogtorio post. Combined with a layout CAD too of course.
- detaro 5y agohttps://github.com/Redcrafter/verilog2factorio https://github.com/Redcrafter/verilog2factorio
- dgb23 5y agoYou always get functions handed to you in programming languages. CPU instructions are handed to you. Scheme, has a small core of special forms which are handed to you. You build up bigger specific things from small general things. In factorio you create bigger functions from smaller ones as explained in the article in great detail. The routing and layout part is about organization, but the more abstract notions of combinations and ratios are "functional" in the sense of the article.
- wdh505 5y agoI prefer open-sourced mindustry
- Kiro 5y agoVery different game. Still great though.
- davesque 5y agoVery neat article. Since I got into and out of Haskell a while back, one of the complaints I always had about breaking into the space was that it was too abstract. Some of the core concepts of FP seemed really arbitrary when described without useful examples. So it's nice that the author has found a great analogy in Factorio. However, I have to say that I don't think the author succeeded in showing me "that real engineering is functional." During my tour of FP, I would always eventually run into a wall of abstraction as soon as things got more than a little bit complicated. In that sense, Factorio comes across as a bit of a contrived example. As soon as you have an algorithm that lends itself to a few pieces of mutable state in a loop with complex terminating conditions, good luck. Yes, it's theoretically possible to shoehorn things like that into the formalities of FP. However, doing so usually ends up feeling like an academic exercise more than anything else. It doesn't feel like it moves you any closer to your ultimate goals; to implement functionality more quickly, cleanly, and intelligibly. That being said, I don't regret getting into FP for a while. It's always a useful challenge to re-frame what you think you know with a different set of concepts. FP also works really well for certain kinds of problems. But I think the number of those are relatively few. This may be reaching, but I like to believe there's some historical precedent for this. After all, none other than Kurt Gödel himself eventually abandoned the λ-calculus in favor of Turing's mechanical (imperative) framing of computation. I want to believe there was some similar sentiment behind this decision. But who knows? It was probably more of a technical thing than I realize. But I've always felt on some level that an overabundance of abstraction necessarily means a lack of power.
- thinkharderdev 5y agoIf you are writing a complex algorithms then an imperative style is usually going to be clearer (and more performant), but when dealing with higher-level code that is just moving data around and doing some relatively straightforward mutations, then functional code can be much more straightforward and intelligible. When you introduce concurrency then that is where I think pure FP really shines. Writing concurrent code with a pure FP effect system like ZIO is so much nicer (and safer!) than writing concurrent code in Java (or any other language I've ever used).
- petethepig 5y agoFactorio is a is queuing systems simulator. Just like your web server, those little factories process resources (requests) at certain speeds and pass them down to a bunch of other queuing systems (databases). I think it's really good at teaching intuition about queuing systems.
- FPGAhacker 5y agoThat’s an interesting take and I agree. I thought about it more like supply chain management, of which queues are a part.
- amelius 5y agoDid anyone tackle the bullwhip effect [1] in their microservices architecture? [1] https://en.wikipedia.org/wiki/Bullwhip_effect https://en.wikipedia.org/wiki/Bullwhip_effect
- Closi 5y agoUnfortunately it’s nothing like supply chain management in reality! It’s a bit like automated warehouse design but not really (Supply chain & logistics consultant here).
- phamilton 5y agoWhat are some of the misconceptions that make it so different? "I need iron plates but there aren't any available" just feels so intuitively like a supply chain problem, I'd love to learn how the real world is so much more complicated.
- chii 5y agoi suppose supply chain management involves negotiation and business acumen, rather than manufacturing process efficiency.
- quartesixte 5y ago
- HKH2 5y agoNo side effects?
- stathibus 5y agoI think it's clear to most people who build things that functional programming only appears in the wild when a programmer sets out to build something with functional programming. Those of us who are not taken by this hobby would never use it for anything.
- exitheone 5y agoFunctional programming is everywhere. Many aspects of for example modern Java also move in the direction of functional programming. Those who never learn it are just stuck writing software in a more complicated and less readable way. Learning FP and using it where it makes sense can do wonders to the quality of code you write. And over the past years many (even "traditional") languages have recognised and embraced that fact.
- mbrodersen 5y agoWe use pure functional programming in production to manage airline pairing/rostering and optimisations. Each customer has about 150k lines of pure functional code running on their servers. Also, Google “Elm” for examples of a pure functional language being used in production by other companies and how Facebook and other companies use Haskell in production.
- wheelerof4te 5y agoLot of games develop some kind of logical thinking. RTS games in particular. I remember playing Age of Empires 2 as a teenager and enjoying the amount of choices I have to win the game. Plus, the game teaches you about efficiency like few other games at the time. Each game, the sheer amount of resources and technologies you had to track in real time is equivalent of small bussines. Then came Starcraft and logical thinking was replaced with player APM.
- ronenlh 5y agoHis talk about this is great: https://youtu.be/A46KQtriYuM https://youtu.be/A46KQtriYuM
- YeGoblynQueenne 5y ago>> The building blocks of every programming language are functions. "Every"? Nope: https://en.wikipedia.org/wiki/Logic_programming https://en.wikipedia.org/wiki/Logic_programming The "building blocks" (actually, the only data structure) of logic programming languages like Prolog, ASP, Mercury, Oz, etc are ... relations. Which map elements of sets without specific inputs and outputs. Put that in Haskell's pipe and smoke it. OK, but now let's ask the important questions: has anyone implemented SLD(NF)-Resolution in Factorio, yet?