Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
Suspicious Dish
Sep 24, 2011

2020 is the year of linux on the desktop, bro
Fun Shoe
Building A Node.JS Server That Won’t Melt – A Node.JS Holiday Season, part 5

Adbot
ADBOT LOVES YOU

Cocoa Crispies
Jul 20, 2001

Vehicular Manslaughter!

Pillbug

Otto Skorzeny posted:

cscope has existed for a zillion years and is a good bit better than this

systems that hook clang now exist and are much better than this

(lisp environments of course have been much better than this forever)
yeah but powerful-langs (or maybe p-lang is short for "post-c language") basically require you to actually call the function to know if it exists, and most of them have a flexible concept of "argument" too

smalltalk was cool because it nailed all that

Gazpacho
Jun 18, 2004

by Fluffdaddy
Slippery Tilde

Sang- posted:

some language *used* to do this - compile no matter what but I can't remember its name
I think pl/I was really big about accepting any statement however malformed

Then you have completely agrammatical langs like tcl that just don't give fucks

I had the best pl flame war once with this guy who thought XML was stupid because somehow tcl already did what XML did and everyone should just use tcl

Gazpacho fucked around with this message at 19:32 on Jan 15, 2013

Cocoa Crispies
Jul 20, 2001

Vehicular Manslaughter!

Pillbug

Gazpacho posted:

I think pl/I was really big about accepting any statement however malformed

Then you have completely agrammatical like tcl that just don't give fucks

I had the best pl flame war once with this guy who thought XML was stupid because somehow tcl already did what XML did and everyone should just use tcl

tcl isn't agrammatical but tbf xml is stupid because lisp has always existed

prefect
Sep 11, 2001

No one, Woodhouse.
No one.




Dead Man’s Band

Cocoa Crispies posted:

yeah but powerful-langs (or maybe p-lang is short for "post-c language") basically require you to actually call the function to know if it exists, and most of them have a flexible concept of "argument" too

smalltalk was cool because it nailed all that

First there was BCPL, then B, then C, now P-langs. That's how it goes, right?

Posting Principle
Dec 10, 2011

by Ralp
protobuf is really cool and is going to make this project super easy

thanks google. thoogle

Gazpacho
Jun 18, 2004

by Fluffdaddy
Slippery Tilde

Cocoa Crispies posted:

tcl isn't agrammatical but tbf xml is stupid because lisp has always existed
Yeah and paren matching is still as much a pain as it was in the beginning

Janitor Prime
Jan 22, 2004

PC LOAD LETTER

What da fuck does that mean

Fun Shoe

Jerry SanDisky posted:

protobuf is really cool and is going to make this project super easy

thanks google. thoogle

Yes it is, I loving love it for making my client sever apis. Automatically versioned binary messages that are forward and backward compatible and are portable across languages?

gently caress you SOAP Web Services

Gazpacho
Jun 18, 2004

by Fluffdaddy
Slippery Tilde
Not saying lisp is a bad language just drat unattractive, it's the Lyle lovett of langs

Catalyst-proof
May 11, 2011

better waste some time with you

Gazpacho posted:

Not saying lisp is a bad language just drat unattractive, it's the Lyle lovett of langs

lisp is beautiful

spongeh
Mar 22, 2009

BREADAGRAM OF PROTECTION

Hard NOP Life posted:

Yes it is, I loving love it for making my client sever apis. Automatically versioned binary messages that are forward and backward compatible and are portable across languages?

gently caress you SOAP Web Services

seriously, protobufs is awesome. we use thrift here which as far as i understand is basically the same idea. but not having to deal with xml hell is fantastic.

Shaggar
Apr 26, 2006
lol @ people using language with bad xml support.

Janitor Prime
Jan 22, 2004

PC LOAD LETTER

What da fuck does that mean

Fun Shoe

Shaggar posted:

lol @ people using language with bad xml support.

Platforms, not languages in my case.

Posting Principle
Dec 10, 2011

by Ralp
one of my endpoints is java, shaggar

Shaggar
Apr 26, 2006
java makes xml ez.

Cocoa Crispies
Jul 20, 2001

Vehicular Manslaughter!

Pillbug
guns make violence ez but it doesn't mean you should use either one

Janitor Prime
Jan 22, 2004

PC LOAD LETTER

What da fuck does that mean

Fun Shoe

Shaggar posted:

java makes xml ez.

:smugdroid: says otherwise

Shaggar
Apr 26, 2006
idk what terrible stuff android Linux does but i wouldn't be surprised if they broke xml stuff on purpose

HORATIO HORNBLOWER
Sep 21, 2002

no ambition,
no talent,
no chance
shags do you have any links to a good primer on dependency injection

MeruFM
Jul 27, 2010
#include export_import.h
import java.j2ee.hypernate
add clogo.jqueryscript

Nomnom Cookie
Aug 30, 2009



HORATIO HORNBLOWER posted:

shags do you have any links to a good primer on dependency injection

the picocontainer project site has a good overview. picocontainer is also a good starting point bc all it does is DI. i didn't really "get" DI when I started using Spring bc the DI stuff is mixed with a lot of other crap. useful crap but it gets in the way if you don't know wtf

