Two Plus Two Publishing LLC Two Plus Two Publishing LLC
 

Go Back   Two Plus Two Poker Forums > >

Notices

Programming Discussions about computer programming

Reply
 
Thread Tools Display Modes
Old 04-16-2018, 12:16 AM   #32376
gaming_mouse
Carpal \'Tunnel
 
gaming_mouse's Avatar
 
Join Date: Oct 2004
Location: taking notes on u (see profile)
Posts: 13,782
Re: ** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD **

Quote:
Originally Posted by blacklab View Post
#!/usr/bin/perl
$e="the it";
$d="the quick brown fox quick fox fox brown it jumped";
while($d=~/(\w+)/g){if($e!~/$1/){$c{$1}++}}
foreach$n(sort{$c{$b}<=>$c{$a}}keys%c){print"$n $c{$n}\n"}

fox 3
quick 2
brown 2
jumped 1
even perl is rather verbose for golfing. java golf is straight masochism.

J fares better, but not as well as the pure golf langs like Jelly, which could likely solve this problem in 10 chars or so. Here's a not even particularly golfed J version in 31 chars:

Code:
NB. sample data
w=.;:'the quick brown fox quick fox fox brown it jumped'
e=.;:'the it'

NB. the solution is f
NB. using 3 instead of 25 for demo purposes

