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
Police Academy III
Nov 4, 2011

BonzoESC posted:

wait are classes in python not just objects?
code:
      f = Class.new(::BlankSlate)
      f.reveal :instance_variable_set
      unless f.instance_methods.include? :class
        f.reveal :class
      end
      f.new

yes they are, but there's not a nice way to make anonymous ones, you have to do something like t = type("bullshit_name", (SuperClass,), {"a_dict": "of attributes"})

Adbot
ADBOT LOVES YOU

Police Academy III
Nov 4, 2011
also, if anyone's curious, here is a list of the real (ie non-syntactic) differences between python and ruby:
  • in ruby you can monkeypatch builtin types
  • python has real multiple inheritance
  • python raises an exception when you access an attribute that doesn't exist, ruby returns nil

Police Academy III
Nov 4, 2011
the best language is lisp and the only people who don't think so are those too dumb to understand lisp. c is also good b/c you can write lisp interpreters in it.

Police Academy III
Nov 4, 2011

tef posted:

python you can monkey patch built-in types using ctypes

please explain, this sounds wonderfully hacky

Police Academy III
Nov 4, 2011

Anal Tributary posted:

what defines something decent in a github, anyways? i've been asked for portfolios and never know what to say because none of the dev stuff i've done ever ends up launching, but i have some github repos with decent code in them.

ya i'd also like to know this, since i don't really see anybody wanting to pull from "lisp interpreter that takes as long to garbage collect as it does to actually run anything" or "dumb ruby roguelike with terrible web interface"

Police Academy III
Nov 4, 2011

baxate posted:

Computer Science is terrible, get a real degree.

it's 2012 buddy, there are no real degrees

Police Academy III
Nov 4, 2011

BonzoESC posted:

code:
Set.new(youre_post.chars).to_a

ur supposed to count them though
the_string.group_by {|x| x}.map {|k, v| [k, v.size]}

Police Academy III
Nov 4, 2011

tef posted:

I almost forgot https://gist.github.com/295200

it's beautiful, tyvm

Police Academy III
Nov 4, 2011

Internaut! posted:

I've always wanted to learn a lisp and clojure seemed like a good one

any benefits other than the java integration? I dunno lisp dialects

clojure's the most "modern" lisp and doesn't have alot of the cruft and implementation issues that CL and Scheme have. It's also got a lot of nice features like data structures as functions and super cool lambda syntax adn lots of nice functional programming stuff, and a heavy focus on concurrency which i've never cared about but you might. It does have a lot of dumb problems though, e.g:
  • (= false (contains? [3 3 3] 3))
  • terrible stack traces (although they used to be worse!)
  • p much everything to do with strings
  • have to call out to java libraries even for simple stuff like Math/sqrt
  • terrible docs
  • i still don't know nor care what the difference between refs, vars, atoms, and agents is
anyway on the whole i'd say go for it, but just be prepared to want to pull your hair out until you get into the swing of it.

Police Academy III
Nov 4, 2011
my biggest gripe with strings is that all the standard seq functions convert strings into lazy seqs of characters which don't work when you need a string. (not= "aaa" (reverse "aaa")) is pretty annoying, and my code always ends up looking like
code:
   (apply str
    (for [[name type] (partition 2 decls)]
      (str (apply str (rest (str type))) " " name ";\n")))
they should've either had seq operations on strings return strings, have seqs of chars implicitly convert to strings, or just used seqs of chars as the basic string type a la haskell. as it is it's just janky and unpleasant.

that said clojure's pretty cool despite its faults. i kinda want to dig up what little i know of prolog and do something with core.logic, if only i can think of something

Police Academy III
Nov 4, 2011

Fren posted:

I want to jump from Common Lisp to clojure but i hate working with the java runtime. like i need to run lein and poo poo and i need a project.clj and all that dumb poo poo. i can't just start throwing poo poo into a file like common lisp. also the syntax is less unified and all the [vector] and {hash} poo poo throws me off because i'm used to everything being in parens

um, you definitely can just throw poo poo into a file w/o worrying about lein and all that poo poo, that's 90% of what i've done w/ clojure. and the []'s and {}'s own since they provide some visual variety and make it easier to pick out lets and such. basically what i'm saying is u should learn clojure since its pretty cool

Police Academy III
Nov 4, 2011

HORATIO HORNBLOWER posted:

sounds like someone couldn't hack it at state college!

the idea of education as bettering yourself is just subtle classism, hth

Police Academy III
Nov 4, 2011
graphs are the most pro-tier data structure, 420 do iterative deepening search everyday

Police Academy III
Nov 4, 2011
caring about whether 0 is false or not is bikeshedding as hell, hth

also if you want a lightweight scripting language you should be using a lisp and not some gay mashup of javascript and visual basic.

Police Academy III
Nov 4, 2011

ahhh spiders posted:

why

because lisp is the best language, idk how this could be confusing

Police Academy III
Nov 4, 2011

ahhh spiders posted:

functions are already first-class values in lua so why would you use lisp

lol "functions are first-class values", im sure this is a shocking concept to java programmers but ppl with taste expect a little more

Police Academy III
Nov 4, 2011
"why would i use the single most powerful language available when i could add in the overhead of parsing and be able to use 1-indexed arrays?" - a bad programmer

Police Academy III
Nov 4, 2011
but for reals spiders, idk what you're so up on lua about. I mean lightweight embeddable scripting is cool, but the language itself is really just one step up from tcl.

Police Academy III
Nov 4, 2011

ahhh spiders posted:

it's even simpler than tcl, which is awesome

simpler how? because using the same datastructure for lists and hashes may keep the implementation simple but its a pretty php thing to do.

