|
New Yorp New Yorp posted:Does "modifying your program to display a political message every time it's run" constitute a coding horror? There's even a GitHub issue about it that's just waiting to turn into a shitfest. not really seeing the problem here
|
# ? Mar 16, 2017 04:35 |
|
|
# ? Jun 5, 2024 07:43 |
|
vim asks me to donate to Uganda on startup and has done so for like, decades, so that seems fine.
|
# ? Mar 16, 2017 04:42 |
|
Asymmetrikon posted:vim asks me to donate to Uganda on startup and has done so for like, decades, so that seems fine. Huh, I wonder how much Vim users have donated by now.
|
# ? Mar 16, 2017 05:27 |
|
I prefer my software to be free as in "suggested donation is $10"
|
# ? Mar 16, 2017 05:47 |
|
Hammerite posted:~~~HYPERLAMBDA~~~ I have recently had to persuade a research group NOT to design an entire language around this concept. It's definitely an ongoing thing.
|
# ? Mar 16, 2017 08:19 |
|
We've been maintaining a client's contracted web app project which uses a bespoke resource bundling system written by the grad students who made the web app. They write a bunch of script tags in XML and put them in named groups. They reference groups from within other groups, then reference a group in a page template, and basically either puke out all the script tags into the page or concatenate the referenced scripts together in order in the end. This happens every time a page template is rendered. Tracking down why the bundler quits without reporting any problems after writing about 80% of the concatenated script has been a thrill.
|
# ? Mar 16, 2017 09:23 |
|
Oh, wow. Based on the above, I googled Hyperlambda and ended up at Hyperlambda.com, which is a blog for.. a rather more sensible person who's writing an event flow DSL in Scala, which is actually useful for the research we're doing. Then I had to find the page for the guy who actually wanted Hyperlambda to be a programming language, and it's here: https://github.com/polterguy/phosphorusfive . This is Hyperlambda: pre:p5.web.widgets.create-container parent:content widgets sys42.widgets.tree _crawl:true _items root:/ .on-get-items p5.io.folder.list-folders:x:/../*/_item-id?value for-each:x:/-/*?name p5.io.folder.list-folders:x:/./*/_dp?value p5.string.split:x:/./*/_dp?value =:/ add:x:/../*/return/* src:@"{0}:{1}" :x:/..for-each/*/p5.string.split/0/-?name :x:/..for-each/*/_dp?value if:x:/./*/p5.io.folder.list-folders/* not add:x:/../*/return/*/_items/0/- src _class:tree-leaf return _items
|
# ? Mar 16, 2017 13:36 |
|
uncurable mlady posted:not really seeing the problem here I feel like mixing politics/religion and software is bad form in general, but especially right now, since the political atmosphere in the US is so strongly polarized. I don't want this to turn into a political discussion. If no one else is bugged by that kind of thing, then it's just me.
|
# ? Mar 16, 2017 16:13 |
|
New Yorp New Yorp posted:Does "modifying your program to display a political message every time it's run" constitute a coding horror? There's even a GitHub issue about it that's just waiting to turn into a shitfest. Master_Odin fucked around with this message at 16:27 on Mar 16, 2017 |
# ? Mar 16, 2017 16:21 |
|
Master_Odin posted:I expect he'll lock the issue like he did the PR that added in this message. Honestly, open source code is free speech. As such, you can add whatever you want when it is your own project. People are free to fork it and start their own project free of messages. However, not every code project needs to be corporate clean less you piss off someone. I personally would not include such a directed message (at least not in such an obvious manner), but others are free to do what they want. HFX fucked around with this message at 17:07 on Mar 16, 2017 |
# ? Mar 16, 2017 17:03 |
|
I mean, obviously the dev is going to alienate some people, but they decided its worth it to them, so good for them I guess. Personally, I wouldn't choose to use or not use something just because of it...it's not like I'm surprised a dev has a political opinion, and if it's a political opinion I disagree with it's not like I'm paying them money or something. Though, I guess by increasing his download count or whatever I'm kind of indirectly "paying" the dev...
|
# ? Mar 16, 2017 17:27 |
|
Ghost of Reagan Past posted:I once, on a lark, wrote an application that'd create a REST API with Flask from a JSON spec. Weird, I did the exact same thing with Flask+JSON, and quit for the same reasons.
|
# ? Mar 16, 2017 17:57 |
|
code:
this is the worst code i've ever seen
|
# ? Mar 16, 2017 18:22 |
|
antpocas posted:this is it The result of hearing "Lists are slow for lookups, use a Dictionary".
|
# ? Mar 16, 2017 18:27 |
|
Bognar posted:The result of hearing "Lists are slow for lookups, use a Dictionary". That's not the big problem.
|
# ? Mar 16, 2017 19:12 |
|
Yeah, this is someone complaining that the compiler keeps throwing irrelevant "wrong type" errors at them. They just want to compile and run, dammit, types don't matter anyway.
|
# ? Mar 16, 2017 19:17 |
|
New Yorp New Yorp posted:I feel like mixing politics/religion and software is bad form in general, but especially right now, since the political atmosphere in the US is so strongly polarized. I'm bugged by it, so you're not alone.
|
# ? Mar 16, 2017 19:42 |
|
antpocas posted:
|
# ? Mar 16, 2017 22:12 |
|
Athas posted:That's not the big problem. The Guard.Against<TException> class is pretty nifty, however its implementation uses reflection the find the constructor for TException, and doesn't cache the constructor anywhere, which kind of bothers me. The extension method IsNull (which is literally public static bool IsNull(this object source) { return source == null; }) is another. (there is also an IsNotNull extension method, its implementation is left as an exercise for the reader). Using Activator.CreateInstance(Type t) without any assurance that t has a default constructor is asking for trouble as well. Using Activator is just nasty in general. The biggest problem is in the constructor though. TypeHelper.LoadInterfaceTypesFromAssembly<T> which I didn't bother posting, is scanning the executing assembly for classes that implement the T interface. Then it's creating a new dictionary based on that (but not before creating a List first! it's not as if there's a ToDictionary method or anything) every single time GenericFactory<T> is instanced, even though this needs to be done exactly once for each closed GenericFactory. TypeHelper.LoadInterfaceTypesFromAssembly<T> shouldn't exist either, but that's beyond the scope of this post.
|
# ? Mar 16, 2017 23:03 |
|
That and, you know, the fact that Activator.CreateInstance has a (String assemblyName, String typeName) overload which makes the class's very existence completely pointless in addition to revolting.
|
# ? Mar 17, 2017 00:08 |
|
NihilCredo posted:That and, you know, the fact that Activator.CreateInstance has a (String assemblyName, String typeName) overload which makes the class's very existence completely pointless in addition to revolting.
|
# ? Mar 17, 2017 00:14 |
|
What kind of weird bubble do you have to live in to avoid a DI container in this day and age? Microsoft's been shipping one with every framework for like seven years.
|
# ? Mar 17, 2017 00:55 |
|
At this 100 person company I work for, there are 2 people who understand DI containers and maybe 10 who use them. Plenty of people think DI is hipster weirdness overhead and a bizarre way to define method parameters.
|
# ? Mar 17, 2017 14:43 |
|
EssOEss posted:At this 100 person company I work for, there are 2 people who understand DI containers and maybe 10 who use them. Plenty of people think DI is hipster weirdness overhead and a bizarre way to define method parameters. Isn't it enterprise weirdness overhead?
|
# ? Mar 17, 2017 15:20 |
|
Edison was a dick posted:Isn't it enterprise weirdness overhead? Kind of. I think that reaching the point in an application where you need a DI container to manage the dependency graph can be an indication that it's poorly architected and needs clearer delineations between subsystems. I read it as, "I've made my dependency chain so byzantine and inscrutable that I need to have special software to manage it"
|
# ? Mar 17, 2017 16:48 |
|
Meh, I am coming around to the fact that DI just makes stuff more complicated and diffuse. Going on all the question on Stack Overflow from people who can't grasp it, it seems needlessly complex.
|
# ? Mar 17, 2017 17:25 |
|
Dependency injection is what we're talking about, right? It's loving amazing. You use it to make your code testable. Instead of having a hardcoded reference to the database, your query code takes the DB connection as a parameter, and then your unit test code can create a mock or fake DB and send that in instead. Ditto with network calls, references to the filesystem, etc. Your unit tests can do everything in memory, which means they run faster and more reliably, which means you run them more often, which means they're more useful. Of course there are good and bad ways to do dependency injection, but one of the things IMO almost every developer should be learning is how to recognize where a dependency should be injected vs. implicit.
|
# ? Mar 17, 2017 17:46 |
|
TooMuchAbstraction posted:Dependency injection is what we're talking about, right? It's loving amazing. You use it to make your code testable. Instead of having a hardcoded reference to the database, your query code takes the DB connection as a parameter, and then your unit test code can create a mock or fake DB and send that in instead. Ditto with network calls, references to the filesystem, etc. Your unit tests can do everything in memory, which means they run faster and more reliably, which means you run them more often, which means they're more useful. I wasn't talking about DI, I was talking about using DI containers to manage constructing and injecting the dependencies. I like DI, I dislike DI containers.
|
# ? Mar 17, 2017 17:55 |
|
Mr Shiny Pants posted:Meh, I am coming around to the fact that DI just makes stuff more complicated and diffuse. Going on all the question on Stack Overflow from people who can't grasp it, it seems needlessly complex. I find dependency injection difficult to wrap my head around but I recognise that it's a bit of a personal blindspot. The same way some people find it difficult to understand pointers, or what have you, dependency injection is something I find difficult to grasp. I've felt at times that I had a good grasp of it, when I've seen an explanation that's particularly compatible with my way of understanding things I guess, but I don't use it enough to keep a handle on it for the next time I need to understand it...
|
# ? Mar 17, 2017 17:57 |
|
New Yorp New Yorp posted:I like DI, I dislike DI containers. It continues to amaze me how many people conflate the two.
|
# ? Mar 17, 2017 17:57 |
|
New Yorp New Yorp posted:I wasn't talking about DI, I was talking about using DI containers to manage constructing and injecting the dependencies. I like DI, I dislike DI containers. I was reacting to this, to be clear: Mr Shiny Pants posted:Meh, I am coming around to the fact that DI just makes stuff more complicated and diffuse. Going on all the question on Stack Overflow from people who can't grasp it, it seems needlessly complex.
|
# ? Mar 17, 2017 17:58 |
|
Hammerite posted:I find dependency injection difficult to wrap my head around but I recognise that it's a bit of a personal blindspot. The same way some people find it difficult to understand pointers, or what have you, dependency injection is something I find difficult to grasp. What's hard to understand about this? Given this: code:
code:
code:
New Yorp New Yorp fucked around with this message at 18:08 on Mar 17, 2017 |
# ? Mar 17, 2017 18:05 |
|
New Yorp New Yorp posted:What's hard to understand about this? Stated differently: constructors exist for a reason, use them.
|
# ? Mar 17, 2017 18:09 |
|
Yeah that's the thing. Dependency injection is just passing your dependencies around as parameters, but then there's dependency injection Frameworks that do magic that makes it implicit somehow.
|
# ? Mar 17, 2017 18:11 |
|
IoC containers are cool and good in plangs where they are idiomatic (c# and java).
|
# ? Mar 17, 2017 18:12 |
|
New Yorp New Yorp posted:What's hard to understand about this? Well, that's not hard to understand at all, in fact it's extremely simple. But generally when I see an explanation of dependency injection it's explained in abstract terms and crucially, the discussion is bundled up with a whole lot of other terms, like "inversion of control" and "SOLID" that I might be able to understand if they were introduced individually but which are too much to take in when all introduced at once and defined abstractly. I'm best equipped to understand concepts when they're expressed in terms of a prototype - a motivating example - rather than an abstract definition. It doesn't help that I tend to remember dependency injection as meaning the kind of big, complex frameworks that other posters are talking about (as being distinct from dependency injection), because that's what I've seen talked about in discussions at work.
|
# ? Mar 17, 2017 18:34 |
|
Hammerite posted:Well, that's not hard to understand at all, in fact it's extremely simple. But generally when I see an explanation of dependency injection it's explained in abstract terms and crucially, the discussion is bundled up with a whole lot of other terms, like "inversion of control" and "SOLID" that I might be able to understand if they were introduced individually but which are too much to take in when all introduced at once and defined abstractly. I'm best equipped to understand concepts when they're expressed in terms of a prototype - a motivating example - rather than an abstract definition. It doesn't help that I tend to remember dependency injection as meaning the kind of big, complex frameworks that other posters are talking about (as being distinct from dependency injection), because that's what I've seen talked about in discussions at work. DI is a method of implementing IoC. It's just a way of solving the problem "I want to test a thing that gets data from a web service/database/other complex component without actually involving the web service/database/other complex component" or, "I want this thing that gets data from something else to be able to get data from any number of something elses based on some set of criteria, without altering the logic of the thing".
|
# ? Mar 17, 2017 18:45 |
|
New Yorp New Yorp posted:DI is a method of implementing IoC. It's just a way of solving the problem "I want to test a thing that gets data from a web service/database/other complex component without actually involving the web service/database/other complex component" or, "I want this thing that gets data from something else to be able to get data from any number of something elses based on some set of criteria, without altering the logic of the thing". My way of looking at it is as follows: "In order to do my job I need an instance of X. Someone give that to me." In the example presented above, Foo needs a Bar to be able to do its work. It explicitly asks for it in the constructor, and Main provides it when it makes a Foo. What DI frameworks do is provide that automatically (via the magic that is also known as reflection). All that Main has to do is tell the DI framework: whenever anyone requests an IBar give them an instance of this Bar object. That's all there is to it. But then, you can't go and say "new Foo()" anymore. You have to go to the DI framework and ask it to make a Foo for you. Then the DI framework will take care of providing all the required dependencies that Foo asks for.
|
# ? Mar 17, 2017 20:37 |
|
One of my favorite systems was a game server holding 10,000 concurrent player connections running on 150 or so threads. The DI system would handle setting up the player classes before processing client input. I.e.: open bank ui is being called, and so the player object and the bank object would be injected. But it would be that players player object cached from a previous call, and we'd context switch away when we saw we couldn't instantiate the bank without a db hit. So it'd make the request and try again when the data came back. Meanwhile game engineers didn't think of that they just thought, this call requires the player and the bank, ok given that do...
|
# ? Mar 17, 2017 20:58 |
|
|
# ? Jun 5, 2024 07:43 |
|
Hammerite posted:It doesn't help that I tend to remember dependency injection as meaning the kind of big, complex frameworks that other posters are talking about (as being distinct from dependency injection), because that's what I've seen talked about in discussions at work. I feel like most tutorials tend to start from a complicated example of everything it can do, instead of just building up from the basics so you can grasp the different layers of functionality At its most basic level a DI framework just provides stuff - it lets you specify which classes it can instantiate, and then you can ask for one. It can obviously do no-arg constructors, and it can also build objects that require other objects it knows how to make. Sometimes you'll need to specifically tell it how to instantiate a particular class. So long as it can put all the pieces together, it'll work out what needs to be made in what order and out pops the thing you wanted You don't need to worry about the process, it handles all that for you, and if the dependencies change it'll just do work out how things are connected now. You added a new dependency to a class's constructor? Cool, if the framework knows how to provide that dependency, it'll do it automatically and everything will still work, even if it means the instantiation order has changed. If you do need to change anything, it'll be something in your DI definitions, all in one place If you like, you can get into fancier stuff, like providing different versions of a particular dependency by specifying different ways to instantiate it. Or scoping stuff so certain objects all share the same instance of a dependency, or whatever. It's all there to help you enforce DI as a pattern and manage all the stuff you need to pass in. Sometimes that stuff and its relationships to other stuff is fairly complicated! It can be a good example of the organisational power of DI frameworks, and how it simplifies complex relationships and lets the computer worry about resolving them, but it doesn't necessarily make for a good introduction to the whole concept
|
# ? Mar 17, 2017 21:10 |