Notorious b.s.d.
Jan 25, 2003

by Reene

Cocoa Crispies posted:

xml is stupid because lisp has always existed

this is only true for a few perverse misuses of xml (xaml, xslt)

the core idea in lisp S-exprs was that code could be data, and data could be code

xml is so, so far from that. it's just a machine-validate-able meta-document format: design a format, specify valid documents in either Schema or DTD form, and any documents in your format can be parsed and validated universally, by any xml parser anywhere.

if your xml can be code, and your code can be xml, you are doing it wrong.

Notorious b.s.d.
Jan 25, 2003

by Reene
also lisp S-exprs didn't have any idea of validation. it either passed through a reader macro successfully, or it didn't.

to recap:

1. the core ideas of xml are just completely missing from lisp.

2. if you add the core ideas of lisp to xml, you are a monster. xml should never be code

3. if you add the core ideas of xml to lisp, you're a weird bastard, just use a lisp xml library sheesh

Shaggar
Apr 26, 2006

HORATIO HORNBLOWER posted:

shags do you have any links to a good primer on dependency injection

tbh idk of any specific tutorials, as i learned most of it through a combo of it being thrust upon me and specific implementation goals.

if you're talking specific implementations the spring documentation isn't bad. some of it is kind of lovely though, especially some of they're database stuff cause 1) its build around hibernate which is poo poo and 2) it features a lot of spring dependencies inside the code which defeats part of the point of DI.

the real basic DI is pretty simple to get a handle on, imo. You've got some object that does stuff based on its internal fields. Where you would normally initialize those fields in the object itself, you can use DI to inject those fields at runtime. In spring you'd wire the beans up in a config file. This lets you do stuff like have different runtime implementations per environment/function w/out changing the code. You can also really easily test code since it involves configuration changes instead of code changes to inject different objects for testing. Also, a lot of sw8 frameworks use spring for stuff like CXF. This lets you do super rad poo poo like change the implementation of an object from a local class to a webservice with a few lines of xml and absolutely no code changes. its cool

The biggest problems you'll run into are doing something dumb like putting a bunch of spring dependencies inside your code thus creating yourself a new static dependency on spring or overcomplicating things and injecting stuff that you don't need to.

Theres also stuff like aspect oriented programming which is black magic. its useful for things like being able to mark all the methods in a class as @Transactional without touching the code. Or in spring-mybatis where it will map the abstract methods in an interface to a method in your mapping file and then generate the proxies automatically for you at runtime. but beyond that it is the realm of the dark gods where we dare not tread.

Its cool stuff if you use it right and if you have some specific questions I could probably help more. trust ur instincts tho. bad DI smells the same as bad code.

Shaggar
Apr 26, 2006

Notorious b.s.d. posted:

this is only true for a few perverse misuses of xml (xaml, xslt)

the core idea in lisp S-exprs was that code could be data, and data could be code

xml is so, so far from that. it's just a machine-validate-able meta-document format: design a format, specify valid documents in either Schema or DTD form, and any documents in your format can be parsed and validated universally, by any xml parser anywhere.

if your xml can be code, and your code can be xml, you are doing it wrong.

lisp is trash for idiots. xml is the best. xaml is the best.

Shaggar
Apr 26, 2006

Nomnom Cookie posted:

the picocontainer project site has a good overview. picocontainer is also a good starting point bc all it does is DI. i didn't really "get" DI when I started using Spring bc the DI stuff is mixed with a lot of other crap. useful crap but it gets in the way if you don't know wtf

yeah that's a good point. spring kind of assumes you know what you want to do with DI first. also another tip: if you see dependencies in your code on the DI framework and they aren't A) at the starting injection point or B) part of a standalone DI utility library you've written then you should physically cringe cause it aint right.

Notorious b.s.d.
Jan 25, 2003

by Reene

Shaggar posted:

lisp is trash for idiots. xml is the best. xaml is the best.

xml has some flaws, but it is on balance pretty awesome

xaml is a perverse misuse of good technology. xml brings no benefit to xaml as a language, and xml is too loving wordy to be syntax for code.

Shaggar
Apr 26, 2006
xaml isn't code its markup

Nomnom Cookie
Aug 30, 2009



a java class that isn't abstract or final is bad

JawnV6
Jul 4, 2004

So hot ...

Notorious b.s.d. posted:

the core idea in lisp S-exprs was that code could be data, and data could be code

see it's some genius poo poo in lisp, but when x86 does it

Sneaking Mission
Nov 11, 2008

star war s-exprs

Gazpacho
Jun 18, 2004

by Fluffdaddy
Slippery Tilde
mccarthy never intended for s-exprs to be the standard syntax of lisp, that was a historical accident and measuring all other languages against it is the surest sign of a lisp fanboy

1337JiveTurkey
Feb 17, 2005

HORATIO HORNBLOWER posted:

shags do you have any links to a good primer on dependency injection

the basic motivation behind dependency injection is that a piece of properly modularized code can't do everything or else it isn't modular. the other pieces of code that particular piece of code needs to function correctly are its dependencies. the usual way of handling dependencies that people first learn about is using imperative code to pull them in during execution.