Police Academy III
Nov 4, 2011
the syntax may be the same, but the semantics of arrays and hashes should be different, and being able to do
code:
a = {"a"}
a[7] = "b"
is pretty terrible imo

Police Academy III
Nov 4, 2011

ahhh spiders posted:

why?

because the list doesn't have 7 elements, the language never tells you if you're using an index that's out of range. it just magically does something which is, again, pretty php

Police Academy III
Nov 4, 2011

Fren posted:

common lisp rules face

Police Academy III
Nov 4, 2011

ahhh spiders posted:

you're just griping for the sake of it

of course i am, i don't use lua.

ahhh spiders posted:

also there's no such thing as an index being out of range, because it's a table

that's my whole point! arrays are not tables, they should have semantics specific to arrays, like index bounds. assembly lets you use a machine word as an int or a memory address or a float or an instruction, but most of the time that's not a good idea and you want assurance that something that is intended to be used in a certain way will be used in that way.

Police Academy III
Nov 4, 2011

Janin posted:

lua doesn't have arrays. it has tables.

if you want to complain that it *should* have arrays, that's fine, but stop pretending to be offended because the lua implementers decided your pet feature wasn't necessary to the language.

frig off janin, a proper array datatype is hardly an obscure feature request

Police Academy III
Nov 4, 2011

Janin posted:

obscure or not, they're not necessary. arrays are only useful if you're going to be doing some sort of performance-sensitive computation. lua is explicitly designed to be a glue language, so there's no point in having features like arrays.

it's not about performance, i don't care if they implement arrays with a loving bloom filter. it's about ensuring that data that is supposed to be used in a certain way is actually being used in that way. the single most common type of datastructure in all programming is "numbered list of stuff", in lua you have no guarantee that a numbered list of stuff will remain a numbered list of stuff.

Police Academy III
Nov 4, 2011

Janin posted:

So go write an array type yourself. Or use someone else's -- if they're as useful as you claim, someone else will already have written one.

man idgaf, i just don't really understand why spiders is so hot to trot about lua when it has bad php stuff in it.

Police Academy III
Nov 4, 2011

ahhh spiders posted:

welcome to my ignore list

can you buy me a big red title too? it'd be nice to get rid of babytar here.

Police Academy III
Nov 4, 2011

Hammerite posted:

tef ive seen you say that in python strings are "infinitely deep" a couuple of times. what does this mean tia

it means that indexing a string gives you another string, so you can do "fart"[0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0]...

Police Academy III
Nov 4, 2011
computers are basically pretending machines when you think about it

Police Academy III
Nov 4, 2011
one of my fav bits of useless trivia is that ANSI C specifies that a char is 1 byte, but doesn't say that a byte has to be 8 bits.

Police Academy III
Nov 4, 2011
c99 actually has a bunch of cool features, my fav is designated initializers
code:
struct Point {
    int x;
    int y;
};

int main() {
    Point p = {.x=7, .y=4};
}

Police Academy III
Nov 4, 2011
ya, you've got to spend like 6 lines of code just to make some dumb class to hold 2 values and then 8 more lines for getters + setters if you don't want to piss off the java oop sperg gods. basically what im saying is that java is terrible.

Police Academy III
Nov 4, 2011
someone tell spiders he should've used a defaultdict there

Police Academy III
Nov 4, 2011

BonzoESC posted:

so, "hello world"

lol

Police Academy III
Nov 4, 2011

Meiwaku posted:

Beyond all the other cool stuff Clojure offers, it's new "reducers" which provide auto-parallelizable collections is an unbelievable killer feature.

Details here;
http://clojure.com/blog/2012/05/08/reducers-a-library-and-model-for-collection-processing.html


It's the first time I've run across a solid example where you can code at the speed of something like Ruby, and in a broad range of cases get better performance than normal C code. As always, your own mileage may vary though.

stuff like this makes me excited about clojure but it also makes me worry that they'll keep adding in more random academic poo poo instead of making docs and error handling that aren't terrible

Police Academy III
Nov 4, 2011
I mean look at this poo poo

quote:

index
function

Usage: (index xrel ks)

Returns a map of the distinct values of ks in the xrel mapped to a
set of the maps in xrel with the corresponding values of ks.

Police Academy III
Nov 4, 2011

Meiwaku posted:

I think you're looking for this;
http://clojuredocs.org/clojure_core/clojure.set/index

The function doc strings are great when you're already familiar with the language, but sites with examples are better suited for when you're getting started. I find this is true for many different languages/systems, and is one reason why you have both the Camel and the Llama book for PERL.

it's nice that someone is working on making the docs less lovely, but
  • why aren't these part of the official docs instead of on some third-party site? (although i guess lein lets you get examples from clojuredocs in a repl so that's p cool)
  • the concept of what a 'rel' is is never explained anywhere on the clojure.set docs page
  • the description for index is practically incomprehensible at any rate. the entire idea is a little wonky w/o some background in relational algebra but they definitely could've been a bit more verbose.

Police Academy III
Nov 4, 2011

graph posted:

lol if you go to college to learn how to program

I went to college to learn how incredibly dumb smart people can be.

Police Academy III
Nov 4, 2011
speaking of p-languages, can someone w/ clojure installed run this and tell me what happens?
code:
(defmulti fart identity)
(defmethod fart 1 [x] "one")

Adbot
ADBOT LOVES YOU

Police Academy III
Nov 4, 2011

trex eaterofcadrs posted:

(fart 1)
prints "one"
any other call to fart will not dispatch
hth

did you actually run it though? because I get
code:
Exception in thread "main" java.lang.IllegalArgumentException: No matching method: addMethod, compiling:(fart-failure.clj:2)
but only if the method is named fart, anything else works as expected.

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