Open Side Menu Go to the Top
Register
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** ** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD **

10-01-2012 , 06:08 PM
CDN = Content delivery network. High performance/availability content delivery.

A lot of sites are using CDNs these days to serve static content (images/css/js/video etc)
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
10-01-2012 , 07:49 PM
A separate domain with static content can skip cookies, use more aggressive caching, and other tricks to speed up delivery.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
10-01-2012 , 08:38 PM
noscript is awesome imo for stopping such requests: never requested = infinite speed increase of course it breaks a ton of sites too until they are whitelisted
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
10-02-2012 , 03:16 AM
Since you use len(deck) anyways here are some building blocks you probably want

Code:
deck_size = len(deck)
deck_middle = int(deck_size/2)

half1=deck[:deck_middle]
half2=deck[deck_middle:]
Edit: Oooops just saw that
a) Question was already answered
b) You needed it way before this post

Anyways in case you want to learn up on it what you want to google is "python slice" or something. Usefull to know that omitting one side like in [:x] and [x:] means "from beginning to" and "untill the end" and it's also usefull to know that you can use negative indices that count backwards i.e. deck[-1] would be the last card.

Good python intrduction:
https://code.google.com/intl/de/edu/...-python-class/

[the exercises feature a bunch of slicing stuff]

Last edited by clowntable; 10-02-2012 at 03:26 AM.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
10-02-2012 , 12:12 PM
Quote:
Originally Posted by Neil S
A separate domain with static content can skip cookies, use more aggressive caching, and other tricks to speed up delivery.
Also, a lot of the big CDN's will deliver content from a location which is physically close to you, reducing latency. IMO, this is one of the biggest advantages.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
10-02-2012 , 12:51 PM
Quote:
Originally Posted by MrWooster
Also, a lot of the big CDN's will deliver content from a location which is physically close to you, reducing latency. IMO, this is one of the biggest advantages.
That's another thing I've been curious about - how can one domain name redirect to any number of different servers depending on where I'm located? Does all traffic to google.com go to one main google server which then geolocates and redirects the traffic to the closest server? That doesn't really seem feasible with their amount of traffic. Or is it somehow handled at the DNS level so google doesn't have to worry about it at all? Sorry for the noob questions, I find this stuff really interesting.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
10-02-2012 , 01:47 PM
So I've been wondering this forever -- can someone explain why there are so many languages that compile to Javascript?

I write JS all the time. I've coded several ~1000 LOC plugins for my web app (somewhat long by JS standards, for those not familiar). They're pure JS, no jQuery or other libs, and have been fully tested across multiple browsers (which just means they work in IE, the ******ed cousin of the web browser industry).

Here's what I don't get -- it wasn't that tough. Why is it necessary to learn a language that ultimately just gets compiled down to JS. Why not just learn JS in the first place?

People often complain about browser compatibility, which is fair. But that's nowhere near the obstacle that it once was.

For one thing, there is plenty of information available about the best practices for common scenarios to ensure compatibility and predictable behavior. And if you don't want to figure that out, just use jQuery. It's absolutely rock solid. I mean, it supports Internet Explorer 6.

Someone wanna shed some light on this for me?
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
10-02-2012 , 02:23 PM
Why do you care what a language compiles down to?

Why not just use the best language for the job?
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
10-02-2012 , 03:37 PM
Quote:
Originally Posted by sdturner02
So I've been wondering this forever -- can someone explain why there are so many languages that compile to Javascript?

I write JS all the time. I've coded several ~1000 LOC plugins for my web app (somewhat long by JS standards, for those not familiar). They're pure JS, no jQuery or other libs, and have been fully tested across multiple browsers (which just means they work in IE, the ******ed cousin of the web browser industry).

Here's what I don't get -- it wasn't that tough. Why is it necessary to learn a language that ultimately just gets compiled down to JS. Why not just learn JS in the first place?

People often complain about browser compatibility, which is fair. But that's nowhere near the obstacle that it once was.

For one thing, there is plenty of information available about the best practices for common scenarios to ensure compatibility and predictable behavior. And if you don't want to figure that out, just use jQuery. It's absolutely rock solid. I mean, it supports Internet Explorer 6.

Someone wanna shed some light on this for me?
little confused by your question. something like jquery isn't compiling down to js, it's just a library. if you can write your own cross-browser stuff, great, but that forced you to *test* your code in a ton of browsers, or just take it on faith that it works in the browsers you didn't test it in. and now every time you change your code, same deal. jquery lets you avoid that problem.