if someone needs a connection to the database they'll start out by writing all the connection code where they need it when they first start programming. more experienced programmers know to stick it into its own module so that they can change the implementation without needing to change every place it's used. that's fine but what if you want to use a mock instead of the real thing or you need something from the servletcontext and it's a unit test?

with dependency injection, you don't include the code needed to retrieve the dependency where you need it. instead the idea is to identify what the dependencies are and provide places where they can be injected (called injection points oddly enough). di frameworks usually offer options for stuff like setters, constructors or just sticking the values directly into fields. identification can be by class alone or might also include annotations to specify a particular type.

the other half is making the code that provides the dependencies. in guice, the framework i have the most experience with, this is done by making modules which define one or more dependencies that they can provide using factory methods, constructors and various other options. if a module depends on something else to construct whatever it's providing, it simply declares its dependencies just like anything else. in other words di is recursive.

an example would be a module providing a user's configuration settings. in order to get that, it needs the user id and a database connection. a different module might provide the user id by looking it up from the servlet session and a third module might provide a database connection from a pool. as an alternative you could just make a module that returns a mock user config and doesn't depend on anything. or you could have a module which just provides a hardcoded user id.

when you run a program using di, you pass in a set of modules to produce an injector. the injector is what you use to actually start creating objects. for testing you don't need to provide every module needed in production and you can pass in different modules that exist only for unit tests. the framework then matches what the modules provide with what they depend on and wires each injection point to a provider. naturally having no provider that can satisfy a dependency is an error, as is having two ambiguous providers. (guice allows for multiple providers to inject a set or map containing one item from each provider.)

it really does look like black magic at first, and i struggled with it myself. my advice is that so long as you remember that it's just matching providers up with injection points, dependency injection is surprisingly simple.

Sneaking Mission
Nov 11, 2008

1337JiveTurkey posted:

the basic motivation behind dependency injection is that a piece of properly modularized code can't do everything or else it isn't modular. the other pieces of code that particular piece of code needs to function correctly are its dependencies. the usual way of handling dependencies that people first learn about is using imperative code to pull them in during execution.

if someone needs a connection to the database they'll start out by writing all the connection code where they need it when they first start programming. more experienced programmers know to stick it into its own module so that they can change the implementation without needing to change every place it's used. that's fine but what if you want to use a mock instead of the real thing or you need something from the servletcontext and it's a unit test?

with dependency injection, you don't include the code needed to retrieve the dependency where you need it. instead the idea is to identify what the dependencies are and provide places where they can be injected (called injection points oddly enough). di frameworks usually offer options for stuff like setters, constructors or just sticking the values directly into fields. identification can be by class alone or might also include annotations to specify a particular type.

the other half is making the code that provides the dependencies. in guice, the framework i have the most experience with, this is done by making modules which define one or more dependencies that they can provide using factory methods, constructors and various other options. if a module depends on something else to construct whatever it's providing, it simply declares its dependencies just like anything else. in other words di is recursive.

an example would be a module providing a user's configuration settings. in order to get that, it needs the user id and a database connection. a different module might provide the user id by looking it up from the servlet session and a third module might provide a database connection from a pool. as an alternative you could just make a module that returns a mock user config and doesn't depend on anything. or you could have a module which just provides a hardcoded user id.

when you run a program using di, you pass in a set of modules to produce an injector. the injector is what you use to actually start creating objects. for testing you don't need to provide every module needed in production and you can pass in different modules that exist only for unit tests. the framework then matches what the modules provide with what they depend on and wires each injection point to a provider. naturally having no provider that can satisfy a dependency is an error, as is having two ambiguous providers. (guice allows for multiple providers to inject a set or map containing one item from each provider.)

it really does look like black magic at first, and i struggled with it myself. my advice is that so long as you remember that it's just matching providers up with injection points, dependency injection is surprisingly simple.

gently caress this

Gazpacho
Jun 18, 2004

by Fluffdaddy
Slippery Tilde
dependency injection = the hotness way of bootstrapping the pieces of your app that different people are working on so that the app "just works" without you having to manage unique startup protocols for each piece

Gazpacho fucked around with this message at 04:28 on Jan 16, 2013

Gazpacho
Jun 18, 2004

by Fluffdaddy
Slippery Tilde
injection junction, what's your function

hooking up DBs and services and caches

Cocoa Crispies
Jul 20, 2001

Vehicular Manslaughter!

Pillbug
dependency injection sounds complicated because it provides flexibility in legacy languages like c# and java, and is usually explained in those terms

in p-languages you can just replace classes or methods on classes to do things like swap in mock objects for tests or change storage backends

Shaggar
Apr 26, 2006
lol

Cocoa Crispies
Jul 20, 2001

Vehicular Manslaughter!

Pillbug

ikr, no idea why legacy people make such a big deal out of something so simple

Adbot
ADBOT LOVES YOU

Base Emitter
Apr 1, 2012

?
di kind of falls over when people overuse it and half their goddamned app is written in an xml file, with legit runtime config scattered throughout but god knows where. that's not really an improvement.

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply