|
MALE SHOEGAZE posted:vim is suiting my needs. I'm sure sublime would be good re: python indenting. I got a gently caress ton of errors the other day after I copied and pasted poo poo from ipython to sublime and even thought all the indents looked fine I had to go through and retab all the offending lines
|
# ? Nov 4, 2015 19:01 |
|
|
# ? May 24, 2024 13:49 |
|
pepito sanchez posted:MonocQc curious what IDE do you use for your erlang? i am hating emacs for haskell and elixir. or it's hating me. or both. i have been trying this out: https://www.jetbrains.com/idea/features/erlang.html i mostly use vim tho
|
# ? Nov 4, 2015 19:20 |
|
vodkat posted:I had to go through and retab all the offending lines sublime doesn't have find/replace?
|
# ? Nov 4, 2015 20:54 |
|
NihilCredo posted:sublime doesn't have find/replace?
|
# ? Nov 4, 2015 21:21 |
|
Captain Foo posted:1) I'm not sure! The game server and all player middlemen processes subscribe to the event sync and write to it. So the way to think about this one is to have the main server that's a big state machine transitioning between day -> night, during the day phase it receives votes from players and tallies them. It can then transition to night on getting the right vote count (and inserts a message about it to players), triggers the scum actions in the same way, and so on. The thing can just wait for votes from players it has in a list with their status. Meanwhile the players can subscribe to these events too, relay them to actual human players, and filter stuff in according to the time of the day related by the server, and filter out according to which events the player is allowed to see. This ends up being a bunch of independently set state machines communicating over messages, but the player process has nearly nothing to know about game mechanics, and can even be used to trigger default actions or route to an AI if you wanted to. pepito sanchez posted:MonocQc curious what IDE do you use for your erlang? i am hating emacs for haskell and elixir. or it's hating me. or both. It's just that my entire Erlang experience started from a hobbyist standpoint and the tooling ended up usable outside of any specific editor so I was fine with that. Yep. There's a quick reference to my setup there.
|
# ? Nov 4, 2015 21:27 |
|
lets talk about terrible programs. Apparently safari on ios eats taps on links under certain situations so you have to write some hacks to force it to actually treat the tap as a click on the link. gently caress you apple your poo poo is garbage
|
# ? Nov 4, 2015 21:43 |
|
Jeffrey of YOSPOS posted:find/replace on whitespace in python sounds like a dangerous game he said he'd just copy/pasted that stuff from outside. hold the selection, replace [ ]{4} with tab within the selection. don't see a problem unless there were string literals with lots of whitespace in there. NihilCredo fucked around with this message at 22:08 on Nov 4, 2015 |
# ? Nov 4, 2015 22:04 |
|
MALE SHOEGAZE posted:i always spend time trying to make my code simple and composable but there is a part of me than sometimes wonders if it's sometimes a bit like premature optimization. Barnyard Protein posted:imo you shouldn't create a function just to make another function smaller unless the composition you create makes sense. short functions are a sign of a good design, but seems like saying "short is better" leads to short functions with bad design. i see this a lot. people have a class with a super long function, but they know Long Function Bad Thing. so they split it up into a bunch of no-return no-argument methods that manipulate the class fields, and one worker method that calls the other chunks. the key here to good design is trying to as much as reasonably possible structure your program as the composition of small, pure or kind-of-pure functions. as much as possible, make the output of a function depend on its inputs. unfortunately a lot of languages kind of work against doing this right and you kind of have to do half-assed pure functions, but it's certainly better than alternatives.
|
# ? Nov 5, 2015 01:20 |
|
Barnyard Protein posted:they split it up into a bunch of no-return no-argument methods that manipulate the class fields i had someone come to my desk and shout at me after i rejected this kind of thing in a code review and wouldn't budge.
|
# ? Nov 5, 2015 01:54 |
|
NihilCredo posted:sublime doesn't have find/replace? I'd expect any programmer's editor to have entab/detab commands, to convert an entire file from one to the other of course even better is to have a mode line in the file and an editor that respects it...
|
# ? Nov 5, 2015 02:10 |
|
NihilCredo posted:he said he'd just copy/pasted that stuff from outside. hold the selection, replace [ ]{4} with tab within the selection. don't see a problem unless there were string literals with lots of whitespace in there. Yea there was probably a much neater way to fix this, its just for those 15 minutes I did spend fixing this all I was thinking was what a stupid loving problem it was
|
# ? Nov 5, 2015 04:27 |
|
lol i just found out in haskell you can docode:
|
# ? Nov 5, 2015 07:25 |
|
lol i just found out in haskell you can docode:
|
# ? Nov 5, 2015 07:34 |
|
thanks radium. thadium.
|
# ? Nov 5, 2015 07:38 |
|
fart simpson posted:lol i just found out in haskell you can do I wonder if this is a natural consequence of how lazy evaluation was implemented or someone went out of their way to guarantee this is a thing in the language
|
# ? Nov 5, 2015 10:54 |
|
most weird syntax issues are fixed with lightweight linters Especially languages as rigid as python hell even jshint fixes 99% of javascript problems
|
# ? Nov 5, 2015 11:11 |
|
Symbolic Butt posted:I wonder if this is a natural consequence of how lazy evaluation was implemented or someone went out of their way to guarantee this is a thing in the language neither, it's a consequence of the syntax for function definitions and pattern matching what "let 2 + 2 = 5" actually does in haskell is create a new infix operator "+" which is only defined for the arguments 2 and 2. this becomes clear if you try "let 2 + 2 = 5 in 1 + 1", which fails with a "non-exhaustive patterns" error.
|
# ? Nov 5, 2015 11:29 |
|
Soricidus posted:neither, it's a consequence of the syntax for function definitions and pattern matching does the infix operator "+" already exist in haskell? because if it does, that's insane, whereas if it doesn't, that's insane
|
# ? Nov 5, 2015 11:33 |
|
it does, but i guess you can redefine it
|
# ? Nov 5, 2015 11:56 |
|
Soricidus posted:neither, it's a consequence of the syntax for function definitions and pattern matching ooohhh thanks, suddenly I feel like I know everything about haskell now Soricidus posted:it does, but i guess you can redefine it it seems more like it's shadowing the previous definition
|
# ? Nov 5, 2015 13:24 |
|
qntm posted:does the infix operator "+" already exist in haskell? because if it does, that's insane, whereas if it doesn't, that's insane Local bindings silently shadow globals while they're in scope
|
# ? Nov 5, 2015 13:24 |
|
Just got given a bunch of specs for new features and saw a line at the bottom: "Clients may require some changes once they have [these features]". They haven't even talked to real users about what they need.
|
# ? Nov 5, 2015 14:25 |
|
changes are normal right? or does that mean "Clients may decide they want to change the spec they just handed you after you've implemented it, causing you to redo all the work you just did"
|
# ? Nov 5, 2015 15:47 |
|
MononcQc posted:A way to organize this one that's interesting is to make it fully asynchronous by sending all player and server actions to a process that acts like an event sync (it can store them transient or permanently if you want game logs). I think this is what I'm planning to do - there are going to be no human players ( I would just run a game if I wanted that ) but to simulate the game of forums Mafia. So I will definitely want detailed logging, so I can report on the results of the game and the actions within. code:
|
# ? Nov 5, 2015 16:17 |
|
Captain Foo posted:I think this is what I'm planning to do - there are going to be no human players ( I would just run a game if I wanted that ) but to simulate the game of forums Mafia. So I will definitely want detailed logging, so I can report on the results of the game and the actions within. Pretty much. This is doable with a gen_event where all the event handlers are more or less filter functions that then forward relevant events to the process that added it. So the game server might subscribe to all events not submitted by the game server, a player may filter for only events targeted to it by the game server or events broadcasted to all possible listeners, and the logfile would subscribe to absolutely everything. This sets up a workable way to do things, but commits you to a few things, such as having no redundancy for a game process (if the event sync goes, you're done), and developing everything extremely asynchronously. This means you'd have rather tricky integration tests to make sure all players and the game can only switch states in lockstep and won't mess each other up if a message is delayed, for example. Writing good tests for that is challenging, and usually they will be very superficial. Anything in great depth regarding these tests will require a tool like QuickCheck or PropEr (free variant). These last two will let you establish a model to compare the actions of your program with, and then sets of commands with pre- and post-conditions, and will then generate random walks through your game state, hoping to show that your software matches your model. It's a more advanced topic and there are tutorials out there for it, but it's usually a far more advanced topic so I'd avoid looking into it until you feel you really need it.
|
# ? Nov 5, 2015 16:33 |
|
MononcQc posted:Pretty much. This is doable with a gen_event where all the event handlers are more or less filter functions that then forward relevant events to the process that added it. So the game server might subscribe to all events not submitted by the game server, a player may filter for only events targeted to it by the game server or events broadcasted to all possible listeners, and the logfile would subscribe to absolutely everything. Thanks for all the insight - this is all going to be run locally, and it's utterly non-critical so I think I'll work on the design of the basic model as you described the first paragraph. On the actual practical side of things, I've built a function to slurp a player list from disk and then return a random selection of ?GAMESIZE players
|
# ? Nov 5, 2015 16:37 |
|
We're integrating some PayPal functionality at work. The "everybody is configured correctly" case is working fine, but we have no idea what'll happen when stuff fails, because PayPal's documentation is poo poo. I'm about to advocate that we should release like this and just leave room in our project planning for the inevitable emergency patches. Ugh.
|
# ? Nov 5, 2015 16:52 |
gonadic io posted:Local bindings silently shadow globals while they're in scope To expand on this, that new definition of the + operator only exists in the expression following "in"--so in practice it is very local. If you try to define a new + function on a more global scope you can, but you have to specify which + function you are using from then on:
|
|
# ? Nov 5, 2015 20:26 |
|
Barnyard Protein posted:changes are normal right? or does that mean "Clients may decide they want to change the spec they just handed you after you've implemented it, causing you to redo all the work you just did" This is pretty much why for my little dev/design shop we don't quote, we estimate and give them a budget of hours to work with. Because getting them to be happy with committing to a spec is nigh on impossible, and were not keen on being left holding the bill because of an overrun on communication or reimplementation.
|
# ? Nov 5, 2015 20:39 |
|
comedyblissoption posted:breaking stuff up into small composable functions is not such an undue burden that 300 line functions are excusable. it's generally easier to write a bunch of small composable functions than the equivalent 300 line function in the first place. i break longer functions into smaller chunks and try to make smaller methods from them if they get to large. i dont turn a few lines into a function just because, only if they can be called more than twice. sometimes i turn them into functions just to help readability, or if I want to test it in isolation. i agree that sometimes the push for smaller functions makes people think that that means cleaner code, which is not always the case.
|
# ? Nov 5, 2015 20:53 |
|
it also depends on the complexity, sometimes the function is way too big but it's all 300 lines of pure drudgework, like say setting up an http request in some lovely C library so, in the case of this clown circus of a function devoid of any significant logic, it gives you almost zero benefit to break down into smaller functions but in general I tend to lazily write big functions. having a conscious effort of pushing them into smaller functions when I feel like it never hurted me
|
# ? Nov 5, 2015 21:26 |
|
CPColin posted:I'm about to advocate that we should release like this and just leave room in our project planning for the inevitable emergency patches. You should do that anyway.
|
# ? Nov 5, 2015 21:32 |
|
Nitrocat posted:i break longer functions into smaller chunks and try to make smaller methods from them if they get to large. i dont turn a few lines into a function just because, only if they can be called more than twice. sometimes i turn them into functions just to help readability, or if I want to test it in isolation. i agree that sometimes the push for smaller functions makes people think that that means cleaner code, which is not always the case. Sometimes I do break things up even if I'll only call it once, especially if a nicely named function call is going to be more comprehensible than whatever 5-6 lines of code are there. Like, if I have 5 lines of code to retrieve a piece of data from the database and put it into a variable, that can look kinda junky since (horror alert), our database refers to all data elements by numeric IDs. So I might replace something like the following: code:
code:
|
# ? Nov 5, 2015 21:41 |
|
Barnyard Protein posted:changes are normal right? or does that mean "Clients may decide they want to change the spec they just handed you after you've implemented it, causing you to redo all the work you just did" they haven't even spoken to clients about the spec. they're just guessing at what they want it's ridiculous
|
# ? Nov 5, 2015 21:46 |
|
pointsofdata posted:they haven't even spoken to clients about the spec. they're just guessing at what they want it's ridiculous do... we work together?
|
# ? Nov 5, 2015 21:50 |
|
lol just now learning about yield return.
|
# ? Nov 5, 2015 22:06 |
|
Shaggar posted:lol just now learning about yield return. dude, yield return owns. how did you not know about yield return. do you know about adding indexers to collections that aren't otherwise accessible using [] syntax?
|
# ? Nov 5, 2015 22:08 |
|
idk never came up until today. ive added [] overloads to stuff before but im not sure if that's what you mean.
|
# ? Nov 5, 2015 22:11 |
|
Shaggar posted:lol just now learning about yield return. don't get to crazy with it, especially when you don't really need deferred execution or when you know exactly how many items you're going to be returning anyway. it's nice not having to define a variable to hold your yielded results but it doesn't come for free
|
# ? Nov 5, 2015 22:15 |
|
|
# ? May 24, 2024 13:49 |
|
Shaggar posted:
Yeah, I mean that. It blew my mind when I first learned it, because it meant you could do things like overload [] on a dictionary or something to use array-like syntax to look up dictionary items, and the like. It's not always insanely useful, but it makes me obnoxiously happy for some reason.
|
# ? Nov 5, 2015 22:26 |