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

Zaxxon posted:

can we put a scripting language in and only let programmers use it?

I guess, but then you should probably just use whatever is going to interface best with your underlying system and give you decent performance which may very well be LUA unfortunately.

Adbot
ADBOT LOVES YOU

Police Academy III
Nov 4, 2011

abraham linksys posted:

wrote a lexer for handlebars syntax highlighting in pygments

still baffled that we all use regular expressions in 2013. you'd think people would at least start habitually commenting them, or at least stop leaving them as weird undocumented strings all over the place. i mean no one's made anything better but it's just one of the least intuitive things in coding today

emacs has some lispy dsl for writing them but honestly i just end up using weird undocumented strings instead since they take up like 10x less space and who doesn't know how to read a regex in this the thirteenth year of the twenty-first century of our lord and saviour jesus "big jc" christ.

Police Academy III
Nov 4, 2011

vapid cutlery posted:

you are so amazingly stupid that i'm not surprised at all that you'd write something like this

uh ok gently caress you too buddy

Police Academy III
Nov 4, 2011
so have a thing

code:
# terrible regex dsl for python, completely untested
# no attempt is made to eliminate redundant grouping
# terrible abuses of operator overloading ahead
# docs:
# use Rx(s) to create a regex matching s literally
# Rx[...] creates charclasses, use slices for ranges
# e.g. Rx['a':'z', 'A':'Z', '_'] === [a-zA-Z_]
# + is concatenation
# | is |
# use r.group() to create a group around a regex,
# use r.group(name) to create a named one
# unary + is +
# ~ is ?
# r.repeat() is *
# r * i matches i repetitions
# r * (i, j) matches between i and j repetitions
# unary minus creates non-greedy matches after
# using any of the previous 5 operations
# any methods that work on a normal python regex
# should also work on an Rx
# examples:
# Rx['a':'z', 'A':'Z', '_'] + Rx['a':'z', 'A':'Z', '0':'9', '_'].repeat()
#   === "[a-zA-Z_][a-zA-Z0-9_]*
# +(Rx('w') | 'a').group() + -Rx['ab'].repeat()
#   === "(w|a)+[ab]*?"

import re

def _charclass_entry_to_str(s):
    if isinstance(s, str):
        return re.sub("(-|])", r"\\\1", s) if isinstance(s, str) else s
    elif isinstance(s, slice):
        for x in [s.start, s.stop]: assert(isinstance(x, str) and len(x) == 1)
        return s.start + "-" + s.stop
    else:
        assert(False)

class _TerribleHack(type):
    def __getitem__(cls, s):
        if isinstance(s, tuple):
            s = reduce(str.__add__, map(_charclass_entry_to_str, s))
        else:
            s = _charclass_entry_to_str(s)
        return cls("[" + s + "]", False)

class Rx(object):
    _identifier_regex = re.compile(r"[a-zA-Z_][a-zA-Z0-9_]*")
    __metaclass__ = _TerribleHack

    def _maybe_escape(self, s):
        if isinstance(s, Rx):
            return s.s
        elif isinstance(s, str):
            return re.escape(s)
        else:
            assert(False)

    def __init__(self, s="", escape=True):
        if isinstance(s, Rx):
            self.s = s.s
        elif isinstance(s, str):
            self.s = re.escape(s) if escape else s
        else:
            assert(False)
        self.rx = None

    def _wrap(self):
        return "(?:" + str(self) + ")"

    def group(self, name=None):
        if name:
            assert(self._identifier_regex.match(name))
            return self.__class__("(P<" + name + ">" + str(self) + ")", False)
        else:
            return self.__class__("(" + str(self) +")", False)

    def repeat(self):
        return self.__class__(self._wrap() + '*', False)

    def __str__(self):
        return self.s

    def __add__(self, other):
        return self.__class__(str(self) + self._maybe_escape(other), False)
    def __radd__(self, other): self.__class__(other) + self

    def __mul__(self, other):
        if isinstance(other, int):
            return self.__class__(self._wrap() + "{%d}" % i, False)
        elif isinstance(other, tuple):
            assert(len(other) == 2)
            return self.__class__(self._wrap() + "{%d, %d}" % other, False)
        else:
            assert(False)

    def __or__(self, other):
        return self.__class__(self._wrap() + "|" + self.__class__(other)._wrap(), False)
    def __ror__(self, other): return self.__class__(other) | self

    def __neg__(self):
        assert(len(self.s) > 1 and ((self.s[-1] in "}*+" and self.s[-2] != "\\") or (self.s[-1] == "?" and self.s[-2] not in "?\\")))
        return self.__class__(str(self) + "?", False)

    def __invert__(self):
        return self.__class__(self._wrap() + "?", False)

    def __pos__(self):
        return self.__class__(self._wrap() + "+", False)

    def __getattr__(self, name):
        self.rx = self.rx or re.compile(self.s)
        try:
            return getattr(self.rx, name)
        except AttributeError:
            raise AttributeError("'" + self.__class__.__name__ + "' object has no attribute '" + name + "'")

