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
BigRedDot
Mar 6, 2008

Javascript is unpleasant much in the same way assembly is unpleasant. It's verbose and asks for lots of boilerplate. Fortunately, you can target Javascript from a higher level just like you can target assembly from a higher level. Personally I use CoffeeScript all the time but I keep meaning to check out Dart.

Adbot
ADBOT LOVES YOU

Doctor w-rw-rw-
Jun 24, 2008

BigRedDot posted:

Javascript is unpleasant much in the same way assembly is unpleasant. It's verbose and asks for lots of boilerplate. Fortunately, you can target Javascript from a higher level just like you can target assembly from a higher level. Personally I use CoffeeScript all the time but I keep meaning to check out Dart.

The I/O sessions had some pretty interesting stuff. They had a demo of Dartium, which is a Chromium modified to have a Dart VM, and it had some pretty dramatic speed improvements. Dart->JS was only something like 1-2% slower than plain Javascript, and Dart run directly was multiple times faster than JS.

Gul Banana
Nov 28, 2003

Thermopyle posted:

I get your point, but I think there's a lot of languages where you wouldn't have as large a portion of developers saying the same sort of things they say about JS.

I mean, if you pick a widely used language like say Python, there's going to be a lot of things that a lot of developers don't like about it, but, at the same time, it seems to me that there's not going to be a lot of developers saying it's a bad language.

I dunno, it just seems as if there's an actual quality difference between JS and other widely used languages that goes beyond the typical "I don't like semantic whitespace" or "too verbose" complaints you hear about other languages.

IMO the difference is this: all languages are flawed, and it'd be difficult for one language to be good at everything, but many languages are at least good at SOMETHING. these are the ones that become popular, typically! python is easy to learn and can be used to combine the results of fast c extensions. that makes it good for science. java is easy to componentise. that makes it good for large teams. haskell has a very expressive type system. that makes it good for proofs. c++ is portable, highly abstract, and high performance. that makes it good for game engines.

javascript derives its popularity not from being good for web development, but from being NECESSARY for web development. it was written in about a week by one guy and then retrofitted with syntax which didn't match its semantics. Netscape did this because of the enormous commercial opportunity, to lock people in to a language that would be hugely important- and they succeeded. first mover advantage and then standardisation in a world of competing web renderers lead to ecmascript's apparently unbreakable monopoly.

look how many projects compile stuff to javascript. it is the assembly language of the web - universal because it is the lowest level *available*. not because of its merit. and now that universality leads to "full-stack" experimentation & it ends up running in problem domains even *less* amenable to its weirdass gotchas & morass of other-than-"The Good Parts".

this is not to say that javascript doesn't have merits. it has a powerful object literal syntax - no coincidence that these js-outside-browser systems revolve around mongodb. it has strong support for asynchronous callbacks, an important UI technique. but if it weren't for historical accident, there's no reason to believe we'd be using something like javascript to achieve - the actual goal - our DHTML.

Opinion Haver
Apr 9, 2007

BigRedDot posted:

Javascript is unpleasant much in the same way assembly is unpleasant. It's verbose and asks for lots of boilerplate. Fortunately, you can target Javascript from a higher level just like you can target assembly from a higher level. Personally I use CoffeeScript all the time but I keep meaning to check out Dart.

I considered CoffeeScript but the syntax is just so janky. f () -> 2 does something different from f() -> 2, and f x, y, g z, a, b probably doesn't do what you think it does at first glance.

Jabor
Jul 16, 2010

#1 Loser at SpaceChem
Imagine if you tried to improve JavaScript by using a bunch of regex replacements to implement various syntactic sugars, and as you added more of them you eventually decided that regexes wouldn't cut it and so you wrote a proper parser (but still kept backwards-compatibility), and then you decided to release it publicly and keep tacking on more syntactic sugar.

That's kind of what CoffeeScript feels like to me.