or do you mean something like coffeescript? people use that just because it has a cleaner syntax than js. they're not really arguing that js is terribly verbose or anything, but coffeescript allows even shorter, cleaner code, and since it's based on ruby i believe, there's not really much of a learning curve. like if you already know ruby and js, you could pick up coffee script in a day.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
10-02-2012 , 04:09 PM
Quote:
Originally Posted by n00b590
That's another thing I've been curious about - how can one domain name redirect to any number of different servers depending on where I'm located? Does all traffic to google.com go to one main google server which then geolocates and redirects the traffic to the closest server? That doesn't really seem feasible with their amount of traffic. Or is it somehow handled at the DNS level so google doesn't have to worry about it at all? Sorry for the noob questions, I find this stuff really interesting.
I cant speak for google, I am fairly sure they have some unique way of doing it, but for traditional CDN networks, I believe that the first server you hit evaluates your location and returns a redirect to the server which is closest to you.

E.g. you access cdn.example.com/content.js

cdn.example.com receives the request, locates you in London and redirects the request to cdn-uk.example.com/content.js


Someone else might be able to chime in... not sure how accurate the above is, but its certainly one way to do it.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
10-02-2012 , 04:10 PM
Quote:
Originally Posted by Neil S
Why do you care what a language compiles down to?

Why not just use the best language for the job?
It's not that I care what a language compiles down to as a general proposition. It's that in this particular case, it's not compiling down to bytecode or something like that, it's just Javascript. And there are tons of languages that do that it seems.

I suppose my thinking is that Javascript isn't so difficult to learn that I think it's necessary to learn a second language that abstracts it away.

Quote:
Originally Posted by gaming_mouse
little confused by your question. something like jquery isn't compiling down to js, it's just a library. if you can write your own cross-browser stuff, great, but that forced you to *test* your code in a ton of browsers, or just take it on faith that it works in the browsers you didn't test it in. and now every time you change your code, same deal. jquery lets you avoid that problem.
Oh I know all of that, that's not what I meant.

Quote:
Originally Posted by gaming_mouse
or do you mean something like coffeescript? people use that just because it has a cleaner syntax than js. they're not really arguing that js is terribly verbose or anything, but coffeescript allows even shorter, cleaner code, and since it's based on ruby i believe, there's not really much of a learning curve.
Yeah this is basically it.

I suppose my take on it is that if you're interested enough in development that you're willing to learn a language that compiles to JS, you're better off spending a little extra time just learning Javascript.

It seems that if language A compiles down to language B, the capabilities of language A are necessarily more confined to some extent than if you're using language B. If language B isn't prohibitively difficult to learn, it seems more logical to learn that instead.

Quote:
Originally Posted by gaming_mouse
like if you already know ruby and js, you could pick up coffee script in a day.
In cases other than where you're working with a team that only uses Coffescript, what's the point of learning it, aside maybe for just your own amusement?

I should also note that I'm not trying to criticize people who use CS or any of the similar tools, and I'm not trying to spark a debate of any sort. I'm just genuinely confused about why it's so common.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
10-02-2012 , 04:28 PM
Quote:
Originally Posted by sdturner02
It seems that if language A compiles down to language B, the capabilities of language A are necessarily more confined to some extent than if you're using language B. If language B isn't prohibitively difficult to learn, it seems more logical to learn that instead.
I mean this is true only in a very narrow sense. You could argue that since every language is boiled down to assembly you're more confined then just using assembly. But the reality is that the ability to build higher order structures, concepts, and libraries makes the higher level language much more powerful.

Obviously a modern programming language is a lot easier to learn than assembly - but the same approximate arguments hold here. People like different syntaxes and different programming concepts. If there's something that provides what you like best - and can run wherever JS runs - why not use it?
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
10-02-2012 , 04:38 PM
I need to access a MySQL database on 1) a remote server 2) my local computer and 3) virtualboxes running on my local computer. What is the best way to set this up?

The database is only updated on the remote server (i.e. local computer and virtualboxes don't need write access), and I don't need a 100% up to date version of the database at all times locally, so for now I've just been transferring the database with FTP and manually updating on my local machine periodically. But this is getting pretty cumbersome with the added complication of the virtualboxes. There's a way to set up the remote server to receive outside connections to MySQL right? I'm thinking that's the way to go, if it's not too complicated to set up.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
10-02-2012 , 04:48 PM
Quote:
Originally Posted by jjshabado
I mean this is true only in a very narrow sense. You could argue that since every language is boiled down to assembly you're more confined then just using assembly. But the reality is that the ability to build higher order structures, concepts, and libraries makes the higher level language much more powerful.

Obviously a modern programming language is a lot easier to learn than assembly - but the same approximate arguments hold here. People like different syntaxes and different programming concepts. If there's something that provides what you like best - and can run wherever JS runs - why not use it?
Your point about the value of familiarity is well taken, especially for me personally -- there's a reason why I default to PHP for everything rather than buckle down and finally sharpen up my Python skills.

My hang up, I guess, is still that Javascript is distinguishable from basically every other programming language in that it's the only option for client side web development.

For example, in the vast majority of cases, PHP can be used to accomplish the identical results of someone coding in Python. Feel free to swap those with Ruby or Clojure or whatever, the result is the same. The same cannot be said about Javascript -- it's JS or nothing.

Ironically, perhaps the strongest evidence to support my argument is actually the existence of all these JS abstraction languages in the first place.

If the real answer is just that people are too lazy/too busy to invest the time learning Javascript, I can accept that.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
10-02-2012 , 04:50 PM
Quote:
Originally Posted by sdturner02

I suppose my take on it is that if you're interested enough in development that you're willing to learn a language that compiles to JS, you're better off spending a little extra time just learning Javascript.

It seems that if language A compiles down to language B, the capabilities of language A are necessarily more confined to some extent than if you're using language B. If language B isn't prohibitively difficult to learn, it seems more logical to learn that instead.
i'd guess that the vast majority of CS users know JS too. They are just looking for some extra niceties and syntactic sugar.

Here's a good post on the reasons to use CS by a very good programmer who is also a JS expert:
http://amix.dk/blog/post/19612
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
10-02-2012 , 05:09 PM
Quote:
Originally Posted by sdturner02
My hang up, I guess, is still that Javascript is distinguishable from basically every other programming language in that it's the only option for client side web development.
This is kind of like saying the only option for programming on a computer is assembly.

Quote:
Originally Posted by sdturner02
The same cannot be said about Javascript -- it's JS or nothing.
Not really. You can write in all these languages you're asking about.

Quote:
Originally Posted by sdturner02
If the real answer is just that people are too lazy/too busy to invest the time learning Javascript, I can accept that.
It's totally not this. It's that most of those languages offer something above and beyond what JS offers. For example, I used GWT for a project a few years ago and it let us use our standard Java IDEs, our standard Java testing tools, and our standard Java <fill in the blank>. We almost never* had to look at the actual JS that was generated.

* and of course those times we did it was ****ing painful.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
10-02-2012 , 05:30 PM
sdturner02, the reason you build compiled languages on javascript is the same reason you build compiled languages on anything else: to produce more powerful tools for development.

The reason we use an assembler instead of machine language isn't that we're lazy. It's that the assembler does things for us.

The reason we use C instead of an assembler isn't that we're lazy. It's that C does things for us.

And on up the chain it goes.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
10-02-2012 , 05:38 PM
yeah what neil said is the heart of the matter
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
10-02-2012 , 06:32 PM
Quote:
Originally Posted by n00b590
I need to access a MySQL database on 1) a remote server 2) my local computer and 3) virtualboxes running on my local computer. What is the best way to set this up?

The database is only updated on the remote server (i.e. local computer and virtualboxes don't need write access), and I don't need a 100% up to date version of the database at all times locally, so for now I've just been transferring the database with FTP and manually updating on my local machine periodically. But this is getting pretty cumbersome with the added complication of the virtualboxes. There's a way to set up the remote server to receive outside connections to MySQL right? I'm thinking that's the way to go, if it's not too complicated to set up.
Things you can do:

1. set remote server to accept connections from anywhere. Set the bind-address in my.cnf
2. Setup a ssh tunnel to get local access from your remote machine.
3. Setup a vpn and bind mysql to the vpn network
4. Setup replication and interact with a local mysql.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
10-02-2012 , 06:34 PM
sdturner is asking about preprocessors. Aren't these different than the general language choices?

I use SASS, a preprocessor to CSS. Using SASS creates native CSS and takes away many of the cross-browser pain-points, especially in regards to CSS3 items that require the -moz-, -webkit-, etc prefixes.

IMO, learning a pre-processor should come *after* learning the native language. This is completely separate from using Python w/o knowing C or assembly. A pre-processor is a slightly more elegant version of the native language, and unless you know the quirks of that language and how to handle the language natively, a pre-processor isn't going to be much use. A pre-processor saves a ton of hand-work, but it can't replace knowledge.

Maybe a decent correlation is trying to use a SQL DSL or ORM without actually knowing any SQL. The ORM isn't going to be very useful in inept hands but could be a powerful tool in hands with lots of SQL knowledge.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
10-02-2012 , 06:58 PM
Quote:
Originally Posted by jjshabado
This is kind of like saying the only option for programming on a computer is assembly.
No, those statements are not analogous.

Assembly is orders of magnitude more difficult to master than Javascript. It isn't even close enough to debate. Assembly is prohibitively difficult to learn such that it would cripple advancement in technology.

Anyone with even just HTML knowledge can figure out enough Javascript in a day for a lot of basic uses. The crux of my entire argument is that Javascript really isn't that hard to learn.

Quote:
Originally Posted by jjshabado
Not really. You can write in all these languages you're asking about.
I suppose if your argument is that CS is sufficiently attenuated from the resulting JS code that it actually qualifies as a new, separate programming language for client side web dev, then this could be correct.

Quote:
Originally Posted by Neil S
sdturner02, the reason you build compiled languages on javascript is the same reason you build compiled languages on anything else: to produce more powerful tools for development.
I'm not sure this is correct.

I would submit that a language built on top of another language is, without exception, less powerful than its base. This is a necessary and unavoidable result of the secondary language possessing, at an absolute minimum, all of the limitations of its base.

The reason we build languages on top of languages is to facilitate production through easier and faster development. The

To illustrate, I would challenge anyone to offer a use of CoffeeScript where an equal result is impossible to achieve with Javascript. Or, similarly, something that can be accomplished using Python or PHP that is impossible to achieve in C.

Quote:
Originally Posted by Neil S
The reason we use C instead of an assembler isn't that we're lazy. It's that C does things for us.
I actually think your example may contradict your argument. We use C instead of assembly because it's easier for development.

As an aside, I can't help but wonder if I should had used a word with a lesser tendency to provoke than "lazy".

Also, I really was not trying to pick another programming language fight, so I really won't be poking this bear anymore.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
10-02-2012 , 07:49 PM
making your superiors look like they don't know what they are talking about (or plainly not stating something factual) is fun. at least until they get mad at you or something.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
10-02-2012 , 08:13 PM
Quote:
Originally Posted by sdturner02
Anyone with even just HTML knowledge can figure out enough Javascript in a day for a lot of basic uses. The crux of my entire argument is that Javascript really isn't that hard to learn.
And the crux of our argument is that this isn't that relevant. GWT is a good example. Some people like Java and the tools they have to work with Java code. So they use GWT not because Javascript is hard to learn - but because they prefer Java.


Quote:
Originally Posted by sdturner02

I suppose if your argument is that CS is sufficiently attenuated from the resulting JS code that it actually qualifies as a new, separate programming language for client side web dev, then this could be correct.
It doesn't matter "how different" it is. It's different. Each of the things listed on your link are different in some way. Some people, some of the time, care about those differences. And its almost never because of not wanting to learn JS.

Quote:
Originally Posted by sdturner02
I'm not sure this is correct.

I would submit that a language built on top of another language is, without exception, less powerful than its base. This is a necessary and unavoidable result of the secondary language possessing, at an absolute minimum, all of the limitations of its base.
This is wrong - especially in a practical sense. Imagine one language supports only the addition operator. Another language builds on that and offers addition, subtraction, and multiplication (all by building on top of the base languages addition feature). Is it really realistic to say that the base language is more powerful?


Quote:
Originally Posted by sdturner02
As an aside, I can't help but wonder if I should had used a word with a lesser tendency to provoke than "lazy".

Also, I really was not trying to pick another programming language fight, so I really won't be poking this bear anymore.
I don't think people care about being called "lazy". I just think most of us think you're really wrong and missing the main point here.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
10-02-2012 , 08:31 PM
People didn't make the move to OOP because they're lazy. C++ boiled down to C. But it was useful anyway.

Likewise, people aren't using languages on top of JS because they're lazy. They want more language features.

Yes, languages can exist that have more features than Javascript does.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
10-02-2012 , 08:38 PM
sdturner, I guess it seems like we're kind of piling on here. But this argument at its core is about the purpose of abstraction layers - which is arguably the most important computer science concept.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote

      
m