Police Academy III
Nov 4, 2011
my favourite way is when you free something you weren't supposed to and then the next call to malloc gives you the same address back again and you're trying to use the same area of memory for two different purposes and wondering why completely separate areas of your program are loving up each other's poo poo

Police Academy III
Nov 4, 2011

Hard NOP Life posted:

In what context?

I think he's talking about this: http://nickknowlson.com/blog/2013/04/16/why-maybe-is-better-than-null/ (i didn't actually read it though)

The idea is that having a type system that allows you to optionally tack on null as a valid value to any type is better than having to check against it all the time, which is pretty obviously right imo.

Police Academy III
Nov 4, 2011

tef posted:

no it's just new people asking the same old questions

hey what does everyone think about nesting in multiline comments?

Police Academy III
Nov 4, 2011

Internaut! posted:

step up and move to the valley, everyone's hiring

Only easy to do if you're american or canadian (yay TN visa). IDK about mexicans, you'd think they could get TN's too but, you know, racism. Pretty sure tef would have to get an H1B or something.

Police Academy III
Nov 4, 2011

prefect posted:

boo. i really only speak english

what's france like? i used to be able to speak french

you can work in a lot of places only speaking english, holland has more fluent english speakers than canada

Jerry SanDisky posted:

1000 islands is nice, and you're really close to Kingston as well

1000 islands is pretty as hell, kingston is boring unless you like prisons or something

Police Academy III
Nov 4, 2011

Jerry SanDisky posted:

kingston has great bars and breweries

which kingston are we talking about here?

(seriously though, kingston has a much better downtown then a lot of towns its size but I'm not sure I'd describe it as "great")

Police Academy III
Nov 4, 2011
i like how the top comment on hn is some libertarian making whiny semantic arguments about what "liberalism" actually is

edit: okay, nm, it's moved down a bunch but it was still pretty lol

Police Academy III fucked around with this message at 19:00 on May 14, 2013

Police Academy III
Nov 4, 2011

Mr Dog posted:

waiting for the hipsters to start programming in x86 asm

i mean hey it has absolutely gently caress-all type safety so they should take to it like stink on poo poo

CISC architectures are for corporate java-drones, it takes a true ruby hackeur to appreciate the sublime beauty of RISC

Police Academy III
Nov 4, 2011
i'm pretty stupid but this blew my mind a bit: http://en.wikipedia.org/wiki/Covariance_and_contravariance_%28computer_science%29

Police Academy III
Nov 4, 2011

PleasingFungus posted:

huh, so covariance is "X or a subclass" (e.g. generics), and contravariance is "X or a parent class" (e.g. ?)

that's not too bad, but wiki does its best to avoid actually explaining it

typical

the thing that got me was how that to maintain liskov substitutability, return types of re-implemented methods must be covariant, while argument types must be contravariant

Police Academy III
Nov 4, 2011
people always act as if you could only like immutability if you're some lisp nerd who wants to look cool doing reduce-map-filter stuff, but really immutability is grand b/c it significantly reduces the amount of mental effort needed to understand any given expression. being able to look at a bit of code and know that the only thing that effects what it does is what you see and that the only thing that it effects is what the result is is great. I like immutability b/c I'm stupid, not because I'm smart.

Police Academy III
Nov 4, 2011

tef posted:

the only problem is that mutability is kinda useful sometimes for performance and you can take my hash tables away from my cold dead hands.