Doctor w-rw-rw-
Jun 24, 2008
CoffeeScript is just polishing up a...thing, but not really improving on it IMO.

What I've seen of Dart has been very promising. It feels like a proper language.

Blotto Skorzany
Nov 7, 2008

He's a PSoC, loose and runnin'
came the whisper from each lip
And he's here to do some business with
the bad ADC on his chip
bad ADC on his chiiiiip

Doctor w-rw-rw- posted:

What I've seen of Dart has been very promising. It feels like a proper language.

I've the opposite impression. Dart feels like trying to import all the accidents of Java into JS and none of the substance. It doesn't help that its creators are embarrassingly unfamiliar with the theory and practice of type systems.

Doctor w-rw-rw-
Jun 24, 2008

Otto Skorzeny posted:

I've the opposite impression. Dart feels like trying to import all the accidents of Java into JS and none of the substance. It doesn't help that its creators are embarrassingly unfamiliar with the theory and practice of type systems.

Dart isn't a JS-based language. Javascript is a target. What are the accidents, by the way?

Also, given that the founder of the V8 project started Dart, I'd like to hear more details about their embarrassing lack of relevant knowledge.

Maluco Marinero
Jan 18, 2001

Damn that's a
fine elephant.

yaoi prophet posted:

I considered CoffeeScript but the syntax is just so janky. f () -> 2 does something different from f() -> 2, and f x, y, g z, a, b probably doesn't do what you think it does at first glance.

Eh, it's been fairly easy for me to adjust to, Ruby's parser is similar, and it's not like you need to actually use parentheses free style. More over, it's pretty much recommended when using function calls as arguments that if you're going to use parentheses free, it's only for the outermost statement, so f x, y, g(z, a, b).

I do agree that Coffeescript is purely a syntactic sugar language, but I don't see that as such a bad thing. The problem with the assembler level analogy is that at present you still have to debug the Javascript, source mapping is still a bit janky to use because you get the line number but still have to observe the underlying Javascript to follow behaviour or expressions properly. Until we're at the point where you can debug without having to deal with the resultant Javascript, I feel like the precompiling languages can't diverge too far from Javascript's core.

Doctor w-rw-rw-
Jun 24, 2008

Maluco Marinero posted:

Eh, it's been fairly easy for me to adjust to, Ruby's parser is similar, and it's not like you need to actually use parentheses free style. More over, it's pretty much recommended when using function calls as arguments that if you're going to use parentheses free, it's only for the outermost statement, so f x, y, g(z, a, b).

I do agree that Coffeescript is purely a syntactic sugar language, but I don't see that as such a bad thing. The problem with the assembler level analogy is that at present you still have to debug the Javascript, source mapping is still a bit janky to use because you get the line number but still have to observe the underlying Javascript to follow behaviour or expressions properly. Until we're at the point where you can debug without having to deal with the resultant Javascript, I feel like the precompiling languages can't diverge too far from Javascript's core.

Not to sound like a broken record, but Dart runs directly on its own non-Javascript VM (when not Javascript-targeted), and can do things like SIMD?

vvvvv Edit: cool. Also, http://www.infoq.com/news/2013/05/Dart-Java-DeltaBlue - apparently it's got some pretty nice performance

Doctor w-rw-rw- fucked around with this message at 10:02 on May 20, 2013

Maluco Marinero
Jan 18, 2001

Damn that's a
fine elephant.
Okay okay, I'll check it out. :)

Hughlander
May 11, 2005

yaoi prophet posted:

I considered CoffeeScript but the syntax is just so janky. f () -> 2 does something different from f() -> 2, and f x, y, g z, a, b probably doesn't do what you think it does at first glance.

We had a memory leak at work in coffee script because someone forgot that:
@object.foo a, b, c will call foo with parameters a, b, and c while:
@object.foo will just get the value of foo and then throw it away with no left hand side.

Blotto Skorzany
Nov 7, 2008