f=. ([:3&{.[:(\:{:"1)~.,.<@#/.~)@-.
Try it online!

Ungolfed version:

Code:
([: 3&{. [: (\: {:"1) ~. ,. <@#/.~)@-.
gaming_mouse is offline   Reply With Quote
Old 04-16-2018, 12:21 AM   #32377
gaming_mouse
Carpal \'Tunnel
 
gaming_mouse's Avatar
 
Join Date: Oct 2004
Location: taking notes on u (see profile)
Posts: 13,782
Re: ** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD **

Quote:
Originally Posted by Sholar View Post
Code:
cat source.txt | tr ' ' '\n' | sort | uniq -c | sort -nr | head -25
seems halfway there (not handling stopwords) and easy enough to slot in punctuation and whatever other refinements.
gaming_mouse is offline   Reply With Quote
Old 04-16-2018, 12:44 PM   #32378
suzzer99
Carpal \'Tunnel
 
suzzer99's Avatar
 
Join Date: Nov 2005
Location: on top of the bell curve
Posts: 84,695
Re: ** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD **

Quote:
Originally Posted by ChrisV View Post
My favourite piece of Java hate, which I've posted before ITT, is that there's an Arrays.toList() method, which takes an array and produces an ArrayList. Easy! Except that this ArrayList is not a java.util.ArrayList, but a java.arrays.ArrayList, which looks and acts exactly the same unless you try to mutate it, in which case it will compile and then throw an exception at runtime. I consider this proof that the programmers of Java actually were trolling us.
But typescript >>>> javascript.
suzzer99 is offline   Reply With Quote
Old 04-16-2018, 12:46 PM   #32379
suzzer99
Carpal \'Tunnel
 
suzzer99's Avatar
 
Join Date: Nov 2005
Location: on top of the bell curve
Posts: 84,695
Re: ** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD **

Quote:
Originally Posted by jmakin View Post
Chris - i may mess around with it later but I had to be extremely careful with how I decided to do things because the file we're parsing is pride and prejudice which is an extremely large book and has about ~11,000 unique words.
Use perl. It would probably be 20x less code and 100x faster.

Last edited by suzzer99; 04-16-2018 at 12:47 PM. Reason: nm my pony got parsed by blacklab
suzzer99 is offline   Reply With Quote
Old 04-16-2018, 01:16 PM   #32380
jmakin
 
jmakin's Avatar
 
Join Date: Jan 2008
Location: Streaming
Posts: 27,068
Re: ** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD **

I use java because it’s easy to turn in and for the TA to compile and run on his machine, plus I don’t know perl
jmakin is online now   Reply With Quote
Old 04-16-2018, 02:03 PM   #32381
Victor
Carpal \'Tunnel
 
Victor's Avatar
 
Join Date: Jul 2003
Posts: 58,937
Re: ** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD **

Quote:
Originally Posted by suzzer99 View Post
But typescript >>>> javascript.
not sure how this applies in any way
Victor is online now   Reply With Quote
Old 04-16-2018, 02:11 PM   #32382
goofyballer
 
goofyballer's Avatar
 
Join Date: Jun 2005
Posts: 61,904
Re: ** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD **

Quote:
Originally Posted by suzzer99 View Post
But typescript >>>> javascript.
I'm not sure why this is a response to Chris's post, but yes, this is a true statement.
goofyballer is offline   Reply With Quote
Old 04-16-2018, 02:23 PM   #32383
suzzer99
Carpal \'Tunnel
 
suzzer99's Avatar
 
Join Date: Nov 2005
Location: on top of the bell curve
Posts: 84,695
Re: ** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD **

Chris's post shows the weird pain that can come with casting types and similar built in types - which you never have to worry about in regular JS. I've had similar hassles trying to feed http headers to an HTTP service in angular 2 and had to jump through all kinds of hoops to cast a simple hash into an HttpInputParamaters object (or w/e it was called). I had tons of Java flashbacks.

There's reason why Javascript chose dynamic typing to begin with. Can you name anything significant that's changed so much about the browser (or node which was built on dynamic typing) that static typing with a klugey add on is now superior? Certainly the option was available to bake in static typing from the beginning if that was deemed superior.

I agree static typing makes people more comfortable who come over from Java or C#. Also auto-complete of 3rd party libs is sweet. But I don't think those outweigh the extra cruft and slowdown. For sure not in node. Obviously with angular 2+ you need it so that's fine.

I can be crusty about learning new things - so I force myself to use important new technology even if I don't think it's superior. IE - I didn't use a linter for a long time, then finally forced myself. Within a few hours I immediately realized I was an idiot for not using it from the beginning. I feel pretty confident that if a technology is superior I will pick up on that after using it for a while.

I used typescript in node for months and never saw any kind of advantage as far as sniffing out run time issues at compile time (that a linter wouldn't also catch). The extra compile step slows node down. Debugging is a mess. And other than auto-complete, which is awesome - in every other way development is slowed down considerably.

The whole key to node imo is to quickly spin up new components and expand scope in a modular way. Stuff like factories and rigid types slow that down imo. Composition over inheritance. Yes you can do static typing w/o inheritance but what's the point?

Typescript is turning node into weblogic imo. The java devs at my old corporate job don't feel comfortable without compile-checking, so they love it. And if it grinds node reboot, debug and dev time down to where you lose half the advantage over Weblogic - they're fine with that because they have no concept how to do node right - and would rather just stick to Java anyway.

Last edited by suzzer99; 04-16-2018 at 02:38 PM.
suzzer99 is offline   Reply With Quote
Old 04-16-2018, 02:50 PM   #32384
Grue
Pooh-Bah
 
Grue's Avatar
 
Join Date: Mar 2004
Location: It is pitch black.
Posts: 5,129
Re: ** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD **

We had a "notable JS expert" do a 2 day training thing with us last week and he more or less said the above re: Typescript. It solves a problem I don't have. I guess if it makes C# people happy go nuts otherwise its a giant waste of time.
Grue is offline   Reply With Quote
Old 04-16-2018, 04:30 PM   #32385
goofyballer
 
goofyballer's Avatar
 
Join Date: Jun 2005
Posts: 61,904
Re: ** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD **

Quote:
Originally Posted by suzzer99 View Post
Stuff like factories and rigid types slow that down imo. Composition over inheritance.
...
Typescript is turning node into weblogic imo.
There's a difference between a language and how people choose to use it - you might as well blame JS dynamic typing for people writing poorly documented libraries that rely on objects having magic properties or something. Type safety doesn't mean you have to write factory classes.

I think it's pretty ****ing magical in TS when I can write complex array operations with map/reduce/whatever and the compiler can verify without me even running my code that it's doing what I wanted and generating the result I expected (usually without me even having to specify types, because it correctly infers types based on the existing vars I use and the code that I write to modify them).
goofyballer is offline   Reply With Quote
Old 04-16-2018, 05:30 PM   #32386
well named
poorly undertitled
 
well named's Avatar
 
Join Date: Jun 2007
Location: esse est coesse
Posts: 73,797
Re: ** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD **

We use typescript and I don't think it's a waste of time, although I agree there are cases where I prefer not to be encumbered with typing. But with typescript I can do that, when I want.

I could imagine even agreeing with the "notable JS expert", it may be a problem he doesn't have. For me, I want typing mostly in large code bases with many authors where it makes it a lot easier to understand how the public interfaces between different parts of the system work together, how to consume those interfaces and what to expect as output, and also a lot easier to do certain kinds of refactoring where the compiler is going to help me know all the places in the code that have to be changed. I find those benefits pretty compelling and have actually relied on them in practice, but I can imagine lots of projects where I wouldn't be as worried about them also.

It's at least possible that we could have gotten some of those benefits with a different linter, I'm not 100% sure. We implemented typescript as part of a plan to upgrade to newer versions of Angular, so we didn't bother evaluating some of those alternatives. So I wouldn't necessarily argue that everyone should adopt it but I don't think it's been worthless.
well named is offline   Reply With Quote
Old 04-16-2018, 07:52 PM   #32387
PJo336
THRILLHOUSE!
 
PJo336's Avatar
 
Join Date: Mar 2007
Posts: 21,463
Re: ** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD **

Oh God are we seriously doing this AGAIN?
PJo336 is offline   Reply With Quote
Old 04-16-2018, 07:55 PM   #32388
Grue
Pooh-Bah
 
Grue's Avatar
 
Join Date: Mar 2004
Location: It is pitch black.
Posts: 5,129
Re: ** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD **

Lol I'm done sorry
Grue is offline   Reply With Quote
Old 04-16-2018, 08:18 PM   #32389
ChrisV
Carpal \'Tunnel
 
ChrisV's Avatar
 
Join Date: Jul 2004
Location: Adelaide, Australia
Posts: 36,220
Re: ** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD **

I'm agnostic about TypeScript. I've used it a little and it just seemed kind of annoying, but I probably didn't get to the point where I was seeing the benefits.

Java sucks because Java sucks. The functional stuff in it sucks because, like TypeScript, it's a new feature awkwardly nailed on to an existing language. (So is LINQ in C#, but they somehow made that good). I think complaints about static typing generally come from people who have never used a modern statically typed language, with good support for functional programming, anonymous types, etc. As of C# 4.0, you can even ignore static typing if you want to, by using the "dynamic" keyword for everything, but nobody does because it provides no benefit.

The difference is just not as great as people make out anymore. Linters in JavaScript provide many of the benefits of static typing. Modern statically typed languages allow you to write much as you would in a dynamic language. I don't find writing in C# or writing in JavaScript to be hugely different experiences. Writing in Java, I feel like the language is constantly getting in my way.
ChrisV is offline   Reply With Quote
Old 04-17-2018, 06:26 AM   #32390
Wolfram
Carpal \'Tunnel
 
Wolfram's Avatar
 
Join Date: Jan 2006
Location: You can be my wingman any time
Posts: 14,550
Re: ** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD **

(yes, we're doing this again)
Quote:
Originally Posted by suzzer99 View Post
The whole key to node imo is to quickly spin up new components and expand scope in a modular way. Stuff like factories and rigid types slow that down imo. Composition over inheritance. Yes you can do static typing w/o inheritance but what's the point?
Static typing has nothing to do with oop methodologies (inheritance, factories etc). You can do oop without static types and vice versa. And you can easily do composition with static types.

I'd also like to second that Typescript is not the best example to judge static types by, because it is an afterthought and not core to the language. My personal experience with dynamic vs static (js vs java/c++) is that dynamic makes it easier to develop quickly, while static makes it easier to develop robustly. Depending on the domain, one can be preferable over the other, e.g. front-end vs back-end.

Last edited by Wolfram; 04-17-2018 at 06:32 AM.
Wolfram is offline   Reply With Quote
Old 04-17-2018, 04:20 PM   #32391
jmakin
 
jmakin's Avatar
 
Join Date: Jan 2008
Location: Streaming
Posts: 27,068
Re: ** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD **

I learned PHP in my web apps class today and realized I could do that golf problem in like ~100 chars.

i like php arrays but man that language looks so ugly
jmakin is online now   Reply With Quote
Old 04-17-2018, 06:29 PM   #32392
RustyBrooks
Carpal \'Tunnel
 
RustyBrooks's Avatar
 
Join Date: Feb 2006
Location: Austin, TX
Posts: 23,451
Re: ** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD **

PHP is a really prime example of how a reasonable piece of technology can also be a piece of **** if you don't actually try to design it, but instead just wing everything.
RustyBrooks is offline   Reply With Quote
Old 04-17-2018, 07:14 PM   #32393
PJo336
THRILLHOUSE!
 
PJo336's Avatar
 
Join Date: Mar 2007
Posts: 21,463
Re: ** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD **

Anyone know if you can multi account aws or is that free tier abuse?
PJo336 is offline   Reply With Quote
Old 04-17-2018, 08:39 PM   #32394
RustyBrooks
Carpal \'Tunnel
 
RustyBrooks's Avatar
 
Join Date: Feb 2006
Location: Austin, TX
Posts: 23,451
Re: ** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD **

Quote:
Originally Posted by PJo336 View Post
Anyone know if you can multi account aws or is that free tier abuse?
I dunno man, define "can"

Like, is it possible to do so? Probably. Do they want you to? No.

The free tier stuff is like.. a few tens of dollars/month at most? Call me old/jaded but I moved from a hosted environment to AWS a long time go, going from $120/mo to like $20-30/mo for very similar results.
RustyBrooks is offline   Reply With Quote
Old 04-17-2018, 08:51 PM   #32395
PJo336
THRILLHOUSE!
 
PJo336's Avatar
 
Join Date: Mar 2007
Posts: 21,463
Re: ** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD **

Quote:
Originally Posted by RustyBrooks View Post
I dunno man, define "can"

Like, is it possible to do so? Probably. Do they want you to? No.

The free tier stuff is like.. a few tens of dollars/month at most? Call me old/jaded but I moved from a hosted environment to AWS a long time go, going from $120/mo to like $20-30/mo for very similar results.
My team makes fun of me because I drop like 30 bucks on food delivery for one dinner and then nitpick a 5 dollar difference on a month of server costs. Ill get over it someday...probably not


That said, im gonna give Firebase a spin
PJo336 is offline   Reply With Quote
Old 04-18-2018, 10:31 AM   #32396
jmakin
 
jmakin's Avatar
 
Join Date: Jan 2008
Location: Streaming
Posts: 27,068
Re: ** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD **

getting much stronger at bash/vim/gdb, classmates remark at how quickly I do things in the lab lol. also, this is my first heavy exposure to C and I'm really enjoying it. IMO everyone should start out by learning C, I have no idea why they start with java/python.

one small irritating thing, I can't quite figure out how to yank an entire file in putty and paste it into windows.

ggVG will select an entire file, but multiple different methods of yanking doesn't yield anything. copy pasting from windows into putty is fine.

Last edited by jmakin; 04-18-2018 at 10:45 AM.
jmakin is online now   Reply With Quote
Old 04-18-2018, 10:53 AM   #32397
RustyBrooks
Carpal \'Tunnel
 
RustyBrooks's Avatar
 
Join Date: Feb 2006
Location: Austin, TX
Posts: 23,451
Re: ** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD **

I personally think people should start with C (not C++!) also. My first class was Pascal but they replaced it with C++ the next year. I actually don't think Java is a very good first choice because it has a lot of complicated and verbose syntax that makes the whole thing look more complicated than it is. C is very bare-bones syntax wise.

I wonder how many CS grads even learn C any more? It's still heavily used in kernel development and probably will be for some time.
RustyBrooks is offline   Reply With Quote
Old 04-18-2018, 11:03 AM   #32398
saw7988
Carpal \'Tunnel
 
saw7988's Avatar
 
Join Date: Jul 2005
Posts: 11,423
Re: ** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD **

C should probably be taught at some level at some point in a CS curriculum. But when/where depends on the goals/courses. First course? Definitely not. I think usually you want to be starting off with something that teaches more core/common/conceptual topics, maybe either Python or C#, and start to learn some basic patterns/algorithms. C is great for an OS course or something later on.
saw7988 is offline   Reply With Quote
Old 04-18-2018, 11:12 AM   #32399
Wolfram
Carpal \'Tunnel
 
Wolfram's Avatar
 
Join Date: Jan 2006
Location: You can be my wingman any time
Posts: 14,550
Re: ** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD **

Quote:
Originally Posted by jmakin View Post
one small irritating thing, I can't quite figure out how to yank an entire file in putty and paste it into windows.

ggVG will select an entire file, but multiple different methods of yanking doesn't yield anything. copy pasting from windows into putty is fine.
The yank buffer only exists inside vim. It's probably easiest to just copy the file using winscp.
Wolfram is offline   Reply With Quote
Old 04-18-2018, 11:19 AM   #32400
jmakin
 
jmakin's Avatar
 
Join Date: Jan 2008
Location: Streaming
Posts: 27,068
Re: ** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD **

I think learning java/python is far more complicated than learning C. I mean the C syntax is super easy, the library's pretty small and easy to understand, and doesn't require some super complicated and annoying IDE like java/C++ frequently do (early on in programming classes).

It's more prone to user error but that's why I think it'd be a good language to start with. The first time you seg fault on an array because of an off by 1 error in a loop and spend an hour looking for it will make you way more careful.

in java you get some meaningless (to the beginner) exception (what's an exception?) and it'll tell you exactly where and how you went wrong. and don't even get me started on trying to explain the JVM to a newbie, i'm 5 years into this and i still barely understand it. I accidentally registered for a compiler project course and the project was literally "implement the JVM" and i never clicked "drop" so fast in my life.

This is by far the most enjoyable language I've programmed in for some reason. I did some C programming last quarter for a microprocessor but I just donked my way through the course and had no idea what I was doing.
jmakin is online now   Reply With Quote

Reply
      

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Forum Jump


All times are GMT -4. The time now is 03:58 PM.


Powered by vBulletin®
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.
Copyright © 2008-2017, Two Plus Two Interactive
 
 
Poker Players - Streaming Live Online