tru dat, also some algorithms are just easier to do with mutably, but on the whole i think immutability works better 9 times out of 10.

Police Academy III
Nov 4, 2011
I like rust's approach of having owned/managed/borrowed pointers as part of the type system but last time I actually tried to use it it was a giant pain in the rear end so hopefully they get it somewhere sensible before they hit 1.0

Police Academy III
Nov 4, 2011
At this point C++ needs to start adding compiler flags to disable features

Police Academy III
Nov 4, 2011
So I managed to hang javac at work today using recursive generics. Probably the only interesting thing I've managed to do at work so far tbqh (besides cleaning my butt with the fancy japanese toilet seats).

Police Academy III
Nov 4, 2011

tef posted:

no one can afford to write software without bugs

nah, just bust out your hoare axioms and proof tableaux and get to work, if you do it fast enough you might get it done before your code gets obsoleted

Police Academy III
Nov 4, 2011

coffeetable posted:

software verification has come a long way since proof tableaux. the industries which are willing to splurge on safety (read: aerospace) have fallen madly in love with formal verification

went to a great talk a few months back on building tools to automate the ESA's model checking

correct me if I'm wrong, but to be able to do useful formal verification, don't you have to use a language with different semantics than the typical imperative/mutable c/java/etc style? i heard that haskell is good for that sort of thing since it's so uptight about everything, and because recursion is easier to verify than loops.

Police Academy III
Nov 4, 2011

yaoi prophet posted:

what keyboard should i get yospos, are kinesises actually that much better than flat keyboards

hey look at what was just posted in the fatwood thread

quote:

the best keyboard is that giant fuckoff microsoft ergonomic thing with the weird toggle switch in the middle

also java sucks, just so everyone knows

Police Academy III
Nov 4, 2011
how to actually use vim: hit ctrl-z and type in killall -9 vim; export EDITOR=nano

Police Academy III
Nov 4, 2011
i use emacs

Police Academy III
Nov 4, 2011

Gazpacho posted:

configuration is for people who are incapable of learning

if ur .emacs is < 1000 lines long ur not doing it right

Police Academy III
Nov 4, 2011
so a guy at work was unironically pushing for us to switch our javascript to dart. looking at the wiki page it doesn't look terrible if not very exciting, basically like the web version of go. has anybody actually used it or looked at it or given a poo poo about it? or is it just gwt 2.0?

Police Academy III
Nov 4, 2011

Vanadium posted:

I'm really amazed the rust people get anything done with how sadistic their type system is.

I don't really see anyone picking up rust that isn't a C++ veteran who needs rust's pointer lifetime/mutability errors to get off because C++'s template errors don't do it for them anymore.

i like rust because it seems like they're trying to tackle problems that no-one else wants to deal with, but gently caress me if trying to use it didn't make me want to tear my hair out.

Police Academy III
Nov 4, 2011
Hey just bumping this thread to let everyone know that dart is poo poo and basically GWT 2.0. I mean you probably could've figured taht out by looking at it yourself for 5 seconds but just in case you wanted official confirmation.

Police Academy III
Nov 4, 2011

Internaut! posted:

what was gwt 1.0

https://en.wikipedia.org/wiki/Google_Web_Toolkit

Police Academy III
Nov 4, 2011
I've been a professional web 'developer' for 9 months now and I still have no idea what mvc is lol

Adbot
ADBOT LOVES YOU

Police Academy III
Nov 4, 2011

Jonny 290 posted:

PL guys i need help

ive got a python thing


i essentially need the functionality of http://www.panix.com/~eli/unicode/convert.cgi in python code form.

what trick should i use? ive tried doing math with all sorts of hex u'\u9750' stuff and its not quite coming out correctly

like i want to feed it "a stray cat" and either a character set or offset and it gives me the string that would display 🄰 🅂🅃🅁🄰🅈 🄲🄰🅃


any ideas?

imo i would just type 1234567890qwertyuioopasdfghjkllllzxcvbnmQWERTYUIOPASDFGHJKLLLLLZXCVBNM + whatever else into that site, copy paste the result and munge it into something easily parsable.

edit so basically what that ^^^ guy was on about

Police Academy III fucked around with this message at 03:27 on Sep 27, 2014

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