He's a PSoC, loose and runnin'
came the whisper from each lip
And he's here to do some business with
the bad ADC on his chip
bad ADC on his chiiiiip

Doctor w-rw-rw- posted:

Dart isn't a JS-based language.
I didn't imply it was, thank you.

Doctor w-rw-rw- posted:

What are the accidents, by the way?
accident (ˈćksɪdənt)
— n
1. an unforeseen event or one without an apparent cause
2. anything that occurs unintentionally or by chance; chance; fortune: I met him by accident
3. a misfortune or mishap, esp one causing injury or death
4. (logic, philosophy) a nonessential attribute or characteristic of something (as opposed to substance)

The particular accidents of Java that I was referring to were its conventions on capitalization and its antipattern of classes-as-ersatz-namespaces. The substance which I was referring to Dart not grabbing from Java is its type system, which while flawed is certainly better than what Dart has.


Doctor w-rw-rw- posted:

Also, given that the founder of the V8 project started Dart, I'd like to hear more details about their embarrassing lack of relevant knowledge.

Thank you for once again putting words in my mouth; I didn't say that the creators of Dart lacked knowledge relevant to implementing the least-bad VM for Javascript, but rather that they lacked knowledge of the theory and practice of type systems. I assume everyone who has looked at Dart's non type non system (type annotations that are meaningless by default with optional runtime assertions that aren't actually assertions, lol) and any even remotely modern type system ( ML's is a good example of a baseline static type system, while being decades old and quite simple; Python is a good example of a dynamic strongish type system that works well) can tell you that Dart programmers (assuming there are any outside of Google) are getting shortchanged.

Suspicious Dish
Sep 24, 2011

2020 is the year of linux on the desktop, bro
Fun Shoe
Dude, Otto, you might have a good argument in there somewhere but it's getting crowded by all those awful words. Any time you pull out a dictionary to define a word that a 3 year old would know, your argument stopped being persuasive and you started being a dick.

So, on the topic of JavaScript. I'm going to say two things. One, this is a decently interesting paper on a canned successor to JavaScript and its type system that I think is fairly neat, and please look at where JavaScript is heading, with ECMAScript Next. It's disappointing that people are all discussing the future language of the web, and nobody has looked at what TC39, the ECMAScript Committee, is planning.

Mr. Crow
May 22, 2008

Snap City mayor for life
Don't have a lot of experience with CMS', boss wants me to find a CMS to use to make an 'admin portal' for modifying / updating a db. We're stuck in a very specific environment (.net 3.5 among other things), so I've narrowed it down to DotNetNuke 6.2.x and MojoPortal. So I guess it would basically be a page-per-table and have some sort of excel-like table for modifying the data (or just a form with a bunch of fields).

