14 ms·
Ask HN: What can you do in one language that can't be done as well in others?
I'd prefer we talk about programming languages, but I suppose literary languages could be interesting, too.
- dClauzel 10y agoBash shell script: using pipes → « cat MonFichier | while read LaLigne ; do echo $LaLigne ; done »
- lastofus 10y agoIt's also one of the coolest features in Elixir IMO. http://elixir-lang.org/getting-started/enumerables-and-streams.html#the-pipe-operator http://elixir-lang.org/getting-started/enumerables-and-strea...
- gargarplex 10y agoAwesome. Is Elixir prevalent in production yet? Will it be? I think I want to learn either OCaml or Elixir next.
- lastofus 10y agoIt's probably more prevalent than OCaml at this point despite it's young age. It builds on top of Erlang/OTP which is quite battle tested and used by several major companies. The community behind it is quite strong as well.
- aashishkoirala 10y agoPipes are pretty prevalent in PowerShell too.
- dozzie 10y agoThough not as useful as in Bourne shell, as you can't save intermediate results to review or reprocess them.
- arms 10y agoElixir's concurrency primitives & actor system make some concurrent and parallel jobs much easier than I'm used to in other languages.
- imaginenore 10y agoI know PHP isn't very popular here, but it's awesome for string manipulation, parsing files. One-line that reads the file, splits multiple lines into an array: <?php $l = explode("\n", file_get_contents("in.txt")); Want to sort them alphabetically? Add sort($l); Trim them? $trimmed = array_map(trim, $l); Remove duplicates? $unique = array_unique($trimmed);
- matthewking 10y agoMost languages have these type of functions, once you've read the file into an array its just array/list manipulation. I haven't compile checked this but here's the same as a C# one liner: List<string> lines = File.ReadAllLines("/file.txt").Distinct().ToList().Select(l => l.Trim()).Sort();
- imauld 10y agoAnd in Python: with open("foo.txt.") as f: foo = sorted(list(set(line.strip() for line in f]))) with is a context manager that will automatically close the file once it's out of scope, not required but it's much cleaner and safer. Should the code change you don't have to worry about the call to close the file getting lost. The call to set() could be replaced with a set comprehension, {i for i in sequence}, but for clarity I used set(). It's certainly not the most efficient way to do it but it's simple and clear.
- astrodev 10y agoEven simpler, and handles the different new line characters: $l = file('in.txt', FILE_IGNORE_NEW_LINES);
- dotancohen 10y agoIf you are turning to PHP for string manipulation, then you are going to love the Practical Extraction and Reporting Language: https://www.cs.purdue.edu/homes/cs290w/perlLecs/PerlPatterns.html https://www.cs.purdue.edu/homes/cs290w/perlLecs/PerlPatterns...
- herbst 10y ago
- deleted 10y ago[deleted]
- astrodev 10y agoYou can easily create domain specific languages in Scala using operator overloading and implicits.
- Jtsummers 10y agoErlang - Actor-based software design and its inherit benefits are trivial to implement compared to (most) other languages. By design, almost trivial distribution across many nodes without resorting to specialized APIs (that aren't common across all platforms) or separate coordination languages. Ada - The type system and the manner in which it can be used to constrain your software (in a positive way) makes ensuring certain safety/reliability much easier. Compare in C, an int is an int. If I make a "temperature_t" it's just a double or something that's aliased. Where as "kelvin_t" in Ada can be made to be only the positive real numbers. Lisps - I'll include Common Lisp, Emacs Lisp, Scheme, Racket, clojure, etc. The meta programming (ruby has this too, actually) makes it much easier to develop large programs almost automatically. The meta programming nature allows you to, within the same language as the primary program you're aiming for, extend your language and program. This reduces the friction of the meta programming tasks, consider C. You can use meta programming, but it requires at least one other language. Plenty of others, three (languages and families) off the top of my head.
- inconclusive 10y agoWhat makes Erlang work well when distributed is having one mailbox per process, to persist messages. Any language can add this as a library, yet most don't.
- Jtsummers 10y agoRe inconclusive: Erlang's language is concise, well-designed, and oriented around the concurrency model. Try tacking it onto C and it won't work well [0]. Take that concurrency model and put it into Python or Lisp or Smalltalk, and it could work fine. Those are expressive languages that are sufficiently malleable to bring in foreign concepts in a native looking fashion. [0] It won't look as clean. It'll work, but it won't be clean. We actually use a very similar model in a project at work. But there's so much bookkeeping because it's C that Erlang hides from you. Other expressive languages would be able to absorb that bookkeeping and hide it from you as well, but C isn't expressive. It's precise. It does what you tell it to do. But it's not able to hide things cleanly behind abstractions that the language itself isn't already built to handle.
- rdnetto 10y agoHaskell and Scala are pretty awesome at embedded DSLs, because of do-blocks. You can use them to bind some value to a symbol (i.e. assign a variable) inside the eDSL, which isn't possible in most languages. (Contrast this to, say, eDSLs in Java, which are limited to fancy builder patterns).
- tluyben2 10y agoIdris and Coq which have more advanced type systems allowing you to create proofs for you software. There are not many languages that allow this. And Shen which has a Turing complete type system meaning it is very flexible but type checking may never halt in certain conditions. I do not know of another language with these properties. Haxe allows you to target absolutely anything and if you miss some exotic it is trivial to allow generation for it. It is also quite mature language with a macro system. Again, maybe MonkeyX compares somewhat but has far less backends and making a backend is not so straightforward. K and Q and their parent APL which allow you to write the most terse code you will ever see (some make a sport of it). Forth you can implement in a few hours on any platform and yet is a very powerful language which makes it easy, once you get used to it, to write terse but easy to understand code. This one I would say is, compared to other languages including Lisp, easier to implement naively while still keeping solid perf. There are also lists of minimal instruction Forths which show you how powerful and easy the basic constructs are and how rapidly you can make a toy language.
- joeclark77 10y agoIn Python you can code an MMO, manipulate a database, set off a Hadoop job processing petabyes of big data in parallel on a thousand servers, conduct statistical analysis on the result set, generate beautiful and meaningful data visualizations, run a web server to make your program accessible to the world, stick an API onto it, and give artificial intelligence to a robot. As Heinlein wrote, "Specialization is for insects."
- jetti 10y agoGallina (The programming language used in Coq) -> Theorem proving assistance
- 0xcoffee 10y agoNot sure how many other languages support this, but I was pleasantly surprised when I used it in typescript. My first exposure to Intersection types: T Extends Foo | Bar T Extends Foo & Bar