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
Look Around You
Jan 19, 2009

clockwork automaton posted:

code:
    do{
                c = fgetc(file);
                if(31 < c && c < 127){
                        c = fgetc(file);
                        if(31 < c && c < 127){
                                c = fgetc(file);
                                if(31 < c && c < 127){
                                        c = fgetc(file);
                                        if(31 < c && c < 127){
                                                fseek(file, -4, SEEK_CUR);
                                                c = fgetc(file);
                                                i = 0;
                                                while(31 < c && c < 127){
                                                        string[i] = (char)c;
                                                        c = fgetc(file);
                                                        i++;
                                                }
                                                string[i] = NULL;
                                                printf("%s\n", string);
                                        }
                                }
                        }
                }
        }while((char)c != EOF);
:eng99: I don't like grading (I don't teach this class, I promise).

CS0449?

Adbot
ADBOT LOVES YOU

Look Around You
Jan 19, 2009

DotFortune posted:

To be fair/make things infinitely worse, this person was going to write different routines for each case: each case being the different positions of records of a csv. But each row was to have 27 records, so the idea was that he was dealing with two rows at a time.

The csv was to have a "special format" with the typical field descriptions being reentered after each row of records (eg: A,B,C\n 1,2,3\n A,B,C\n 4,5,6), and each row needed to end with an extra comma, and the "ID" field needed to be last. When explaining why I was frustrated about this solution, he replied: "Can you just guarantee the files will be this way?"

I decided to just designate a portion of the data we created as his. It's not like he finished with his solution, anyway. I really hope I get to see it when it's done.

What.

I would have just said "no" but maybe I'm kind of a dick?

Look Around You
Jan 19, 2009

Janin posted:

code:
let genBind decl = do
        varName <- newName "opt"
        exp <- case decl of 
                GroupDecl{} -> return (BindS (VarP varName) var_groupParse)
                OptionDecl' (OptionDecl fname shorts longs def _ qParserExp _ _) -> do
                        valExp <- case lookup fname valDecls of
                                Just e -> e
                                Nothing -> [| (\_ -> valid) |]
                        parserExp <- qParserExp
                        return (BindS
                                (VarP varName)
                                (AppE   
                                        (AppE   
                                                (AppE   
                                                        (AppE   
                                                                (AppE   
                                                                        var_optionParse
                                                                        (LitE (StringL shorts)))
                                                                (ListE (map (LitE . StringL) longs)))
                                                        (LitE (StringL def)))
                                                parserExp)
                                        valExp))
                _ -> return (LetS [])
        return (varName, exp)

Holy poo poo.

Look Around You
Jan 19, 2009

shrughes posted:

In Coffeescript:

z = [0..2] becomes z = [0, 1, 2]

z = [0..1] becomes z = [0, 1]

z = [0..0] becomes z = [0]

z = [0..-1] becomes z = [0, -1]

Then there's z = [0...n], the secret feature which does what you want and isn't documented.

Comprehensions in Coffeescript are also not monadic:
code:
coffee> [x,y] for x in [0..3] for y in [4..8]
[ [ [ 0, 4 ],
    [ 1, 4 ],
    [ 2, 4 ],
    [ 3, 4 ] ],
  [ [ 0, 5 ],
    [ 1, 5 ],
    [ 2, 5 ],
    [ 3, 5 ] ],
  [ [ 0, 6 ],
    [ 1, 6 ],
    [ 2, 6 ],
    [ 3, 6 ] ],
  [ [ 0, 7 ],
    [ 1, 7 ],
    [ 2, 7 ],
    [ 3, 7 ] ],
  [ [ 0, 8 ],
    [ 1, 8 ],
    [ 2, 8 ],
    [ 3, 8 ] ] ]
vs.
code:
Prelude> [(x,y) | x <- [0..4], y <- [5..8]]
[(0,5),(0,6),(0,7),(0,8),(1,5),(1,6),(1,7),
(1,8),(2,5),(2,6),(2,7),(2,8),(3,5),(3,6),
(3,7),(3,8),(4,5),(4,6),(4,7),(4,8)]
(which is equivalent to:)
code:
import Control.Monad
testMonad :: [a] -> [b] -> [(a,b)]
testMonad a b = do
  aa <- a
  bb <- b
  return (aa,bb)

 testMonad [0..4] [5..8]
[(0,5),(0,6),(0,7),(0,8),(1,5),(1,6),(1,7),
(1,8),(2,5),(2,6),(2,7),(2,8),(3,5),(3,6),
(3,7),(3,8),(4,5),(4,6),(4,7),(4,8)]
Edit: tables. Also python!
code:
>>> [(x,y) for x in range(0,5) for y in range(5,9)]
[(0, 5), (0, 6), (0, 7), (0, 8), (1, 5), (1, 6),
 (1, 7), (1, 8), (2, 5), (2, 6), (2, 7), (2, 8),
 (3, 5), (3, 6), (3, 7), (3, 8), (4, 5), (4, 6), (4, 7), (4, 8)

Look Around You fucked around with this message at 01:59 on Dec 13, 2011

Look Around You
Jan 19, 2009

Vanadium posted:

Well, the first example is more like [ [ (x, y) | x <- [ 0..3] ] | y <- [4..8] ]

EDIT: wait no.. How so?
If it were monadic it would return a [[0,5], [0,6], ...] instead of [[[0,5],[0,6]..][[1,5],...]]]

E2: I see what you mean, that still doesn't make sense for coffeescript to do it that way by default... I would expect a list comp to produce a flat list of the results, which in this case is a list of two integers. How would you represent the haskell thing in coffeescript then?

Look Around You fucked around with this message at 02:12 on Dec 13, 2011

Look Around You
Jan 19, 2009

shrughes posted:

That's just a parsing thing, it's parsing it as ([x,y] for x in [0..3]) for y in [4..8]

Yeah, I see that, but if it's parsing it like that, there doesn't seem to be a way to get it to parse it the way one would expect it to parse it.

Look Around You
Jan 19, 2009

Jabor posted:

Doesn't Meat Boy have a level editor for Super Meat World? If so, then Insert is an obvious privilege to have and not at all strange. Worst case you get a bunch of junk in the database that you need to prune out. (Okay, actual worst-case is impersonating another user for the purpose of uploading levels which is pretty bad, but it's not a huge exploit)

Update, not so much. Unless you're somehow limited to only being able to update levels you created.

edit: Actually, could you go and UPDATE all the "kid's christmas" levels to ones easy enough for me to complete? tia

Wouldn't it make more sense to send a request to a web api and have a separate server application handle the actual SQL stuff? I mean I would think it'd be a lot safer than having the game directly connect to the database, especially if it's possible for someone to find the login stuff from the binary.

Look Around You
Jan 19, 2009

Markov Chain Chomp posted:

To be fair, what you guys are doing is blaming the victim. It's not any more convincing than when people blame women for being raped.

This is a loving terrible attempt at an analogy and it's actually pretty insulting.

Look Around You
Jan 19, 2009

Nippashish posted:

Horrible analogy aside, he's completely right.

So everyone rushing and taking down the db was not cool, I'll agree there. The issue here though is that he was told about a vulnerability and not only refused to take steps to fix it, but he actually took a condescending stance towards someone pointing out a massive security hole. When he took that stance, pretty much the only way to get any action done was to act on the vulnerability. I mean, this doesn't seem so serious at this point because it was only levels or whatever, but what if in the future he decided to put in in-app purchases and decided to store payment data or credit card info in there or whatever? It's not a leap to figure he'd do that with the attitude he was taking, and that's where the real problem is.

Look Around You
Jan 19, 2009

Nippashish posted:

"When she went out dressed like that pretty much the only thing that could have happened did. It's not a leap to figure out what a man would do after seeing her, and that's where the real problem is."

So yeah, it's an offensive analogy, but it's very accurate.

I was going to write out a response to how the two do not compare at all but this is so loving ridiculous that it's not even worth it.

Look Around You
Jan 19, 2009

Markov Chain Chomp posted:

What people did to the db was literally the worst-case scenario for what could have happened and you can't assume he would have used a similar setup for actual payment stuff like that. That's just lazy for you to make that point.

You can't assume that he wouldn't have either, especially judging by his blasé responses that "everything is fine" when it clearly isn't (people rendered the game unplayable with this exploit).

Markov Chain Chomp posted:

How do they differ at all?

Fine. Nobody is relying on the girl to dress "not like a slut" or what the gently caress ever because they (potentially) have personal assets on the line. The way she dresses has no bearing on whether my money is where it should be at the end of the day. Conversely, people DO rely on stored information to be secure, just like they rely (as an above poster mentioned) on a bank vault being locked and secured. Accessing the database to get the guy to (hopefully) fix poo poo before people potentially get personal information stolen is nowhere near the same as someone raping a girl to prove I don't even loving know because this does not make sense to do.

As I stated, based on his reaction, there is no way you can make any assumptions as to what he'll do with more sensitive data when he is already making horrible decisions (this setup is a horrible decision) and trying to justify them based on his "knowledge" of how to do things.

Look Around You
Jan 19, 2009

Dicky B posted:

indie_game_developers.txt

http://www.youtube.com/watch?feature=player_embedded&v=YtBZ68Fx1Kw

that quote

1:34 "I'm like in a loving concentration camp [...] is another good one. I think they're both this dude?

Look Around You
Jan 19, 2009

point of return posted:

Fast Eddie's idea of "fixing" Solstace's page. As you can see, by replacing the hottips with something that doesn't parse, you, too, can claim your page is fixed.

Haha that's amazing.

Look Around You
Jan 19, 2009

Hoooly gently caress.

So after some discussion(starting there and going till the end of the thread right now) in the General Programming thread about why a guy had to put eval(input(prompt)) instead of input(prompt), I looked it up in the docs. Apparently in python 2.x (including the current version, 2.7.2), input() is is the same as eval(raw_input()). This was fixed for python 3.x but still holy poo poo. And the worst part is that pretty much every tutorial has you use input with it's implicit eval and even relying on it to convert the results without a second thought (and without even mentioning it).

I have no idea how they thought a built in function named input should automatically and implicitly do an eval on the raw stuff it gets. Like god drat.

Look Around You
Jan 19, 2009

xf86enodev posted:

Python should finally catch up and release their docs on youtube!

Seriously, does no one read any documentation anymore? I mean you know that you don't know what a thing does but do it anyway. And then you bitch when something goes wrong? :iia:

I mean I could see that with more obscure api calls, but a function named input should probably be a safe way of getting input. And as was said, most documentation aimed at beginners says to use input, not raw_input. I just have no idea why they thought that a function just named input should eval what it gets implicitly. It's loving stupid.

Look Around You
Jan 19, 2009

Plorkyeran posted:

http://codepad.org/mQ1GHYeS

php:
<?php

if (true) { function foo() { echo "php"; } }
else { function foo() { echo " sucks"; } }

foo();

if (true) {
    function bar() { echo "php"; }
} else {
    function bar() { echo " sucks"; }
}

bar();
Output:
php sucks

Apparently it's fixed in 5.3.

This is amazing.

Look Around You
Jan 19, 2009

Aleksei Vasiliev posted:

Pretty sure he's crazy. The newsletter is a rant about some judge violating his human rights, and demands 2mil EUR from the German chancellor.

Also if he gets 2mil EUR in donations he'll release the program for free to everyone.

Can we send him a huge rear end fake €2,000,000 note so that he publishes it or would that be illegal/immoral?

Look Around You
Jan 19, 2009

Doc Hawkins posted:

Oh, it's not an awful language. In fact, it's not a language at all. :smuggo:

What the gently caress is this poo poo? Like I honestly have no idea how he's saying that a turing complete language that's actually pretty powerful despite having a simple syntax isn't a language.

this dumbfuck posted:

Years ago I read something which explained, in my opinion, why Lisp has never achieved the mainstream adoption its passionate advocates believe it deserves. Lisp projects experience a degree of balkanization because everything is left wide open; you can use more than one object-oriented paradigm (potentially even at the same time), you write your own this, you write your own that, you write your own everything.

I don't know any extremely popular languages which provide a few simple but powerful constructs. Wait, Lua is pretty widespread and it has no built in OO system. I just :psyduck:

e:
I mean lisp definitely isn't mainstream probably because it's not the most readable thing ever (and because most people aren't 100% comfortable with functional programming), but that certainly doesn't mean it's not a powerful programming language.

Look Around You fucked around with this message at 03:38 on Jan 24, 2012

Look Around You
Jan 19, 2009

TRex EaterofCars posted:

It's even worse because he basically takes a Douglas Crockford's "Javascript is Lisp in C's clothing" and deranges it beyond reason. He then goes on to claim that Lisp is simply for AST manipulation and really isn't abstract enough to handle pragmatic programming.

I haven't seen such a stupid hunk of poo poo since I watched some talk where the guy called Barbara Liskov a "dude"

Yeah I saw that and shut my brain off because I couldn't comprehend just how loving stupid this guy is. Like jesus christ.

e:
I mean the least insane point he has I guess is the "it lacks some built in stuff" but that doesn't really keep a language from being a language. Just loving christ that guy.

Look Around You fucked around with this message at 04:33 on Jan 24, 2012

Look Around You
Jan 19, 2009

Plorkyeran posted:

Lua has syntax and features explicitly intended for prototype-based OOP.

Yeah but I mean so does Javascript.

Look Around You
Jan 19, 2009

Plorkyeran posted:

And Lisp doesn't, which is what he was talking about there.

Lua also has a decent module system.

It's actually sort of pathetic that there are so many high-level languages which don't have features which Lua has.

Common Lisp also has CLOS as part of its ANSI standard. And honestly you don't absolutely need objects in a functional language.

Look Around You
Jan 19, 2009

Doc Hawkins posted:

I dunno about that. After all, here we are, reacting to it.

The line between branding and trolling can become quite thin in the celebrity-developer world.

I guess I'm just wondering if anyone who knows poo poo about development/CS/etc would ever want to hire someone this loving stupid. I don't even think anyone takes Joel Spolsky seriously anymore, other than that he helped found StackOverflow or whatever.

e:
Well anyone important anyway.

Look Around You
Jan 19, 2009

Suspicious Dish posted:

There's another whole side of metaprogramming: C even has a side of this, since it has no OOP by default. You can still get a lot of work done right out of the box, though.

You don't have objects in C, but you can implement one. You can even get a little more advanced, and use more structures and function pointers to implement virtual methods.

This is a simplified version, but this sort of system is the core of GObject. Of course, it's a little more advanced than this, because all those static sub_object_class things that I create don't exist (we have a system called GType).

And of course GObjects have other things that modern OO environments have, like properties (which are somewhat of a mess to write right now, but people are working on it) and signals (the latter involving a whole generic "Variant" type called "GValue", and a marshaller system so that you can call function pointers with the right arguments).

There's a lot of cool tricks in GObject, some of them on the line between "awesome" and "horror", and if people are interested, I'll explain this stuff.

I've browsed through the GObject documentation a bit but still don't entirely comprehend it all. It seems like a lot of it relies on how C requires structs to be laid out in memory though.

Look Around You
Jan 19, 2009

BonzoESC posted:

Doesn't C++ have the same implementation?

Yeah, multiple inheritance fucks poo poo up. I'm pretty sure GObject uses vtables though which I think most C++ compilers use for virtual functions.

Look Around You
Jan 19, 2009

edit: I'm a big huge retard who doesn't think before he posts when he's tired and poo poo

Mozilla is developing a new language called rust.

It seems to aim to be sort of C-ish but with new features kind of like Go I guess but unlike Go it's incredibly incohesive.

Interesting facts from their tutorial

  • Semicolons are required(except when they're not!) -- by this I mean apparently there is a semantic difference between if true { 5 } and if true { 5; }. They are both expressions; the first version returns 5, while the second returns nil. Apparently someone decided that the presence or absence of a line terminator should decide whether or not the block returns a value or nil.

  • I can't tell if it's always like this or not but apparently local variables get type inference, but "global" constants don't, and thus are declared like this: const repeat: uint = 5u;. Maybe I'm dumb but this syntax is pretty unintuitive (especially with syntax highlighting as on their site). *

  • Nil is not written as nil; instead it is written as (). This works in a lisp-ish language but there's not even a concept of parenthesized lists in this language so it looks extremely out of place (I guess they wanted to simplify their grammar for functions without arguments maybe)

  • Macros/macro functions are specifically set off by a #. Example: std::io::println(#fmt("%s is %d", "the answer", 42));. This has potential but still strikes me as a bit awkward and unnecessarily leaking implementation details into code (why can't fmt just look like a plain function?).

  • An alt construct that implements pattern matching. Cryptic syntax included: 2 | 3 means 2 or 3 (makes sense), 4 to 10 (also is ok), _ is "default" (this is alright I guess but it looks like line noise). Also apparently an alt block that fails won't silently fall through. Instead it is designed to "blow up" according to the tutorial.

  • 3 types of pointers and 3 types of closures, all identified with different sigils (@/fn@ is a "boxed" pointer/closure; ~/fn~ is a "unique" pointer/closure (only one owner/reference allowed); */fn are "normal" pointers/closures

  • Strutures and vectors (their array types) are unique and immutable by default, which does not make much sense in a language trying to appeal as a systems-ish language.

It looks like it has some potential but it seems to have an identity crisis. It's trying to be a bit of everything but it doesn't seem to fit heavily in anything. Unsafe pointers, but a heavy functional emphasis. It's hard to tell exactly what they're getting at and in the end it just looks like a mash of line noise like perl. I guess my biggest issue is that in trying to make it look like C/C++ it really betrays it's highly functional nature. I just really don't know where they're going with it.

example from their standard library:
code:
/*
Function: merge_sort

Merge sort. Returns a new vector containing the sorted list.

Has worst case O(n log n) performance, best case O(n), but
is not space efficient. This is a stable sort.
*/
fn merge_sort<T: copy>(le: lteq<T>, v: [const T]) -> [T] {
    fn merge<T: copy>(le: lteq<T>, a: [T], b: [T]) -> [T] {
        let rs: [T] = [];
        let a_len: uint = len::<T>(a);
        let a_ix: uint = 0u;
        let b_len: uint = len::<T>(b);
        let b_ix: uint = 0u;
        while a_ix < a_len && b_ix < b_len {
            if le(a[a_ix], b[b_ix]) {
                rs += [a[a_ix]];
                a_ix += 1u;
            } else { rs += [b[b_ix]]; b_ix += 1u; }
        }
        rs += slice::<T>(a, a_ix, a_len);
        rs += slice::<T>(b, b_ix, b_len);
        ret rs;
    }
    let v_len: uint = len::<T>(v);
    if v_len == 0u { ret []; }
    if v_len == 1u { ret [v[0]]; }
    let mid: uint = v_len / 2u;
    let a: [T] = slice::<T>(v, 0u, mid);
    let b: [T] = slice::<T>(v, mid, v_len);
    ret merge::<T>(le, merge_sort::<T>(le, a), merge_sort::<T>(le, b));
}
* I get that it's var: type but var: type = number looks weird to me for some reason.

edit: Well after sleeping a few hours I realize that I guess () can be an empty tuple, which the language does have. I still stand by it being a bit of an abuse of notation though.

Look Around You fucked around with this message at 14:24 on Jan 28, 2012

Look Around You
Jan 19, 2009

shrughes posted:

stuff making me look dumb
Yeah, those are all legit defences. A lot of this was a kneejerk reaction to looking at it at like 1:30-2am and being tired as hell and not thinking straight. Most of it is either personal preference or just not thinking things through (mostly just not thinking things through).

Especially the blowing up thing, I definitely didn't think that through at all.

Basically posting tired is stupid and makes you look stupid.

e:

tef posted:


I like rust. The design seems to come from years of dealing with c++ programmers who think they know better.


Oh You! Does this mean go is cohesive?


memory & type safe systems programming. that thing you can't do in c++, c or most functional languages.

Yeah I'm basically retarded and thought things through like not at all and ended up making an rear end out of myself posting like an idiot at 2 am.

Look Around You fucked around with this message at 14:21 on Jan 28, 2012

Look Around You
Jan 19, 2009

Scaramouche posted:

Don't feel too bad, shrughes is basically a jerk. It's kind of his thing.

I don't feel bad really (and I don't hold it against him), I just feel dumb because I posted a kneejerk reaction of something without taking much time to figure out reasons behind it. Maybe part of it was I wasn't able to get a feel for the goals and stuff of the language right away, but that's not really an excuse for me posting retarded poo poo, that's just me not taking the time to comprehend something and then spouting poo poo off about ideas that I only half understood.

Look Around You
Jan 19, 2009

tef posted:

We're all terrible.

Rust is 0.1 - much of the effort put into it is to see if certain language features can work together to build robust code. The syntax especially is being worked out as they write more and more code in it - the language has changed considerably (from what I have noticed) as they have gotten to the fully bootstrapped stage.

If you want to talk about issues in the language, the developers are fairly active on irc and answered a whole bunch of my stupid questions eventually - they will probably be more qualified to answer your questions than anyone here.

[...]

really I don't want to defend rust here but only to say that it hasn't been properly introduced. if you're curious about it I would highly recommend the faq and the design docs over what has been poorly explained here. I think rust deserves a fair trial*.

even so I still don't get the whole magic semicolon thing


* rob pike has somewhat angry words about this http://commandcenter.blogspot.com/2011/12/esmereldas-imagination.html - to some extent it is right, but at other times it can be a failure to communicate the design constraints of the language.

Basically yeah, I didn't try it and was talking about impressions I got from the documentation. Interestingly enough, while I was writing that post I was compiling the Rust compiler/toolsuite. I still haven't gotten around to trying it yet but it does look interesting. It certainly wasn't fair of me to pass judgement without trying it.

That said I still have some confusion about the ; thing and the () for nil thing, but overall they're pretty minor. (the problem I have with () for nil is that in rust specifically tuples need to have arity strictly greater than 1, so an empty tuple for nil doesn't really make much sense to me.)

Look Around You
Jan 19, 2009

The problem I have with "a block returns it's last value if it has no semicolon" is a couple things.
Here's an example which compiles fine and acts like you'd expect:
code:
use std;

fn main(args: [str]) {
	let s = args[1];
	let aval = alt s {
		"a" { std::io::println("aval is 1 now"); 1 }
		"b" { std::io::println("aval is 2"); 2 }
		"c" { std::io::print("aval "); std::io::println("is 3"); 3 }
		_ { std::io::println("better set it to 4"); four() }
	} ;
	std::io::println(#fmt("aval is %d after the alt", aval));
}

fn four() -> int {
	// we can comment out ret 4; and uncomment the following line
	// and still compile
	// 4
	ret 4;
}
This however is invalid:
code:
use std;

fn main(args: [str]) {
	let s = args[1];
	let aval = alt s {
		"a" { std::io::println("aval is 1 now"); 1 }
		"b" { std::io::println("aval is 2"); 2 }
		"c" { std::io::print("aval "); std::io::println("is 3"); 3 }
		_ { std::io::println("better set it to 4"); four(); }
	} ;
	std::io::println(#fmt("aval is %d after the alt", aval));
}

fn four() -> int {
	// we can comment out ret 4; and uncomment the following line
	// and still compile
	// 4
	ret 4;
}


code:
$ rustc test.rs
test.rs:9:4: 9:55 error: mismatched types: expected `int` but found `()` (types differ)
test.rs:9 		_ { std::io::println("better set it to 4"); four(); }
              ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
error: aborting due to previous errors
So yeah I guess that's why I don't really like having a ';' be the difference between "return the value of the last expression" and "return ()/nil"

The error descriptions that the compiler generates are pretty good but that's kind of a weird, subtle bug IMO.

Look Around You
Jan 19, 2009

Mr.Radar posted:

They could done macros that calculated the seconds from given time periods, e.g.
code:
#define TIME_S(s) (s)
#define TIME_MS(m, s) TIME_S(60*(m)+(s))
#define TIME_HMS(h, m, s) TIME_MS(60*(h)+(m), (s))
#define TIME_DHMS(d, h, m, s) TIME_HMS(24*(d)+(h), (m), (s))
//Convenience macros
#define TIME_D(d) TIME_DHMS((d), 0, 0, 0)
#define TIME_H(h) TIME_HMS((h), 0, 0)
//etc..
Any compiler worth anything would be able to constant-fold those expressions down to literal numbers so there's no drawback in terms of performance and a large gain in flexibility.

I would like to know how they are going to a) use macros in a language which has none and b) rely on compilation optimization in a language which is not compiled.

(yes I know that the ruby interpreter could do this [and in fact probably does] but I don't know if that's good to rely on if you need the response time that they are apparently aiming for with this library)

Look Around You
Jan 19, 2009

evensevenone posted:

Would this make you feel better? The last thing is evaluated always returned. Statements are separated by semicolons. if you put a semicolon, and there is nothing after it, what is returned is the evaluation of nothing, which is nil.

This discussion has passed and I don't have the rust compiler on this computer but is block-keyword { ; stuff } legal?

Add to that the fact that a stray semicolon will literally cause a compilation error even if it's in a space where they almost always are legal and you have a problem IMO.

edit: and I'm not sure "pay more attention when you code" is applicable here; thinking extremely hard about the placement of a ";" is probably not the best usage of a developer's time. Especially when an extremely subtle one character difference (that looks legal) is a compilation error.

edit(again): removed retarded incorrect statement made due to lack of sleep (this is a running theme)

Look Around You fucked around with this message at 11:53 on Feb 3, 2012

Look Around You
Jan 19, 2009

Optimus Prime Ribs posted:

I've never seen that goofy "more than one dollar sign" poo poo in PHP before, but just what the hell is it supposed to do?
Like, this makes no sense:

http://codepad.org/tMhOK1dO
http://codepad.org/3xDgPwrA
http://codepad.org/1IxeJDDO

:psyduck:

Apparently they are "variable variables":

PHP docs posted:

Variable variables

Sometimes it is convenient to be able to have variable variable names. That is, a variable name which can be set and used dynamically. A normal variable is set with a statement such as:

php:
<?
$a = 'hello';
?>
A variable variable takes the value of a variable and treats that as the name of a variable. In the above example, hello, can be used as the name of a variable by using two dollar signs. i.e.

php:
<?
$$a = 'world';
?>
At this point two variables have been defined and stored in the PHP symbol tree: $a with contents "hello" and $hello with contents "world". Therefore, this statement:

php:
<?
echo "$a ${$a}";
?>
produces the exact same output as:

php:
<?
echo "$a $hello";
?>
i.e. they both produce: hello world.

Look Around You
Jan 19, 2009

Suspicious Dish posted:

Oh, the rabbit hole goes much deeper than that.

First, an old PHP feature: bare strings. In PHP, $foo = hello; is equivalent to $foo = "hello";, even though this triggers a warning in newer versions of PHP.

$foo is really shorthand for ${foo}, which is really shorthand for ${"foo"}. The thing inside the braces can be any arbitrary PHP expression, so $$foo is shorthand for ${${"foo"}}.

You can even do this:

php:
<?php
$wow_php_is_dumb "what did you expect?";

$language "php";
echo ${wow_ $language _is_dumb};

Try it at home!

You can do:

php:
<?php
$wow_php_is_dumb_times_100 "are you not getting it yet?";

$language "php";
echo ${wow_ $language _is_dumb_times_ (10*10)};

Link!

Now, remember.... any PHP expression.

Go ahead and digest this. I'll wait.

:stare:

Jesus christ what the gently caress. Why do people still use this garbage?

Look Around You
Jan 19, 2009

Haystack posted:

LAMP stacks made it really, really easy for beginners and non-technical people to start web programming, and it kind of built inertia from there.

Yeah but at some point you'd think people would realize just how loving terrible PHP is all around, as a language and with it's libraries...

Who am I kidding people are loving retarded and would rather straight up cut and paste things and cobble together piles of poo poo than put any effort in at all.

Look Around You
Jan 19, 2009

taqueso posted:

For a lot of people, copy/pasting and getting things to barely work is a massive amount of effort.

This is true. I'm pretty behind in actual courses taken in my CS program due to a few years of health issues, but in my "intro to systems programming" class or whatever last semester, we spent the first 4 or 5 weeks just learning C and comparing it to (gently caress) Java. The last project of the semester was writing a simplified HTTP server with pthreads that responds to GET requests. This kid in my class asked me a couple days before the project was due (and a day or so before the final) if function parameters in C were passed by copy or not :eng99:

Look Around You
Jan 19, 2009

Optimus Prime Ribs posted:

I've never heard "pass by value" be referred to as "pass by copy" before, but yes.
In C and C++ you could pass an int (for example) by value by doing void foo(int butts), or by reference by doing void bar(int& boobs).

You could even pass a pointer! void baz(int* ohgod) :toot:

There's no references in C. Everything is passed by value (he also said copy and not value so I reproduced it), if you need to change it you explicitly pass it a pointer, and even then the actual pointer is passed by value. References are entirely a C++ thing.

Look Around You
Jan 19, 2009

Internet Janitor posted:

I don't really see what's so strange about it.

code:
((Integer)null).equals(new Object()); // throws NullPointerException

I guess it's strange because in most contexts you expect it to auto-(un)box so intuitively it should work. But it doesn't there.

The following prints "true" for example:

code:
public class Test {
  public static void main(String[] args) {
    Integer i = new Integer(5);
    int j = 4;
    if (i + j == 9) {
      System.out.println("true");
    } else {
      System.out.println("false");
    }
  }
}
e: 8 space indents -> 2 spaces for less huge rear end tabs.

Look Around You
Jan 19, 2009

Look Around You posted:

I guess it's strange because in most contexts you expect it to auto-(un)box so intuitively it should work. But it doesn't there.

The following prints "true" for example:

code:
public class Test {
  public static void main(String[] args) {
    Integer i = new Integer(5);
    int j = 4;
    if (i + j == 9) {
      System.out.println("true");
    } else {
      System.out.println("false");
    }
  }
}
e: 8 space indents -> 2 spaces for less huge rear end tabs.

Obviously this is better than undefined behavior of unboxing a null but that's the problem with nullable reference types in a language where you're pretty required to use objects for things.

Look Around You
Jan 19, 2009

JewKiller 3000 posted:

[pointers vs references]

:eng101:

There's a lot of good points here. I haven't done much C++ programming, but I do know there's const parameters to functions and I guess I was wondering how much they're used; const correctness seems pretty hard to implement correctly but it seems like it would help things out w.r.t. passing stack allocated things. Especially because stack allocation is a huge feature in C++ that allows RAII and automatic cleanup of locals without manual memory management/garbage collection.

Adbot
ADBOT LOVES YOU

Look Around You
Jan 19, 2009

Zombywuf posted:

So, apparently this thread hates functions that mutate their arguments.

lol

And I really mean that, I did lol.

I don't hate it but I like knowing whether or not calling a function will change it's arguments. That's the big thing about it for me.

The worst part about this in Java is that since all object arguments to functions are passed via a copy of it's reference and there's absolutely no way to specify const-ness you have no idea what the gently caress that function does to your poo poo half the time if you didn't write it. Also a lot of people writing Java think that AnObject x = new AnObject(); AnObject y = x; means that y gets a copy of the object x instead of becoming a copy of the reference to x which is pretty bad too.

e:

MEAT TREAT posted:

Ding ding ding. This is why Null Integers are useful.

I agree that they're useful sometimes, but not by default.

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