I'm working on a prototype and having a hard time figuring out how to approach it. Seems like I can't do anything with in-page functionality, so I'll need to plug-in some library and figure out how to tie it together I guess. It seems especially irrelevant since he just had me create an identical restful service for getting the data out of the database, but I'm out of here Friday so I know no longer give a poo poo (or if someone thinks they know the reasoning to his madness, I'd be happy to know more!). Hoping to re-use the business and transport objects from that project and then the only thing I'd have to do is tie it all together, somehow; but I'm failing to see how to do this outside of the traditional website model and within the scope of the CMS.

Any help or direction to get started would be wonderful, not having much luck with the CMS documentation amid all the buzzwords titles and articles.

Mr. Crow fucked around with this message at 16:33 on May 20, 2013

Blotto Skorzany
Nov 7, 2008

He's a PSoC, loose and runnin'
came the whisper from each lip
And he's here to do some business with
the bad ADC on his chip
bad ADC on his chiiiiip

Suspicious Dish posted:

Any time you pull out a dictionary to define a word that a 3 year old would know, your argument stopped being persuasive and you started being a dick.


I don't think your typical 3 year old (nor indeed your typical poster) is familiar with the Aristotelian distinction between substance and accidents, and was worried that my prior use of the term 'accidents' in that manner was being misunderstood to mean "mistakes", which is why I posted the definition and bolded the relevant part, which you seem to have ignored.

JawnV6
Jul 4, 2004

So hot ...
Dicks can be quite persuasive.

Doctor w-rw-rw-
Jun 24, 2008
We should probably not assume too much about what the other "really" said.

Otto Skorzeny posted:

I didn't imply it was, thank you.
I was being technical. Strictly speaking they're not importing Java into JS, they're importing into Dart, which *can* compile to JS, but doesn't have to.

Otto Skorzeny posted:

The particular accidents of Java that I was referring to were its conventions on capitalization and its antipattern of classes-as-ersatz-namespaces. The substance which I was referring to Dart not grabbing from Java is its type system, which while flawed is certainly better than what Dart has.
I'll ignore the dickish preface to this. Your usage of the word "accident" was patently obvious. I don't mind the capitalization conventions, and I'm not sure how that's really a mistake. As for classes-as-ersatz-namespaces I can sort of see what you're getting at but I'd appreciate it if you expanded on the details of that.

Otto Skorzeny posted:

Thank you for once again putting words in my mouth; I didn't say that the creators of Dart lacked knowledge relevant to implementing the least-bad VM for Javascript, but rather that they lacked knowledge of the theory and practice of type systems. I assume everyone who has looked at Dart's non type non system (type annotations that are meaningless by default with optional runtime assertions that aren't actually assertions, lol) and any even remotely modern type system ( ML's is a good example of a baseline static type system, while being decades old and quite simple; Python is a good example of a dynamic strongish type system that works well) can tell you that Dart programmers (assuming there are any outside of Google) are getting shortchanged.
I didn't imply you said that, thank you. I was actually asking where their language knowledge was lacking using similar words ("embarrassingly unfamiliar" -> "embarrassing lack").

Ciaphas
Nov 20, 2005

> BEWARE, COWARD :ovr:


Are IEEE floating points arranged any different in memory on little-endian systems as opposed to big-endian, or is that just integers?

Oh my god I've got so much code to rewrite to be endianess-agnostic, someone please just loving give me a clean death

Blotto Skorzany
Nov 7, 2008

He's a PSoC, loose and runnin'
came the whisper from each lip
And he's here to do some business with
the bad ADC on his chip
bad ADC on his chiiiiip

Ciaphas posted:

Are IEEE floating points arranged any different in memory on little-endian systems as opposed to big-endian, or is that just integers?

Oh my god I've got so much code to rewrite to be endianess-agnostic, someone please just loving give me a clean death

Different systems will arrange floats differently, yes. Not all systems that are little-endian will swap bytes for floating point values, but some will.

MDDY
Mar 21, 2008

Is there a good book to read to help solidify good programming practices and techniques? I haven't done any serious programming in a few years and I am looking to kind of relearn things with good base this time around. I am familiar with a half dozen languages, and I have a reasonable grasp of how to program. I am mostly just looking to refine my skills from a CS perspective.

Carthag Tuek
Oct 15, 2005

Tider skal komme,
tider skal henrulle,
slćgt skal fřlge slćgters gang



Syle187 posted:

Is there a good book to read to help solidify good programming practices and techniques? I haven't done any serious programming in a few years and I am looking to kind of relearn things with good base this time around. I am familiar with a half dozen languages, and I have a reasonable grasp of how to program. I am mostly just looking to refine my skills from a CS perspective.

The OP from the Coding Beauty thread had a couple:


I'm currently reading Kernighan & Pike, The Practice of Programming which is very good:

Bunny Cuddlin
Dec 12, 2004

Carthag posted:

The OP from the Coding Beauty thread had a couple:


I'm currently reading Kernighan & Pike, The Practice of Programming which is very good:



Those are all good books but please don't try to read TAoCP, the dragon book, or the K&R book to learn good programming practices

ultrafilter
Aug 23, 2007

It's okay if you have any questions.


Seriously.

Blotto Skorzany
Nov 7, 2008

He's a PSoC, loose and runnin'
came the whisper from each lip
And he's here to do some business with
the bad ADC on his chip
bad ADC on his chiiiiip
I don't have my copy on hand, but as I recall the dragon book even says in the beginning that their example code has been deliberately written in a noobish style

Sab669
Sep 24, 2009

Otto Skorzeny posted:

I don't have my copy on hand, but as I recall the dragon book even says in the beginning that their example code has been deliberately written in a noobish style

That seems like a poor idea, unless figure 1A is "lovely code you will write" and then 1B is "good code you might write after 5+ years"

JawnV6
Jul 4, 2004

So hot ...

Sab669 posted:

That seems like a poor idea, unless figure 1A is "lovely code you will write" and then 1B is "good code you might write after 5+ years"

Given that it's a book about compilers, source code maintainability may not have been their primary concern.

Sab669
Sep 24, 2009

Oh fair enough, I was thinking it was The Art of Computer Programming he was talking about, for some reason :downs:

Ciaphas
Nov 20, 2005

> BEWARE, COWARD :ovr:


Can anyone explain where my thinking has gone awry with respect to little endian systems and bit-shift operators?

http://codepad.org/5b5DbEBu

C++ code:
#include <stdio.h>

int main()
{
   unsigned int x;
   unsigned char* p1 = (unsigned char*)&x;
   unsigned char* p2 = p1 + 1;
   
   x = 1; // 1, 0x01000000 in memory
   printf("%3d %p %3d %p %3d\n", x, p1, *p1, p2, *p2);
   x <<= 7; // 128 0x80000000 ?
   printf("%3d %p %3d %p %3d\n", x, p1, *p1, p2, *p2); // yes
   x <<= 1; // 0 0x00000000 ?
   printf("%3d %p %3d %p %3d\n", x, p1, *p1, p2, *p2); // NOPE it's actually 256 0x00010000
   x <<= 1; // 0 0x00000000 ?
   printf("%3d %p %3d %p %3d\n", x, p1, *p1, p2, *p2);

   return 0;
}
pre:
  1 0xbf72c6f4   1 0xbf72c6f5   0
128 0xbf72c6f4 128 0xbf72c6f5   0
256 0xbf72c6f4   0 0xbf72c6f5   1
512 0xbf72c6f4   0 0xbf72c6f5   2
Why did left-shifting one from 128 make it 256 instead of making the sole high bit fall off the left side and make the whole thing zero?

Ciaphas fucked around with this message at 18:59 on May 22, 2013

shrughes
Oct 11, 2008

(call/cc call/cc)

Ciaphas posted:

Why did left-shifting one from 128 make it 256 instead of making the sole high bit fall off the left side and make the whole thing zero?

x is an int, a 32-bit signed integer on most systems. Your expectations would be correct if x was an unsigned char (and if CHAR_BIT is 8, which is true literally everywhere).

Edit: Hold on, what.

code:
 x = 1; // 1 0x01000000
   printf("%3d %p %3d %p %3d\n", x, p1, *p1, p2, *p2);
   x <<= 7; // 128 0x80000000 ?
This is wrong ^.

You mean
code:
x = 1;  // 1 0x00000001
x <<= 7;  // 128 0x00000080

Ciaphas
Nov 20, 2005

> BEWARE, COWARD :ovr:


The hex I put in the comments there is how it seems to me to be laid out in memory (as affirmed by the pointer printouts), not its actual value. Which is what's confusing me about the shift operators.

pseudorandom name
May 6, 2007

The shift operators operate on integers, not bytes in memory.

shrughes
Oct 11, 2008

(call/cc call/cc)

Ciaphas posted:

The hex I put in the comments there is how it seems to me to be laid out in memory (as affirmed by the pointer printouts), not its actual value. Which is what's confusing me about the shift operators.

Okay. So the direction of the shift operators doesn't depend on how it's laid out in memory. It purely operates on the numerical value, and "left" and "right" refer to the classic way we write down numbers, with the least significant bit on the rightmost end.

Imagine the value 1036 in a 32-bit int being written out in binary as

00000000000000000000010000001100.

Then `1036 >> 3` will be

00000000000000000000000010000001.

The bits are shifted to the right -- this is the same as dividing by 8 and rounding down.

Now, in memory, these values might be laid out:

unsigned char a[4] = { 0x0c, 0x04, 0x00, 0x00 };
unsigned char b[4] = { 0x81, 0x00, 0x00, 0x00 };

on a little-endian system.

Ciaphas
Nov 20, 2005

> BEWARE, COWARD :ovr:


pseudorandom name posted:

The shift operators operate on integers, not bytes in memory.

shrughes posted:

Okay. So the direction of the shift operators doesn't depend on how it's laid out in memory. It purely operates on the numerical value, and "left" and "right" refer to the classic way we write down numbers, with the least significant bit on the rightmost end.

Oh. That'd about do it, then. Thanks :saddowns:

Woodsy Owl
Oct 27, 2004
What is a decent, goon-recommended raytracing tutorial? I can't manage to find any suitable for my admittedly feeble mind.

aerique
Jul 16, 2008

Woodsy Owl posted:

What is a decent, goon-recommended raytracing tutorial? I can't manage to find any suitable for my admittedly feeble mind.

I like this guy's site and articles: http://iquilezles.org/www/articles/terrainmarching/terrainmarching.htm

Suspicious Dish
Sep 24, 2011

2020 is the year of linux on the desktop, bro
Fun Shoe

Woodsy Owl posted:

What is a decent, goon-recommended raytracing tutorial? I can't manage to find any suitable for my admittedly feeble mind.

Read a graphics-minded physics / geometry tutorial. The idea of raycasting is very simple, but actually doing it commands a knowledge of how complex geometry works, and how light actually interacts with objects on a scene.

loinburger
Jul 10, 2004
Sweet Sauce Jones
I've got a distributed application on a WAN where the nodes log data locally along with a timestamp - most of this data is only relevant to the local machine (memory consumption and so on), but with some of the log data I'd like to be able to perform diagnostics that correlate the timestamps created by multiple nodes (for example, if Node_1 transmits a message at Time_1 and Node_2 receives the message at Time_2, then I'd like to be able to take (Time_2 - Time_1) and know approximately how long it took the message to reach its destination).

The nodes may be running on machines with inaccurate local clocks, so when a node initializes I query an NTP server to figure out the approximate clock error. However, I know fuckall about clock skew, and am wondering if this is good enough, or if I need to re-query the NTP server every minute, or every hour, or every day, etc. (assuming that any changes to the clock are a result of skew, and not a result of e.g. somebody manually changing the clock).

loinburger fucked around with this message at 21:33 on May 23, 2013

nielsm
Jun 1, 2009



The NTP protocol is designed to work continuously, with the client constantly improving its clock precision. Just use NTP as intended and you should be fine. (There is also the SNTP, Simple NTP, which isn't able to do the continuous sync thing. Make sure you aren't actually using that.)

Adbot
ADBOT LOVES YOU

Workaday Wizard
Oct 23, 2009

by Pragmatica
I am trying to intercept and modify network traffic going through an "ad-hoc" network running on my Windows 7 laptop (my laptop is the access point).

Currently I am able to sniff the traffic, but I am at a loss with regards to actually stopping the packets at my machine and then re-sending them with extra modifications.

The way network adapters work on Windows is total magick to me.

(I can't use Linux because NVIDIA® Optimus™ Sucks© Balls℠)

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